From 5099b9846dcd8c62a877140f99936ea8f7101e4e Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 23 Feb 2025 20:42:12 +0100 Subject: fw: Build application firmware for bootloader This changes the flash address for which the application firmware is built. Furthermore it adds the MCUboot header as offset to the application firmware. For details see the documentation of the enabled Kconfig flag. --- README.md | 4 +++- fw/prj.conf | 2 ++ fw/sign.sh | 26 ++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100755 fw/sign.sh diff --git a/README.md b/README.md index 1654143..dd640d3 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ The content of this repository can be build with CMake and Ninja. ``` cmake -Bbuild -GNinja ninja -C build +./fw/sign.sh ``` Exported files related to the printed circuit board (PCB) can be found in the @@ -22,7 +23,8 @@ tree build/pcb The resulting firmware can be flashed via a ST-LINK debugger / programmer. ``` -st-flash --connect-under-reset write build/fw/zephyr/zephyr.bin 0x8000000 +st-flash --connect-under-reset write build/fw/bootloader/zephyr/zephyr.bin 0x8000000 +st-flash --connect-under-reset write build/fw/zephyr/zephyr.bin.signed 0x8040000 ``` UART shell output can be retrieved with `picocom`. diff --git a/fw/prj.conf b/fw/prj.conf index 2485227..1769590 100644 --- a/fw/prj.conf +++ b/fw/prj.conf @@ -9,3 +9,5 @@ CONFIG_NETWORKING=y CONFIG_NET_SHELL=y CONFIG_GPIO=y + +CONFIG_BOOTLOADER_MCUBOOT=y diff --git a/fw/sign.sh b/fw/sign.sh new file mode 100755 index 0000000..343a038 --- /dev/null +++ b/fw/sign.sh @@ -0,0 +1,26 @@ +#!/bin/sh + + +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at https://mozilla.org/MPL/2.0/. + + +set -euf + + +ROOT="$(dirname "$0")" +MCUBOOT="${ROOT}/zephyrproject/bootloader/mcuboot" +IMGTOOL="${MCUBOOT}/scripts/imgtool.py" +KEY="${MCUBOOT}/root-rsa-2048.pem" +INPUT="${ROOT}/../build/fw/zephyr/zephyr.bin" +OUTPUT="${INPUT}.signed" + + +python $IMGTOOL sign \ + --version 0.0.0 \ + --header-size 0x200 \ + --slot-size 0xc0000 \ + --key "${KEY}" \ + "${INPUT}" \ + "${OUTPUT}" -- cgit v1.2.3-70-g09d2