From 25f35c7d0e27af4308b8c263fde6661dbe29c2cc Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Tue, 26 Jan 2021 20:31:45 +0100 Subject: Generate pinetime-recovery : a light version of InfiniTime design to be used as a recovery firmware : it only provides basic UI and BLE connectivity for OTA. This new FW is build on the same codebasse than the actual InfiniTime. Only the display task is different (this allows to remove lvgl from the recovery fw, which is very heavy). CMake builds and docker have been modified accordingly. Note than the fw is converted into an image and then into a DFU in the cmake build (previously, it was only done in the --- docker/Dockerfile | 3 ++- docker/post_build.sh.in | 11 ++++------- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'docker') diff --git a/docker/Dockerfile b/docker/Dockerfile index 7f0fb4b0..bc709997 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -17,7 +17,8 @@ RUN apt-get update -qq \ # aarch64 packages libffi-dev \ libssl-dev \ - python3-dev \ + python3-dev \ + python \ && rm -rf /var/cache/apt/* /var/lib/apt/lists/*; RUN pip3 install adafruit-nrfutil diff --git a/docker/post_build.sh.in b/docker/post_build.sh.in index 53ae343a..db6e7a94 100755 --- a/docker/post_build.sh.in +++ b/docker/post_build.sh.in @@ -9,15 +9,12 @@ export PROJECT_VERSION="@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT mkdir -p "$OUTPUT_DIR" cp "$SOURCES_DIR"/bootloader/bootloader-5.0.4.bin $OUTPUT_DIR/bootloader.bin +cp "$BUILD_DIR/src/pinetime-mcuboot-app-image-$PROJECT_VERSION.bin" "$OUTPUT_DIR/pinetime-mcuboot-app-image-$PROJECT_VERSION.bin" +cp "$BUILD_DIR/src/pinetime-mcuboot-app-dfu-$PROJECT_VERSION.zip" "$OUTPUT_DIR/pinetime-mcuboot-app-dfu-$PROJECT_VERSION.zip" -"$TOOLS_DIR"/mcuboot/scripts/imgtool.py create --version 1.0.0 \ - --align 4 --header-size 32 --slot-size 475136 --pad-header \ - "$BUILD_DIR/src/pinetime-mcuboot-app-$PROJECT_VERSION.bin" \ - "$OUTPUT_DIR/image-$PROJECT_VERSION.bin" +cp "$BUILD_DIR/src/pinetime-mcuboot-recovery-loader-image-$PROJECT_VERSION.bin" "$OUTPUT_DIR/pinetime-mcuboot-recovery-loader-image-$PROJECT_VERSION.bin" +cp "$BUILD_DIR/src/pinetime-mcuboot-recovery-loader-dfu-$PROJECT_VERSION.zip" "$OUTPUT_DIR/pinetime-mcuboot-recovery-loader-dfu-$PROJECT_VERSION.zip" -adafruit-nrfutil dfu genpkg --dev-type 0x0052 \ - --application "$OUTPUT_DIR/image-$PROJECT_VERSION.bin" \ - "$OUTPUT_DIR/dfu-$PROJECT_VERSION.zip" mkdir -p "$OUTPUT_DIR/src" cd "$BUILD_DIR" -- cgit v1.2.3 From 740b3d7b58dd92a6a6f99620a090ae4f05c03299 Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Mon, 1 Feb 2021 21:07:53 +0100 Subject: Add new cmake option to disable the generation of DFU file (which needs adafruit-nrfutil on the build machine) : BUILD_DFU (disabled by default, enabled in docker build). --- CMakeLists.txt | 9 +++++++++ doc/buildAndProgram.md | 23 ++++++++++++++++------- docker/build.sh | 1 + src/CMakeLists.txt | 27 ++++++++++++++++++++++++--- 4 files changed, 50 insertions(+), 10 deletions(-) (limited to 'docker') diff --git a/CMakeLists.txt b/CMakeLists.txt index 4234b983..8c35215e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,10 @@ if(DEFINED USE_DEBUG_PINS AND USE_DEBUG_PINS) add_definitions(-DUSE_DEBUG_PINS) endif() +if(BUILD_DFU) + set(BUILD_DFU true) +endif() + message("BUILD CONFIGURATION") message("-------------------") message(" * Version : " ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) @@ -62,6 +66,11 @@ if(USE_DEBUG_PINS) else() message(" * Debug pins : Disabled") endif() +if(BUILD_DFU) + message(" * Build DFU (using adafruit-nrfutil) : Enabled") +else() + message(" * Build DFU (using adafruit-nrfutil) : Disabled") +endif() set(VERSION_EDIT_WARNING "// Do not edit this file, it is automatically generated by CMAKE!") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h) diff --git a/doc/buildAndProgram.md b/doc/buildAndProgram.md index 72870e3d..3139c7f5 100644 --- a/doc/buildAndProgram.md +++ b/doc/buildAndProgram.md @@ -25,7 +25,10 @@ CMake configures the project according to variables you specify the command line **NRFJPROG**|Path to the NRFJProg executable. Used only if `USE_JLINK` is 1.|`-DNRFJPROG=/opt/nrfjprog/nrfjprog` **GDB_CLIENT_BIN_PATH**|Path to arm-none-eabi-gdb executable. Used only if `USE_GDB_CLIENT` is 1.|`-DGDB_CLIENT_BIN_PATH=/home/jf/nrf52/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi-gdb` **GDB_CLIENT_TARGET_REMOTE**|Target remote connection string. Used only if `USE_GDB_CLIENT` is 1.|`-DGDB_CLIENT_TARGET_REMOTE=/dev/ttyACM0` +**BUILD_DFU (\*)**|Build DFU files while building (needs [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil)).|`-BUILD_DFU=1` +####(*) Note about **BUILD_DFU**: +DFU files are the files you'll need to install your build of InfiniTime using OTA (over-the-air) mecanism. To generate the DFU file, the Python tool [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil) is needed on your system. Check that this tool is properly installed before enabling this option. #### CMake command line for JLink ``` @@ -44,11 +47,14 @@ cmake -DARM_NONE_EABI_TOOLCHAIN_PATH=... -DNRF5_SDK_PATH=... -DUSE_OPENOCD=1 -DG ### Build the project During the project generation, CMake created the following targets: -- FLASH_ERASE : mass erase the flash memory of the NRF52. -- FLASH_pinetime-app : flash the firmware into the NRF52. -- pinetime-app : build the standalone (without bootloader support) version of the firmware. -- pinetime-mcuboot-app : build the firmware with the support of the bootloader (based on MCUBoot). -- pinetime-graphics : small firmware that writes the boot graphics into the SPI flash. +- **FLASH_ERASE** : mass erase the flash memory of the NRF52. +- **FLASH_pinetime-app** : flash the firmware into the NRF52. +- **pinetime-app** : build the standalone (without bootloader support) version of the firmware. +- **pinetime-recovery** : build the standalone recovery version of infinitime (light firmware that only supports OTA and basic UI) +- **pinetime-recovery-loader** : build the standalone tool that flashes the recovery firmware into the external SPI flash +- **pinetime-mcuboot-app** : build the firmware with the support of the bootloader (based on MCUBoot). +- **pinetime-mcuboot-recovery** : build pinetime-recovery with bootloader support +- **pinetime-mcuboot-recovery-loader** : build pinetime-recovery-loader with bootloader support If you just want to build the project and run it on the Pinetime, using *pinetime-app* is recommanded. See [this page](../bootloader/README.md) for more info about bootloader support. @@ -63,8 +69,11 @@ Binary files are generated into the folder `src`: - **pinetime-app.map** : map file - **pinetime-mcuboot-app.bin, .hex and .out** : firmware with bootloader support in bin, hex and out formats. - **pinetime-mcuboot-app.map** : map file - - **pinetime-graphics.bin, .hex and .out** : firmware for the boot graphic in bin, hex and out formats. - - **pinetime-graphics.map** : map file + - **pinetime-mcuboot-app-image** : MCUBoot image of the firmware + - **pinetime-mcuboot-ap-dfu** : DFU file of the firmware + +The same files are generated for **pinetime-recovery** and **pinetime-recoveryloader** + ### Program and run #### Using CMake targets diff --git a/docker/build.sh b/docker/build.sh index 8f0d0fa9..2fa7d920 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -63,6 +63,7 @@ CmakeGenerate() { -DUSE_OPENOCD=1 \ -DARM_NONE_EABI_TOOLCHAIN_PATH="$TOOLS_DIR/$GCC_ARM_VER" \ -DNRF5_SDK_PATH="$TOOLS_DIR/$NRF_SDK_VER" \ + -DBUILD_DFU=1 \ "$SOURCES_DIR" cmake -L -N . } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b6a7889c..c39c1ac5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -842,10 +842,17 @@ add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_NAME} COMMAND ${CMAKE_OBJCOPY} -O binary ${EXECUTABLE_MCUBOOT_FILE_NAME}.out "${EXECUTABLE_MCUBOOT_FILE_NAME}.bin" COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_MCUBOOT_FILE_NAME}.out "${EXECUTABLE_MCUBOOT_FILE_NAME}.hex" COMMAND ${CMAKE_SOURCE_DIR}/tools/mcuboot/imgtool.py create --align 4 --version 1.0.0 --header-size 32 --slot-size 475136 --pad-header ${EXECUTABLE_MCUBOOT_FILE_NAME}.bin ${IMAGE_MCUBOOT_FILE_NAME} - COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_MCUBOOT_FILE_NAME} ${DFU_MCUBOOT_FILE_NAME} COMMENT "post build steps for ${EXECUTABLE_MCUBOOT_FILE_NAME}" ) +if(BUILD_DFU) + add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_NAME} + POST_BUILD + COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_MCUBOOT_FILE_NAME} ${DFU_MCUBOOT_FILE_NAME} + COMMENT "post build (DFU) steps for ${EXECUTABLE_MCUBOOT_FILE_NAME}" + ) +endif() + # InfiniTime recovery firmware (autonomous) set(EXECUTABLE_RECOVERY_NAME "pinetime-recovery") set(EXECUTABLE_RECOVERY_FILE_NAME ${EXECUTABLE_RECOVERY_NAME}-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}) @@ -907,10 +914,17 @@ add_custom_command(TARGET ${EXECUTABLE_RECOVERY_MCUBOOT_NAME} COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME}.out "${EXECUTABLE_RECOVERYY_MCUBOOT_FILE_NAME}.hex" COMMAND ${CMAKE_SOURCE_DIR}/tools/mcuboot/imgtool.py create --align 4 --version 1.0.0 --header-size 32 --slot-size 475136 --pad-header ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME}.bin ${IMAGE_RECOVERY_MCUBOOT_FILE_NAME} COMMAND python ${CMAKE_SOURCE_DIR}/tools/bin2c.py ${IMAGE_RECOVERY_MCUBOOT_FILE_NAME} recoveryImage > recoveryImage.h - COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_RECOVERY_MCUBOOT_FILE_NAME} ${DFU_RECOVERY_MCUBOOT_FILE_NAME} COMMENT "post build steps for ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME}" ) +if(BUILD_DFU) + add_custom_command(TARGET ${EXECUTABLE_RECOVERY_MCUBOOT_NAME} + POST_BUILD + COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_RECOVERY_MCUBOOT_FILE_NAME} ${DFU_RECOVERY_MCUBOOT_FILE_NAME} + COMMENT "post build (DFU) steps for ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME}" + ) +endif() + # Build binary that writes the recovery image into the SPI flash memory set(EXECUTABLE_RECOVERYLOADER_NAME "pinetime-recovery-loader") set(EXECUTABLE_RECOVERYLOADER_FILE_NAME ${EXECUTABLE_RECOVERYLOADER_NAME}-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}) @@ -978,10 +992,17 @@ add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}.out "${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}.hex" COMMAND ${CMAKE_SOURCE_DIR}/tools/mcuboot/imgtool.py create --align 4 --version 1.0.0 --header-size 32 --slot-size 475136 --pad-header ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}.bin ${IMAGE_MCUBOOT_RECOVERYLOADER_FILE_NAME} COMMAND python ${CMAKE_SOURCE_DIR}/tools/bin2c.py ${IMAGE_MCUBOOT_RECOVERYLOADER_FILE_NAME} recoveryLoaderImage > recoveryLoaderImage.h - COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_MCUBOOT_RECOVERYLOADER_FILE_NAME} ${DFU_MCUBOOT_RECOVERYLOADER_FILE_NAME} COMMENT "post build steps for ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}" ) +if(BUILD_DFU) + add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} + POST_BUILD + COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_MCUBOOT_RECOVERYLOADER_FILE_NAME} ${DFU_MCUBOOT_RECOVERYLOADER_FILE_NAME} + COMMENT "post build (DFU) steps for ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}" + ) +endif() + # FLASH if (USE_JLINK) -- cgit v1.2.3