From 155429107e1829b7e3ab82cfd1fc980d632fd913 Mon Sep 17 00:00:00 2001 From: James Rich <2199651+jamesarich@users.noreply.github.com> Date: Fri, 23 Oct 2026 13:15:04 -0500 Subject: [PATCH 1/5] chore: drop duplicate defines and fix stale comments No behavior or size change. Removes a repeated PEER_ADDRESS_TYPE_INVALID and UF2_EXIT_ON_EJECT define, moves ADAFRUIT_DEV_REV to the Makefile where DFU_DEV_REV is already chosen per MCU, and adds a compile-time check that the lazy-erase page map covers the app region. --- Makefile | 1 + .../libraries/bootloader_dfu/dfu_single_bank.c | 1 + .../libraries/bootloader_dfu/dfu_transport_ble.c | 5 ++--- src/boards/t1000_e/board.h | 6 ------ src/dfu_init.c | 9 --------- src/usb/msc_uf2.c | 4 ++-- src/usb/uf2/ghostfat.c | 5 ++--- 7 files changed, 8 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index bb10e1506..0bb08e8fc 100644 --- a/Makefile +++ b/Makefile @@ -336,6 +336,7 @@ ifeq ($(DEBUG), 1) endif CFLAGS += -DDFU_APP_DATA_RESERVED=$(DFU_APP_DATA_RESERVED) +CFLAGS += -DADAFRUIT_DEV_REV=$(DFU_DEV_REV) #------------------------------------------------------------------------------ # Linker Flags diff --git a/lib/sdk11/components/libraries/bootloader_dfu/dfu_single_bank.c b/lib/sdk11/components/libraries/bootloader_dfu/dfu_single_bank.c index 76487480f..384760a74 100644 --- a/lib/sdk11/components/libraries/bootloader_dfu/dfu_single_bank.c +++ b/lib/sdk11/components/libraries/bootloader_dfu/dfu_single_bank.c @@ -108,6 +108,7 @@ static void dfu_prepare_func_app_erase(uint32_t image_size) if (dfu_image_page_count < 1) dfu_image_page_count = 1; // This should not happen static uint8_t dfu_page_erased_static[256]; + _Static_assert(sizeof(dfu_page_erased_static) >= (BOOTLOADER_REGION_START - MBR_SIZE - DFU_APP_DATA_RESERVED) / CODE_PAGE_SIZE, "lazy-erase page map smaller than the app region"); dfu_page_erased = dfu_page_erased_static; memset(dfu_page_erased, 0, dfu_image_page_count); diff --git a/lib/sdk11/components/libraries/bootloader_dfu/dfu_transport_ble.c b/lib/sdk11/components/libraries/bootloader_dfu/dfu_transport_ble.c index fd2e3dedc..50849ba3b 100644 --- a/lib/sdk11/components/libraries/bootloader_dfu/dfu_transport_ble.c +++ b/lib/sdk11/components/libraries/bootloader_dfu/dfu_transport_ble.c @@ -51,8 +51,8 @@ enum { BLE_CONN_CFG_HIGH_BANDWIDTH = 1 }; #define DEVICE_NAME "AdaDFU" /**< Name of device. Will be included in the advertising data. */ #endif //DEVICE_NAME -#define MIN_CONN_INTERVAL (uint16_t)(MSEC_TO_UNITS(10, UNIT_1_25_MS)) /**< Minimum acceptable connection interval (11.25 milliseconds). */ -#define MAX_CONN_INTERVAL (uint16_t)(MSEC_TO_UNITS(30, UNIT_1_25_MS)) /**< Maximum acceptable connection interval (15 milliseconds). */ +#define MIN_CONN_INTERVAL (uint16_t)(MSEC_TO_UNITS(10, UNIT_1_25_MS)) /**< Minimum acceptable connection interval (10 milliseconds). */ +#define MAX_CONN_INTERVAL (uint16_t)(MSEC_TO_UNITS(30, UNIT_1_25_MS)) /**< Maximum acceptable connection interval (30 milliseconds). */ #define SLAVE_LATENCY 0 /**< Slave latency. */ #define CONN_SUP_TIMEOUT (4 * 100) /**< Connection supervisory timeout (4 seconds). */ @@ -60,7 +60,6 @@ enum { BLE_CONN_CFG_HIGH_BANDWIDTH = 1 }; #define APP_ADV_TIMEOUT BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED /**< The advertising timeout in units of seconds. This is set to @ref BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED so that the advertisement is done as long as there there is a call to @ref dfu_transport_close function.*/ #define APP_DIRECTED_ADV_TIMEOUT 50 /**< number of direct advertisement (each lasting 1.28seconds). */ #define PEER_ADDRESS_TYPE_INVALID 0xFF /**< Value indicating that no valid peer address exists. This will be the case when a private resolvable address is used in which case there is no address available but instead an IRK is present. */ -#define PEER_ADDRESS_TYPE_INVALID 0xFF /**< Value indicating that no valid peer address exists. This will be the case when a private resolvable address is used in which case there is no address available but instead an IRK is present. */ #define SEC_PARAM_TIMEOUT 30 /**< Timeout for Pairing Request or Security Request (in seconds). */ #define SEC_PARAM_BOND 0 /**< Perform bonding. */ diff --git a/src/boards/t1000_e/board.h b/src/boards/t1000_e/board.h index a7bffb79f..4aa590bc7 100644 --- a/src/boards/t1000_e/board.h +++ b/src/boards/t1000_e/board.h @@ -63,12 +63,6 @@ * drive therefore leaves DFU and boots the application. */ #define UF2_EXIT_ON_EJECT -/* P0.18 is RESET and is not exposed as a button, so there is no way to reset - * out of UF2 mode once in it, and the host just re-mounts the drive if we stay - * enumerated. Ejecting the drive therefore leaves DFU and boots the - * application. */ -#define UF2_EXIT_ON_EJECT - //--------------------------------------------------------------------+ // BLE OTA //--------------------------------------------------------------------+ diff --git a/src/dfu_init.c b/src/dfu_init.c index e19cffa36..9b81e6e8f 100644 --- a/src/dfu_init.c +++ b/src/dfu_init.c @@ -83,15 +83,6 @@ */ #define ADAFRUIT_DEVICE_TYPE 0x0052 -#if defined(NRF52840_XXAA) - #define ADAFRUIT_DEV_REV 52840 -#elif defined(NRF52833_XXAA) - #define ADAFRUIT_DEV_REV 52833 -#elif defined NRF52832_XXAA - #define ADAFRUIT_DEV_REV 0xADAF -#else - #error Unknown MCU -#endif diff --git a/src/usb/msc_uf2.c b/src/usb/msc_uf2.c index e8345fcf4..499bd5831 100644 --- a/src/usb/msc_uf2.c +++ b/src/usb/msc_uf2.c @@ -183,8 +183,8 @@ int32_t tud_msc_write10_cb (uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* uint32_t count = 0; while ( count < bufsize ) { - // Consider non-uf2 block write as successful - // only break if write_block is busy with flashing (return 0) + // Non-uf2 and rejected blocks count as consumed like good ones. + // The loop only stops early on a 0 return, which write_block never gives. if ( 0 == write_block(lba, buffer, &_wr_state) ) break; lba++; diff --git a/src/usb/uf2/ghostfat.c b/src/usb/uf2/ghostfat.c index 07a68060a..b09c9f7eb 100644 --- a/src/usb/uf2/ghostfat.c +++ b/src/usb/uf2/ghostfat.c @@ -463,9 +463,8 @@ void read_block(uint32_t block_no, uint8_t *data) { /** * Write an uf2 block wrapped by 512 sector. * @return number of bytes processed, only 3 following values - * -1 : if not an uf2 block - * 512 : write is successful (BPB_SECTOR_SIZE == 512) - * 0 : is busy with flashing, tinyusb stack will call write_block again with the same parameters later on + * -1 : if not an uf2 block, or the block is rejected + * 512 : otherwise (BPB_SECTOR_SIZE == 512) */ int write_block (uint32_t block_no, uint8_t *data, WriteState *state) { From dd862c2991ee52d5559a9e793922c639c38f7897 Mon Sep 17 00:00:00 2001 From: James Rich <2199651+jamesarich@users.noreply.github.com> Date: Fri, 23 Oct 2026 16:36:35 -0500 Subject: [PATCH 2/5] fix(heltec_t114): point INDEX.HTM at a real URL --- src/boards/heltec_t114/board.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/boards/heltec_t114/board.h b/src/boards/heltec_t114/board.h index 348f0bdb9..44dbc3cbf 100644 --- a/src/boards/heltec_t114/board.h +++ b/src/boards/heltec_t114/board.h @@ -100,6 +100,6 @@ #define UF2_PRODUCT_NAME "HT-n5262" #define UF2_VOLUME_LABEL "HT-n5262" #define UF2_BOARD_ID "HT-n5262" -#define UF2_INDEX_URL "HT-n5262" +#define UF2_INDEX_URL "http://heltec.org/" #endif From 970b606d65e3f87e4e06eac8a9e5010677527674 Mon Sep 17 00:00:00 2001 From: James Rich <2199651+jamesarich@users.noreply.github.com> Date: Fri, 23 Oct 2026 16:36:39 -0500 Subject: [PATCH 3/5] chore: remove the unused CMake build --- AGENTS.md | 14 +- CMakeLists.txt | 336 ------------------------- CONTRIBUTING.md | 9 +- src/boards/heltec_t096/board.cmake | 1 - src/boards/heltec_t1/board.cmake | 1 - src/boards/heltec_t114/board.cmake | 1 - src/boards/mesh_tracker_x1/board.cmake | 1 - src/boards/thinknode_m1/board.cmake | 1 - 8 files changed, 6 insertions(+), 358 deletions(-) delete mode 100644 CMakeLists.txt delete mode 100644 src/boards/heltec_t096/board.cmake delete mode 100644 src/boards/heltec_t1/board.cmake delete mode 100644 src/boards/heltec_t114/board.cmake delete mode 100644 src/boards/mesh_tracker_x1/board.cmake delete mode 100644 src/boards/thinknode_m1/board.cmake diff --git a/AGENTS.md b/AGENTS.md index e44c70aa8..504434ceb 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -31,8 +31,7 @@ can upgrade in-app over USB/serial (`feature/firmware` there). Meshtastic's separate `Adafruit_nRF52_Bootloader` fork is a **different lineage without** the OTAFIX patches — don't confuse the two. -This is C, built with a bare Makefile (the supported path) or `CMakeLists.txt` -(**not** fully wired — see the CMake gotcha below). Not PlatformIO. +This is C, built with a bare Makefile. Not PlatformIO. ## Build @@ -69,16 +68,11 @@ Each board directory can carry: `src/screen.c`. - `board.mk` — Makefile board config (`MCU_SUB_VARIANT`, per-board `CFLAGS` like the BLE `DEVICE_NAME`). -- `board.cmake` — **only exists for 5 of 19 boards** (`heltec_t096`, - `heltec_t1`, `heltec_t114`, `mesh_tracker_x1`, `thinknode_m1`). `cmake -DBOARD=` fails outright. Nobody - uses the CMake path in practice (CI and `tools/build_all.py` both use - `make`); don't assume feature parity between the two build systems. - `pinconfig.c` — present on some boards, board-specific pin table. -`Makefile` and `CMakeLists.txt` both dynamically discover the board's files -under `src/boards/$(BOARD)/` — there is no separate hardcoded board list to -keep in sync in either build system (unlike the CI matrix, see below). +The `Makefile` dynamically discovers the board's files under +`src/boards/$(BOARD)/` — there is no separate hardcoded board list to keep in +sync (unlike the CI matrix, see below). ### Core bootloader (`src/`) diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 567a815af..000000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,336 +0,0 @@ -cmake_minimum_required(VERSION 3.17) -find_package(Python COMPONENTS Interpreter) - -if (NOT DEFINED BOARD) - message(FATAL_ERROR "BOARD is not defined") -endif () - -if (NOT DEFINED TOOLCHAIN) - set(TOOLCHAIN gcc) -endif () - -# include board specific -include(${CMAKE_CURRENT_LIST_DIR}/src/boards/${BOARD}/board.cmake) - -# toolchain set up -if (MCU_VARIANT STREQUAL "nrf5340_application") - set(CMAKE_SYSTEM_PROCESSOR cortex-m33 CACHE INTERNAL "System Processor") - set(JLINK_DEVICE nrf5340_xxaa_app) -else () - set(CMAKE_SYSTEM_PROCESSOR cortex-m4 CACHE INTERNAL "System Processor") - set(JLINK_DEVICE ${MCU_VARIANT}_xxaa) -endif () - -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/cmake/toolchain/arm_${TOOLCHAIN}.cmake) - -project(Adafruit_nRF52_Bootloader C ASM) - -set(NRFX_DIR ${CMAKE_CURRENT_LIST_DIR}/lib/nrfx) -set(SDK11_DIR ${CMAKE_CURRENT_LIST_DIR}/lib/sdk11/components) -set(SDK_DIR ${CMAKE_CURRENT_LIST_DIR}/lib/sdk/components) -set(SOFTDEVICE_DIR ${CMAKE_CURRENT_LIST_DIR}/lib/softdevice) -set(TINYUSB_DIR ${CMAKE_CURRENT_LIST_DIR}/lib/tinyusb/src) - -set(UF2CONV_PY ${CMAKE_CURRENT_LIST_DIR}/lib/uf2/utils/uf2conv.py) -set(UF2_FAMILY_ID_BOOTLOADER 0xd663823c) - -#------------------- -# Bootloader -#------------------- -set(CMAKE_EXECUTABLE_SUFFIX .elf) -add_executable(bootloader) - -# SD_VERSION can be overwritten by board.cmake -if(NOT DEFINED SD_VERSION) - if(MCU_VARIANT STREQUAL "nrf52833") - set(SD_VERSION 7.3.0) - else() - set(SD_VERSION 6.1.1) - endif() -endif () - -set(MBR_HEX ${SOFTDEVICE_DIR}/mbr/hex/mbr_nrf52_2.4.1_mbr.hex) - -target_sources(bootloader PUBLIC - # src - src/dfu_ble_svc.c - src/dfu_init.c - src/flash_nrf5x.c - src/main.c - src/screen.c - src/images.c - src/boards/boards.c - # nrfx - ${NRFX_DIR}/drivers/src/nrfx_power.c - ${NRFX_DIR}/drivers/src/nrfx_nvmc.c - ${NRFX_DIR}/mdk/system_${MCU_VARIANT}.c - # sdk 11 - ${SDK11_DIR}/libraries/bootloader_dfu/bootloader.c - ${SDK11_DIR}/libraries/bootloader_dfu/bootloader_settings.c - ${SDK11_DIR}/libraries/bootloader_dfu/bootloader_util.c - ${SDK11_DIR}/libraries/bootloader_dfu/dfu_transport_serial.c - ${SDK11_DIR}/libraries/bootloader_dfu/dfu_transport_ble.c - ${SDK11_DIR}/libraries/bootloader_dfu/dfu_single_bank.c - ${SDK11_DIR}/ble/ble_services/ble_dfu/ble_dfu.c - ${SDK11_DIR}/ble/ble_services/ble_dis/ble_dis.c - ${SDK11_DIR}/drivers_nrf/pstorage/pstorage_raw.c - # latest sdk - ${SDK_DIR}/libraries/timer/app_timer.c - ${SDK_DIR}/libraries/scheduler/app_scheduler.c - ${SDK_DIR}/libraries/util/app_error.c - ${SDK_DIR}/libraries/util/app_util_platform.c - ${SDK_DIR}/libraries/crc16/crc16.c - ${SDK_DIR}/libraries/hci/hci_mem_pool.c - ${SDK_DIR}/libraries/hci/hci_slip.c - ${SDK_DIR}/libraries/hci/hci_transport.c - ${SDK_DIR}/libraries/util/nrf_assert.c - # ASM - ${NRFX_DIR}/mdk/gcc_startup_${MCU_VARIANT}.S - ) -target_include_directories(bootloader PUBLIC - src - src/boards - src/boards/${BOARD} - src/cmsis/include - src/usb - ${TINYUSB_DIR} - # nrfx - ${NRFX_DIR} - ${NRFX_DIR}/mdk - ${NRFX_DIR}/hal - ${NRFX_DIR}/drivers/include - ${NRFX_DIR}/drivers/src - # sdk 11 for cdc/ble dfu - ${SDK11_DIR}/libraries/bootloader_dfu - ${SDK11_DIR}/libraries/bootloader_dfu/hci_transport - ${SDK11_DIR}/drivers_nrf/pstorage - ${SDK11_DIR}/ble/common - ${SDK11_DIR}/ble/ble_services/ble_dfu - ${SDK11_DIR}/ble/ble_services/ble_dis - # later sdk with updated drivers - ${SDK_DIR}/libraries/timer - ${SDK_DIR}/libraries/scheduler - ${SDK_DIR}/libraries/crc16 - ${SDK_DIR}/libraries/util - ${SDK_DIR}/libraries/hci/config - ${SDK_DIR}/libraries/hci - ${SDK_DIR}/libraries/uart - ${SDK_DIR}/drivers_nrf/delay - # Softdevice - ${SOFTDEVICE_DIR}/mbr/headers - ) - -# Debug option -if (CMAKE_BUILD_TYPE STREQUAL "Debug") - # TODO not work yet, also need to add segger rtt, DFU_APP_DATA_RESERVED=0, BOOTLOADER_REGION_START=0xED000 - set(LD_FILE ${CMAKE_CURRENT_LIST_DIR}/linker/${MCU_VARIANT}_debug.ld) - - target_sources(bootloader PUBLIC - lib/SEGGER_RTT/RTT/SEGGER_RTT.c - ) - target_include_directories(bootloader PUBLIC - lib/SEGGER_RTT/RTT - ) - - target_compile_definitions(bootloader PUBLIC - CFG_DEBUG - SEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL - DFU_APP_DATA_RESERVED=0 - ) - - if (MCU_VARIANT STREQUAL "nrf52840") - target_compile_definitions(bootloader PUBLIC BOOTLOADER_REGION_START=0xEA000) - else () - target_compile_definitions(bootloader PUBLIC BOOTLOADER_REGION_START=0x6D000) - endif () -else () - set(LD_FILE ${CMAKE_CURRENT_LIST_DIR}/linker/${MCU_VARIANT}.ld) -endif () - -target_link_options(bootloader PUBLIC - "LINKER:--script=${LD_FILE}" - -L${NRFX_DIR}/mdk - --specs=nosys.specs --specs=nano.specs - ) -target_compile_options(bootloader PUBLIC - -fno-builtin - -fshort-enums - -fstack-usage - -fno-strict-aliasing - -Wall - -Wextra - -Werror - -Wfatal-errors - -Werror-implicit-function-declaration - -Wfloat-equal - -Wundef - -Wshadow - -Wwrite-strings - -Wsign-compare - -Wmissing-format-attribute - -Wno-endif-labels - -Wunreachable-code - # Suppress warning caused by SDK - -Wno-unused-parameter -Wno-expansion-to-defined -Wno-array-bounds - ) -target_compile_definitions(bootloader PUBLIC - SOFTDEVICE_PRESENT - ) - -if (TRACE_ETM STREQUAL "1") - # ENABLE_TRACE will cause system_nrf5x.c to set up ETM trace - target_compile_definitions(bootloader PUBLIC ENABLE_TRACE) -endif () - -if (MCU_VARIANT STREQUAL "nrf52") - # UART transport - target_sources(bootloader PUBLIC - ${SDK_DIR}/libraries/uart/app_uart.c - ${SDK_DIR}/drivers_nrf/uart/nrf_drv_uart.c - ${SDK_DIR}/drivers_nrf/common/nrf_drv_common.c - ) - target_include_directories(bootloader PUBLIC - ${SDK11_DIR}/libraries/util - ${SDK_DIR}/drivers_nrf/common - ${SDK_DIR}/drivers_nrf/uart - ) -else () - # USB transport - target_sources(bootloader PUBLIC - src/boards/${BOARD}/pinconfig.c - src/usb/msc_uf2.c - src/usb/usb.c - src/usb/usb_desc.c - src/usb/uf2/ghostfat.c - # TinyUSB - ${TINYUSB_DIR}/portable/nordic/nrf5x/dcd_nrf5x.c - ${TINYUSB_DIR}/common/tusb_fifo.c - ${TINYUSB_DIR}/device/usbd.c - ${TINYUSB_DIR}/device/usbd_control.c - ${TINYUSB_DIR}/class/cdc/cdc_device.c - ${TINYUSB_DIR}/class/msc/msc_device.c - ${TINYUSB_DIR}/tusb.c - ) -endif () - -#---------------------------------------------------- -# MCU Variant differences -# Supported are: nrf52 (nrf52832), nrf52833, nrf52840 -#---------------------------------------------------- -if (MCU_VARIANT STREQUAL "nrf52") - set(SD_NAME s132) - set(DFU_DEV_REV 0xADAF) - set(DFU_APP_DATA_RESERVED 7*4096) - target_compile_definitions(bootloader PUBLIC - NRF52 - NRF52832_XXAA - S132 - ) -elseif (MCU_VARIANT STREQUAL "nrf52833") - set(SD_NAME s140) - set(DFU_DEV_REV 52833) - set(DFU_APP_DATA_RESERVED 7*4096) - target_compile_definitions(bootloader PUBLIC - NRF52833_XXAA - S140 - ) -elseif (MCU_VARIANT STREQUAL "nrf52840") - set(SD_NAME s140) - set(DFU_DEV_REV 52840) - # App reserved 40KB (8+32) to match circuitpython for 840 - set(DFU_APP_DATA_RESERVED 10*4096) - target_compile_definitions(bootloader PUBLIC - NRF52840_XXAA - S140 - ) -else () - message(FATAL_ERROR "MCU_VARIANT ${MCU_VARIANT} is unknown") -endif () - -set(SD_FILENAME ${SD_NAME}_nrf52_${SD_VERSION}) -set(SD_HEX ${SOFTDEVICE_DIR}/${SD_FILENAME}/${SD_FILENAME}_softdevice.hex) - -target_include_directories(bootloader PUBLIC - ${SOFTDEVICE_DIR}/${SD_FILENAME}/${SD_FILENAME}_API/include - ) - -if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") - target_compile_definitions(bootloader PUBLIC DFU_APP_DATA_RESERVED=${DFU_APP_DATA_RESERVED}) -endif () - -#---------------------------------- -# Get UF2 version from git -#---------------------------------- -execute_process(COMMAND git describe --dirty --always --tags OUTPUT_VARIABLE GIT_VERSION) -string(STRIP ${GIT_VERSION} GIT_VERSION) - -execute_process(COMMAND bash "-c" "git submodule status | cut -d\" \" -f3,4 | paste -s -d\" \" -" - OUTPUT_VARIABLE GIT_SUBMODULE_VERSIONS - ) -string(STRIP ${GIT_SUBMODULE_VERSIONS} GIT_SUBMODULE_VERSIONS) -string(REPLACE ../ "" GIT_SUBMODULE_VERSIONS ${GIT_SUBMODULE_VERSIONS}) -string(REPLACE lib/ "" GIT_SUBMODULE_VERSIONS ${GIT_SUBMODULE_VERSIONS}) - -string(REPLACE "-" ";" RELEASE_VERSION ${GIT_VERSION}) -list(GET RELEASE_VERSION 0 RELEASE_VERSION) -string(REPLACE "." ";" RELEASE_VERSION ${RELEASE_VERSION}) -list(GET RELEASE_VERSION 0 RELEASE_VERSION_MAJOR) -list(GET RELEASE_VERSION 1 RELEASE_VERSION_MINOR) -list(GET RELEASE_VERSION 2 RELEASE_VERSION_PATCH) -math(EXPR MK_BOOTLOADER_VERSION "(${RELEASE_VERSION_MAJOR} << 16) + (${RELEASE_VERSION_MINOR} << 8) + ${RELEASE_VERSION_PATCH}") - -cmake_print_variables(GIT_VERSION GIT_SUBMODULE_VERSIONS MK_BOOTLOADER_VERSION) - -target_compile_definitions(bootloader PUBLIC - UF2_VERSION_BASE="${GIT_VERSION}" - UF2_VERSION="${GIT_VERSION} - ${GIT_SUBMODULE_VERSIONS}" - BLEDIS_FW_VERSION="${GIT_VERSION} ${SD_NAME} ${SD_VERSION}" - MK_BOOTLOADER_VERSION=${MK_BOOTLOADER_VERSION} - ) - -#---------------------------------- -# Post build -#---------------------------------- - -# run size after build -add_custom_command(TARGET bootloader POST_BUILD - COMMAND ${CMAKE_SIZE} $ - ) - -# Add bin/hex output -add_custom_command(TARGET bootloader POST_BUILD - COMMAND ${CMAKE_OBJCOPY} -Obinary $ $/bootloader.bin - COMMAND ${CMAKE_OBJCOPY} -Oihex $ $/bootloader.hex - COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/tools/hexmerge.py --overlap=replace -o $/bootloader_mbr.hex $/bootloader.hex ${MBR_HEX} - COMMAND ${Python_EXECUTABLE} ${UF2CONV_PY} -f ${UF2_FAMILY_ID_BOOTLOADER} -c -o $/bootloader_mbr.uf2 $/bootloader_mbr.hex - VERBATIM) - -#---------------------------------- -# Flashing target -#---------------------------------- - -if (NOT DEFINED NRFJPROG) - set(NRFJPROG nrfjprog) -endif() - -add_custom_target(flash-jlink - DEPENDS bootloader - COMMAND ${NRFJPROG} --program $ --verify --sectoranduicrerase -f nrf52 --reset - ) - -add_custom_target(flash-uf2 - DEPENDS bootloader - COMMAND ${Python_EXECUTABLE} ${UF2CONV_PY} -f ${UF2_FAMILY_ID_BOOTLOADER} --deploy $/bootloader_mbr.uf2 - ) - -add_custom_target(flash-sd - COMMAND ${NRFJPROG} --program ${SD_HEX} --verify --sectorerase -f nrf52 --reset - ) - -add_custom_target(flash-mbr - COMMAND ${NRFJPROG} --program ${MBR_HEX} --verify --sectorerase -f nrf52 --reset - ) - -add_custom_target(flash-erase - COMMAND ${NRFJPROG} -f nrf52 --eraseall - ) \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 723d15aae..c029c91b6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,9 +7,8 @@ recover — so a few things here are stricter than a typical repo. ## Before you start - **Read [`AGENTS.md`](./AGENTS.md) first.** It covers the board abstraction, - the build system split (`make` vs. the incomplete `CMakeLists.txt`), the - vendored submodules, and a list of known gotchas. This file covers - process; that one covers the code. + the build, the vendored submodules, and a list of known gotchas. This file + covers process; that one covers the code. - **New board support needs real hardware.** `UF2_BOARD_ID`, VID/PID, and pin definitions cannot be guessed from a datasheet alone — see [Adding a new board](#adding-a-new-board) below. @@ -40,10 +39,6 @@ Board names are the directory names under `src/boards/`. `tools/build_all.py` builds every board and prints a pass/fail + size table — run it before opening a PR; it's the same check CI's board matrix does per-PR, just local. -**Use `make`, not `cmake`.** `CMakeLists.txt` only has a `board.cmake` for 5 -of the 19 boards; `cmake -DBOARD=` fails outright. Nobody -uses the CMake path in practice. - There is no lint or test suite — for a bootloader, "does it compile for every board" (CI's job) and real hardware testing are the correctness signals that exist. diff --git a/src/boards/heltec_t096/board.cmake b/src/boards/heltec_t096/board.cmake deleted file mode 100644 index 25daf71d0..000000000 --- a/src/boards/heltec_t096/board.cmake +++ /dev/null @@ -1 +0,0 @@ -set(MCU_VARIANT nrf52840) diff --git a/src/boards/heltec_t1/board.cmake b/src/boards/heltec_t1/board.cmake deleted file mode 100644 index 25daf71d0..000000000 --- a/src/boards/heltec_t1/board.cmake +++ /dev/null @@ -1 +0,0 @@ -set(MCU_VARIANT nrf52840) diff --git a/src/boards/heltec_t114/board.cmake b/src/boards/heltec_t114/board.cmake deleted file mode 100644 index 25daf71d0..000000000 --- a/src/boards/heltec_t114/board.cmake +++ /dev/null @@ -1 +0,0 @@ -set(MCU_VARIANT nrf52840) diff --git a/src/boards/mesh_tracker_x1/board.cmake b/src/boards/mesh_tracker_x1/board.cmake deleted file mode 100644 index 25daf71d0..000000000 --- a/src/boards/mesh_tracker_x1/board.cmake +++ /dev/null @@ -1 +0,0 @@ -set(MCU_VARIANT nrf52840) diff --git a/src/boards/thinknode_m1/board.cmake b/src/boards/thinknode_m1/board.cmake deleted file mode 100644 index 25daf71d0..000000000 --- a/src/boards/thinknode_m1/board.cmake +++ /dev/null @@ -1 +0,0 @@ -set(MCU_VARIANT nrf52840) From 58179be1bf66f31fdc8652fd17af5db494584d9d Mon Sep 17 00:00:00 2001 From: James Rich <2199651+jamesarich@users.noreply.github.com> Date: Sun, 25 Oct 2026 12:40:18 -0500 Subject: [PATCH 4/5] docs: describe how the Makefile picks up board files --- AGENTS.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 504434ceb..a1bffe1f3 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -70,9 +70,12 @@ Each board directory can carry: `CFLAGS` like the BLE `DEVICE_NAME`). - `pinconfig.c` — present on some boards, board-specific pin table. -The `Makefile` dynamically discovers the board's files under -`src/boards/$(BOARD)/` — there is no separate hardcoded board list to keep in -sync (unlike the CI matrix, see below). +The `Makefile` takes the board from `BOARD`: it includes +`src/boards/$(BOARD)/board.mk`, puts `src/boards/$(BOARD)` on the include path +for `board.h`, and compiles `pinconfig.c` on every MCU but the nRF52832. Other sources are +listed explicitly, so a new file in a board directory is not compiled until the +`Makefile` names it. There is no separate board list to keep in sync (unlike +the CI matrix, see below). ### Core bootloader (`src/`) From e529cfd7eab7e9938b76dd35d0831ff9e10d8583 Mon Sep 17 00:00:00 2001 From: James Rich <2199651+jamesarich@users.noreply.github.com> Date: Sun, 25 Oct 2026 15:43:39 -0500 Subject: [PATCH 5/5] chore: remove the cmake helpers and correct the board-list note --- AGENTS.md | 4 +-- cmake/cpu/cortex-m33.cmake | 19 -------------- cmake/cpu/cortex-m4.cmake | 23 ----------------- cmake/toolchain/arm_gcc.cmake | 46 --------------------------------- cmake/toolchain/set_flags.cmake | 17 ------------ 5 files changed, 2 insertions(+), 107 deletions(-) delete mode 100644 cmake/cpu/cortex-m33.cmake delete mode 100644 cmake/cpu/cortex-m4.cmake delete mode 100644 cmake/toolchain/arm_gcc.cmake delete mode 100644 cmake/toolchain/set_flags.cmake diff --git a/AGENTS.md b/AGENTS.md index a1bffe1f3..49f985a3e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -74,8 +74,8 @@ The `Makefile` takes the board from `BOARD`: it includes `src/boards/$(BOARD)/board.mk`, puts `src/boards/$(BOARD)` on the include path for `board.h`, and compiles `pinconfig.c` on every MCU but the nRF52832. Other sources are listed explicitly, so a new file in a board directory is not compiled until the -`Makefile` names it. There is no separate board list to keep in sync (unlike -the CI matrix, see below). +`Makefile` names it. There is no separate board list to keep in sync here; +the one hand-kept list is branch protection's required checks (see CI below). ### Core bootloader (`src/`) diff --git a/cmake/cpu/cortex-m33.cmake b/cmake/cpu/cortex-m33.cmake deleted file mode 100644 index a028cd412..000000000 --- a/cmake/cpu/cortex-m33.cmake +++ /dev/null @@ -1,19 +0,0 @@ -if (TOOLCHAIN STREQUAL "gcc") - set(TOOLCHAIN_COMMON_FLAGS - -mthumb - -mcpu=cortex-m33 - -mfloat-abi=hard - -mfpu=fpv5-sp-d16 - ) - - set(FREERTOS_PORT GCC_ARM_CM33_NTZ_NONSECURE CACHE INTERNAL "") - -elseif (TOOLCHAIN STREQUAL "iar") - set(TOOLCHAIN_COMMON_FLAGS - --cpu cortex-m33 - --fpu VFPv5-SP - ) - - set(FREERTOS_PORT IAR_ARM_CM4F CACHE INTERNAL "") - -endif () diff --git a/cmake/cpu/cortex-m4.cmake b/cmake/cpu/cortex-m4.cmake deleted file mode 100644 index 79f97e24a..000000000 --- a/cmake/cpu/cortex-m4.cmake +++ /dev/null @@ -1,23 +0,0 @@ -if (TOOLCHAIN STREQUAL "gcc") - set(TOOLCHAIN_COMMON_FLAGS - -mthumb - -mcpu=cortex-m4 - -mfloat-abi=hard - -mfpu=fpv4-sp-d16 - ) - - if (NOT DEFINED FREERTOS_PORT) - set(FREERTOS_PORT GCC_ARM_CM4F CACHE INTERNAL "") - endif () - -elseif (TOOLCHAIN STREQUAL "iar") - set(TOOLCHAIN_COMMON_FLAGS - --cpu cortex-m4 - --fpu VFPv4 - ) - - if (NOT DEFINED FREERTOS_PORT) - set(FREERTOS_PORT IAR_ARM_CM4F CACHE INTERNAL "") - endif () - -endif () diff --git a/cmake/toolchain/arm_gcc.cmake b/cmake/toolchain/arm_gcc.cmake deleted file mode 100644 index 5203d1e4d..000000000 --- a/cmake/toolchain/arm_gcc.cmake +++ /dev/null @@ -1,46 +0,0 @@ -set(CMAKE_SYSTEM_NAME Generic) - -set(CMAKE_C_COMPILER "arm-none-eabi-gcc") -set(CMAKE_CXX_COMPILER "arm-none-eabi-g++") -set(CMAKE_ASM_COMPILER "arm-none-eabi-gcc") - -set(CMAKE_SIZE "arm-none-eabi-size" CACHE FILEPATH "") -set(CMAKE_OBJCOPY "arm-none-eabi-objcopy" CACHE FILEPATH "") -set(CMAKE_OBJDUMP "arm-none-eabi-objdump" CACHE FILEPATH "") - -set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE) - -# Look for includes and libraries only in the target system prefix. -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) - -# pass TOOLCHAIN_CPU to -set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_SYSTEM_PROCESSOR) - -include(${CMAKE_CURRENT_LIST_DIR}/../cpu/${CMAKE_SYSTEM_PROCESSOR}.cmake) - -# enable all possible warnings for building examples -list(APPEND TOOLCHAIN_COMMON_FLAGS - -fdata-sections - -ffunction-sections - -fsingle-precision-constant - -fno-strict-aliasing - ) - -set(TOOLCHAIN_EXE_LINKER_FLAGS - -Wl,--print-memory-usage - -Wl,--gc-sections - #-Wl,--cref - ) - -include(${CMAKE_CURRENT_LIST_DIR}/set_flags.cmake) - -# try_compile is cmake test compiling its own example, -# pass -nostdlib to skip stdlib linking -get_property(IS_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE) -if (IS_IN_TRY_COMPILE) - set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -nostdlib") - set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -nostdlib") -endif () diff --git a/cmake/toolchain/set_flags.cmake b/cmake/toolchain/set_flags.cmake deleted file mode 100644 index bbbd21125..000000000 --- a/cmake/toolchain/set_flags.cmake +++ /dev/null @@ -1,17 +0,0 @@ -include(CMakePrintHelpers) - -# join the toolchain flags into a single string -list(JOIN TOOLCHAIN_COMMON_FLAGS " " TOOLCHAIN_COMMON_FLAGS) - -foreach (LANG IN ITEMS C CXX ASM) - set(CMAKE_${LANG}_FLAGS_INIT ${TOOLCHAIN_COMMON_FLAGS}) - - #cmake_print_variables(CMAKE_${LANG}_FLAGS_INIT) - - # optimization flags for LOG, LOGGER ? - #set(CMAKE_${LANG}_FLAGS_RELEASE_INIT "-Os") - #set(CMAKE_${LANG}_FLAGS_DEBUG_INIT "-O0") -endforeach () - -# Linker -list(JOIN TOOLCHAIN_EXE_LINKER_FLAGS " " CMAKE_EXE_LINKER_FLAGS_INIT)