summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-François Milants <jf@codingfield.com>2021-02-01 21:07:53 +0100
committerJean-François Milants <jf@codingfield.com>2021-02-01 21:07:53 +0100
commit740b3d7b58dd92a6a6f99620a090ae4f05c03299 (patch)
tree0c5235441c573eea52d8db8a9df79888fb1b27b0
parentd2bb209d7f5b74447c80e404ae7249fa0d151c41 (diff)
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).
-rw-r--r--CMakeLists.txt9
-rw-r--r--doc/buildAndProgram.md23
-rwxr-xr-xdocker/build.sh1
-rw-r--r--src/CMakeLists.txt27
4 files changed, 50 insertions, 10 deletions
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)