How to expand the size of a heap?
When I'm using the cjson library for learning, nuttx gets assertion errors. I don't think it's the program, it's the heap space that's too small causing the error, I tried to increase "The default stack size for tasks", however it didn't help. I don't know what to do anymore.
_assert: Current Version: NuttX 12.3.0 eddd90de78-dirty Nov 22 2023 18:50:25m _assert: Assertion failed panic: at file: :0 task: 0x801e001 up_dump_register: R0: 00000000 R1: 00000000 R2: 10005400 R3: 656b6f74 up_dump_register: R4: 10005288 R5: 00000000 R6: 00000000 FP: 00000000 up_dump_register: R8: 00000000 SB: 00000000 SL: 00000000 R11: 00000000 up_dump_register: IP: 10005010 SP: 10004f30 LR: 080097b7 PC: 08009a96 up_dump_register: xPSR: 21000000 PRIMASK: 00000000 CONTROL: 00000000 up_dump_register: EXC_RETURN: fffffff9 dump_stack: User Stack: dump_stack: base: 0x10001420 dump_stack: size: 00016352 dump_stack: sp: 0x10004f30 stack_dump: 0x10004f20: 10005010 080097b7 08009a96 21000000 0000000c 20001740 10 stack_dump: 0x10004f40: 1000fff8 00000000 00000010 00000000 00000010 10005400 07 stack_dump: 0x10004f60: 00000000 0000000b 200002e6 08025e5c 10005c10 0801e137 2c stack_dump: 0x10004f80: 00000000 0000000b 2000034c 0801fea3 08025e54 08025e5c 00 stack_dump: 0x10004fa0: 00000000 0801fd95 00000000 2000034c 00000000 08025e5c 00 stack_dump: 0x10004fc0: 00000014 10005c10 00000001 0801daf3 10005010 10005be0 0b stack_dump: 0x10004fe0: 10004ffc 01005010 000051b0 0801dd25 03040000 0801decb 00 stack_dump: 0x10005000: 08bd0c02 ffffff03 10005150 0801dfa9 09fe6a13 01570000 00 stack_dump: 0x10005020: 08bd0c02 d4097203 00007dc8 00000043 fffe0000 8c18fffd 3f stack_dump: 0x10005040: 42c80000 bca1cb9f 00000000 0001003f 00000000 00000000 f4 stack_dump: 0x10005060: 0000004a 0000c900 00000000 00000000 00000000 00000000 00 stack_dump: 0x10005080: 00000000 00000000 00000000 00000000 00000000 00000000 00 stack_dump: 0x100050a0: 00000000 00000000 00000000 00000000 00000000 00000000 00 stack_dump: 0x100050c0: 00000000 00000000 00000000 00000000 00000000 00000000 00 stack_dump: 0x100050e0: 00000000 00000000 00000000 00000000 00000000 00000000 00 stack_dump: 0x10005100: 00000000 00000000 00000000 00000000 00000000 00000000 00 stack_dump: 0x10005120: 00000000 00006a13 00000000 00000000 10000000 ffffffff 13 stack_dump: 0x10005140: 09fe6a13 01570000 00000001 03040000 08bd0c02 d4097203 03 stack_dump: 0x10005160: fffe0000 8c18fffd 39e44a72 3a83126f 42c80000 bca1cb9f 0f stack_dump: 0x10005180: 00000000 00000000 fe3a4f03 01012414 0000004a 0000c900 00 stack_dump: 0x100051a0: 00000000 00000000 00000000 00000000 00000000 00000000 00 stack_dump: 0x100051c0: 00000000 00000000 00000000 00000000 00000000 00000000 00 stack_dump: 0x100051e0: 00000000 00000000 00000000 00000000 00000000 00000000 00 stack_dump: 0x10005200: 00000000 00000000 00000000 00000000 00000000 00000000 00 stack_dump: 0x10005220: 00000000 00000000 00000000 00000000 00000000 00000000 00 stack_dump: 0x10005240: 00000000 00000000 00000000 00000000 00000000 00006a13 00 stack_dump: 0x10005260: 0d000000 00e64e88 10001410 00000001 01f7dc88 70115809 01 stack_dump: 0x10005280: 6d475c63 a8da0410 09fe6a13 01570000 00000001 03040000 03 stack_dump: 0x100052a0: 00007dc8 00000043 fffe0000 8c18fffd 39e44a72 3a83126f 4f stack_dump: 0x100052c0: 00000000 0001003f 00000000 00000000 fe3a4f03 01012414 00 stack_dump: 0x100052e0: 00000000 00000000 00000000 00000000 00000000 00000000 00 stack_dump: 0x10005300: 00000000 00000000 00000000 00000000 00000000 00000000 00 stack_dump: 0x10005320: 00000000 00000000 00000000 00000000 00000000 00000000 00 stack_dump: 0x10005340: 00000000 00000000 00000000 00000000 00000000 00000000 00 stack_dump: 0x10005360: 00000000 00000000 00000000 00000000 00000000 00000000 00 stack_dump: 0x10005380: 00000000 00000000 00000000 00000000 00000000 00000000 03 stack_dump: 0x100053a0: 00000000 00000000 17000000 4c5cf151 6a005400 00000001 03 stack_dump: 0x100053c0: 08025ee8 10005408 00000000 08007729 00000000 10001410 01 stack_dump: 0x100053e0: 00000000 080039bb 00000000 10001040 00000001 00000001 00 dump_tasks: PID GROUP PRI POLICY TYPE NPX STATE EVENT SIGMASK D dump_task: 0 0 0 FIFO Kthread - Ready 000000000000> dump_task: 1 1 100 RR Task - Waiting Semaphore 000000000000> dump_task: 2 2 50 RR Task - Running 000000000000> dump_task: 3 3 100 RR Task - Waiting Signal 000000000000>
@GC-20-20 if you increased the stack size and the problem didn't fix, then maybe the issue is something else. You got a very informative dump, so you can use this information to find what is the issue. Enable the inclusion of debug symbol in the nuttx ELF file: Build Setup -> Debug Options -> [*] Generate Debug Symbols
Then you can use: arm-none-addr2line -e linux 0x08009a96
08009a96 is the PC where the crashed happened.
More info: https://cwiki.apache.org/confluence/display/NUTTX/Analyzing+Cortex-M+Hardfaults
If it is not enough to find the issue, when you will need to use GDB + OpenOCD, see more here: https://nuttx.apache.org/docs/latest/quickstart/debugging.html