Author: Jean-François Milants <jf@codingfield.com>
Remove CMake targets and corresponding CLI arguments that are specific to the debugging environment (USE_JLINK, USE_OPENOCD and USE_GDB_CLIENT).
.devcontainer/build.sh | 1 CMakeLists.txt | 33 ------------------ cmake-nRF5x/CMake_nRF5x.cmake | 51 ----------------------------- doc/buildAndProgram.md | 40 +--------------------- docker/build.sh | 1 src/CMakeLists.txt | 65 -------------------------------------
diff --git a/.devcontainer/build.sh b/.devcontainer/build.sh index 5dcdf91dc06189cb35666470c5e042215d8c7178..3d8aecbff32c5b799b6eabedb81c201542909fe8 100644 --- a/.devcontainer/build.sh +++ b/.devcontainer/build.sh @@ -60,7 +60,6 @@ cd "$BUILD_DIR" cmake -G "Unix Makefiles" \ -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ - -DUSE_OPENOCD=1 \ -DARM_NONE_EABI_TOOLCHAIN_PATH="$TOOLS_DIR/$GCC_ARM_VER" \ -DNRF5_SDK_PATH="$TOOLS_DIR/$NRF_SDK_VER" \ "$SOURCES_DIR" diff --git a/CMakeLists.txt b/CMakeLists.txt index 1da460c4994a0554ca8e4d0f587bdb2551bb8acb..75a6baa5d3f4cc596ae98fe4238ba26ec1ff19fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,28 +24,6 @@ if (NOT NRF5_SDK_PATH) message(FATAL_ERROR "The path to the NRF52 SDK must be specified on the command line (add -DNRF5_SDK_PATH=<path>") endif () -if(USE_JLINK) - if (NOT NRFJPROG) - message(FATAL_ERROR "the path to the tool nrfjprog must be specified on the command line (add -DNRFJPROG=<path>") - endif () -endif() - -if(USE_GDB_CLIENT) - if(NOT GDB_CLIENT_BIN_PATH) - set(GDB_CLIENT_BIN_PATH "arm-none-eabi-gdb") - endif() - - if(NOT GDB_CLIENT_TARGET_REMOTE) - message(FATAL_ERROR "The GDB target must be specified (add -DGDB_CLIENT_TARGET_REMOTE=<target>") - endif() -endif() - -if(USE_OPENOCD) - if(NOT OPENOCD_BIN_PATH) - set(OPENOCD_BIN_PATH "openocd") - endif() -endif() - if(DEFINED USE_DEBUG_PINS AND USE_DEBUG_PINS) add_definitions(-DUSE_DEBUG_PINS) endif() @@ -81,17 +59,6 @@ message(" * Toolchain : " ${ARM_NONE_EABI_TOOLCHAIN_PATH}) message(" * GitRef(S) : " ${PROJECT_GIT_COMMIT_HASH}) message(" * NRF52 SDK : " ${NRF5_SDK_PATH}) message(" * Target device : " ${TARGET_DEVICE}) -set(PROGRAMMER "???") -if(USE_JLINK) - message(" * Programmer/debugger : JLINK") - message(" * NrfJprog : " ${NRFJPROG}) -elseif(USE_GDB_CLIENT) - message(" * Programmer/debugger : GDB Client") - message(" * GDB Client path : " ${GDB_CLIENT_BIN_PATH}) - message(" * GDB Target : " ${GDB_CLIENT_TARGET_REMOTE}) -elseif(USE_OPENOCD) - message(" * Programmer/debugger : OpenOCD Client") -endif() if(USE_DEBUG_PINS) message(" * Debug pins : Enabled") else() diff --git a/cmake-nRF5x/CMake_nRF5x.cmake b/cmake-nRF5x/CMake_nRF5x.cmake index 9bf63f2a3c346fdfac61bd750be356a293291c53..95f1fdb609726cfe3ec556edee9878623b9cf6f3 100755 --- a/cmake-nRF5x/CMake_nRF5x.cmake +++ b/cmake-nRF5x/CMake_nRF5x.cmake @@ -229,24 +229,6 @@ LIST(APPEND SDK_SOURCE_FILES "${NRF5_SDK_PATH}/modules/nrfx/drivers/src/nrfx_twi.c" ) - # adds target for erasing - if(USE_JLINK) - add_custom_target(FLASH_ERASE - COMMAND ${NRFJPROG} --eraseall -f ${NRF_TARGET} - COMMENT "erasing flashing" - ) - elseif(USE_GDB_CLIENT) - add_custom_target(FLASH_ERASE - COMMAND ${GDB_CLIENT_BIN_PATH} -nx --batch -ex 'target extended-remote ${GDB_CLIENT_TARGET_REMOTE}' -ex 'monitor swdp_scan' -ex 'attach 1' -ex 'mon erase_mass' - COMMENT "erasing flashing" - ) - elseif(USE_OPENOCD) - add_custom_target(FLASH_ERASE - COMMAND ${OPENOCD_BIN_PATH} -f interface/stlink.cfg -c 'transport select hla_swd' -f target/nrf52.cfg -c init -c halt -c 'nrf5 mass_erase' -c reset -c shutdown - COMMENT "erasing flashing" - ) - endif() - if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin") set(TERMINAL "open") elseif(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") @@ -255,16 +237,6 @@ else() set(TERMINAL "gnome-terminal") endif() - if(USE_JLINK) - add_custom_target(START_JLINK - COMMAND ${TERMINAL} "${DIR_OF_nRF5x_CMAKE}/runJLinkGDBServer-${NRF_TARGET}" - COMMAND ${TERMINAL} "${DIR_OF_nRF5x_CMAKE}/runJLinkExe-${NRF_TARGET}" - COMMAND sleep 2s - COMMAND ${TERMINAL} "${DIR_OF_nRF5x_CMAKE}/runJLinkRTTClient" - COMMENT "started JLink commands" - ) - endif() - endmacro(nRF5x_setup) # adds a target for comiling and flashing an executable @@ -281,29 +253,6 @@ COMMAND ${CMAKE_SIZE_UTIL} ${EXECUTABLE_NAME}.out COMMAND ${CMAKE_OBJCOPY} -O binary ${EXECUTABLE_NAME}.out "${EXECUTABLE_NAME}.bin" COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_NAME}.out "${EXECUTABLE_NAME}.hex" COMMENT "post build steps for ${EXECUTABLE_NAME}") - - # custom target for flashing the board - if(USE_JLINK) - add_custom_target("FLASH_${EXECUTABLE_NAME}" - DEPENDS ${EXECUTABLE_NAME} - COMMAND ${NRFJPROG} --program ${EXECUTABLE_NAME}.hex -f ${NRF_TARGET} --sectorerase - COMMAND sleep 0.5s - COMMAND ${NRFJPROG} --reset -f ${NRF_TARGET} - COMMENT "flashing ${EXECUTABLE_NAME}.hex" - ) - elseif(USE_GDB_CLIENT) - add_custom_target("FLASH_${EXECUTABLE_NAME}" - DEPENDS ${EXECUTABLE_NAME} - COMMAND ${GDB_CLIENT_BIN_PATH} -nx --batch -ex 'target extended-remote ${GDB_CLIENT_TARGET_REMOTE}' -ex 'monitor swdp_scan' -ex 'attach 1' -ex 'load' -ex 'kill' ${EXECUTABLE_NAME}.hex - COMMENT "flashing ${EXECUTABLE_NAME}.hex" - ) - elseif(USE_OPENOCD) - add_custom_target("FLASH_${EXECUTABLE_NAME}" - DEPENDS ${EXECUTABLE_NAME} - COMMAND ${OPENOCD_BIN_PATH} -c "tcl_port disabled" -c "gdb_port 3333" -c "telnet_port 4444" -f interface/stlink.cfg -c 'transport select hla_swd' -f target/nrf52.cfg -c "program \"${EXECUTABLE_NAME}.hex\"" -c reset -c shutdown - COMMENT "flashing ${EXECUTABLE_NAME}.hex" - ) - endif() endmacro() diff --git a/doc/buildAndProgram.md b/doc/buildAndProgram.md index d3cf50e2290cf4d74f8e5041a405016b601d6000..78bea1b458b5dbfc658486bbae51d0db88839694 100644 --- a/doc/buildAndProgram.md +++ b/doc/buildAndProgram.md @@ -40,11 +40,7 @@ Variable | Description | Example| ----------|-------------|--------| **ARM_NONE_EABI_TOOLCHAIN_PATH**|path to the toolchain directory|`-DARM_NONE_EABI_TOOLCHAIN_PATH=/home/jf/nrf52/gcc-arm-none-eabi-10.3-2021.10/`| **NRF5_SDK_PATH**|path to the NRF52 SDK|`-DNRF5_SDK_PATH=/home/jf/nrf52/Pinetime/sdk`| -**USE_JLINK, USE_GDB_CLIENT and USE_OPENOCD**|Enable *JLink* mode, *GDB Client* (Black Magic Probe) mode or *OpenOCD* mode (set the one you want to use to `1`)|`-DUSE_JLINK=1` **CMAKE_BUILD_TYPE (\*)**| Build type (Release or Debug). Release is applied by default if this variable is not specified.|`-DCMAKE_BUILD_TYPE=Debug` -**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)).|`-DBUILD_DFU=1` **BUILD_RESOURCES (\*\*)**| Generate external resource while building (needs [lv_font_conv](https://github.com/lvgl/lv_font_conv) and [lv_img_conv](https://github.com/lvgl/lv_img_conv). |`-DBUILD_RESOURCES=1` **TARGET_DEVICE**|Target device, used for hardware configuration. Allowed: `PINETIME, MOY-TFK5, MOY-TIN5, MOY-TON5, MOY-UNK`|`-DTARGET_DEVICE=PINETIME` (Default) @@ -57,30 +53,16 @@ #### (\*\*) Note about **BUILD_DFU** DFU files are the files you'll need to install your build of InfiniTime using OTA (over-the-air) mechanism. 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 - -``` -cmake -DARM_NONE_EABI_TOOLCHAIN_PATH=... -DNRF5_SDK_PATH=... -DUSE_JLINK=1 -DNRFJPROG=... ../ -``` - -#### CMake command line for GDB Client (Black Magic Probe) - -``` -cmake -DARM_NONE_EABI_TOOLCHAIN_PATH=... -DNRF5_SDK_PATH=... -DUSE_GDB_CLIENT=1 -DGDB_CLIENT_BIN_PATH=... -DGDB_CLIENT_TARGET_REMOTE=... ../ -``` - -#### CMake command line for OpenOCD +#### CMake command ``` -cmake -DARM_NONE_EABI_TOOLCHAIN_PATH=... -DNRF5_SDK_PATH=... -DUSE_OPENOCD=1 -DGDB_CLIENT_BIN_PATH=[optional] ../ +cmake -DARM_NONE_EABI_TOOLCHAIN_PATH=... -DNRF5_SDK_PATH=... ``` ### 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-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 @@ -107,24 +89,6 @@ - **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 - -These target have been configured during the project generation by CMake according to the parameters you provided to the command line. - -Mass erase: - -``` -make FLASH_ERASE -``` - -Flash the application: - -``` -make FLASH_pinetime-app -``` ### How to generate files needed by the factory diff --git a/docker/build.sh b/docker/build.sh index 58dcccc1d8b7ff4b64f37d89a57babecd7b8fd5b..07e0d17e49f92b333f6593a82e1600bd1d727848 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -63,7 +63,6 @@ cmake -G "Unix Makefiles" \ -S "$SOURCES_DIR" \ -B "$BUILD_DIR" \ -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ - -DUSE_OPENOCD=1 \ -DARM_NONE_EABI_TOOLCHAIN_PATH="$TOOLS_DIR/$GCC_ARM_PATH" \ -DNRF5_SDK_PATH="$TOOLS_DIR/$NRF_SDK_VER" \ -DBUILD_DFU=1 \ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 92f309a12e118a592638a62ed37138f68c5dce04..513902998bdb6c69640297957d4a1653a5570fc6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1139,68 +1139,3 @@ if(BUILD_RESOURCES) add_subdirectory(resources) endif() - -# FLASH -if (USE_JLINK) - add_custom_target(FLASH_ERASE - COMMAND ${NRFJPROG} --eraseall -f ${NRF_TARGET} - COMMENT "erasing flashing" - ) - add_custom_target("FLASH_${EXECUTABLE_NAME}" - DEPENDS ${EXECUTABLE_NAME} - COMMAND ${NRFJPROG} --program ${EXECUTABLE_FILE_NAME}.hex -f ${NRF_TARGET} --sectorerase - COMMAND sleep 0.5s - COMMAND ${NRFJPROG} --reset -f ${NRF_TARGET} - COMMENT "flashing ${EXECUTABLE_FILE_NAME}.hex" - ) - -elseif (USE_GDB_CLIENT) - add_custom_target(FLASH_ERASE - COMMAND ${GDB_CLIENT_BIN_PATH} -nx --batch -ex 'target extended-remote ${GDB_CLIENT_TARGET_REMOTE}' -ex 'monitor swdp_scan' -ex 'attach 1' -ex 'mon erase_mass' - COMMENT "erasing flashing" - ) - add_custom_target("FLASH_${EXECUTABLE_NAME}" - DEPENDS ${EXECUTABLE_NAME} - COMMAND ${GDB_CLIENT_BIN_PATH} -nx --batch -ex 'target extended-remote ${GDB_CLIENT_TARGET_REMOTE}' -ex 'monitor swdp_scan' -ex 'attach 1' -ex 'load' -ex 'kill' ${EXECUTABLE_FILE_NAME}.hex - COMMENT "flashing ${EXECUTABLE_FILE_NAME}.hex" - ) -elseif (USE_OPENOCD) - if (USE_CMSIS_DAP) - add_custom_target(FLASH_ERASE - COMMAND ${OPENOCD_BIN_PATH} -c 'source [find interface/cmsis-dap.cfg]' -c 'transport select swd' - -c 'source [find target/nrf52.cfg]' - -c 'init' - -c 'halt' - -c 'nrf5 mass_erase' - -c 'halt' - -c 'reset' - -c 'exit' - COMMENT "erasing flashing" - ) - add_custom_target("FLASH_${EXECUTABLE_NAME}" - DEPENDS ${EXECUTABLE_NAME} - COMMAND ${OPENOCD_BIN_PATH} - -c 'tcl_port disabled' - -c 'gdb_port 3333' - -c 'telnet_port 4444' - -c 'source [find interface/cmsis-dap.cfg]' - -c 'transport select swd' - -c 'source [find target/nrf52.cfg]' - -c 'halt' - -c "program \"${EXECUTABLE_FILE_NAME}.hex\"" - -c 'reset' - -c 'shutdown' - COMMENT "flashing ${EXECUTABLE_BIN_NAME}.hex" - ) - else () - add_custom_target(FLASH_ERASE - COMMAND ${OPENOCD_BIN_PATH} -f interface/stlink.cfg -c 'transport select hla_swd' -f target/nrf52.cfg -c init -c halt -c 'nrf5 mass_erase' -c reset -c shutdown - COMMENT "erasing flashing" - ) - add_custom_target("FLASH_${EXECUTABLE_NAME}" - DEPENDS ${EXECUTABLE_NAME} - COMMAND ${OPENOCD_BIN_PATH} -c "tcl_port disabled" -c "gdb_port 3333" -c "telnet_port 4444" -f interface/stlink.cfg -c 'transport select hla_swd' -f target/nrf52.cfg -c "program \"${EXECUTABLE_FILE_NAME}.hex\"" -c reset -c shutdown - COMMENT "flashing ${EXECUTABLE_FILE_NAME}.hex" - ) - endif () -endif ()