Skip to content

Emulated nRF52 boards keep what they store - #786

Merged
A13xB0 merged 2 commits into
mainfrom
fix-565-nrf52-storage
Oct 30, 2026
Merged

A13xB0 merged 2 commits into
mainfrom
fix-565-nrf52-storage

Conversation

@A13xB0

@A13xB0 A13xB0 commented Oct 24, 2026

Copy link
Copy Markdown
Collaborator

Closes #565.

There were two faults.

1. The SoftDevice refused every flash operation. I found it with the GDB stub from #191, breaking after the svc 0x28 stub (sd_flash_page_erase) on a RAK_4631:

pc=49d62 r0=f   (NRF_ERROR_FORBIDDEN), page 0xED, every attempt

FICR never wrote CODEPAGESIZE (0x010) or CODESIZE (0x014). With both at zero, the SoftDevice sees no flash and forbids every page. So LittleFS never formatted, and IdentityStore::save() failed. Both registers are now set (4 kB pages, 256 of them). After the fix, the same breakpoint shows r0=0 for pages 0xED, 0xEE, 0xEF and onward.

2. Renode rebuilt flash from the image at every start, so even working storage would not have survived a restart. NVMC now writes the InternalFS region (0xED000, 28 kB) to the node's directory whenever CONFIG returns to read-only. The next start of the same build loads it back. The file is keyed by the image's hash, so a different build starts empty, as reflashing a board does.

Live check on RAK_4631 v1.17.1: set af 7, then node.stop and node.start, then get af returns 7.0 (the default is 1.0).

As the issue's comment warns, identity is no evidence here because it is seed-derived. The preference is the evidence.

FICR left CODEPAGESIZE and CODESIZE at zero, so the SoftDevice saw no
flash and answered every sd_flash_page_erase and sd_flash_write with
NRF_ERROR_FORBIDDEN (found with node.debug's GDB stub: r0 = 0xF after
svc 0x28). LittleFS never formatted.

Renode also rebuilt flash at every start. NVMC now writes the
InternalFS region to the node's directory whenever flash goes back to
read-only, and the next start of the same build loads it.

Closes #565.
@A13xB0
A13xB0 merged commit fedb38d into main Oct 30, 2026
10 checks passed
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.

Persistent storage does not work on emulated nRF52 boards

1 participant