cancel
Showing results for 
Search instead for 
Did you mean: 

Mongoose Crashes when Cache is enabled on H757

hussamaldean
Associate

 

Hey embedded folks — I’ve been debugging a persistent issue with Ethernet on an STM32H7 (dual-core) MCU using the Mongoose TCP/IP stack, and I could use some insight.
What’s happening:

 

  • I'm using RAM_D2 (0x30000000) for ETH descriptors, placed correctly with linker and MPU configured as non-cacheable.
  • Ping works initially, but I start getting duplicate replies and eventually:
    assertion "q->tail + n + sizeof(n) <= q->size" failed in mg_queue_read_len
  • If I disable the CPU caches, everything works fine — but obviously, that’s not ideal long-term and CPU usage shoots from 5% to 65%.
What I’ve tried:
MPU config for RAM_D2: non-cacheable, bufferable
Descriptor alignment (32B) and placement verified
Compared with Mongoose H747 example — setup is nearly identical

Still running into “no free descriptors” or corrupted queue crashes when caches are enabled
Questions:
  • What’s the correct sequence for D-Cache clean/invalidate with DMA descriptors?
  • Should I invalidate the whole 16KB D2 SRAM region, or only parts used?
  • Anyone successfully using Mongoose with D-Cache enabled on STM32H7?
Any tips, examples, or code snippets would be greatly appreciated.
2 REPLIES 2

You should be very careful with Invalidate DCache, it can impact structures abutting those you're trying to affect, and can cause problems with the write buffers and stack

Instrument code, perhaps sanity check it manipulating structures

You're using DMA? For what specifically?

Clean DCache is the "Flush" operation, perhaps use with other memory fencing functions

Use Invalidate DCache ONLY on structures that have been written via DMA

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

DMA descriptors of the Ethernet.

The rest of the mongoose source file, I see no DMA handler at all.