Commit Graph

54 Commits (3eaf2f03b76ec00678e95ac35bf5c5dc29b8d839)

Author SHA1 Message Date
Dirk Van Haerenborgh 96cd40ba53 Use flash erase units for encryption key updates
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>
2026-11-10 11:19:28 +01:00
Daniele Lacamera 6925d20c55 make: let user-provided options win over target defaults
Target-specific assignments in arch.mk/options.mk/board.mk used hard
'=', silently clobbering values the user set via command line,
environment, or a sourced .config (e.g. LSCRIPT_IN from PR #958 was
defeated on every target with a dedicated script).

Convert the target-default assignments to '?=' (first-set wins) and,
for LSCRIPT_IN, capture the user value before the target files are
parsed so the last-resort default (hal/$(TARGET).ld) and the ARMClang
.sct default only apply when the user provided nothing.

CMake: WOLFBOOT_LSCRIPT_TEMPLATE had the same flaw (plain set() over a
user -D value); guard it with NOT DEFINED and let test-app use an
absolute user template as-is.

Document LSCRIPT_IN as a user option in docs/compile.md.

The x86 FSP TGL boards (kontron_vx3060_s2, nai_68int6) share
hal/x86_fsp_tgl_stage1.ld; arch.mk selects it via 'LSCRIPT_IN ?=', but
the hard default here ran first, so the stage1 build of those boards
looked for a non-existent hal/kontron_vx3060_s2_stage1.ld (CI:
'kontron_vx3060_s2 build test', red on master).
2026-11-04 18:16:06 +01:00
David Garske 767ef3de3c Add compressed firmware updates installed into an execute-in-place slot 2026-11-04 14:35:53 +01:00
David Garske 80a186f5c5
Merge pull request #953 from bigbrett/tc3-port-tweaks
Monolithic self-update version check + TC3xx/wolfHSM changes
2026-10-30 10:47:03 -07:00
Brett Nicholas 3c56b4bac0 Make wolfHSM cert chain name constraints optional, updates to support new wolfHSM keygen macro protection, further reducing codesize 2026-10-28 14:25:29 -07:00
David Garske 4f0948e11d PolarFire SoC: a FIT ramdisk that must load, and failover actions before the golden boot 2026-10-27 16:06:05 -07:00
Brett Nicholas 213d7d75ce bounds-check journal sector flags, test ECC self-update, fix doc typos 2026-10-27 16:46:40 +01:00
Brett Nicholas 258c640459 Add journal marker sector to better detect cut erase 2026-10-27 16:46:40 +01:00
Brett Nicholas 8b9fd4ca59 Update docs and comment cleanup 2026-10-27 16:46:40 +01:00
Brett Nicholas 1f6d07227d add ELF_FLASH_SCATTER_PRESERVE_SECTORS and associated tests 2026-10-27 16:46:40 +01:00
Brett Nicholas 41fbe4b326 Improve support for ECC flash parts:
- Add NVM ECC mode, which introduces a new erase check HAL API to use
   flash controller HW to blank check sectors instead of reading them
   and comparing to an erased byte (which typically triggers an ECC
   fault)
 - Add NVM Journal mode as an alternative to NVM_FLASH_WRITE_ONCE that
   does not require a sector-size RAM buffer and dramatically reduces
   the number of erases and programs required to set individual flags,
   while also being much more robust to power-cuts.
2026-10-27 16:46:40 +01:00
David Garske aef57a113d versal: support the system watchdog timer (WWDT) 2026-10-22 18:11:12 +02:00
Mattia Moffa bd3b0c8101 keytools: allow linking against an installed wolfSSL
Until now, the keytools could only build against the lib/wolfssl
submodule. This allows building them using an installed wolfssl.

