Thank you for your contribution! Your page was very helpful to me. I am one of those unsuspecting embedded developers that got bit by sprintf using %f.
I’ve got heap_useNewlib_NXP.c running on Cypress PSoC 6 (M4). I’ve attached my linker script in case anyone finds it useful. I decided to give the heap all available memory:
> heap-stats
Total heap size: 57183
Free bytes in the heap now: 29919
Looks like I’ve got lots of room now. When I first switched, it seemed that newlib’s heap used more space than heap4, and I was already tight on space, so I had problems. Eventually I switched to newlib-nano supplemented with Marco Paland’s printf.
The comment is either not complete or maybe a bit misleading.
Thread-safe newlib heap allocator also plays nicely with BufferAllocation_2.c, of course.
When it comes to special cases like using dynamic non-cachable memory for some purposes, but cachable for others, things might get more complicated. If this applies to your MCU at all.
Sorry for my ignorance, but could you expand a bit on the scenario with mixed cacheable and non-cacheable memory? I believe the STM32F7 part has an L1 Cache and some RAM is cached while other is not, so I guess this caveat could be applied to that part?
When DMA accesses physical memory, it bypasses the caching mechanisms.
So if cached memory is used, the driver must flush and refresh the memory sections before they can be accessed.
The STM32F7 driver likes to assign uncached memory to be used by DMA. Therefore, I prefer to use BufferAllocation_1.c, so the allocation is under our control ( and not the heap ).
As Hein explained it’s all about DMA based drivers. You have a number of options as disable caching completely and nether mind manual cache management or use caches and dedicated buffers from non-cached configured MPU regions for DMA drivers along with cached memory for normal heap or enable caching completely and take care about cache management in your DMA powered drivers.
It depends on your use cases / requirements.
For FreeRTOS TCP including the STM32F7 driver you should follow Hein’s advise b/c he’s the creator