Stack and heap information

Hi ! :slight_smile:

I’m using the evaluation board based on STM32F446RET and uploaded PX4 F/W.

However, there is a problem on memory (maybe).

Firstly, I removed a lot of part in ‘nuttx_px4fmu-v4_default.cmake’ file and just executed ‘nsh’ in terminal.

After that I added sensor parts such as MPU9250, MS5611 and so on. It was initialized but I cannot check the sensor’s value.

When I debug on eclipse, the program stopped at ‘mm_mallinfo’ function in ‘mm_mallinfo.c’ file.

I think that I have to configure 'Stack and heap information’ in ‘px4fmu-v4/nsh/defconfig’ file. (753 line)

What value should I change and how can I know it?

@DoEon_Lee: This won’t quite answer your question, but I think it will give you some additional information that you should find useful.

Before tweaking the Stack allocation, make sure the linker script has the correct flash, and memory allocations set. The linker script ld.script can be found in nuttx-configs/px4fmu-v4/scripts.

If you search for “stack” in the defconfig file, you will see a number of stack allocation sizes for various threads/processes.

When you start a daemon with px4_task_spawn_cmd(), one of the arguments that is passed to the function is the stack to be allocated to that process. You can see how much stack is allocated and currently being used by a process by running top from the NSH shell.

To see how much heap you have used, run free from the NSH shell.