Keil MDK TCP/IP stack basic configuration
RTX integration
- According to the MDK Middleware recommendations, these are the changes to make to the RTX configuration file,
CMSIS/RTX_Config_CM.c
:- Increase the
Number of concurrent running user threads
by2
- Increase the
Number of threads with user-provided stack
size by2
- Increase
Total stack size [bytes] for threads with user-provided stack
size by1536 bytes
- Enable
User Timers
- Increase the
For RTX5 just use the same config you used without the TCP/IP stack
MDK integration
Add the proper libraries to the Run-Time Environment configuration; in the Run-Time Environment management window:
- for CMSIS Driver, used as Ethernet driver: select
CMSIS Driver -> Ethernet MAC (API) -> Ethernet MAC
andCMSIS Driver -> Ethernet PHY (API) -> LAN8742A
(check the correct PHY for your hardware, this one is the one used on the Nucleo boards) - for MDK itself:
- set
Network
Variant as eitherMDK-Plus
orMDK-Professional
, depending on your license - set
Network -> Interface -> ETH
count to 1 - select
Network -> Core
and its Variant asIPv4 Release
- select
Network -> Socket -> BSD
,Network -> Socket -> TCP
, andNetwork -> Socket -> UDP
- set
- for CMSIS Driver, used as Ethernet driver: select
Then there are several config files we need to change according to our application. All support using the Configuration Wizard
- In
Network/Net_Config_ETH_0.h
:- select
IPv4
, uncheckNetBIOS Name Service
and checkDynamic Host Configuration
(DHCP); or set your static configuration if not using DHCP - Optionally enable IPv6 as you wish
- we can configure our MAC address here too
- select
- In
Network/Net_Config.c
, only if you won't use DHCP, untickStart System Services
. You can change your host name here in case you'd like to use NetBIOS - In
Network/Net_Config_BSD.h
setNumber of BSD Sockets 10
- Try to serve as many simultaneous connections as possible within our constraintsNumber of Streaming Server Sockets 2
- the number of listening servers, we just need 1 now but soon we'll be expanding- In
Network/Net_Config_TCP.h
setNumber of TCP Sockets 10
(as many as BSD sockets) - In
Network/Net_Config_UDP.h
setNumber of UDP Sockets 11
(as many as BSD + one for DHCP)
- In
Finally, in the project configuration (
Project -> Options for Target 'Target 1'
):- in the
Linker
tab we've addedMisc Controls: --diag_suppress 6918
to silence a warning due to padding on a RAM region (this belongs to CMSIS-Driver)
- in the
We didn't change any other default parameters, this is just an approach; for serious work and performance, a tuning operation might be needed.
Initialization
- Create an app_main task
- Initialize the network
- Wait on a signal/flag that will be set by the netDHCP_Notify() hook when the server assigns us an address.
- Create the server task to run Mongoose, and terminate.
RTX:
RTX5:
For more information consult the MDK Middleware documentation