1

I'd like to allocate some memory on mm_heap, but its size is zero: debug mm_heap

This causes the memory allocation to fail. How can I debug this problem?

For reference, I'm using Nuttx on a STM32F765.

Stephan R.
  • 13
  • 2

2 Answers2

3

The heap size is zero because nothing was ever added to the heap. You can see this because the number of memory regions (mm_nregions) is also zero.

Memory regions are added to heap by mm_addregion() in mm_initialize(); There is guaranteed to be called at least once to add at least one memory regions. If the number of memory regions is zero this function failed for some reason.

The only way that the function can fail is it is passed bad parameters. The passing of the parameters is based one provided by the implementation of up_allocateheap() that you are using.

So what you must to is look at up_allocateheap() to understand what is being passed. The perhaps put a breakpoint of mm_addregion() to see exactly what it is unhappy about.

user6711188
  • 136
  • 2
0

Thank you very much for your answer.

I was able to solve the problem.

There was a little mix-up in stm32_boot.c and stm32_appinitialize.c in my program (copy-paste error).

Also I had not activated the "BOARD_LATE_INITIALIZE" in the menueconfig -> RTOS Features -> RTOS hooks.

Therefore, the GPIO initialization function was called before the initialization of the heap, which caused the error I described in the question.

Stephan R.
  • 13
  • 2