cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple STM32H7 Ethernet issue

Steven Burck
Associate III

I have seen the issues with DMA and the STM32H7 (here: https://community.st.com/s/article/FAQ-Ethernet-not-working-on-STM32H7x3), and I believe that I have implemented everything that was written there. To place all my variables into D1 SRAM, I replaced my linker script file with one from the STM32H7 demo programs (and I see in the debugger all data are at 0x24xxxxxx). I enabled the MPU and set it up like in the example in the FAQ, and see that STM32CubeMX did, in fact map the Tx/Rx Descriptors and buffers to the MPU regions as in the example.

I have a double issue with the way the PHY is implemented: I am using, for historical reasons, a TI TLK105L PHY on this project, rather than the LAN8742 that STM32CubeMX supports. The first issue is that, although ST claims that you can select either LAN8742 or User Defined PHY, what it really means is you can select LAN8742 or leave the selection of PHY at "choose", then ignore the warning message and allow it to generate code which doesn't have any PHY code at all. So I generated code for the LAN8742, and began to debug it. The first issue was where the LAN8742 figures out its own internal address (0-31) by trial and error, using an extended register which is different from that of the TI part. I replaced the code there with a fixed address (mine is set by the strapping pins, and I don't need to modify it in software). I then proceeded to read the ID registers as a check to make sure the CPUs MACC is speaking with the PHY, and it is.

However, there is still a bit of code in the file LAN8742.c which won't work correctly - although I didn't bother modifying it, because the Cube-generated code doesn't call it. The only functions called there are LAN8742_RegisterBusIO (which doesn't actually touch the hardware, and isn't a problem), and LAN8742_Init (which the only problem I had was the one mentioned earlier). Nowhere is the code calling functions such as get/set Link Status, etc. For now I left it alone.

I now am trying to find what I have to fix - I have to fix something, as nothing is working. I am running FreeRTOS, with the EthIF task blocking after HAL_ETH_GetRxDataBuffer returns with an error (no data available), the tcpip_thread blocking on a mailbox, the Timer service blocking on empty timer lists, and my default task which is doing a bunch of stuff and resting and the idle task sharing the CPU.

I tried to shorten the very long semaphore wait in the loop around low_level_input, by changing it from TIME_WAITING_FOR_INPUT (which was portMAX_DELAY) to 1000, but it doesn't seem to be getting back to low_level_input a second time, which leads me to believe I'm missing something in the mapping which is making the DMA idle, or something to that effect.

There is the remote possibility that this is a hardware issue, but I doubt it (the board is new and we are shaking out the bugs), but as I know there is so much room for SW issues, I'm betting on it. In any case, that's my part of the job.

Has anyone else had to deal with either of these issues - either the Etherne DMA mapping issue, or the Cube generated ethernetif.c code for a different PHY? Any help will be greatly appreciated.

24 REPLIES 24
Adam BERLINGER
ST Employee

Hello,

when configuring project from CubeMX, please make sure the following configuration is correct:

 - configuring GPIO speed (all pins should be configured to very high)

 - configuring MPU

 - HW checksum configuration (LwIP > Checksum: Enable only "CHECKSUM_BY_HARDWARE")

 - DHCP configuration: disable if not supported by the router/PC (LwIP > General Settings)

 - enable ETH global interrupt (priority must match with FreeRTOS, by default should be 5)

Also problem can be with firewall, if you are trying communication with the device from your PC, since some protocols can be blocked. E.g. I can't ping other devices from my work laptop.

Best regards,

Adam Berlinger

ranran
Senior II

Hi,

Is there a way to get the STM32CubeMX project of this example ?

Best Regards,

Ran

MX_Master
Associate II

Hi, you can find an example project here - https://github.com/MX-Master/STM32H7_Nucleo-H743ZI_Ethernet_LwIP

ranran
Senior II

Hello,

There are some strange issue with Ethernet in stm32h7:

I thought it was working fine, but now I observe a very strange issue with ethernet in stm32h7.

On start running the project the pinging to target works excellent. no issues.

But on halting with debugger, and then continuing, it then ping 3 times (with ack) and then get no ack on the 4th try, and it keeps like this over and over !

I then noticed that if I use the exact clock configuration of the Ethernet example project (instead of generated clock configuration from stm32cubemx which I use in my project , it works fine !!).

What is the magic in the clock configuration that behaves better when stopping and continuing in debugger ?

I need to generate clock from stm32cubemx.

please help

Thanks

MX_Master
Associate II

Latest commit to this example project fixes clock configuration. Clock source frequency was changed from 25 MHz to 8 MHz. I think it will help to solve your problem (:

ranran
Senior II

It happens in eval (not nucleo), and the clock source is not the problem.

I don't know why setting in code the clock configuration as in example changes behaviour to be good.

Can someone provide the stm32cubex configuration for these example please ?

alister
Lead

@Adam BERLINGER​ this problem described by the op in Oct 2018 still occurs with STM32CubeMX V5.1.0:

I have a double issue with the way the PHY is implemented: I am using, for historical reasons, a TI TLK105L PHY on this project, rather than the LAN8742 that STM32CubeMX supports. The first issue is that, although ST claims that you can select either LAN8742 or User Defined PHY, what it really means is you can select LAN8742 or leave the selection of PHY at "choose", then ignore the warning message and allow it to generate code which doesn't have any PHY code at all.

Can you check its bug was raised and, if so, when we can expect its fix please, or if not, please raise it?

Thanks

FRain
Associate II

@MX_Master​ I am trying to get it work using the HALH7 1.5, the example from your git helped a lot of things that I was missing but it looks like there is still something that won't work. Have you put all the special stuff in your README.md ?

When I program your precompiled HEX it works, however I don't know why on My CubeIDE it won't work, everything is configured like you (as far as I know)... the Ethernet IP was really easier to use on F4 and F7.

Anyway If you are able/ available to help I could share my example. The goal is to migrate a ethernet bootloader That I have working on F7 (goin to be open source)

> When I program your precompiled HEX it works, however I don't know why on My CubeIDE it won't work

Have you noticed that the MX_Master's example is for SW4STM32? Have you imported it and checked the link script after import?

Custom absolute sections should be in place:

https://github.com/MX-Master/STM32H7_Nucleo-H743ZI_Ethernet_LwIP/blob/87cb2fa46fe47ba0f8bf326d0799c8bd95553e54/STM32H743ZITx_FLASH.ld#L166

-- pa