This application provides an example of Azure RTOS NetX Duo stack usage on STM32H573G-DK board, it shows how to develop Web HTTP server based application. The application is designed to load files and dyncamic web pages stored in SD card using a Web HTTP server, the code provides all required features to build a compliant Web HTTP Server. The main entry function tx_application_define() is called by ThreadX during kernel start, at this stage, all NetX and FileX resources are created.
A NX_PACKET_POOL NxAppPool is allocated
A NX_IP instance NetXDuoEthIpInstance using that pool is initialized
A NX_PACKET_POOL WebServerPool is allocated
A NX_WEB_HTTP_SERVER HTTPServer instance using that pool is initialized
The ARP, ICMP and protocols (TCP and UDP) are enabled for the NX_IP instance
A DHCP client is created.
The application then creates 2 threads with different priorities:
NxAppThread (priority 10, PreemtionThreashold 10) : created with the TX_AUTO_START flag to start automatically.
AppServerThread (priority 5, PreemtionThreashold 5) : created with the TX_DONT_START flag to be started later.
LedThread (priority 15, PreemtionThreashold 15) : created with the TX_DONT_START flag to be started later.
The NxAppThread starts and perform the following actions:
Starts the DHCP client
Waits for the IP address resolution
Resumes the AppServerThread
The AppServerThread, once started:
Fx_media_open.
Starts HTTP server.
Each command coming from client (browser) is treated on the callback webserver_request_notify_callback.
The LedThread, once resumed from the dashboard:
The board IP address “IP@” is printed on the HyperTerminal
Home page is well displayed on the browser after entering the url: http://IP@/about.html
Dashboard is well displayed on the browser after entering the url: http://IP@/dashboard.html
On dashboard, You can command Green LED and watch some infos about threadx and netxduo.
If the WEB HTTP server is not successfully started, the green LED stays OFF. In case of other errors, the Web HTTP server does not operate as designed (Files stored in the SD card are not loaded in the web browser).
The uSD card must be plugged before starting the application. The board must be in a DHCP Ethernet network.
Hotplug is not implemented for this example, that is, the SD card is expected to be inserted before application running. The SDC card should contain the html pages. #### ThreadX usage hints
place in RAM_region { last section FREE_MEM };
either define the RW_IRAM1 region in the ".sct" file
or modify the line below in "tx_initialize_low_level.S to match the memory region being used
LDR r1, =|Image$$RW_IRAM1$$ZI$$Limit|
._threadx_heap :
{
. = ALIGN(8);
__RAM_segment_used_end__ = .;
. = . + 64K;
. = ALIGN(8);
} >RAM_D1 AT> RAM_D1
The simplest way to provide memory for ThreadX is to define a new section, see ._threadx_heap above.
In the example above the ThreadX heap size is set to 64KBytes.
The ._threadx_heap must be located between the .bss and the ._user_heap_stack sections in the linker script.
Caution: Make sure that ThreadX does not need more than the provided heap memory (64KBytes in this example).
Read more in STM32CubeIDE User Guide, chapter: "Linker script".
RTOS, ThreadX, Network, NetxDuo, Web HTTP Server, FileX, File ,SDMMC, UART
This application runs on STM32H573xx devices.
This application has been tested with STMicroelectronics STM32H573G-DK boards Revision: MB1520-H573I-B02 and can be easily tailored to any other supported device and development board.
This application uses USART1 to display logs, the hyperterminal configuration is as follows:
In order to make the program work, you must do the following :