jlaitine opened a new pull request, #19061:
URL: https://github.com/apache/nuttx/pull/19061

   ## Summary
   
   Here is one proposal, how we could save a bit of flash on small systems.
   
   First commit (not too significant one) doesn't change functionality, just 
cleans up a tiny amount of flash (64 bytes on 32-bit arm) by removing a 
duplicate string and an extra function call. The duplicate string was not 
cleaned up by linker because the string was only *almost* the same, the other 
one had one extra space.
   
   The second one adds two new CONFIG flags giving more granularity to 
configure what to dump at crash:
   
   CONFIG_SCHED_DUMP_STACK : Output stack dump at crash, consumes ~1kB flash ( 
If disabled, it still dumps the current stack, irq stack and kernel stack base 
and size )
   CONFIG_SCHED_DUMP_TASKS : Output tasks dump at crash, consumes ~0.5kB flash
   
   By removing these two, 1.6kB can be saved in flash size.
   
   Both flags are defined !CONFIG_DEFAULT_SMALL, so with normal configurations 
the functionality is unchanged.
   
   ## Impact
   
   Impacts boards definining CONFIG_BUILD_SMALL, reducing flash consumption and 
output of kernel panic dump by default. On these systems, restoring the 
original panic dump would require adding CONFIG_SCHED_DUMP_STACK=y, 
CONFIG_SCHED_DUMP_TASKS=y to the defconfig.
   
   ## Testing
   
   Tested on stm32-f765II (pixhawk4 board)
   
   With both the new flags disabled, the crash dump looks like this:
   
   ```
   Hard Fault escalation:
   PANIC!!! Hard Fault!:
        IRQ: 3 regs: 0x2007dac8
        BASEPRI: 00000080 PRIMASK: 00000000 IPSR: 00000003 CONTROL: 00000000
        CFSR: 00008200 HFSR: 40000000 DFSR: 00000000 BFAR: 0000016c AFSR: 
00000000
   Hard Fault Reason:
   Current Version: NuttX  12.12.0 97e9848b92 Jun  8 2026 13:41:23 arm
   Assertion failed panic: at file: :0 task: px4_entry process: px4_entry 
0x8100039
   R0: 00000000 R1: 00000000 R2: 00000080  R3: 00000000
   R4: 00000000 R5: 00000000 R6: 00000220  FP: 00000000
   R8: 00000220 SB: 00000260 SL: 00000020 R11: 00000000
   IP: 00000000 SP: 2007dba0 LR: 0801c345  PC: 0801c348
   xPSR: 61000000 BASEPRI: 00000080 CONTROL: 00000000
   EXC_RETURN: ffffffed
   IRQ Stack: base: 0x200212c0 size: 768
   User Stack: base: 0x2007d110 size: 3152
   ```
   
   With CONFIG_SCHED_DUMP_TASKS=y, CONFIG_SCHED_DUMP_STACK=n:
   
   ```
   Hard Fault escalation:
   PANIC!!! Hard Fault!:
        IRQ: 3 regs: 0x2007dac8
        BASEPRI: 00000080 PRIMASK: 00000000 IPSR: 00000003 CONTROL: 00000000
        CFSR: 00008200 HFSR: 40000000 DFSR: 00000000 BFAR: 0000016c AFSR: 
00000000
   Hard Fault Reason:
   Current Version: NuttX  12.12.0 648d0d828a Jun  8 2026 14:57:34 arm
   Assertion failed panic: at file: :0 task: px4_entry process: px4_entry 
0x8100039
   R0: 00000000 R1: 00000000 R2: 00000080  R3: 00000000
   R4: 00000000 R5: 00000000 R6: 00000220  FP: 00000000
   R8: 00000220 SB: 00000260 SL: 00000020 R11: 00000000
   IP: 00000000 SP: 2007dba0 LR: 0801c595  PC: 0801c598
   xPSR: 61000000 BASEPRI: 00000080 CONTROL: 00000000
   EXC_RETURN: ffffffed
   IRQ Stack: base: 0x200212c0 size: 768
   User Stack: base: 0x2007d110 size: 3152
      PID GROUP PRI POLICY   TYPE    NPX STATE   EVENT      SIGMASK          
STACKBASE  STACKSIZE      USED   FILLED    COMMAND
     ----   --- --- -------- ------- --- ------- ---------- ---------------- 
0x200212c0       768       600    78.1%    irq
         0     0   0 FIFO     Kthread -   Ready              0000000000000000 
0x2002b3cc       734       472    64.3%    Idle_Task
         1     0 249 FIFO     Kthread -   Waiting Semaphore  0000000000000000 
0x20041988      1216       336    27.6%    hpwork 0x20020b88 0x20020bd8
         2     0  50 FIFO     Kthread -   Waiting Semaphore  0000000000000000 
0x20041f80      1568       336    21.4%    lpwork 0x20020b18 0x20020b68
         3     3 100 FIFO     Task    -   Waiting Semaphore  0000000000000000 
0x2007c498      2016       336    16.6%    uwork
         4     4 100 FIFO     Task    -   Running            0000000000000000 
0x2007d110      3152       776    24.6%    px4_entry
         5     0 255 FIFO     Kthread -   Waiting Semaphore  0000000000000000 
0x200430b0      1240       344    27.7%    wq:manager
         6     0 205 FIFO     Kthread -   Waiting Semaphore  0000000000000000 
0x200436b8      3440       448    13.0%    wq:lp_default 80f6350
   
   ```
   
   Ad the current functionality, both flags = y:
   
   ```
   Hard Fault escalation:
   PANIC!!! Hard Fault!:
        IRQ: 3 regs: 0x2007dac8
        BASEPRI: 00000080 PRIMASK: 00000000 IPSR: 00000003 CONTROL: 00000000
        CFSR: 00008200 HFSR: 40000000 DFSR: 00000000 BFAR: 0000016c AFSR: 
00000000
   Hard Fault Reason:
   Current Version: NuttX  12.12.0 648d0d828a Jun  8 2026 15:04:19 arm
   Assertion failed panic: at file: :0 task: px4_entry process: px4_entry 
0x8100039
   R0: 00000000 R1: 00000000 R2: 00000080  R3: 00000000
   R4: 00000000 R5: 00000000 R6: 00000220  FP: 00000000
   R8: 00000220 SB: 00000260 SL: 00000020 R11: 00000000
   IP: 00000000 SP: 2007dba0 LR: 0801c715  PC: 0801c718
   xPSR: 61000000 BASEPRI: 00000080 CONTROL: 00000000
   EXC_RETURN: ffffffed
   User Stack:
     base: 0x2007d110
     size: 00003152
       sp: 0x2007dba0
   0x2007db80: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
0800eef9
   0x2007dba0: 00000260 00000000 00000220 0801c74d 00000088 2007e2b0 00000220 
080b3497
   0x2007dbc0: 00000088 2007e2b0 2007dc40 2007e2b4 00000220 00000000 00000000 
080b341f
   0x2007dbe0: 00000088 080b2499 2002641c 00000000 080f7dcc 00000000 080b2389 
080f7dcc
   0x2007dc00: 00000000 080b251d 00000003 2007dc40 00000001 080b2e1b 00000000 
00000000
   0x2007dc20: 00000000 2007e2b0 00000000 00000003 080fe28c 08008000 080fe218 
080a75f3
   0x2007dc40: 000009b4 00000000 696e6906 6c616974 64657a69 524f7520 6f6c2042 
6e696767
   0x2007dc60: 00000067 00000000 00000000 00000000 00000000 00000000 00000000 
00000000
   0x2007dc80: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
00000000
   0x2007dca0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
00000000
   0x2007dcc0: 00000000 00000000 00000003 080aa097 00000000 00000001 40021800 
00000000
   0x2007dce0: 2007d0f8 2007d0f8 00000000 080a91b1 00000000 00000000 00000000 
00000000
   0x2007dd00: 00000000 00000000 2007d0f8 0800aaa9 00000001 08009e33 00000001 
2007d0f8
   0x2007dd20: 2007d0f8 08100049 00000018 00000000 00000001 08100039 00000001 
08104719
   0x2007dd40: 2007d0f8 0801928b 08100039 0801928b 00000000 00000000 00000000 
00000000
   0x2007dd60: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
00000000
      PID GROUP PRI POLICY   TYPE    NPX STATE   EVENT      SIGMASK          
STACKBASE  STACKSIZE      USED   FILLED    COMMAND
     ----   --- --- -------- ------- --- ------- ---------- ---------------- 
0x200212c0       768       656    85.4%!   irq
         0     0   0 FIFO     Kthread -   Ready              0000000000000000 
0x2002b3cc       734       472    64.3%    Idle_Task
         1     0 249 FIFO     Kthread -   Waiting Semaphore  0000000000000000 
0x20041988      1216       336    27.6%    hpwork 0x20020b88 0x20020bd8
         2     0  50 FIFO     Kthread -   Waiting Semaphore  0000000000000000 
0x20041f80      1568       336    21.4%    lpwork 0x20020b18 0x20020b68
         3     3 100 FIFO     Task    -   Waiting Semaphore  0000000000000000 
0x2007c498      2016       336    16.6%    uwork
         4     4 100 FIFO     Task    -   Running            0000000000000000 
0x2007d110      3152       776    24.6%    px4_entry
         5     0 255 FIFO     Kthread -   Waiting Semaphore  0000000000000000 
0x200430b0      1240       344    27.7%    wq:manager
         6     0 205 FIFO     Kthread -   Waiting Semaphore  0000000000000000 
0x200436b8      3440       448    13.0%    wq:lp_default 80f6528
   
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to