Skip to content

feat: make the memory footprint tunable and lower defaults to measured floors - #187

Draft
benjaminbruun wants to merge 10 commits into
masterfrom
feat/memory-tunables
Draft

benjaminbruun wants to merge 10 commits into
masterfrom
feat/memory-tunables

Conversation

@benjaminbruun

Copy link
Copy Markdown
Member

The stack/heap requirements imposed on integrating apps become overridable Kconfig options, and the defaults drop to measured values: SoftSIM workqueue stack 10000 -> 6000 and heap (plus its build-assert floor) 30000 -> 24000, based on on-target measurement over provisioning, attach and 12 re-attach cycles (heap peak 17.9 KB, stack high-water 2.2 KB). Also defers the SIM context allocation to the modem INIT request, moves scratch buffers off .bss, sizes SS_STORAGE_PATH_MAX to real paths, and adds docs/memory.md with the measured budget.

@benjaminbruun
benjaminbruun force-pushed the feat/memory-tunables branch 2 times, most recently from ae76c86 to 54929a8 Compare August 25, 2026 13:54
CONFIG_SOFTSIM_STACK_SIZE replaces the hardcoded 10000, and the main-stack/
heap values move from overlay assignments to Kconfig defaults so an
application prj.conf can override them. Values unchanged.

Signed-off-by: Benjamin Bruun <bb@onomondo.com>
nrf_softsim_init() eagerly allocated ~5 KB of heap the INIT handler already
allocates on demand; APDU/RESET without a context now answer with an error.

Signed-off-by: Benjamin Bruun <bb@onomondo.com>
The R-APDU buffer and the PSA cipher scratch are only live inside one
function each; as stack locals they stop costing 516 B of permanent RAM.

Signed-off-by: Benjamin Bruun <bb@onomondo.com>
The longest path in a provisioned profile is 20 chars; 100 mostly paid in
storage-layer stack frames. The port sources now get the same define.

Signed-off-by: Benjamin Bruun <bb@onomondo.com>
The default case answered nothing, leaving the modem waiting forever on
any command a future firmware adds.

Signed-off-by: Benjamin Bruun <bb@onomondo.com>
Measured RAM/flash budgets for the nRF9151 sample, where the module's
static and heap bytes go, and how to measure before trimming a knob.

Signed-off-by: Benjamin Bruun <bb@onomondo.com>
On-target nRF9151-DK: heap peak 17856 B and softsim-thread HWM 2200 B
across provisioning, attach and 12 re-attach cycles; defaults keep OTA
headroom and margin (heap 24000, stack 6000).

Signed-off-by: Benjamin Bruun <bb@onomondo.com>
Measured: TF-M uses ~40 KB; the only cut is one 8 KB SPU step, and the
instance also serves the integrating application's PSA/ITS usage.

Signed-off-by: Benjamin Bruun <bb@onomondo.com>
An application's own CONFIG_HEAP_MEM_POOL_SIZE beat the Kconfig default
and tripped the floor assert. Declare HEAP_MEM_POOL_ADD_SIZE_SOFTSIM so
the kernel rounds the effective pool up to it, and assert on the
effective K_HEAP_MEM_POOL_SIZE.

Signed-off-by: Benjamin Bruun <bb@onomondo.com>
Signed-off-by: Benjamin Bruun <bb@onomondo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant