nihalpasham / rustBoot

rustBoot is a standalone bootloader written entirely in `Rust`, designed to run on anything from a microcontroller to a system on chip. It can be used to boot into bare-metal firmware or Linux.
MIT License
214 stars 21 forks source link

Updated board specific dependencies #54

Closed imrank03 closed 2 years ago

imrank03 commented 2 years ago

Changelog:

Tested with stm32h723 and stm32f746, remaining boards need to be tested.

Here's the command line output for stm32h723,

❯ cargo stm32h723 build-sign-flash rustBoot 1234 1235
    Finished dev [unoptimized + debuginfo] target(s) in 0.08s
     Running `target/debug/xtask stm32h723 build-sign-flash rustBoot 1234 1235`
$ cargo build --release
   Compiling rustBoot-hal v0.1.0 (/Users/imrankhaleelsab/Imran/Boschspace/rustBoot/boards/hal)
   Compiling rustBoot-update v0.1.0 (/Users/imrankhaleelsab/Imran/Boschspace/rustBoot/boards/update)
   Compiling stm32h723_bootfw v0.1.0 (/Users/imrankhaleelsab/Imran/Boschspace/rustBoot/boards/firmware/stm32h723/boot_fw_blinky_green)
    Finished release [optimized] target(s) in 1.70s
$ cargo build --release
   Compiling stm32h723_updtfw v0.1.0 (/Users/imrankhaleelsab/Imran/Boschspace/rustBoot/boards/firmware/stm32h723/updt_fw_blinky_red)
    Finished release [optimized] target(s) in 1.54s
$ cargo build --release
   Compiling stm32h723 v0.1.0 (/Users/imrankhaleelsab/Imran/Boschspace/rustBoot/boards/bootloaders/stm32h723)
    Finished release [optimized] target(s) in 2.24s
$ rust-objcopy -I elf32-littlearm ../../target/thumbv7em-none-eabihf/release/stm32h723_bootfw -O binary stm32h723_bootfw.bin
$ rust-objcopy -I elf32-littlearm ../../target/thumbv7em-none-eabihf/release/stm32h723_updtfw -O binary stm32h723_updtfw.bin
$ cargo run mcu-image ../boards/sign_images/signed_images/stm32h723_bootfw.bin nistp256 ../boards/sign_images/keygen/ecc256.der 1234
    Finished dev [unoptimized + debuginfo] target(s) in 0.09s
     Running `/Users/imrankhaleelsab/Imran/Boschspace/rustBoot/target/debug/rbsigner mcu-image ../boards/sign_images/signed_images/stm32h723_bootfw.bin nistp256 ../boards/sign_images/keygen/ecc256.der 1234`

Update type:      Firmware
Curve type:       nistp256
Input image:      stm32h723_bootfw.bin
Public key:       ecc256.der
Image version:    1234
Output image:     stm32h723_bootfw_v1234_signed.bin
Calculating sha256 digest...
Signing the firmware...
Done.
Output image successfully created with 5168 bytes.

$ cargo run mcu-image ../boards/sign_images/signed_images/stm32h723_updtfw.bin nistp256 ../boards/sign_images/keygen/ecc256.der 1235
    Finished dev [unoptimized + debuginfo] target(s) in 0.09s
     Running `/Users/imrankhaleelsab/Imran/Boschspace/rustBoot/target/debug/rbsigner mcu-image ../boards/sign_images/signed_images/stm32h723_updtfw.bin nistp256 ../boards/sign_images/keygen/ecc256.der 1235`

Update type:      Firmware
Curve type:       nistp256
Input image:      stm32h723_updtfw.bin
Public key:       ecc256.der
Image version:    1235
Output image:     stm32h723_updtfw_v1235_signed.bin
Calculating sha256 digest...
Signing the firmware...
Done.
Output image successfully created with 5152 bytes.

$ probe-rs-cli erase --chip STM32H723ZGTx
$ probe-rs-cli download --format Bin --base-address 0x8020000 --chip STM32H723ZGTx stm32h723_bootfw_v1234_signed.bin
     Erasing sectors ✔ [00:00:02] [##################################################################################################] 128.00KiB/128.00KiB @ 62.88KiB/s (eta 0s )
 Programming pages   ✔ [00:00:00] [####################################################################################################]  6.00KiB/ 6.00KiB @  1.17KiB/s (eta 0s )
    Finished in 2.195s
$ probe-rs-cli download --format Bin --base-address 0x8060000 --chip STM32H723ZGTx stm32h723_updtfw_v1235_signed.bin
     Erasing sectors ✔ [00:00:01] [##################################################################################################] 128.00KiB/128.00KiB @ 64.77KiB/s (eta 0s )
 Programming pages   ✔ [00:00:00] [####################################################################################################]  6.00KiB/ 6.00KiB @  1.20KiB/s (eta 0s )
    Finished in 2.135s
$ cargo flash --chip STM32H723ZGTx --release
    Finished release [optimized] target(s) in 0.11s
    Flashing /Users/imrankhaleelsab/Imran/Boschspace/rustBoot/boards/target/thumbv7em-none-eabihf/release/stm32h723
        WARN probe_rs::config::target > Using custom sequence for STM32H7
     Erasing sectors ✔ [00:00:01] [##################################################################################################] 128.00KiB/128.00KiB @ 66.32KiB/s (eta 0s )
 Programming pages   ✔ [00:00:00] [####################################################################################################] 45.00KiB/45.00KiB @ 13.69KiB/s (eta 0s )
    Finished in 2.913s