cancel
Showing results for 
Search instead for 
Did you mean: 

How to make Ethernet and lwIP working on STM32

Piranha
Chief II

This is an umbrella topic where I will collect the key problems and solutions to finally get networking on STM32 working. The issues formatted as bold are the most critical ones.

HAL ETH drivers have been significantly reworked since the following firmware packages: CubeF4 v1.27.0, CubeF7 v1.17.0, CubeH5 v1.0.0, CubeH7 v1.10.0

Series: F1, F2, F4, F7, H5, H7 (all STM32 with Ethernet)

Series: F1, F2, F4, F7 (older Synopsys basic peripheral)

Series: H5, H7 (newer Synopsys QoS peripheral)

Series: F7, H7 (Cortex-M7 CPU)

lwIP API related:

Other related information:

Another detailed topic by @alister​: "[bug fixes] STM32H7 Ethernet". While mostly dedicated to H7 series, it also has a good amount of information relevant to all Ethernet/lwIP related development.

Open source zero-copy Ethernet/lwIP driver example. The hardware driver is for F2 series, which means that it's almost the same for all Fx series. The lwIP related code and general ideas are still valid for all series.

My other closely related topic: "Actually working STM32 Ethernet and lwIP demonstration firmware". As that topic is currently unavailable, because ST still has not moved it to the new forum, I am attaching a PDF copy of that topic and the related firmware files to this topic.

25 REPLIES 25
alister
Lead

@JBerry​ , @MTros.1​  this is a community forum and as you're presently working on H7 ethernet and using H7_FW v1.8.0, and as Piranha may also have a day job and mightn't be working on either, perhaps you're best positioned to do this investigation and contribute the answers.

I'd documented and fixed/improved the H7_FW v1.5.0/v1.6.0 ethernet problems at https://community.st.com/s/question/0D50X0000C6eNNSSQ2/bug-fixes-stm32h7-ethernet. It's valid for v1.7.0 too.

I haven't the time to read H7_FW v1.8.0 now. Could you read the the issues I'd documented and fixed/improved there, compare the fixes, and read the issues Piranha's posted here, and post the results of your analysis there and here please?

DMann.1
Associate

Are you saying the current release of LWIP and FreeRTOS do not work at all without bug fixes, or just simply inefficient and bugs are present?

Mikk Leini
Senior

I stumbled upon this STM32 LwIP disaster also and after 1w of swearing and debugging, moved over to Mbed with my F7 device. Mbed TCP/IP stack and OS works out of a box. I'm still in mid development but haven't seen any network issues. But the grass is not bright green there either - the list of debuggable MCU's is quite short. Need dual project solution with shared code to get the job done. Develop and debug HW level code in STM32CubeIDE and run whole application in Mbed.

bully
Senior

Hello,

oh my god... Any update on this matter ? Do we have some working example code with FreeRTOS and LWIP ?

If not which one is closest one ?

I was about to debug code for simple UDP client using Socket API for LwIP, but I guess this is dead end path :-(...

Can I get any better if I use raw API of LwIP or even use LwIP without FreeRTOS ?

I don't have such complex task to do (gateway from UART connection to MQTT-SN server)...

@Mikk Leini​ : I'd be more than happy to read if you are willing to provide some more details about your work with STM32 and MbedOS.

Thanks in advance,

regards,

Rob.

RZasa.1
Associate III

Hi Piranha,

See my last answer in this topic:

https://community.st.com/s/question/0D50X0000BMErkFSQT/stm32f407-lwip-ip-stack-stop-working-during-tcp-port-scanning-from-vulnerabilities-test-tool

In my case code generated by STM32CubeIDE was simply setting not enough stack size for "EthIf" thread.

Hello, Piranha.

I read many of your messages about Ethernet driver for LWIP.

I use NUCLEO-767ZI and I use BSD sockets and therefore FreeRTOS.

For NUCLEO-767ZI I wrote code and it work fine. But I decide move project on NUCLEO-H755. And I start fight with MPU and others...

JMath.2
Associate II

This patch is for V1.6.0, has any of this been merged by ST into 1.7.0?

Thank you for your work.

It's tough to work with a PDF and code snipits. Moving this to a GitHub fork of 1.6.0 would allow all those changes to be tracked and pulled into our code.

RZasa.1
Associate III

I am currently experiencing one of those strange behaviours. LWIP is not able to get IP but when I add one line of code somewhere - even if it is after LWIP initialisation (so totally irrevelant to LWIP operation) LWIP is working again. Problem will come and go as I am developing my application by adding more lines of code. All my threads have enough stack memory allocated but the problem looks like something related to memory. I am not sure how to debug it. I am using NUCLEO-F767ZI

Parvez Akhtar
Associate II

Hi,

I am using CubeF4 v1.27.1 and Olimex P407 board. I wanted to use LwIP_HTTP_Server_Netconn_RTOS example with RMII interface. I have correctly configured all the Pins. I am able to ping the device but the moment web server is being browsed from browser the devices gets stuck in deadlock and ethernet interrupt stops working.

I found interrupt is being stopped due to DMA error

if (__HAL_ETH_DMA_GET_IT(heth, ETH_DMASR_AIS))

 {

  if (__HAL_ETH_DMA_GET_IT_SOURCE(heth, ETH_DMAIER_AISE))

  {

   heth->ErrorCode |= HAL_ETH_ERROR_DMA;

   /* if fatal bus error occurred */

   if (__HAL_ETH_DMA_GET_IT(heth, ETH_DMASR_FBES))

   {

    /* Get DMA error code */

    heth->DMAErrorCode = READ_BIT(heth->Instance->DMASR, (ETH_DMASR_FBES | ETH_DMASR_TPS | ETH_DMASR_RPS));

/********* here interrupt is being disabled from *****/

    /* Disable all interrupts */

    __HAL_ETH_DMA_DISABLE_IT(heth, ETH_DMAIER_NISE | ETH_DMAIER_AISE);

/********

    /* Set HAL state to ERROR */

    heth->gState = HAL_ETH_STATE_ERROR;

   }

Please let me know if this is already fixed. ethernetif.c file is attached.

Regards,

Parvez Akhtar

This issue is already reported in the following topic. That link is also listed in the main post of this topic and reportedly ST is working on a fix. Also, if you have something else to add, please do it in the linked specific topic, not this one. 😊