feat: make the memory footprint tunable and lower defaults to measured floors - #187
Draft
benjaminbruun wants to merge 10 commits into
Draft
benjaminbruun wants to merge 10 commits into
benjaminbruun wants to merge 10 commits into
Conversation
benjaminbruun
force-pushed
the
feat/memory-tunables
branch
2 times, most recently
from
August 25, 2026 13:54
ae76c86 to
54929a8
Compare
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>
benjaminbruun
force-pushed
the
feat/memory-tunables
branch
from
August 25, 2026 14:12
54929a8 to
1705dfa
Compare
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>
This was referenced Aug 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.