Compare commits

...
1 Commits
Author SHA1 Message Date
Jeremy Janella 5627222f4a docs: updated readme 2026-08-15 18:25:35 -04:00
+35 -67
View File
@@ -112,28 +112,17 @@ int main() {
}
```
Also, create an overlay for the firmware being executed in place. This is so the code jumps to addresses in the right block. Create `zephyr/samples/basic/blinkyslow/boards/nucleo_g431rb.overlay`
## Build the blinkys
The west build `-DSB_CONFIG_BOOTLOADER_MCUBOOT=y` flag enables MCUboot on the blinkys.
```sh
west build -p always -b nucleo_g431rb zephyr/samples/basic/blinky -d build/blinky --sysbuild -- -DSB_CONFIG_BOOTLOADER_MCUBOOT=y #-CONFIG_MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD=y
west build -p always -b nucleo_g431rb zephyr/samples/basic/blinkyslow -d build/blinkyslow --sysbuild -- -DSB_CONFIG_BOOTLOADER_MCUBOOT=y
```
/ {
chosen {
zephyr,code-partition = &slot1_partition;
};
};
```
## Flash the blinkys
```sh
pyocd flash -t stm32g431rbtx build
/blinky/mcuboot/zephyr/zephyr.bin
pyocd flash -t stm32g431rbtx --base-address 0x0000C000 build/blinky/blinky/zephyr/zephyr.bin
```
(blinkyslow is a clone of blinky with a different frequency)
## Set up crypto
@@ -143,28 +132,6 @@ python bootloader/mcuboot/scripts/imgtool.py keygen -k private.pem -t rsa-2048
openssl rsa -in private.pem -pubout > public.pem
```
## Sign the blinkys
```sh
python bootloader/mcuboot/scripts/imgtool.py sign \
--key private.pem \
--header-size 0x200 \
--pad-header \
--align 8 \
--version 1.2 \
--slot-size 0x8000 \
build/blinky/zephyr/zephyr.bin \
blinky-signed.bin
python bootloader/mcuboot/scripts/imgtool.py sign \
--key private.pem \
--header-size 0x200 \
--pad-header \
--align 8 \
--version 1.2 \
--slot-size 0x8000 \
build/blinkyslow/zephyr/zephyr.bin \
blinkyslow-signed.bin
```
@@ -178,6 +145,32 @@ west build -p always -b nucleo_g431rb -d build_fast zephyr/samples/basic/blinky
west build -p always -b nucleo_g431rb -d build_slow zephyr/samples/basic/blinkyslow
```
## Sign the firmware
```sh
python bootloader/mcuboot/scripts/imgtool.py sign \
--key private.pem \
--header-size 0x200 \
--pad-header \
--align 8 \
--pad \
--version 1.2 \
--slot-size 0xA000 \
build_fast/zephyr/zephyr.bin \
blinky-signed.bin
python bootloader/mcuboot/scripts/imgtool.py sign \
--key private.pem \
--header-size 0x200 \
--pad-header \
--align 8 \
--pad \
--version 1.2 \
--slot-size 0xA000 \
build_slow/zephyr/zephyr.bin \
blinkyslow-signed.bin
```
## Flash the firmware
`su root` allows flashing to usb devices, run `nix develop` again if using it.
@@ -185,34 +178,9 @@ west build -p always -b nucleo_g431rb -d build_slow zephyr/samples/basic/blinkys
`flash0@0x08000000` in `zephyr/dts/arm/st/g4/stm32g4.dtsi`
```sh
pyocd flash -t stm32g431rbtx build_mcuboot/zephyr/zephyr.hex
pyocd flash -t stm32g431rbtx --base-address 0x0800C000 build_fast/zephyr/zephyr.bin
pyocd flash -t stm32g431rbtx --base-address 0x08014000 build_slow/zephyr/zephyr.bin
pyocd flash -t stm32g431rbtx --base-address 0x0800C000 blinky-signed.bin
pyocd flash -t stm32g431rbtx --base-address 0x08016000 blinkyslow-signed.bin
```
<!-- # Add the key file path to the KConfig https://docs.zephyrproject.org/latest/build/kconfig/setting.html
echo "
# Set the key file
CONFIG_BOOT_SIGNATURE_KEY_FILE=public.pem" >> "./zephyr/boards/st/nucleo_g431rb/nucleo_g431rb_defconfig" -->
<!-- west build -p always -b nucleo_g431rb bootloader/mcuboot/boot/zephyr -d build/mcuboot -- -DEXTRA_CONF_FILE=mcuboot-nucleo-g431rb.conf
west flash -d build/mcuboot --runner pyocd # (as root, with nix develop)
cd zephyr
# Package 1
west build -p always -b nucleo_g431rb samples/basic/blinky -d build/app -- -DCONFIG_BOOTLOADER_MCUBOOT=y -DCONFIG_MCUBOOT_GENERATE_UNSIGNED_IMAGE=y
west flash -d build/app --runner pyocd # (as root, with nix develop)
# Package 2
west build -p always -b nucleo_g431rb samples/basic/blinkyslow -d build/blinkyslow -- -DCONFIG_BOOTLOADER_MCUBOOT=y -DCONFIG_MCUBOOT_GENERATE_UNSIGNED_IMAGE=y
pyocd flash --target stm32g431rbtx --base-address 0x08014800 build/blinkyslow/zephyr/zephyr.signed.hex
``` -->