diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 65233633..6953d761 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -3,8 +3,10 @@ *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.* diff --git a/.github/workflows/githubci.yml b/.github/workflows/githubci.yml index 68b4f7f2..658cff5d 100644 --- a/.github/workflows/githubci.yml +++ b/.github/workflows/githubci.yml @@ -33,6 +33,11 @@ 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: diff --git a/CMakeLists.txt b/CMakeLists.txt index 567a815a..c0ae6f21 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_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(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(UF2CONV_PY ${CMAKE_CURRENT_LIST_DIR}/lib/uf2/utils/uf2conv.py) set(UF2_FAMILY_ID_BOOTLOADER 0xd663823c) @@ -42,14 +42,10 @@ 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() + set(SD_VERSION 6.1.1) endif () -set(MBR_HEX ${SOFTDEVICE_DIR}/mbr/hex/mbr_nrf52_2.4.1_mbr.hex) +set(MBR_HEX ${SOFTDEVICE}/mbr/hex/mbr_nrf52_2.4.1_mbr.hex) target_sources(bootloader PUBLIC # src @@ -61,31 +57,31 @@ target_sources(bootloader PUBLIC 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 + ${NRFX}/drivers/src/nrfx_power.c + ${NRFX}/drivers/src/nrfx_nvmc.c + ${NRFX}/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 + ${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 # 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 + ${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 # ASM - ${NRFX_DIR}/mdk/gcc_startup_${MCU_VARIANT}.S + ${NRFX}/mdk/gcc_startup_${MCU_VARIANT}.S ) target_include_directories(bootloader PUBLIC src @@ -93,31 +89,31 @@ target_include_directories(bootloader PUBLIC src/boards/${BOARD} src/cmsis/include src/usb - ${TINYUSB_DIR} + ${TUSB} # nrfx - ${NRFX_DIR} - ${NRFX_DIR}/mdk - ${NRFX_DIR}/hal - ${NRFX_DIR}/drivers/include - ${NRFX_DIR}/drivers/src + ${NRFX} + ${NRFX}/mdk + ${NRFX}/hal + ${NRFX}/drivers/include + ${NRFX}/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 + ${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 # 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 + ${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 # Softdevice - ${SOFTDEVICE_DIR}/mbr/headers + ${SOFTDEVICE}/mbr/headers ) # Debug option @@ -149,7 +145,7 @@ endif () target_link_options(bootloader PUBLIC "LINKER:--script=${LD_FILE}" - -L${NRFX_DIR}/mdk + -L${NRFX}/mdk --specs=nosys.specs --specs=nano.specs ) target_compile_options(bootloader PUBLIC @@ -185,14 +181,14 @@ 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 + ${SDK}/libraries/uart/app_uart.c + ${SDK}/drivers_nrf/uart/nrf_drv_uart.c + ${SDK}/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 + ${SDK11}/libraries/util + ${SDK}/drivers_nrf/common + ${SDK}/drivers_nrf/uart ) else () # USB transport @@ -203,13 +199,13 @@ else () 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 + ${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 ) endif () @@ -226,6 +222,10 @@ 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,6 +234,10 @@ 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) @@ -243,16 +247,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_DIR}/${SD_FILENAME}/${SD_FILENAME}_softdevice.hex) - -target_include_directories(bootloader PUBLIC - ${SOFTDEVICE_DIR}/${SD_FILENAME}/${SD_FILENAME}_API/include - ) +set(SD_HEX ${SOFTDEVICE}/${SD_FILENAME}/${SD_FILENAME}_softdevice.hex) 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 497831d3..2f1ad996 100644 --- a/Makefile +++ b/Makefile @@ -10,9 +10,6 @@ # 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 @@ -21,11 +18,7 @@ SD_PATH = lib/softdevice/$(SD_FILENAME) # SD_VERSION can be overwritten by board.mk ifndef SD_VERSION - ifeq ($(MCU_SUB_VARIANT),nrf52833) - SD_VERSION = 7.3.0 - else - SD_VERSION = 6.1.1 - endif +SD_VERSION = 6.1.1 endif SD_FILENAME = $(SD_NAME)_nrf52_$(SD_VERSION) @@ -96,10 +89,25 @@ 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/particle_argon/board.h b/src/boards/particle_argon/board.h index 1f31d931..3f7078a6 100644 --- a/src/boards/particle_argon/board.h +++ b/src/boards/particle_argon/board.h @@ -57,10 +57,10 @@ // USB //--------------------------------------------------------------------+ -// Shared VID/PID with pca10056 +// Shared VID/PID with Feather nRF52840, will be disabled for building in the future #define USB_DESC_VID 0x239A -#define USB_DESC_UF2_PID 0x00DA -#define USB_DESC_CDC_ONLY_PID 0x00DA +#define USB_DESC_UF2_PID 0x0029 +#define USB_DESC_CDC_ONLY_PID 0x0029 #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 ee5236af..6db75bef 100644 --- a/src/boards/particle_boron/board.h +++ b/src/boards/particle_boron/board.h @@ -57,10 +57,10 @@ // USB //--------------------------------------------------------------------+ -// Shared VID/PID with pca10056 +// Shared VID/PID with Feather nRF52840, will be disabled for building in the future #define USB_DESC_VID 0x239A -#define USB_DESC_UF2_PID 0x00DA -#define USB_DESC_CDC_ONLY_PID 0x00DA +#define USB_DESC_UF2_PID 0x0029 +#define USB_DESC_CDC_ONLY_PID 0x0029 #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 3c778281..ac2c9a77 100644 --- a/src/boards/particle_xenon/board.h +++ b/src/boards/particle_xenon/board.h @@ -57,10 +57,10 @@ // USB //--------------------------------------------------------------------+ -// Shared VID/PID with pca10056 +// Shared VID/PID with Feather nRF52840, will be disabled for building in the future #define USB_DESC_VID 0x239A -#define USB_DESC_UF2_PID 0x00DA -#define USB_DESC_CDC_ONLY_PID 0x00DA +#define USB_DESC_UF2_PID 0x0029 +#define USB_DESC_CDC_ONLY_PID 0x0029 #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 51dc2fb2..92ce3462 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 0x00DA -#define USB_DESC_CDC_ONLY_PID 0x00DA +#define USB_DESC_UF2_PID 0x0029 +#define USB_DESC_CDC_ONLY_PID 0x0029 #define UF2_PRODUCT_NAME "Nordic nRF52840 DK" #define UF2_BOARD_ID "nRF52840-pca10056-v1" diff --git a/src/boards/pca10100/board.cmake b/src/boards/pca10100/board.cmake deleted file mode 100644 index cb4f2f9e..00000000 --- a/src/boards/pca10100/board.cmake +++ /dev/null @@ -1 +0,0 @@ -set(MCU_VARIANT nrf52833) diff --git a/src/boards/pca10100/board.h b/src/boards/pca10100/board.h index e96b11c8..743f1758 100644 --- a/src/boards/pca10100/board.h +++ b/src/boards/pca10100/board.h @@ -50,12 +50,11 @@ //--------------------------------------------------------------------+ // USB //--------------------------------------------------------------------+ -#define USB_DESC_VID 0x239A -#define USB_DESC_UF2_PID 0x00D8 -#define USB_DESC_CDC_ONLY_PID 0x00D8 +#define USB_DESC_VID 0x1915 +#define USB_DESC_UF2_PID 0x521F +#define USB_DESC_CDC_ONLY_PID 0x521F #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" diff --git a/src/boards/pca10100/board.mk b/src/boards/pca10100/board.mk index a979f7e5..d76b2b71 100644 --- a/src/boards/pca10100/board.mk +++ b/src/boards/pca10100/board.mk @@ -1 +1,2 @@ -MCU_SUB_VARIANT = nrf52833 \ No newline at end of file +MCU_SUB_VARIANT = nrf52833 +SD_VERSION=7.2.0 \ No newline at end of file