diff options
Diffstat (limited to 'fw')
-rw-r--r-- | fw/CMakeLists.txt | 37 | ||||
-rw-r--r-- | fw/README.md | 6 | ||||
-rw-r--r-- | fw/app/meson.build | 45 | ||||
-rw-r--r-- | fw/btl/meson.build | 28 | ||||
-rw-r--r-- | fw/meson.build | 9 | ||||
-rwxr-xr-x | fw/nucleo.sh | 38 | ||||
-rw-r--r-- | fw/rtos/CMakeLists.txt | 16 | ||||
-rw-r--r-- | fw/rtos/meson.build | 3 | ||||
-rw-r--r-- | fw/rtos/modules/meson.build | 10 | ||||
-rw-r--r-- | fw/sim/meson.build | 27 |
10 files changed, 122 insertions, 97 deletions
diff --git a/fw/CMakeLists.txt b/fw/CMakeLists.txt deleted file mode 100644 index 2affe92..0000000 --- a/fw/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# 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/. - -cmake_minimum_required(VERSION 3.20.0) - -include(ExternalProject) - -set(KEY_DEFAULT "$ENV{HOME}/mcuboot/key.pem") -set(KEY ${KEY_DEFAULT} CACHE STRING "Firmware signing key path") -message(STATUS "Firmware signing key path: ${KEY}") - -set(BOARD_DEFAULT "native_sim/native/64") -set(BOARD ${BOARD_DEFAULT} CACHE STRING "Zephyr board identifier") -message(STATUS "Selected board: ${BOARD}") - -add_subdirectory(rtos) -string(REPLACE ";" "," ZEPHYR_MODULES_COMMA "${ZEPHYR_MODULES}") - -if(BOARD STREQUAL "nucleo_f767zi") - ExternalProject_Add( - btl - PREFIX btl - SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/rtos/modules/mcuboot/boot/zephyr" - BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/btl" - INSTALL_COMMAND "" - LIST_SEPARATOR "," - CMAKE_ARGS - "-DBOARD=${BOARD}" - "-DZEPHYR_BASE=${ZEPHYR_BASE}" - "-DZEPHYR_MODULES=${ZEPHYR_MODULES_COMMA}" - "-DEXTRA_CONF_FILE=${CMAKE_CURRENT_SOURCE_DIR}/btl/bootloader.conf" - -DCONFIG_BOOT_SIGNATURE_KEY_FILE="${KEY}" - ) -endif() - -add_subdirectory(app) diff --git a/fw/README.md b/fw/README.md deleted file mode 100644 index 9883b2d..0000000 --- a/fw/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# iot-contact Firmware - -This is the firmware for iot-contact. It is based on the Zephyr real time -operating system [1]. - -[1]: https://zephyrproject.org diff --git a/fw/app/meson.build b/fw/app/meson.build new file mode 100644 index 0000000..97c17f1 --- /dev/null +++ b/fw/app/meson.build @@ -0,0 +1,45 @@ +external_project = import('unstable-external_project') + +application_source = meson.current_source_dir() + +external_project.add_project( + configure_zephyr, + configure_options: [ + '--source-tree', application_source, + '--build-tree', meson.current_build_dir() / 'build', + '--board', board, + '--zephyr-base', zephyr, + '--zephyr-modules', ';'.join(zephyr_modules), + ], + verbose: true, +) + +application = custom_target( + 'application', + output: ['application.bin'], + command: [ + build_zephyr, + '--build-tree', meson.current_build_dir() / 'build', + '--binary-name', 'zephyr.bin', + '--target-name', 'application.bin', + ], +) + +application_signed = custom_target( + 'application_signed', + output: ['application.signed.bin'], + command: [ + imgtool, + 'sign', + '--version', '0.0.0', + '--header-size', '0x200', + '--slot-size', '0xc0000', + '--key', signing_key, + meson.current_build_dir() / 'application.bin', + meson.current_build_dir() / 'application.signed.bin', + ], + build_by_default: true, + depends: application, + install: true, + install_dir: 'website/static', +) diff --git a/fw/btl/meson.build b/fw/btl/meson.build new file mode 100644 index 0000000..4d80a58 --- /dev/null +++ b/fw/btl/meson.build @@ -0,0 +1,28 @@ +external_project = import('unstable-external_project') + +external_project.add_project( + configure_zephyr, + configure_options: [ + '--source-tree', bootloader_firmware, + '--build-tree', meson.current_build_dir() / 'build', + '--board', board, + '--zephyr-base', zephyr, + '--zephyr-modules', ';'.join(zephyr_modules), + '--extra-config', meson.current_source_dir() / 'bootloader.conf', + '--signing-key', signing_key, + ], + verbose: true, +) + +bootloader = custom_target('bootloader', + output: ['bootloader.bin'], + command: [ + build_zephyr, + '--build-tree', meson.current_build_dir() / 'build', + '--binary-name', 'zephyr.bin', + '--target-name', 'bootloader.bin', + ], + build_by_default: true, + install: true, + install_dir: 'website/static', +) diff --git a/fw/meson.build b/fw/meson.build new file mode 100644 index 0000000..8194827 --- /dev/null +++ b/fw/meson.build @@ -0,0 +1,9 @@ +board = 'nucleo_f767zi' + +fs = import('fs') +signing_key = fs.expanduser('~') / 'mcuboot' / 'key.pem' + +subdir('rtos') +subdir('app') +subdir('btl') +subdir('sim') diff --git a/fw/nucleo.sh b/fw/nucleo.sh deleted file mode 100755 index ad0467b..0000000 --- a/fw/nucleo.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/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 - - -SCRIPT="$(realpath "$0")" -FW="$(dirname "$SCRIPT")" -ROOT="$(dirname "$FW")" -BUILD="${ROOT}/build" -BOOTLOADER_FIRMWARE="${BUILD}/fw/btl/zephyr/zephyr.bin" -APPLICATION_FIRMWARE="${BUILD}/fw/app/zephyr/zephyr.bin" -APPLICATION_FIRMWARE_SIGNED="${BUILD}/fw/app/zephyr/zephyr.signed.bin" -BOOTLOADER_FLASH_ADDRESS='0x8000000' -APPLICATION_FLASH_ADDRESS='0x8040000' -IMGTOOL="${ROOT}/imgtool.py" -KEY="${HOME}/mcuboot/key.pem" -BOARD='nucleo_f767zi' - - -set -x - -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" diff --git a/fw/rtos/CMakeLists.txt b/fw/rtos/CMakeLists.txt deleted file mode 100644 index d9f116c..0000000 --- a/fw/rtos/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# 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(ZEPHYR_MODULES - "${CMAKE_CURRENT_SOURCE_DIR}/modules/cmsis" - "${CMAKE_CURRENT_SOURCE_DIR}/modules/hal_stm32" - "${CMAKE_CURRENT_SOURCE_DIR}/modules/mbedtls" - "${CMAKE_CURRENT_SOURCE_DIR}/modules/mcuboot" - PARENT_SCOPE -) - -set(ZEPHYR_BASE - "${CMAKE_CURRENT_SOURCE_DIR}/zephyr" - PARENT_SCOPE -) diff --git a/fw/rtos/meson.build b/fw/rtos/meson.build new file mode 100644 index 0000000..800153d --- /dev/null +++ b/fw/rtos/meson.build @@ -0,0 +1,3 @@ +subdir('modules') + +zephyr = meson.current_source_dir() / 'zephyr' diff --git a/fw/rtos/modules/meson.build b/fw/rtos/modules/meson.build new file mode 100644 index 0000000..14b14f5 --- /dev/null +++ b/fw/rtos/modules/meson.build @@ -0,0 +1,10 @@ +zephyr_modules = [ + meson.current_source_dir() / 'cmsis', + meson.current_source_dir() / 'hal_stm32', + meson.current_source_dir() / 'mbedtls', + meson.current_source_dir() / 'mcuboot', +] + +mcuboot = meson.current_source_dir() / 'mcuboot' +bootloader_firmware = mcuboot / 'boot' / 'zephyr' +imgtool = mcuboot / 'scripts' / 'imgtool.py' diff --git a/fw/sim/meson.build b/fw/sim/meson.build new file mode 100644 index 0000000..a4dcb8a --- /dev/null +++ b/fw/sim/meson.build @@ -0,0 +1,27 @@ +external_project = import('unstable-external_project') + +external_project.add_project( + configure_zephyr, + configure_options: [ + '--source-tree', application_source, + '--build-tree', meson.current_build_dir() / 'build', + '--board', 'native_sim/native/64', + '--zephyr-base', zephyr, + '--zephyr-modules', ';'.join(zephyr_modules), + ], + verbose: true, +) + +simulation = custom_target( + 'simulation', + output: ['simulation-linux-amd64.exe'], + command: [ + build_zephyr, + '--build-tree', meson.current_build_dir() / 'build', + '--binary-name', 'zephyr.exe', + '--target-name', 'simulation-linux-amd64.exe', + ], + build_by_default: true, + install: true, + install_dir: 'website/static', +) |