diff options
-rw-r--r-- | fw/CMakeLists.txt | 17 | ||||
-rw-r--r-- | fw/nucleo.conf | 5 | ||||
-rwxr-xr-x | fw/nucleo.sh | 29 | ||||
-rw-r--r-- | fw/zephyrproject/bootloader/bootloader.conf | 7 |
4 files changed, 52 insertions, 6 deletions
diff --git a/fw/CMakeLists.txt b/fw/CMakeLists.txt index 8d9591f..eff06f2 100644 --- a/fw/CMakeLists.txt +++ b/fw/CMakeLists.txt @@ -11,6 +11,23 @@ set(ZEPHYR_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/zephyrproject/modules/crypto/mbedtls" "${CMAKE_CURRENT_SOURCE_DIR}/zephyrproject/bootloader/mcuboot" ) + +string(REPLACE ";" "," ZEPHYR_MODULES_COMMA "${ZEPHYR_MODULES}") +include(ExternalProject) +ExternalProject_Add( + bootloader + PREFIX bootloader + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/zephyrproject/bootloader/mcuboot/boot/zephyr" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/bootloader" + INSTALL_COMMAND "" + LIST_SEPARATOR "," + CMAKE_ARGS + "-DBOARD=nucleo_f767zi" + "-DZEPHYR_MODULES=${ZEPHYR_MODULES_COMMA}" + "-DEXTRA_CONF_FILE=${CMAKE_CURRENT_SOURCE_DIR}/zephyrproject/bootloader/bootloader.conf" + -DCONFIG_BOOT_SIGNATURE_KEY_FILE="${KEY}" +) + find_package(Zephyr REQUIRED HINTS diff --git a/fw/nucleo.conf b/fw/nucleo.conf new file mode 100644 index 0000000..32e6d4a --- /dev/null +++ b/fw/nucleo.conf @@ -0,0 +1,5 @@ +# 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/. + +CONFIG_BOOTLOADER_MCUBOOT=y diff --git a/fw/nucleo.sh b/fw/nucleo.sh index 24966b1..be694b8 100755 --- a/fw/nucleo.sh +++ b/fw/nucleo.sh @@ -23,24 +23,41 @@ SCRIPT="$(realpath "$0")" FW="$(dirname "$SCRIPT")" ROOT="$(dirname "$FW")" BUILD="${ROOT}/nucleo" -FIRMWARE="${BUILD}/fw/zephyr/zephyr.bin" -FLASH_ADDRESS='0x8000000' +BOOTLOADER_FIRMWARE="${BUILD}/fw/bootloader/zephyr/zephyr.bin" +APPLICATION_FIRMWARE="${BUILD}/fw/zephyr/zephyr.bin" +APPLICATION_FIRMWARE_SIGNED="${BUILD}/fw/zephyr/zephyr.signed.bin" +BOOTLOADER_FLASH_ADDRESS='0x8000000' +APPLICATION_FLASH_ADDRESS='0x8040000' +MCUBOOT="${ROOT}/fw/zephyrproject/bootloader/mcuboot" +IMGTOOL="${MCUBOOT}/scripts/imgtool.py" +KEY="${HOME}/mcuboot/key.pem" BOARD='nucleo_f767zi' +EXTRA_CONFIGS="${ROOT}/fw/nucleo.conf" BAUDRATE='115200' SERIAL_PORT='/dev/ttyACM0' CONFIG_OVERLAY="${FW}/my.conf" -overlay_config='' if test -f "$CONFIG_OVERLAY" then - overlay_config="-DEXTRA_CONF_FILE="${CONFIG_OVERLAY}"" + EXTRA_CONFIGS="${EXTRA_CONFIGS} ${CONFIG_OVERLAY}" fi set -x rm -rf "$BUILD" -cmake "-B${BUILD}" -GNinja -DBOARD="$BOARD" "$overlay_config" +cmake "-B${BUILD}" -GNinja -DBOARD="$BOARD" \ + -DEXTRA_CONF_FILE="${EXTRA_CONFIGS}" -DKEY="$KEY" ninja -C "$BUILD" -st-flash --connect-under-reset write "$FIRMWARE" "$FLASH_ADDRESS" +python "$IMGTOOL" sign \ + --version 0.0.0 \ + --header-size 0x200 \ + --slot-size 0xc0000 \ + --key "$KEY" \ + "$APPLICATION_FIRMWARE" \ + "$APPLICATION_FIRMWARE_SIGNED" +st-flash --connect-under-reset write "$BOOTLOADER_FIRMWARE" \ + "$BOOTLOADER_FLASH_ADDRESS" +st-flash --connect-under-reset write "$APPLICATION_FIRMWARE_SIGNED" \ + "$APPLICATION_FLASH_ADDRESS" picocom -b "$BAUDRATE" "$SERIAL_PORT" diff --git a/fw/zephyrproject/bootloader/bootloader.conf b/fw/zephyrproject/bootloader/bootloader.conf new file mode 100644 index 0000000..c42b7fc --- /dev/null +++ b/fw/zephyrproject/bootloader/bootloader.conf @@ -0,0 +1,7 @@ +# 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/. + + +CONFIG_BOOT_MAX_IMG_SECTORS_AUTO=n +CONFIG_BOOT_SIGNATURE_TYPE_ED25519=y |