cancel
Showing results for 
Search instead for 
Did you mean: 

Why does LwIP need CPU DCache (on STM32H743)?

musmuris
Associate II

To enable LwIP in CubeMX (inside CubeIDE) it needs the CPU data cache enabled.  Ok, no problems, but it doesn't explain why and I can't find why this is the case. Is anyone able to offer an explaination?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Pavel A.
Evangelist III

@musmuris The D-cache is required because the LwIP code uses "cache maintenance" operations (aka flush & discard). These may crash when the cache is not active - because of bug or "feature" in some low level stuff (CMSIS or whatever). Nucleo-H743ZI2 is a mature well known board, the ready examples should work. So, better start with these examples and *do not touch anything* for now, just let it work as is. If you want to edit the board config in CubeMX/IDE & re-generate the project: please suppress the urge until you get the ETH example working. (yes, these examples have some other issues but deal with them later). 

If you absolutely have to disable the D cache: a. Skip the enable (rather than enable then disable), b. Remove/comment out the "cache maintenance" stuff.

Good luck.

 

 

View solution in original post

9 REPLIES 9
STOne-32
ST Employee

Dear @musmuris ,

 

Welcome in STCommunity , I assume the MCU is STM32H5 series ? , we will move the topic to MCU boards for follow up .

Ciao

STOne-32.

@STOne-32 

Thanks. I assumed this was more a CubeMX thing, but wasn't sure where to put it.  It's actually the STM32H743  (Nucleo-H743ZI2 board to be even more precise)

LCE
Principal

It does NOT need any cache, that's just some *** CubeMX restriction.

I have lwip running on F7 and H7 STMs, no cache enabled.

SofLit
ST Employee

Hello,

You need to enable the cache to boost the performance. You can also disable the cache but with less performance.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

@SofLit wrote:

Hello,

You need to enable the cache to boost the performance. You can also disable the cache but with less performance.


@SofLit  Thanks - I understand that, but that doesn't mean it's mandated but CubeMX makes you do it (rather than just recommend) - And if you then disable it then LwIP gets disabled.   If DCache is not required then this is a bug in CubeMX isn't it?

I'm obviously happy to enable it and use DCache - but I like to understand reasons for things (or if it's just a bug)

Thanks,

Nigel 

"And if you then disable it then LwIP gets disabled"

From my point of view it doesn't make sense to force the user to enable the cache for that feature (except there is something I'm not aware of). So we need the help of @Sara BEN HADJ YAHYA 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Pavel A.
Evangelist III

@musmuris The D-cache is required because the LwIP code uses "cache maintenance" operations (aka flush & discard). These may crash when the cache is not active - because of bug or "feature" in some low level stuff (CMSIS or whatever). Nucleo-H743ZI2 is a mature well known board, the ready examples should work. So, better start with these examples and *do not touch anything* for now, just let it work as is. If you want to edit the board config in CubeMX/IDE & re-generate the project: please suppress the urge until you get the ETH example working. (yes, these examples have some other issues but deal with them later). 

If you absolutely have to disable the D cache: a. Skip the enable (rather than enable then disable), b. Remove/comment out the "cache maintenance" stuff.

Good luck.

 

 


@Pavel A. wrote:

The D-cache is required because the LwIP code uses "cache maintenance" operations (aka flush & discard). These may crash when the cache is not active 

 

Thanks - that's a good reason! As I said I have no need to disable the cache, I just like to know why things are needed where possible

 


Nucleo-H743ZI2 is a mature well known board, the ready examples should work. 

The examples do - but trying to start from scratch is a nightmare.  I have managed to walk a narrow path and get PING working, but then it only handles 10 UDP packets before crashing.  But diffing that solution with a broken one I made it's really hard to tell what is wrong (i.e. it's in clocks or something).  Also CubeMX has changed and no longer has (for example) the Rx Buffers option on ETH which others show in screenshots
The best example doesn't use CubeMX so is harder to take and adapt for people new to STM32 (I'm gonna need to add QSPI flash next)

Pavel A.
Evangelist III

This is why I don't recommend to start from scratch with a cube-generated project. Ethernet examples are hand-tuned. Cube can generate code for some things but not others, have to merge carefully.