cancel
Showing results for 
Search instead for 
Did you mean: 

[Bug] Heap and Stack size of 0x00

AScha.381
Associate II

The Linker Script is not being updated, if a heap or stack size of 0x00 is being written in MX and a code is being generated. Also mx.scratch won't be deleted.

I'm using STM32CubeIDE v 1.3.1 and tried it on the L011F4 and L452RE controllers.

To set the heap or stack on 0x00 you have to either set it to 0x00 in the Linker Script everytime manually oder set it in MX to 0x00 and don't have an updated Linker Script.

2 REPLIES 2
KnarfB
Principal III

What is the use case for setting both to 0? In the startup code there are some function calls like calls to SystemInit(), __libc_init_array() and main(). So the first stack overflow will occur already before entering main(). And, there are C runtime lib functions and fault handlers needing a piece of stack.

For the heap, I suspect, but haven't checked newlibc source code, that there may be also init functions that set up a heap data stucture and need some tiny little heap space.

You can, of course, write your own bare metal code, but I would not use CubeMX for code generation then.

AScha.381
Associate II

I don't need the heap in my use case. But I do need the free space it would take. Setting it to 1 is fine, but 0 doesn't work because the Linker Script won't be generated. It also works fine if I set it to 0 in the Linker Script, but it needs to be manually set to 0 everytime the code is generated.

The stack won't be set to 0 in my use case, but has has the same problem when setting it to 0 in CubeMX.