feat(boards/px4/fmu-v4): trim work queue stacks to measured high-water

Work queue stacks are carved from the same allocator pool as the heap on
NuttX, so an over-reserved queue stack costs the board free memory directly.
This board runs out of heap before MAVLink can start (#28109).

Measured at default sizes with CONFIG_STACK_COLORATION=y, reading StackUsed
from top and /proc/<pid>/stack:

  queue         default   peak   set to   margin
  lp_default       3472   1412     2400     1.70x
  hp_default       2776   1104     2300     2.08x
  I2C1             2312    840     1900     2.26x

Effect: 2040 B returned to the heap.

Verified after trimming, on the resulting firmware rather than by calculation:

  queue         trimmed   peak   margin
  lp_default       2376   1388    1.71x
  hp_default       2272   1104    2.06x
  I2C1             1872    840    2.23x

lp_default's peak appears only after provoking the parameter autosave, which
runs on that queue and writes through to storage. Idle it reads 1100 B, so the
deep path has to be triggered deliberately: change a parameter to a genuinely
different value, since PX4 only saves when the value changed, then re-read
StackUsed. On a board too full to run top this is readable with
cat /proc/<pid>/stack, which reports the same up_check_tcbstack() figure.

The remaining queues are left alone because they have no slack: rate_ctrl
1.28x, SPI1 1.42x, INS0 1.56x, nav_and_controllers 1.69x. SPI2 looks generous
at 3.02x but CONFIG_WQ_SPI_STACKSIZE sizes every SPI queue, so its headroom
cannot be taken without starving SPI1.

INS0 is why these are measured rather than estimated: its peak is 1180 B with
ekf2 stopped and 3828 B once ekf2 runs in that queue.
This commit is contained in:
gguidone authored and Matthias Grob committed 2026-08-05 09:25:08 +02:00
1 parent 61b7efcbc3
commit 35ad0fb424
1 file changed
+3
+3
View File
@@ -104,3 +104,6 @@ CONFIG_SYSTEMCMDS_USB_CONNECTED=y
CONFIG_SYSTEMCMDS_VER=y
CONFIG_SYSTEMCMDS_WORK_QUEUE=y
CONFIG_EXAMPLES_FAKE_GPS=y
CONFIG_WQ_LP_DEFAULT_STACKSIZE=2400
CONFIG_WQ_HP_DEFAULT_STACKSIZE=2300
CONFIG_WQ_I2C_STACKSIZE=1900