From 2d68ec56e3de2c692c6c02de1921d04d14ba6c93 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 5 Jun 2024 17:29:26 +0700 Subject: [PATCH 1/4] default SD version to 7.3.0 for 833, 6.1.1 for 840 and 832 some cmake rename --- .github/workflows/githubci.yml | 7 +- CMakeLists.txt | 150 ++++++++++++++++---------------- Makefile | 24 ++--- src/boards/pca10100/board.cmake | 1 + src/boards/pca10100/board.mk | 3 +- 5 files changed, 84 insertions(+), 101 deletions(-) create mode 100644 src/boards/pca10100/board.cmake diff --git a/.github/workflows/githubci.yml b/.github/workflows/githubci.yml index 658cff5d..103ecaa9 100644 --- a/.github/workflows/githubci.yml +++ b/.github/workflows/githubci.yml @@ -33,15 +33,10 @@ jobs: matrix: board: ${{ fromJSON(needs.set-matrix.outputs.matrix) }} steps: - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: '3.x' - - name: Checkout Code uses: actions/checkout@v4 with: - fetch-depth: 0 + fetch-tags: true submodules: true - name: Install ARM GCC diff --git a/CMakeLists.txt b/CMakeLists.txt index c0ae6f21..567a815a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,11 +25,11 @@ set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/cmake/toolchain/arm_${TOOLCHA project(Adafruit_nRF52_Bootloader C ASM) -set(NRFX ${CMAKE_CURRENT_LIST_DIR}/lib/nrfx) -set(SDK11 ${CMAKE_CURRENT_LIST_DIR}/lib/sdk11/components) -set(SDK ${CMAKE_CURRENT_LIST_DIR}/lib/sdk/components) -set(SOFTDEVICE ${CMAKE_CURRENT_LIST_DIR}/lib/softdevice) -set(TUSB ${CMAKE_CURRENT_LIST_DIR}/lib/tinyusb/src) +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) @@ -42,10 +42,14 @@ add_executable(bootloader) # SD_VERSION can be overwritten by board.cmake if(NOT DEFINED SD_VERSION) - set(SD_VERSION 6.1.1) + if(MCU_VARIANT STREQUAL "nrf52833") + set(SD_VERSION 7.3.0) + else() + set(SD_VERSION 6.1.1) + endif() endif () -set(MBR_HEX ${SOFTDEVICE}/mbr/hex/mbr_nrf52_2.4.1_mbr.hex) +set(MBR_HEX ${SOFTDEVICE_DIR}/mbr/hex/mbr_nrf52_2.4.1_mbr.hex) target_sources(bootloader PUBLIC # src @@ -57,31 +61,31 @@ target_sources(bootloader PUBLIC src/images.c src/boards/boards.c # nrfx - ${NRFX}/drivers/src/nrfx_power.c - ${NRFX}/drivers/src/nrfx_nvmc.c - ${NRFX}/mdk/system_${MCU_VARIANT}.c + ${NRFX_DIR}/drivers/src/nrfx_power.c + ${NRFX_DIR}/drivers/src/nrfx_nvmc.c + ${NRFX_DIR}/mdk/system_${MCU_VARIANT}.c # sdk 11 - ${SDK11}/libraries/bootloader_dfu/bootloader.c - ${SDK11}/libraries/bootloader_dfu/bootloader_settings.c - ${SDK11}/libraries/bootloader_dfu/bootloader_util.c - ${SDK11}/libraries/bootloader_dfu/dfu_transport_serial.c - ${SDK11}/libraries/bootloader_dfu/dfu_transport_ble.c - ${SDK11}/libraries/bootloader_dfu/dfu_single_bank.c - ${SDK11}/ble/ble_services/ble_dfu/ble_dfu.c - ${SDK11}/ble/ble_services/ble_dis/ble_dis.c - ${SDK11}/drivers_nrf/pstorage/pstorage_raw.c + ${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}/libraries/timer/app_timer.c - ${SDK}/libraries/scheduler/app_scheduler.c - ${SDK}/libraries/util/app_error.c - ${SDK}/libraries/util/app_util_platform.c - ${SDK}/libraries/crc16/crc16.c - ${SDK}/libraries/hci/hci_mem_pool.c - ${SDK}/libraries/hci/hci_slip.c - ${SDK}/libraries/hci/hci_transport.c - ${SDK}/libraries/util/nrf_assert.c + ${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}/mdk/gcc_startup_${MCU_VARIANT}.S + ${NRFX_DIR}/mdk/gcc_startup_${MCU_VARIANT}.S ) target_include_directories(bootloader PUBLIC src @@ -89,31 +93,31 @@ target_include_directories(bootloader PUBLIC src/boards/${BOARD} src/cmsis/include src/usb - ${TUSB} + ${TINYUSB_DIR} # nrfx - ${NRFX} - ${NRFX}/mdk - ${NRFX}/hal - ${NRFX}/drivers/include - ${NRFX}/drivers/src + ${NRFX_DIR} + ${NRFX_DIR}/mdk + ${NRFX_DIR}/hal + ${NRFX_DIR}/drivers/include + ${NRFX_DIR}/drivers/src # sdk 11 for cdc/ble dfu - ${SDK11}/libraries/bootloader_dfu - ${SDK11}/libraries/bootloader_dfu/hci_transport - ${SDK11}/drivers_nrf/pstorage - ${SDK11}/ble/common - ${SDK11}/ble/ble_services/ble_dfu - ${SDK11}/ble/ble_services/ble_dis + ${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}/libraries/timer - ${SDK}/libraries/scheduler - ${SDK}/libraries/crc16 - ${SDK}/libraries/util - ${SDK}/libraries/hci/config - ${SDK}/libraries/hci - ${SDK}/libraries/uart - ${SDK}/drivers_nrf/delay + ${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}/mbr/headers + ${SOFTDEVICE_DIR}/mbr/headers ) # Debug option @@ -145,7 +149,7 @@ endif () target_link_options(bootloader PUBLIC "LINKER:--script=${LD_FILE}" - -L${NRFX}/mdk + -L${NRFX_DIR}/mdk --specs=nosys.specs --specs=nano.specs ) target_compile_options(bootloader PUBLIC @@ -181,14 +185,14 @@ endif () if (MCU_VARIANT STREQUAL "nrf52") # UART transport target_sources(bootloader PUBLIC - ${SDK}/libraries/uart/app_uart.c - ${SDK}/drivers_nrf/uart/nrf_drv_uart.c - ${SDK}/drivers_nrf/common/nrf_drv_common.c + ${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}/libraries/util - ${SDK}/drivers_nrf/common - ${SDK}/drivers_nrf/uart + ${SDK11_DIR}/libraries/util + ${SDK_DIR}/drivers_nrf/common + ${SDK_DIR}/drivers_nrf/uart ) else () # USB transport @@ -199,13 +203,13 @@ else () src/usb/usb_desc.c src/usb/uf2/ghostfat.c # TinyUSB - ${TUSB}/portable/nordic/nrf5x/dcd_nrf5x.c - ${TUSB}/common/tusb_fifo.c - ${TUSB}/device/usbd.c - ${TUSB}/device/usbd_control.c - ${TUSB}/class/cdc/cdc_device.c - ${TUSB}/class/msc/msc_device.c - ${TUSB}/tusb.c + ${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 () @@ -222,10 +226,6 @@ if (MCU_VARIANT STREQUAL "nrf52") NRF52832_XXAA S132 ) - target_include_directories(bootloader PUBLIC - ${SOFTDEVICE}/s132_nrf52_6.1.1/s132_nrf52_6.1.1_API/include - ) - elseif (MCU_VARIANT STREQUAL "nrf52833") set(SD_NAME s140) set(DFU_DEV_REV 52833) @@ -234,10 +234,6 @@ elseif (MCU_VARIANT STREQUAL "nrf52833") NRF52833_XXAA S140 ) - target_include_directories(bootloader PUBLIC - ${SOFTDEVICE}/s140_nrf52_6.1.1/s140_nrf52_6.1.1_API/include - ) - elseif (MCU_VARIANT STREQUAL "nrf52840") set(SD_NAME s140) set(DFU_DEV_REV 52840) @@ -247,16 +243,16 @@ elseif (MCU_VARIANT STREQUAL "nrf52840") NRF52840_XXAA S140 ) - target_include_directories(bootloader PUBLIC - ${SOFTDEVICE}/s140_nrf52_6.1.1/s140_nrf52_6.1.1_API/include - ) - else () message(FATAL_ERROR "MCU_VARIANT ${MCU_VARIANT} is unknown") endif () set(SD_FILENAME ${SD_NAME}_nrf52_${SD_VERSION}) -set(SD_HEX ${SOFTDEVICE}/${SD_FILENAME}/${SD_FILENAME}_softdevice.hex) +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}) diff --git a/Makefile b/Makefile index 2f1ad996..497831d3 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,9 @@ # local customization -include Makefile.user +# Board specific +-include src/boards/$(BOARD)/board.mk + SDK_PATH = lib/sdk/components SDK11_PATH = lib/sdk11/components TUSB_PATH = lib/tinyusb/src @@ -18,7 +21,11 @@ SD_PATH = lib/softdevice/$(SD_FILENAME) # SD_VERSION can be overwritten by board.mk ifndef SD_VERSION -SD_VERSION = 6.1.1 + ifeq ($(MCU_SUB_VARIANT),nrf52833) + SD_VERSION = 7.3.0 + else + SD_VERSION = 6.1.1 + endif endif SD_FILENAME = $(SD_NAME)_nrf52_$(SD_VERSION) @@ -89,25 +96,10 @@ endif BMP_PORT ?= $(shell ls -1 /dev/cu.usbmodem????????1 | head -1) GDB_BMP = $(GDB) -ex 'target extended-remote $(BMP_PORT)' -ex 'monitor swdp_scan' -ex 'attach 1' -#--------------------------------- -# Select the board to build -#--------------------------------- -# Note: whitespace is not allowed in the filenames... it WILL break this part of the script -BOARD_LIST = $(sort $(filter-out boards.h boards.c,$(notdir $(wildcard src/boards/*)))) - -ifeq ($(filter $(BOARD),$(BOARD_LIST)),) - $(info You must provide a BOARD parameter with 'BOARD='. Supported boards are:) - $(foreach b,$(BOARD_LIST),$(info - $(b))) - $(error Invalid BOARD specified) -endif - # Build directory BUILD = _build/build-$(BOARD) BIN = _bin/$(BOARD) -# Board specific --include src/boards/$(BOARD)/board.mk - # MCU_SUB_VARIANT can be nrf52 (nrf52832), nrf52833, nrf52840 ifeq ($(MCU_SUB_VARIANT),nrf52) SD_NAME = s132 diff --git a/src/boards/pca10100/board.cmake b/src/boards/pca10100/board.cmake new file mode 100644 index 00000000..cb4f2f9e --- /dev/null +++ b/src/boards/pca10100/board.cmake @@ -0,0 +1 @@ +set(MCU_VARIANT nrf52833) diff --git a/src/boards/pca10100/board.mk b/src/boards/pca10100/board.mk index d76b2b71..a979f7e5 100644 --- a/src/boards/pca10100/board.mk +++ b/src/boards/pca10100/board.mk @@ -1,2 +1 @@ -MCU_SUB_VARIANT = nrf52833 -SD_VERSION=7.2.0 \ No newline at end of file +MCU_SUB_VARIANT = nrf52833 \ No newline at end of file From 438a08e0ac7ae62fa6d77954f2eec78d6ef47a8b Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 5 Jun 2024 17:30:27 +0700 Subject: [PATCH 2/4] change PID of argon,boron,xenon, pca10056 to 0x00DA (allocated by Adafruit), previously these shared with feather nrf52840 change PID of pca10100 to 0x00D8 (allocated by Adafruit) --- src/boards/particle_argon/board.h | 6 +++--- src/boards/particle_boron/board.h | 6 +++--- src/boards/particle_xenon/board.h | 6 +++--- src/boards/pca10056/board.h | 4 ++-- src/boards/pca10100/board.h | 7 ++++--- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/boards/particle_argon/board.h b/src/boards/particle_argon/board.h index 3f7078a6..1f31d931 100644 --- a/src/boards/particle_argon/board.h +++ b/src/boards/particle_argon/board.h @@ -57,10 +57,10 @@ // USB //--------------------------------------------------------------------+ -// Shared VID/PID with Feather nRF52840, will be disabled for building in the future +// Shared VID/PID with pca10056 #define USB_DESC_VID 0x239A -#define USB_DESC_UF2_PID 0x0029 -#define USB_DESC_CDC_ONLY_PID 0x0029 +#define USB_DESC_UF2_PID 0x00DA +#define USB_DESC_CDC_ONLY_PID 0x00DA #define UF2_PRODUCT_NAME "Particle Argon" #define UF2_VOLUME_LABEL "ARGONBOOT " diff --git a/src/boards/particle_boron/board.h b/src/boards/particle_boron/board.h index 6db75bef..ee5236af 100644 --- a/src/boards/particle_boron/board.h +++ b/src/boards/particle_boron/board.h @@ -57,10 +57,10 @@ // USB //--------------------------------------------------------------------+ -// Shared VID/PID with Feather nRF52840, will be disabled for building in the future +// Shared VID/PID with pca10056 #define USB_DESC_VID 0x239A -#define USB_DESC_UF2_PID 0x0029 -#define USB_DESC_CDC_ONLY_PID 0x0029 +#define USB_DESC_UF2_PID 0x00DA +#define USB_DESC_CDC_ONLY_PID 0x00DA #define UF2_PRODUCT_NAME "Particle Boron" #define UF2_VOLUME_LABEL "BORONBOOT " diff --git a/src/boards/particle_xenon/board.h b/src/boards/particle_xenon/board.h index ac2c9a77..3c778281 100644 --- a/src/boards/particle_xenon/board.h +++ b/src/boards/particle_xenon/board.h @@ -57,10 +57,10 @@ // USB //--------------------------------------------------------------------+ -// Shared VID/PID with Feather nRF52840, will be disabled for building in the future +// Shared VID/PID with pca10056 #define USB_DESC_VID 0x239A -#define USB_DESC_UF2_PID 0x0029 -#define USB_DESC_CDC_ONLY_PID 0x0029 +#define USB_DESC_UF2_PID 0x00DA +#define USB_DESC_CDC_ONLY_PID 0x00DA #define UF2_PRODUCT_NAME "Particle Xenon" #define UF2_VOLUME_LABEL "XENONBOOT " diff --git a/src/boards/pca10056/board.h b/src/boards/pca10056/board.h index 92ce3462..51dc2fb2 100644 --- a/src/boards/pca10056/board.h +++ b/src/boards/pca10056/board.h @@ -53,8 +53,8 @@ // Shared VID/PID with Feather nRF52840, will be disabled for building in the future #define USB_DESC_VID 0x239A -#define USB_DESC_UF2_PID 0x0029 -#define USB_DESC_CDC_ONLY_PID 0x0029 +#define USB_DESC_UF2_PID 0x00DA +#define USB_DESC_CDC_ONLY_PID 0x00DA #define UF2_PRODUCT_NAME "Nordic nRF52840 DK" #define UF2_BOARD_ID "nRF52840-pca10056-v1" diff --git a/src/boards/pca10100/board.h b/src/boards/pca10100/board.h index 743f1758..e96b11c8 100644 --- a/src/boards/pca10100/board.h +++ b/src/boards/pca10100/board.h @@ -50,11 +50,12 @@ //--------------------------------------------------------------------+ // USB //--------------------------------------------------------------------+ -#define USB_DESC_VID 0x1915 -#define USB_DESC_UF2_PID 0x521F -#define USB_DESC_CDC_ONLY_PID 0x521F +#define USB_DESC_VID 0x239A +#define USB_DESC_UF2_PID 0x00D8 +#define USB_DESC_CDC_ONLY_PID 0x00D8 #define UF2_PRODUCT_NAME "Nordic nRF52833 DK" +#define UF2_VOLUME_LABEL "NRF833BOOT" #define UF2_BOARD_ID "nRF52833-pca10100-v1" #define UF2_INDEX_URL "https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52833-DK" From c5150ccf02335fc19a0f36f3230a27acd88a1907 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 5 Jun 2024 17:32:51 +0700 Subject: [PATCH 3/4] update PR template --- .github/PULL_REQUEST_TEMPLATE.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 6953d761..65233633 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -3,10 +3,8 @@ *By completing this PR sufficiently, you help us to review this Pull Request quicker and also help improve the quality of Release Notes* - [ ] Please provide specific title of the PR describing the change -- [ ] Please provide related links (*eg. Issue which will be closed by this Pull Request*) - [ ] If you are adding an new boards, please make sure - [ ] Provide link to your allocated VID/PID if applicable - - [ ] Add your board to [action ci](/.github/workflows) in correct workflow and alphabet order for release binary - [ ] `UF2_BOARD_ID` in your board.h follow correct format from [uf2 specs](https://github.com/microsoft/uf2#files-exposed-by-bootloaders) *This checklist items that are not applicable to your PR can be deleted.* From 5f99d530ff2e471c9000a358871ddb97ae357019 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 5 Jun 2024 17:34:56 +0700 Subject: [PATCH 4/4] revert fetch-depth 0 --- .github/workflows/githubci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/githubci.yml b/.github/workflows/githubci.yml index 103ecaa9..68b4f7f2 100644 --- a/.github/workflows/githubci.yml +++ b/.github/workflows/githubci.yml @@ -36,7 +36,7 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 with: - fetch-tags: true + fetch-depth: 0 submodules: true - name: Install ARM GCC