Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The changes can write before ENCRYPT_CACHE when trailer data does not fit and lose encryption keys on write-once flash because page-based placement conflicts with sector-based key selection and readers.
3 open issues
What changed in this PR
This PR introduces page-sized flash operations for encryption-key and trailer-magic updates, as a step toward reducing wolfBoot’s staging RAM requirements.
Changes:
- Adds
WOLFBOOT_PAGE_SIZE, defaulting toWOLFBOOT_SECTOR_SIZE. - Uses page-sized alignment, copying, erasing, and writing in
hal_set_key(). - Changes write-once redundant-copy offsets to use page size.
| File | Description |
|---|---|
src/libwolfboot.c |
Adds the page-size fallback and applies page sizing to encryption-key updates. |
Review effort: Balanced
|
Hi @vhdirk thanks for this pull request. I do not see you on our contributor agreement list. To get setup please send an email to support at wolfssl dot com and reference this pull request and include details about your project and location. Are you planning any additional contributions? Thanks, David Garske, wolfSSL |
|
@dgarske we (aloxy) should be on the contributer list; we've contributed before. I myself may not be on there. On zendesk, we've mostly been in contact with @danielinux. While I did not reference this PR exactly, Daniele is aware that I have a series of patches coming up. |
bf273e9 to
ae7fb81
Compare
Add FLASH_ERASE_UNIT / WOLFBOOT_FLASH_ERASE_UNIT independently of the logical sector size, with a sector-sized fallback and a 128-byte default for STM32L0. Update non-write-once hal_set_key() to cache and rewrite only the erase units touched by the key, nonce, and trailer magic. Preserve surrounding data, handle fields spanning units and FLAGS_HOME, and validate geometry and partition bounds before accessing flash. Default NVM_CACHE_SIZE to the erase unit in non-write-once builds while keeping write-once caches and redundant trailer copies sector-sized. On STM32L0 with 4 KiB sectors, the cache shrinks to 128 bytes. Add erase-geometry, data-preservation, error-handling, and cache-scrubbing tests for ChaCha20, AES-256, straddling fields, FLAGS_HOME, and the sector fallback. Document the configuration and HAL erase contract. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ae7fb81 to
3458db7
Compare
|
Okay to test. Contributor agreement on file for company. |


This commit introduces
FLASH_ERASE_UNITas the smallest possible erase unit.Together with a smaller sized
ENCRYPT_CACHEsize, this lowers the amount of ram and copies needed for key/trailer manipulationThis was (re)written with extensive help from AI tools.