ECE471/571 (RTOS) STM32 FreeRTOS+LwIP Example - My own Web Site

In STM32CubeMX

  1. Initialize all peripherals with in default mode? - yes
  2. System Core
  3. Connectivity: enable Ethernet: RMII (already enabled))
  4. Middleware - enable FreeRTOS
  5. Middleware - enable LwIP
  6. System Core Again
    • SYS - select Timebase Source: TIM2
    • NVIC - Enable Ethernet Global Interrupt (sometimes it does not get enabled automatically!)
    • disable USB_OTG_FS (optional)

Adapt and compile a project

  1. Under the project root (top) directory create a directory named Fs
  2. Download and unpack the provided sample startup content to the Fs directory
  3. Download the provided file and unpack it to that directory
  4. If the directory shows up in the IDE then: Resource Configuration / Exclude from build
  5. Customize the contents as necessary, keep the main file named as index.html (all lowercase)
  6. Run makefsdata.exe in the project root (top) directory
  7. Rename the generated fsdata.c to fsdata_custom.c, move it to Middlewares\Third_Party\LwIP\src\apps\http\, and "Exclude from build" in the project settings
  8. See also: makefsdata utility
  9. Open source/lwip.c and inspect the contents of the function void MX_LWIP_Init(void)
  10. Open source/main.c
  11. Update the following code fragment:
    /* USER CODE BEGIN Includes */
    #include "lwip/apps/httpd.h"
    /* USER CODE END Includes */
  12. Update the following code fragment:
      /* USER CODE BEGIN 2 */
      //start the web server after MX_LWIP_Init() is called
      /* USER CODE END 2 */
  13. Update the following code fragment:
    void StartDefaultTask(void const * argument)
      /* init code for LWIP */
      // MX_LWIP_Init(); -- moved back to the main function
      /* USER CODE BEGIN 5 */
      /* Infinite loop */
      /* USER CODE END 5 */
  • Lookup the board IP address in your Router.
    Many examples provided on the Internet use way around by setting up a constant static IP address. Use of static IP is not realistic. At the same time this is no a computer network course. Hence we will not discuss solutions such as service discovery.
  • Open the Web browser and type: http://<:insert_server_ip_address>/
  • web site front local main page local list page general bookmarks software bookmarks go back copyright info