I have some experience coding 8 bit MCUs. I just am learning Cortex M.
I started with FreeRTOS from the official source, on a STM32 4kB M0. At first I had some issues with heap allocation and getting everything to compile. It’s my first time working with dyanmic memory allocation.
Anyway, I got everything compiling and have all the correct portables linked together on the 4kB STM32 M0.
When I go to create a task, I get the malloc error, from tasks.c I tried a few versions and went over everything in the MAP file.
It seems like at compile time, I have 1kB of RAM left (we have the STM32 peripheral drivers + CMSIS-Core + FreeRTOS & HEAP (1kB) in RAM at compile time). I think 1kB is sufficient to create a task. I can initialize the kernel, but when I go to add tasks it returns the malloc error.
I noticed that on the 4kB M0, I can also get FreeRTOS running with the official STM Cube FreeRTOS + CMSIS API port. Clearly a lot of work was done to get the CMSIS-API calls wired in.
I made sure to copy stack and heap settings from the STM port from the Cube, in case I am overflowing something. It made no difference, I will will get the malloc error when I go to create a task.
Ostensibly, that heap area is already carved out of memory at compile time so it should be there… right?
I have an 8kB STM32 CM0 development board lying around, and copied over the CM0 portables. Everything works great. So I am calling that I passed the “idiot” test…
Is there a lot of optimization and changes to FreeRTOS to get it work on a 4kB STM32 CM0? More generally, any 4kB CM0?
Am I missing something obvious, or is 4kB just too little without some major work?