2024-01-15 03:11 AM - last edited on 2024-01-15 04:56 AM by SofLit
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?
Solved! Go to Solution.
2024-01-15 12:23 PM - edited 2024-01-15 12:27 PM
@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.
2024-01-15 03:38 AM
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.
2024-01-15 03:41 AM
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)
2024-01-15 03:45 AM
It does NOT need any cache, that's just some *** CubeMX restriction.
I have lwip running on F7 and H7 STMs, no cache enabled.
2024-01-15 04:19 AM
Hello,
You need to enable the cache to boost the performance. You can also disable the cache but with less performance.
2024-01-15 04:42 AM
@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
2024-01-15 05:04 AM
"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
2024-01-15 12:23 PM - edited 2024-01-15 12:27 PM
@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.
2024-01-15 01:36 PM
@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)
2024-01-15 02:40 PM
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.