4 Replies Latest reply on Jul 2, 2020 10:45 AM by CaKu_4284131

    Has anyone ported heap_useNewlib (for FreeRTOS) to PSoC 6?


      I'm suddenly having to learn about newlib the hard way. I fell into a pitfall involving concurrency protection for malloc/free/etc. inside of sprintf using %f, [See long saga at Intermittent CM4 FAULT! Bus Fault! in floating point app - Kernel - FreeRTOS Community Forums] 


      I think the main thing I needed is:

      #define configUSE_NEWLIB_REENTRANT              1

      in  FreeRTOSConfig.h. But now I'm having trouble with "ERROR: region RAM overflowed with stack."


      I'm interested in trying Dave Nadler's heap_useNewlib. (See newlib and FreeRTOS ). I tried heap_useNewlib_NXP.c but it needs HEAP_SIZE in the linker file:

      extern char __HeapBase, __HeapLimit, HEAP_SIZE;  // make sure to define these symbols in linker command file
      static int heapBytesRemaining = (int)&HEAP_SIZE; // that's (&__HeapLimit)-(&__HeapBase)


      __HeapBase and __HeapLimit are in cy8c6xx7_cm4_dual.ld, but not HEAP_SIZE. I imagine it's a simple thing to add, but I've never worked with ld files before, and my first attempt failed. Has anyone already been down this road?