summaryrefslogtreecommitdiff
path: root/fw
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2025-03-26 21:27:32 +0100
committerxengineering <me@xengineering.eu>2025-03-26 22:02:17 +0100
commitc5f301aa879bc52add50d8d5f917ee551fe1673e (patch)
tree7441b2dae18e0234f5fb3535552bf3076a410911 /fw
parent2b7ecfb1f5b6c9f98d239c893d4b4130176a1beb (diff)
downloadiot-contact-c5f301aa879bc52add50d8d5f917ee551fe1673e.tar
iot-contact-c5f301aa879bc52add50d8d5f917ee551fe1673e.tar.zst
iot-contact-c5f301aa879bc52add50d8d5f917ee551fe1673e.zip
fw: app: Build as CMake External Project
This adopts this pattern from the bootloader build. It adds more flexibility. It is assumed that in this way multiple builds for different boards can easily be achieved.
Diffstat (limited to 'fw')
-rw-r--r--fw/CMakeLists.txt41
-rw-r--r--fw/app/CMakeLists.txt2
-rwxr-xr-xfw/nucleo.sh17
3 files changed, 34 insertions, 26 deletions
diff --git a/fw/CMakeLists.txt b/fw/CMakeLists.txt
index 5b1e42b..aa5af1c 100644
--- a/fw/CMakeLists.txt
+++ b/fw/CMakeLists.txt
@@ -4,28 +4,45 @@
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 "native_sim/native/64")
-add_subdirectory(rtos)
+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}")
-include(ExternalProject)
+
+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()
+
ExternalProject_Add(
- btl
- PREFIX btl
- SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/rtos/modules/mcuboot/boot/zephyr"
- BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/btl"
+ app
+ PREFIX app
+ SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/app"
+ BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/app"
INSTALL_COMMAND ""
LIST_SEPARATOR ","
CMAKE_ARGS
- "-DBOARD=nucleo_f767zi"
+ "-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}"
)
-
-add_subdirectory(app)
diff --git a/fw/app/CMakeLists.txt b/fw/app/CMakeLists.txt
index ce10104..47f75f6 100644
--- a/fw/app/CMakeLists.txt
+++ b/fw/app/CMakeLists.txt
@@ -10,7 +10,7 @@ find_package(Zephyr
"${ZEPHYR_BASE}"
)
-project(iot-contact-fw)
+project(iot-contact-app)
target_sources(app
PRIVATE
diff --git a/fw/nucleo.sh b/fw/nucleo.sh
index b48b759..e89ff07 100755
--- a/fw/nucleo.sh
+++ b/fw/nucleo.sh
@@ -24,30 +24,21 @@ FW="$(dirname "$SCRIPT")"
ROOT="$(dirname "$FW")"
BUILD="${ROOT}/nucleo"
BOOTLOADER_FIRMWARE="${BUILD}/fw/btl/zephyr/zephyr.bin"
-APPLICATION_FIRMWARE="${BUILD}/fw/zephyr/zephyr.bin"
-APPLICATION_FIRMWARE_SIGNED="${BUILD}/fw/zephyr/zephyr.signed.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'
-MCUBOOT="${ROOT}/fw/btl/mcuboot"
-IMGTOOL="${MCUBOOT}/scripts/imgtool.py"
+IMGTOOL="${ROOT}/imgtool.py"
KEY="${HOME}/mcuboot/key.pem"
BOARD='nucleo_f767zi'
-EXTRA_CONFIGS=''
BAUDRATE='115200'
SERIAL_PORT='/dev/ttyACM0'
-CONFIG_OVERLAY="${FW}/my.conf"
-if test -f "$CONFIG_OVERLAY"
-then
- EXTRA_CONFIGS="${EXTRA_CONFIGS} ${CONFIG_OVERLAY}"
-fi
-
set -x
rm -rf "$BUILD"
-cmake "-B${BUILD}" -GNinja -DBOARD="$BOARD" \
- -DEXTRA_CONF_FILE="${EXTRA_CONFIGS}" -DKEY="$KEY"
+cmake "-B${BUILD}" -GNinja -DBOARD="$BOARD"
ninja -C "$BUILD"
python "$IMGTOOL" sign \
--version 0.0.0 \