cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H745 and Ethernet

jgauthier
Senior

I have read quite a few threads about ethernet on the H7, along with several internet posts. Part of me wonders if I should even try... But I am.

I've followed this guide:

https://community.st.com/s/article/How-to-create-project-for-STM32H7-with-Ethernet-and-LwIP-stack-working?t=1679361727348

As well as this guide:

https://github.com/AnielShri/STM32H745_Ethernet/blob/master/Documentation/lwip_nortos.md

They are similar, with some slight differences with the MPU cache settings.

For me, the first post results in a hard fault. But with the second, I am able to boot.

While I would eventually like to get to RTOS, at the moment I'm just trying to implement this using LWIP.

My first test is just basic ICMP - which doesn't work. That is, until I comment out this line:

SCB_EnableDCache();

So, of course, that implies something with the data cache, and memory locations.

So, my settings looks like these:

0693W00000aJMqQQAW.pngLWIP settings:

0693W00000aJMqVQAW.png 

I've added the following to the linker script:

  /* Modification start */
  .lwip_sec (NOLOAD) : {
    . = ABSOLUTE(0x30040000);
    *(.RxDecripSection) 
    
    . = ABSOLUTE(0x30040060);
    *(.TxDecripSection)
    
    . = ABSOLUTE(0x30040200);
    *(.RxArraySection) 
  } >RAM_D2

Sometimes, I get this error upon each ICMP packet that is received:

 Assertion "pbuf_free: p->ref > 0" failed at line 753 in ../Middlewares/Third_Party/LwIP/src/core/pbuf.c

Again, it goes away when I disable the dcache. I'm not sure what else to try. I must have something not quite right. Thanks.

8 REPLIES 8
Pavel A.
Evangelist III

>That is, until I comment out this line:

>SCB_EnableDCache();

>So, of course, that implies something with the data cache, and memory locations.

Of course it does. But this is a bit complicated. So keep reading the forum posts, especially by @Piranha​  who made several valuable digests.

Also look at most recent ST examples for H7 here.

Hold your impulse to generate projects with CubeMX/IDE until you have at least one ready example (for some eval board) working more or less.

Also note that recently ST ​is moving from LwIP and FreeRTOS to Microsoft's offering: AzureRTOS (ThreadX, NetX etc.), if this sounds good to you, research that direction.

LCE
Principal

Not so helpful, but... I never enabled the caches in the first place.

I'm using H723 / H735 (they have different memory layout and restrictions compared to the H74x) with lwIP, works great.

Thanks for your response. I do have that page bookmarked. I will explore it further. I have read a lot of @Piranha's posts. I felt like I am so close. I am interested that they are moving to a new stack. One point of concern is that they've been using FreeRTOS/LWIP for years and it's still buggy. Are they starting the clock over with a new stack?

In CubeMX, you cannot enable LWIP without the caches. Doesn't mean much, but there it is. If all else fails I will continue down that path. I really wanted to get them working in conjunction.

One more reason to use CubeMX only as a starting point... (I did so too, and then threw out almost everything, including the ETH HAL drivers).

It does do a decent job for many things. This is more complex and does seem to challenge it. What ETH drivers are you using currently?

Piranha
Chief II

https://community.st.com/s/question/0D53W00001Z9K9TSAV/maintaining-cpu-data-cache-coherence-for-dma-buffers

https://community.st.com/s/question/0D50X0000BOtfhnSQB/how-to-make-ethernet-and-lwip-working-on-stm32

> It does do a decent job for many things.

The only thing it is actually useful, is setting up a pin layout for a PCB design. Otherwise it is "great" for generating a broken bloatware, fooling the beginners and ticking the boxes for managers. Therefore it is great in wasting a humanity's time on a useless pseido-solution. Such a pseido-solutions greatly hold us back of the realization that a software development is an ENGINEERING and should be treated like that. Instead the current industry and education system treats software development as some bohemian art.

Post edited to adhere community guidelines.

@Pavel A.​ I implemented The AzureRTOs stack and spent less time doing it than I did the FreeRTOS stack. Definitely appreciate the tip. I have a multithreaded TCP server working that communicates using queues.