-
Notifications
You must be signed in to change notification settings - Fork 11
Rewrite ec-slimloader to use persistent state journal and ROM authentication #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jerrysxie
merged 74 commits into
OpenDevicePartnership:main
from
Wassasin:feature/mbi-and-combined
Oct 2, 2025
Merged
Changes from all commits
Commits
Show all changes
74 commits
Select commit
Hold shift + click to select a range
b041d3f
Remove MBI creation in linker and use cortex-m-rt linker script, clea…
Wassasin 7de19b9
Separated out boot_application
Wassasin 31c8313
Added ROM API functions; fixed defmt linking
Wassasin 0f4c29a
Added embassy-imxrt as dependency
Wassasin f086b74
WIP work on board impl
Wassasin 2a49894
WIP first RC
Wassasin fa2d130
Write Descriptors as part of the ec-slimloader
Wassasin 01a89ca
Fixed defmt dependency
Wassasin f3f2e62
Added check for IVT image type marker
Wassasin 82c2812
Changed FLASH size to 24K
Wassasin 2971dee
Moved ec-slimloader to subfolder
Wassasin c045170
Copied ec-slimloader-descriptors to this repository
Wassasin 82debbf
Moved over to workspace
Wassasin 76f4ef7
Bumped down to 2021 edition
Wassasin b1e818c
Copied bootloader-tool into this repository
Wassasin 09749b2
WIP
Wassasin 061748b
WIP
Wassasin 049ec95
Load-to-ram via bootloader-tool works
Wassasin cb3fb47
WIP example application
Wassasin 00d0ea0
Fixed example slot setting
Wassasin 65bc78e
Add support for download slot (but not run slot (yet))
Wassasin 3ea3736
Use (temporarily) embassy-imxrt branch with fixes, set clock speed to…
Wassasin f2e9fa4
Quick update on README
Wassasin 945bdd8
Renamed ec-slimloader-descriptors to ec-slimloader-state
Wassasin 5705c86
Moved example application to rt685s subfolder
Wassasin 413eac2
Added bootloader application in example folder
Wassasin 3f5456c
Moved some config parameters from bootloader to trait
Wassasin 7474c53
Decoupled defmt from bootloader example
Wassasin a66b636
Moved .vscode to root; applied only to example
Wassasin c15084b
Removed runner for ec-slimloader library crate
Wassasin b051364
Removed example from bootloader-tool; as we are now using the ec-slim…
Wassasin 87afc53
Cleaned up example application
Wassasin 13064b6
Removed superfluous error handlers from application
Wassasin e5c40e6
Added comments to ec-slimloader; removed old stubs
Wassasin 70535d6
Ran cargo +nightly fmt
Wassasin 80741ee
Split ec-slimloader into ec-slimloader-imxrt and moved over to defmt-…
Wassasin c320942
Moved library crates into subfolder workspace
Wassasin c61d915
Straightened features and dependencies, start on CI
Wassasin 8819544
Updated dependencies and made defmt feature separate
Wassasin d9f6692
Moved certificates to rsa3096
Wassasin e680bba
Enabled trustzone mode for application
Wassasin 58a2020
Changed memory map and clocking
Wassasin c0765a8
Removed old descriptors, moved journal module to top level
Wassasin 07a6769
Fixed RSA3072 certificate generation
Wassasin 14ad8eb
Merged upstream/feature/hsm-pure-sign
Wassasin f8eac9d
Added reading OTP fuses and allow unsigned images to be booted in dev…
Wassasin f9c933a
Moved back to mainline embassy-imxrt
Wassasin 26283d4
WIP multiple certificates
Wassasin 800a7af
Cleaned up manual let else
Wassasin 63c483e
Fix unit tests
Wassasin 3f94a9f
Moved to XIP with load-to-ram mode
Wassasin ce58f3c
Split out imxrt-rom
Wassasin face6a6
WIP OTP fuses
Wassasin 8741408
Cleaned up register/otp/shadow
Wassasin 6fdac46
Moved OTP registers to device-driver; fixed writing of fuses
Wassasin 59550d8
Fix dependencies and errors
Wassasin 44b038a
Fixed OTP memory mapping, increased bootloader RAM
Wassasin 522bece
Rename boot* registers to boot*cfg
Wassasin 7acb07f
Added sec_boot_cfg[5] to registers
Wassasin aca6b83
Moved verification completely to separate module, gated by non-secure…
Wassasin 8079c20
Fixed ./libs CI
Wassasin abd09c4
Work on CI pipeline
Wassasin ddecbaa
Moved register definitions to json because of problematic yaml depend…
Wassasin 1c1a530
Fixed example cargo deny
Wassasin 53c3a91
Fixed clippy warnings for bootloader-tool
Wassasin 1bfa48c
WIP CI
Wassasin 36c7d16
Removed superfluous files; fixed cargo +nightly fmt
Wassasin 97f11fd
Moved device-driver manifest to temporary generated rust code to miti…
Wassasin e5163ce
Remove setting boot0 shadow in devmode
Wassasin 4b3bd9e
Moved boot0 fuse values from bootloader shadow to directly in applica…
Wassasin 0b1026a
flash.rs: update comment to match behavior
jerrysxie 3e091e6
mbi.rs: swap major and minor
jerrysxie 135e72c
Updated padding tests to test different paddings
jerrysxie 783055d
Update README to reflect the state of the parts
jerrysxie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,92 @@ | ||
| # ec-slimloader | ||
| # ec-slimloader **OUTDATED** | ||
|
|
||
| A light-weight stage-one bootloader for loading an app image as configured by ec-slimloader-descriptors | ||
| A light-weight stage-two bootloader written in Rust for loading an app image as configured by ec-slimloader-descriptors. Also contains a tool for signing images, flashing them to the device, setting fuses (or shadow registers) containing crypto keys, and an example application to showcase the bootloaders A/B state functionality. | ||
|
|
||
| Currently this bootloader can only be used on the IMXRT600 series of chipsets from NXP. | ||
|
|
||
| ## Organisation | ||
|
|
||
| This repository is split up into four parts: | ||
| * ec-slimloader: the binary project which forms the second stage bootloader | ||
| * ec-slimloader-descriptors: the library crate containing a descriptor of where each image slot exists, as well as a persistent fail-safe state journal for recording the A/B bootloading state. | ||
| * bootloader-tool: a command-line utility using the NXP SPSDK tooling to generate keys, sign images, and flash them to the target device. Also integrates probe-rs and allows for attaching to the RTT buffer for displaying `defmt` output. | ||
| * example: an example application image that uses the state-journal to select alternative images to execute. | ||
|
|
||
| ## Memory layout | ||
| This repository has default configuration files detailing the used memory layout. This layout will probably will need to be adapted for your specific usecase. | ||
|
|
||
| ## Quick guide | ||
| This guide details how to use this repository on the NXP MIMXRT685S-EVK. First step is compiling the bootloader and application: | ||
|
|
||
| ```bash | ||
| pushd ec-slimloader | ||
| cargo build --release --features defmt | ||
| popd | ||
| pushd examples/rt685s-application | ||
jerrysxie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| cargo build --release | ||
| popd | ||
| ``` | ||
|
|
||
| In general, the bootloader-tool is a `clap` supported CLI application with for each subcommand a full `--help`: | ||
| ``` | ||
| cargo run -- --help | ||
| Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.10s | ||
| Running `target/debug/bootloader-tool --help` | ||
| Usage: bootloader-tool [OPTIONS] [COMMAND] | ||
|
|
||
| Commands: | ||
| generate Generate keys and certificates | ||
| sign Sign binaries for flashing or OTA | ||
| download Download binaries to the device | ||
| run Run binaries, setting the shadow registers, by going through the bootloader chain for testing purposes | ||
| fuse Burn fuse registers with key material and settings | ||
| help Print this message or the help of the given subcommand(s) | ||
|
|
||
| Options: | ||
| -c, --config <FILE> Configuration file path [default: ./config.toml] | ||
| -h, --help Print help | ||
| -V, --version Print version | ||
| ``` | ||
|
|
||
| For now we need to prepare our testing setup by generating the key material: | ||
| ```bash | ||
| cd bootloader-tool | ||
| cargo run -- generate certificates | ||
| cargo run -- generate otp | ||
| ``` | ||
|
|
||
| This key material is only used for testing right now, and everything is put in the `./artifacts` directory. This can be configured in the `./config.toml` file. | ||
| We are working on a setup to also support external HSM integration. | ||
|
|
||
| Now we have everything ready to start flashing. | ||
| We can use run `run` command to immediately flash and `attach` in the same way you are familiar with from `probe-rs`. However, we need the bootloader to start up the application, and we need the FCB (we call everything in 0x0 to 0x1000 the 'prelude') to start the bootloader. We can extract the FCB from the `ec-slimloader` as it is built with the appropriate feature flags to include a FCB in the ELF file. Extraction happens as a side-product of signing: | ||
|
|
||
| ```bash | ||
| cargo run -- sign bootloader -i ../target/thumbv8m.main-none-eabihf/release/ec-slimloader | ||
| ``` | ||
|
|
||
| We can now flash the FCB: | ||
|
|
||
| ```bash | ||
| cargo run -- download prelude --prelude-path ../target/thumbv8m.main-none-eabihf/release/ec-slimloader.prelude.elf | ||
| ``` | ||
|
|
||
| And we can flash the application into *both slots*: | ||
| ```bash | ||
| cargo run -- download application -i ../examples/rt685s-application/target/thumbv8m.main-none-eabihf/release/example-application --slot 0 | ||
| cargo run -- download application -i ../examples/rt685s-application/target/thumbv8m.main-none-eabihf/release/example-application --slot 1 | ||
| ``` | ||
|
|
||
| To flash & attach to the bootloader now run, whilst setting the OTP shadow registers: | ||
| ```bash | ||
| cargo run -- download bootloader -i ../target/thumbv8m.main-none-eabihf/release/ec-slimloader | ||
| ``` | ||
|
|
||
| To flash & attach to the application (TODO it now is not resetting the state journal so take care), assuming you have a and FCB bootloader already flashed: | ||
| ```bash | ||
| cargo run -- run application -i ../examples/rt685s-application/target/thumbv8m.main-none-eabihf/release/example-application | ||
| ``` | ||
|
|
||
| You can use the `USER_1` button to change the state journal to either `confirmed` or try the other slot in state `initial` if the current image is already `confirmed`. | ||
|
|
||
| You can use the `USER_2` button the reboot into the bootloader, which will set an image to `failed` if it does not verify or if it was in `attempting` without putting the state in `confirmed`. | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| [env] | ||
| RUST_LOG = "none,bootloader_tool=debug" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| /target | ||
|
|
||
| # Software package | ||
| /elftosb* | ||
|
|
||
| /binaries.tar.xz | ||
| /gpio-blinky | ||
| /*.bin |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.