The changes are mostly just in the build system, but sign.c has some
changes to avoid using mp_* functions, which are not usually exported in
the wolfssl shared object. Instead of doing that, we now sign to DER and
split into r/s.
2026-10-20 16:01:23 +02:00
David Garske cd4174ccc9 update_disk: fail closed when the boot-part DTB fixup does not land, and run it on the BL31 handoff 2026-10-07 20:44:28 -07:00
David Garske 339d3a6396 update_disk: tell the OS which slot it booted from via /chosen/wolfboot,boot-part 2026-10-07 20:07:38 -07:00
David Garske 80dbb6da15 update_disk: golden slot tried after the A/B attempts, exempt from anti-rollback and never written 2026-10-07 20:07:38 -07:00
Daniele Lacamera 8bdcc4e761 F-14272: consume the update state in the DISABLE_BACKUP path
The direct update->BOOT copy left the update partition at
IMG_STATE_UPDATING, so wolfBoot_start() re-entered wolfBoot_update(0)
on every boot: a wasted verification, and with ALLOW_DOWNGRADE a full
BOOT re-flash on every power-up. Reset the update state to NEW after
the update succeeds, as the swap path's final erase does; the write is
best effort, so in setups where the bootloader cannot write the update
partition the documented application requirement covers it. Add a
DISABLE_BACKUP unit variant with a state-consumption test.
2026-09-29 08:43:26 +02:00
David Garske 8f4578c84e Add optional boot confirmation and rollback for the disk boot path 2026-09-29 07:41:43 +02:00
David Garske 490a3791f9 Fix to keep the FIT DTB's own bootargs unless LINUX_BOOTARGS is explicitly configured 2026-09-24 16:03:12 +02:00
David Garske 664b09a075 update_disk: load signed image from a file when a filesystem is present 2026-09-02 10:47:33 +02:00
Brett Nicholas 25aa151f0b add asymmetric partition sizing for monolithic updates 2026-08-19 17:47:48 +02:00
David Garske c8faa5adc2 Authenticate raw device tree via signed HDR_DEVICE_TREE_DIGEST TLV (Fenrir #7998) 2026-08-13 08:39:22 +02:00
Mattia Moffa 6da07ffc3d Add support for ARM Compiler for Embedded on stm32u5 2026-07-31 16:00:14 +02:00
Brett Nicholas 235bd820e6 Add support for auxillary algorithms and cert chain/TPM usage 2026-07-22 11:47:16 +02:00
Brett Nicholas f7ea40f7cc Add oneshot hash build option 2026-04-17 08:25:51 +02:00
Daniele Lacamera b705ca74ae Warn when DISABLE_BACKUP is enabled
F/2257
2026-04-08 19:53:50 +02:00
Daniele Lacamera af670811fe zephyr integration as TEE.
- Integrates wolfPSA as psa_crypto/psa_store engine in TrustZone
- Provides interface to access APIs from non-secure mode
- Patches to enable wolfboot as TEE module in zephyr
- Patches to enable stm32h563-nucleo/ns as target in zephyr
- psa_crypto zephyr example using wolfboot/wolfPSA as secure engine
2026-01-07 08:27:58 +01:00
Brett Nicholas a3af00114b Improve docs for USER_XXX variables to clarify intent 2025-12-10 07:43:32 +01:00
Brett Nicholas 57b874be2d Simplify use of user-supplied keys and certificates with test app via
new `USER_ variables`
2025-12-10 07:43:32 +01:00
Brett Nicholas 004e91db9f remove path override disclaimer from docs 2025-10-02 15:16:27 +02:00
Brett Nicholas 2e06a5fafe Refactor Makefiles to allow overriding library dependency paths 2025-10-02 15:16:27 +02:00
Daniele Lacamera c1fbfd6b1d Rephrased description of assembly optimization 2024-10-25 09:18:06 +02:00
Daniele Lacamera 72a0aa3853 Added Benchmark script. Added ARMASM support. 2024-10-24 21:20:09 +02:00
Brett Nicholas 2d6308ec2c - Infineon TC3xx support
- fix (existing) unused variable compiler warnings
- documentation updates
- add multi-sector erase option
2024-07-31 09:22:31 +02:00
Daniele Lacamera fd80688a8e Added documentation on FLASH_OTP_KEYSTORE 2024-05-15 10:55:47 +02:00
David Garske 5ba777c748 Add documentation for ECC P-521. 2024-03-01 12:28:07 -08:00
Dimitri Papadopoulos be037ca04d Fix typos found by codespell 2023-07-04 07:43:02 +02:00
Daniele Lacamera 43fa7b17f1 Added WOLFBOOT_HUGE_STACK option
The option can be enabled to use RSA4096 with fast math.
2023-03-21 17:06:22 +01:00
David Garske ac6f5207c7 Update documentation. 2022-12-19 11:38:00 +01:00
David Garske f283929161 Improvements to gap fill. The default gap filling byte is `0xFF`. If using `FLAGS_INVERT=1` uses `0x00`. Can be overridden at build-time using `FILL_BYTE`. Fixes ZD 15356. 2022-12-19 11:38:00 +01:00
Daniele Lacamera 2e7b63eae5 Adding support for ED448 verification 2021-12-13 12:05:37 +01:00
Daniele Lacamera 39ee01a948 Added roll-back feature via inverse patch 2021-08-17 15:44:34 +02:00
Daniele Lacamera f9b826b677 SMALL_STACK: Added description in documentation
+ enabled option in the imx-rt1060 build
2021-07-09 11:18:27 +02:00
Daniele Lacamera f2bab09777 Added support for SIGN=NONE 2021-06-28 13:52:00 +02:00
Daniele Lacamera 4e27d9197f Added compile-time option to invert FLAGS logic (FLAGS_INVERT=1) 2020-11-03 11:05:14 +01:00
Daniele Lacamera b0fbafe014 Added DISABLE_BACKUP option 2020-09-14 16:31:07 +02:00
Daniele Lacamera f6252917d4 Updated documentation of compile-time options 2020-09-11 12:01:06 +02:00
David Garske c0b534edd7 wolfBoot Aarch64 support (Xilinx Zynq and Raspberry Pi):
* Added Aarch64 boot/startup support
* Added configuration templates for Raspberry Pi 3 and Xilinx ZynqMP UltraScale+
* Added Xilinx Zynq QSPI bare-metal Driver
* Added `NO_XIP` option for full `ext_flash_*` API on all partitions
* Added Xilinx SDK Project Template
* Added support for DTS image partitions
* Added wolfBoot signing tool in Native C (`tools/keytools/sign.c`).
* Added libwolfboot functions `int wolfBoot_fallback_is_possible(void);` and `int wolfBoot_dualboot_candidate(void);`
* Performance improvement to only hash application firmware image once
2020-03-04 12:04:46 -08:00
Daniele Lacamera 581d82517d Fixed docs/compile.md 2019-10-10 20:54:31 +02:00
Daniele Lacamera e897c5d7c3 Added description for `make config` 2019-10-10 20:49:09 +02:00