Main Content

Configure Ethernet Options in STM32CubeMX for STM32 Processor Based Boards

To use Ethernet (TCP, UDP, or MQTT) blocks in models targeting STM32 based boards, you must configure Ethernet options using STM32CubeMX. STM32CubeMX is a configuration tool that enables you to set up peripherals and network features required for these protocols.

If you are new to STM32CubeMX tool, see https://www.st.com/en/development-tools/stm32cubemx.html

Prerequisite

Complete the following tutorials:

Configure STM32H7xx Based Boards

This section describes how to configure the Ethernet options in STM32CubeMX project for STM32H7xx-based boards.

  1. Click Launch to open the selected STM32CubeMX project in STM32CubeMX tool.

  2. In the STM32CubeMX tool, you can configure the peripherals for the selected STM32 processors.

  3. In the STM32CubeMX tool, go to System Core > CORTEX_M7 > Parameter Settings > Cortex Interface settings and set the CPU ICache and CPU DCache to Enabled.

    Cortex interface

  4. Go to Connectivity > ETH > Mode and select the Mode as RMII.

  5. Navigate to Configurations > NVIC Settings and enable the parameters Ethernet global interrupt and Ethernet wake-up interrupt through EXTI line 86.

    Ethernet global

  6. Go to ETH > Parameters Settings > Ethernet Configuration and ensure that the Rx Buffers Address is set to 0x30040200.

    Note

    For STM32H723xx ,STM32H735xx STM32H725xx,STM32H733xx, and STM32H730xx based boards, ensure that the Rx Buffers Address is set to 0x30000200.

    Ethernet configuration

  7. Go to Middleware > LWIP > Mode and enable the Mode.

  8. In the Platform settings, set the Found solutions to LAN8742.

    LWIP LAN

  9. Go to File and Click Save Project.

Configure STM32F7xx/STM32xx Based Boards

This section describes how to configure the Ethernet options in STM32CubeMX project for STM32F7xx or any STM32xx based boards.

  1. Click Launch to open the selected STM32CubeMX project in STM32CubeMX tool.

    Note

    You can configure Ethernet options for STM32F4xx-based boards in a similar way to STM32F7xx-based boards.

    Launch stm32cubemx

  2. Go to Connectivity > ETH > Mode and select the Mode as RMII.

  3. Navigate to Configurations > NVIC Settings and enable the parameter Ethernet global interrupt.

    Ethernet

  4. Go to Middleware > LWIP > Mode and enable the Mode.

    LWIP

  5. Go to File and Click Save Project.

Configure Ethernet FreeRTOS Settings

In addition to the generic configurations mentioned above, configure these settings to enable Ethernet functionality when using FreeRTOS as the operating system.

  1. Open the IOC file and navigate to LWIP > Key Options > Infrastructure - Heap and Memory Pools Options.

    Increase the MEM_SIZE to 10*1024 and set the LWIP_RAMN_HEAP_POINTER to 0x30020000. Increase these values if the model contains more Ethernet blocks or requires additional memory based on complexity. Ensure the values remain within the valid range.

    Ethernet FreeRTOS

  2. In the IOC file, select FreeRTOS. Set the Interface to CMSIS_V2, then go to Tasks and Queues. if LWIP is enabled, a default task is automatically created. Ensure the stack size is set to 256, with the option to increase it based on application requirements.

    Tasks and Queues

  3. Go to Config Parameters and set TOTAL_HEAP_SIZE to 30,720. Adjust the heap size as needed based on application requirements.

    heap size

See Also

| | | | |

Topics