2022-01-19 01:15 AM
Hi!
The following was tested with Nucleo-H7ZI.
I have generated a project with basic defenition of freeRTOS and LWIP.
Once an ehternet cable is connected to the board the program collapses and goes to hardfault.
after comparing the LWIP code from current cube version to previous cube generation version that worked and still work i found that is one main difference: location of the ethernet receive buffers (ethernetif.c file, line number 87), in the problematic new version its set to 0x300400c0, in the version that works the value is 0x30040200.
Changing the value allows the code to run properly upon cable connection, moreover, i can ping the board and all seems to work well.
since this value is generated by cube i want to understand if Is this a known bug?
perhaps i am missing something?
thanks in advance.
2022-01-19 02:03 PM
Yes this looks like RX buffers should be aligned on 512 bytes.
In this thread I've asked @Imen DAHMEN to forward this to the appropriate team to check with other ETH issues.
2022-01-21 02:32 AM
I had a project running on STM32H723 with Rx buffer address 0x300000F0. I did some experimenting until I got to the F0 address. I have no idea what's going on in the 48 bytes in between
2022-01-23 12:31 AM
i have taken the 0x30040200 value because it worked in previous versions (and obviously was the cube generated value),
as i said before, this fixed the issue, but since this is part of CubeMx generated code i cant just leave it at that cause ill have a problem every time i regenerate my project.
2022-02-02 05:02 AM
Hello,
I think this could be misalignment between MPU settings and Ethernet buffers and descriptors.
The MPU sets first 256 bytes starting at 0x30040000 as "Device" type. The first 192 bytes are used by Ethernet DMA descriptors and rest by DMA RX buffers (exceeding the 256 bytes configured by MPU). While the "Device" is necessary for DMA descriptors, it prevents unaligned access to the memory, which is used by LwIP stack. So there are two solutions how to handle this:
In general the MPU should configured in following way:
I hope this helps.
Best regards,
Adam Berlinger
2022-04-04 02:38 AM
Hello,
I think @Adam BERLINGER already provided the answer but just to confirm and complement:
RX buffers address must be aligned to MPU configuration. In fact the RX buffers should not be put inside ETH DMA descriptor MPU region (Device not cacheable) but after this region.
In the Cube MX configuration, the Rx buffer is put at address 0x300400c0 and the MPU is configured as ETH DMA descriptor MPU region (Device not cacheable) form 0x30000000 to 0x300000FF so the Rx buffers are inside ETH DMA descriptor region.
Note that in the new ETH driver the RX buffers are allocated dynamically and are not set to fixed address.
Kind Regards,