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

Pyocd has now been changed to probe-rs-cli #35

Closed imrank03 closed 2 years ago

imrank03 commented 2 years ago

Pyocd has now been changed to probe-rs-cli to flash secure boot and update firmware and tested on stm32h723 board.

Here's the command line output.

imran@ubuntu:~/Desktop/rustBoot$ cargo stm32h723 build-sign-flash rustBoot
Compiling typenum v1.15.0
Compiling version_check v0.9.4
..
..
Compiling rustBoot v0.1.0 (/home/imran/Desktop/rustBoot/rustBoot)
Compiling xtask v0.1.0 (/home/imran/Desktop/rustBoot/xtask)
Finished dev [unoptimized + debuginfo] target(s) in 7.43s
Running target/debug/xtask stm32h723 build-sign-flash rustBoot
$ cargo build --release
Compiling version_check v0.9.4
Compiling typenum v1.15.0
..
..
Compiling rustBoot-hal v0.1.0 (/home/imran/Desktop/rustBoot/boards/hal)
Compiling rustBoot-update v0.1.0 (/home/imran/Desktop/rustBoot/boards/update)
Finished release [optimized] target(s) in 26.19s
$ cargo build --release
Compiling stm32h723_updtfw v0.1.0 (/home/imran/Desktop/rustBoot/boards/firmware/stm32h723/updt_fw_blinky_red)
Finished release [optimized] target(s) in 1.03s
$ cargo build --release
Compiling stm32h723 v0.1.0 (/home/imran/Desktop/rustBoot/boards/bootloaders/stm32h723)
Finished release [optimized] target(s) in 1.50s
$ python3 convert2bin.py
$ python3 signer.py
['sign.py', '--ecc256', '--sha256', 'stm32h723_bootfw.bin', 'ecc256.der', '1234']
Update type:          Firmware
Input image:          stm32h723_bootfw.bin
Selected cipher:      ecc256
Public key:           ecc256.der
Output image:         stm32h723_bootfw_v1234_signed.bin
Not Encrypted
Calculating sha256 digest...
Signing the firmware...
Done.
Output image successfully created.
['sign.py', '--ecc256', '--sha256', 'stm32h723_updtfw.bin', 'ecc256.der', '1235']
Update type:          Firmware
Input image:          stm32h723_updtfw.bin
Selected cipher:      ecc256
Public key:           ecc256.der
Output image:         stm32h723_updtfw_v1235_signed.bin
Not Encrypted
Calculating sha256 digest...
Signing the firmware...
Done.
Output image successfully created.
$ 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:00] [##################################################################################################]  3.00KiB/ 3.00KiB @  7.30KiB/s (eta 0s )
Programming pages   ✔ [00:00:00] [##################################################################################################]  3.00KiB/ 3.00KiB @  3.85KiB/s (eta 0s )
Finished in 0.611s
$ probe-rs-cli download --format Bin --base-address 0x8060000 --chip stm32h723zgtx stm32h723_updtfw_v1235_signed.bin
Erasing sectors ✔ [00:00:00] [##################################################################################################]  3.00KiB/ 3.00KiB @  7.17KiB/s (eta 0s )
Programming pages   ✔ [00:00:00] [##################################################################################################]  3.00KiB/ 3.00KiB @  3.77KiB/s (eta 0s )
Finished in 0.613s
$ cargo flash --chip stm32h723zgtx --release
Finished release [optimized] target(s) in 0.04s
Flashing /home/imran/Desktop/rustBoot/boards/target/thumbv7em-none-eabihf/release/stm32h723
Erasing sectors ✔ [00:00:02] [##################################################################################################] 47.00KiB/47.00KiB @ 17.60KiB/s (eta 0s )
Programming pages   ✔ [00:00:03] [##################################################################################################] 47.00KiB/47.00KiB @  7.60KiB/s (eta 0s )
Finished in 5.773s

imran@ubuntu:~/Desktop/rustBoot$ probe-rs-cli dump --chip stm32h723zgtx 0x08020000 3
Addr 0x08020000: 0x54535552
Addr 0x08020004: 0x00000980
Addr 0x08020008: 0x00040001
Read 3 words in 4.666941ms

imran@ubuntu:~/Desktop/rustBoot$ hexdump -C -n8 boards/rbSigner/signed_images/stm32h723_bootfw_v1234_signed.bin
00000000  52 55 53 54 80 09 00 00                           |RUST....|
00000008