Compare commits

..
32 Commits
Author SHA1 Message Date
Ha Thach 7210c3914d Merge pull request #309 from markbirss/master
Adds support for the Makerdiary nRF52840 Connect Kit board
2023-08-01 20:51:33 +07:00
Mark Trevor Birss 8b8c9d58be Update board.h 2023-08-01 15:44:15 +02:00
Mark Trevor Birss 39da39544b Update githubci.yml 2023-07-21 12:58:07 +02:00
Mark Trevor Birss 386ed04058 Update githubci.yml add Makerdiary nrf52840 connectkit 2023-07-21 10:37:04 +02:00
Mark Trevor Birss c87ea51b86 Update board.h
changes requested to board-id
2023-07-20 17:28:03 +02:00
Ha Thach 9924e54654 Merge pull request #310 from adafruit/add-cmake
Add cmake build for nrf52840
2023-07-20 22:12:12 +07:00
hathach 2de2fbf82f add PR template 2023-07-20 22:06:28 +07:00
hathach dbc7648649 add linker --print-memory-usage 2023-07-20 22:00:29 +07:00
hathach ffa2379818 add cmake support, starting with feather nrf52840 and pca10056. Seems to work well 2023-07-20 21:07:49 +07:00
Mark Trevor Birss aebee3dfd4 Add files via upload 2023-07-20 09:46:00 +02:00
Ha Thach 277a0c83f4 Merge pull request #305 from hyx0329/pr-m60-fix
Fix M60
2023-05-26 14:39:17 +07:00
hyx0329 e34b183f1d Fix support for M60 keyboard
- Change BUTTON_2 to ESC and setup related pins properly
- Always enable the battery
2023-05-25 17:56:05 +08:00
hyx0329 188e25948b Add board_init2 and board_teardown2
This also replace `board_init_extra`.
2023-05-25 17:52:02 +08:00
Ha Thach 80c3a8401b Merge pull request #293 from Montvydas/bugfix-ota-dfu-stuck
Set the default max MTU size within the DFU transport to 23
2023-02-27 14:35:00 +07:00
montea 5f95de1314 Set MTU to 23 within main.c file as per request on the comment above it 2023-02-13 10:46:51 +00:00
montea a980696dd0 Changed the default max MTU size within the DFU transport to 23, which is the required size for the legacy bootloader to perform a successful OTA with the latest Nordic-DFU-Library. 2023-02-12 18:51:21 +00:00
Ha Thach 2107d4e97f Merge pull request #291 from aovestdipaperino/master
Add support for XIAO BLE Sense boards
2023-02-08 09:00:40 +07:00
Paperinik 1bca78c0c8 Update githubci.yml
Added:
-xiao_nrf52840_ble
-xiao_nrf52840_ble_sense
2023-02-05 18:27:02 -08:00
Paperinik d7494e81ce Update board.h 2023-02-05 18:24:19 -08:00
Paperinik aac573642b Update board.h
UF2 board ID updated to specs.
2023-02-05 18:23:35 -08:00
Paperino cf3f39f576 Add support for Xiao BLE boards 2023-01-26 17:37:43 -08:00
Paperino 99ad4d5c0f Add support for xiao ble nrf52840 based boards. 2023-01-26 17:37:18 -08:00
Ha Thach da70d4a6ab Merge pull request #284 from kylemccreery/pillbug
Add new board PillBug
2022-11-18 17:33:10 +07:00
Kyle McCreery 4f908f3330 Initial commit of reformatted pillbug defines 2022-11-09 23:24:49 -05:00
Ha Thach b55f516c11 Merge pull request #281 from adafruit/update-doc
update readme doc
2022-10-16 20:06:08 +07:00
hathach d2977b16c8 update readme doc 2022-10-16 19:24:08 +07:00
Ha Thach 0cb582d10c Merge pull request #280 from adafruit/add-debug-build
Add debug build
2022-10-16 16:24:58 +07:00
Ha Thach 7229caf9d6 Merge branch 'master' into add-debug-build 2022-10-16 13:13:54 +07:00
hathach 3af7f744b4 add temp flash-skip-crc target 2022-10-16 13:09:19 +07:00
Ha Thach de32e8cf0a Merge pull request #273 from whiz00/build-fix
fix 'array subscript 0 is outside array bounds' for newer gcc versions
2022-09-08 17:49:27 +07:00
Gabriel Hansson 5217eb6dbc fix error: array subscript 0 is outside array bounds for newer gcc versions 2022-08-29 18:29:21 +00:00
hathach c42dce080c add debug linker when building with DEBUG=1
extend bootloader start to reserved app for debug build
2022-07-14 12:28:02 +07:00
33 changed files with 1191 additions and 41 deletions

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
## Checklist
*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.*
-----------
## Description of Change
Please describe your proposed Pull Request and it's impact.
+4 -1
View File
@@ -45,6 +45,7 @@ jobs:
- 'mikoto'
- 'nice_nano'
- 'nrf52840_bboard'
- 'nRF52840_connect_kit'
- 'nrf52840_m2'
- 'ohs2020_badge'
- 'particle_argon'
@@ -58,7 +59,9 @@ jobs:
- 'raytac_mdbt50q_rx'
- 'sparkfun_nrf52840_micromod'
- 'waveshare_nrf52840_eval'
- 'xiao_nrf52840_ble'
- 'xiao_nrf52840_ble_sense'
steps:
- name: Setup Python
uses: actions/setup-python@v3
+304
View File
@@ -0,0 +1,304 @@
cmake_minimum_required(VERSION 3.17)
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 ${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)
#-------------------
# Bootloader
#-------------------
set(CMAKE_EXECUTABLE_SUFFIX .elf)
add_executable(bootloader)
#set_target_properties(bootloader PROPERTIES OUTPUT_NAME "${BOARD}_bootloader.elf")
# SD_VERSION can be overwritten by board.cmake
if(NOT DEFINED SD_VERSION)
set(SD_VERSION 6.1.1)
endif ()
set(MBR_HEX ${SOFTDEVICE}/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/boards/boards.c
# nrfx
${NRFX}/drivers/src/nrfx_power.c
${NRFX}/drivers/src/nrfx_nvmc.c
${NRFX}/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
# 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
# ASM
${NRFX}/mdk/gcc_startup_${MCU_VARIANT}.S
)
target_include_directories(bootloader PUBLIC
src
src/boards
src/boards/${BOARD}
src/cmsis/include
src/usb
${TUSB}
# nrfx
${NRFX}
${NRFX}/mdk
${NRFX}/hal
${NRFX}/drivers/include
${NRFX}/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
# 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
# Softdevice
${SOFTDEVICE}/mbr/headers
)
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)
message(FATAL_ERROR "Debug build not supported yet")
else ()
set(LD_FILE ${CMAKE_CURRENT_LIST_DIR}/linker/${MCU_VARIANT}.ld)
endif ()
target_link_options(bootloader PUBLIC
"LINKER:--script=${LD_FILE}"
-L${NRFX}/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
)
target_compile_definitions(bootloader PUBLIC
SOFTDEVICE_PRESENT
DFU_APP_DATA_RESERVED=7*4096
)
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}/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}/libraries/util
${SDK}/drivers_nrf/common
${SDK}/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
${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 ()
#----------------------------------------------------
# MCU Variant differences
# Supported are: nrf52 (nrf52832), nrf52833, nrf52840
#----------------------------------------------------
if (MCU_VARIANT STREQUAL "nrf52")
set(SD_NAME s132)
set(DFU_DEV_REV 0xADAF)
target_compile_definitions(bootloader PUBLIC
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)
target_compile_definitions(bootloader PUBLIC
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)
target_compile_definitions(bootloader PUBLIC
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)
#----------------------------------
# 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="${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} $<TARGET_FILE:bootloader>
)
# Add bin/hex output
add_custom_command(TARGET bootloader POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:bootloader> $<TARGET_FILE_DIR:bootloader>/bootloader.bin
COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:bootloader> $<TARGET_FILE_DIR:bootloader>/bootloader.hex
VERBATIM)
#----------------------------------
# Flashing target
#----------------------------------
if (NOT DEFINED NRFJPROG)
set(NRFJPROG nrfjprog)
endif()
add_custom_target(flash
DEPENDS bootloader
COMMAND ${NRFJPROG} --program $<TARGET_FILE:bootloader> --verify --sectoranduicrerase -f nrf52 --reset
)
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
)
+31 -4
View File
@@ -27,7 +27,11 @@ SD_HEX = $(SD_PATH)/$(SD_FILENAME)_softdevice.hex
MBR_HEX = lib/softdevice/mbr/hex/mbr_nrf52_2.4.1_mbr.hex
# linker by MCU eg. nrf52840.ld
LD_FILE = linker/$(MCU_SUB_VARIANT).ld
ifeq ($(DEBUG), 1)
LD_FILE = linker/$(MCU_SUB_VARIANT)_debug.ld
else
LD_FILE = linker/$(MCU_SUB_VARIANT).ld
endif
GIT_VERSION := $(shell git describe --dirty --always --tags)
GIT_SUBMODULE_VERSIONS := $(shell git submodule status | cut -d" " -f3,4 | paste -s -d" " -)
@@ -109,17 +113,18 @@ ifeq ($(MCU_SUB_VARIANT),nrf52)
SD_NAME = s132
DFU_DEV_REV = 0xADAF
CFLAGS += -DNRF52 -DNRF52832_XXAA -DS132
CFLAGS += -DDFU_APP_DATA_RESERVED=7*4096
DFU_APP_DATA_RESERVED=7*4096
else ifeq ($(MCU_SUB_VARIANT),nrf52833)
SD_NAME = s140
DFU_DEV_REV = 52833
CFLAGS += -DNRF52833_XXAA -DS140
CFLAGS += -DDFU_APP_DATA_RESERVED=7*4096
DFU_APP_DATA_RESERVED=7*4096
else ifeq ($(MCU_SUB_VARIANT),nrf52840)
SD_NAME = s140
DFU_DEV_REV = 52840
CFLAGS += -DNRF52840_XXAA -DS140
CFLAGS += -DDFU_APP_DATA_RESERVED=10*4096
# App reserved 40KB to match circuitpython for 840
DFU_APP_DATA_RESERVED=10*4096
else
$(error Sub Variant $(MCU_SUB_VARIANT) is unknown)
endif
@@ -321,6 +326,21 @@ ifeq ($(DEBUG), 1)
RTT_SRC = lib/SEGGER_RTT
IPATH += $(RTT_SRC)/RTT
C_SRC += $(RTT_SRC)/RTT/SEGGER_RTT.c
DFU_APP_DATA_RESERVED = 0
# expand bootloader address to 28KB of reserved app
ifeq ($(MCU_SUB_VARIANT),nrf52840)
CFLAGS += -DBOOTLOADER_REGION_START=0xED000
else
CFLAGS += -DBOOTLOADER_REGION_START=0x6D000
endif
endif
CFLAGS += -DDFU_APP_DATA_RESERVED=$(DFU_APP_DATA_RESERVED)
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
ifneq ($(findstring 12.,$(shell $(CC) --version 2>/dev/null)),)
CFLAGS += --param=min-pagesize=0
endif
#------------------------------------------------------------------------------
@@ -330,6 +350,7 @@ endif
LDFLAGS += \
$(CFLAGS) \
-Wl,-L,linker -Wl,-T,$(LD_FILE) \
-Wl,--print-memory-usage \
-Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections \
-specs=nosys.specs -specs=nano.specs
@@ -476,6 +497,12 @@ dfu-flash: flash-dfu
flash-dfu: $(BUILD)/$(MERGED_FILE).zip
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
$(NRFUTIL) --verbose dfu serial --package $< -p $(SERIAL) -b 115200 --singlebank --touch 1200
# flash skip crc magic ( app valid = 0x0001, crc = 0x0000 )
#flash-skip-crc:
# nrfjprog --memwr $(BOOT_SETTING_ADDR) --val 0x00000001 -f nrf52
# nrfjprog --memwr 0xFF000 --val 0x00000001 -f nrf52
# nrfjprog --memwr 0x7F000 --val 0x00000001 -f nrf52
#------------------- Debugging -------------------
+23 -28
View File
@@ -2,7 +2,17 @@
[![Build Status](https://github.com/adafruit/Adafruit_nRF52_Bootloader/workflows/Build/badge.svg)](https://github.com/adafruit/Adafruit_nRF52_Bootloader/actions)
This is a CDC/DFU/UF2 bootloader for nRF52 boards.
A CDC/DFU/UF2 bootloader for Nordic nRF52 microcontroller. UF2 is an easy-to-use bootloader that appears as a flash drive. You can just copy `.uf2`-format application images to the flash drive to load new firmware. See https://github.com/Microsoft/uf2 for more information.
DFU via serial/CDC requires [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil), a modified version of [Nordic nrfutil](https://github.com/NordicSemiconductor/pc-nrfutil). Install `python3` if it is not installed already and run this command to install adafruit-nrfutil from PyPi:
```
$ pip3 install --user adafruit-nrfutil
```
## Supported Boards
Officially supported boards are:
- [Adafruit CLUE](https://www.adafruit.com/product/4500)
- [Adafruit Circuit Playground Bluefruit](https://www.adafruit.com/product/4333)
@@ -12,34 +22,9 @@ This is a CDC/DFU/UF2 bootloader for nRF52 boards.
- [Adafruit ItsyBitsy nRF52840 Express](https://www.adafruit.com/product/4481)
- [Adafruit LED Glasses Driver nRF52840](https://www.adafruit.com/product/5217)
- Adafruit Metro nRF52840 Express
- [Akizukidenshi AE-BL652-BO](https://akizukidenshi.com/catalog/g/gK-15567/)
- [Electronut Labs Papyr](https://docs.electronut.in/papyr/)
- [iLabs Challenger 840 BLE](https://ilabs.se/challenger-840-ble-datasheet/)
- [MakerDiary MDK nRF52840 USB Dongle](https://makerdiary.com/products/nrf52840-mdk-usb-dongle)
- [MakerDiary nRF52840 M.2 Module](https://makerdiary.com/products/nrf52840-m2-module)
- [Nordic nRF52840DK PCA10056](https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52840-DK)
- [Nordic nRF52840DK PCA10059 ("Dongle")](https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52840-Dongle)
- Particle Argon
- Particle Boron
- Particle Xenon
- [SparkFun MicroMod nRF52840](https://www.sparkfun.com/products/16984)
- [Raytac MDBT50Q-RX Dongle](https://www.adafruit.com/product/5199)
UF2 is an easy-to-use bootloader that appears as a flash drive. You can just copy `.uf2`-format
application images to the flash drive to load new firmware. See https://github.com/Microsoft/uf2 and https://github.com/adafruit/uf2-samdx1 for more information.
[adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil), a modified version of [Nordic nrfutil](https://github.com/NordicSemiconductor/pc-nrfutil), is required to perform DFU. Install `python3` if it is not installed already and run this command to install adafruit-nrfutil from PyPi:
```
$ pip3 install --user adafruit-nrfutil
```
Clone this repo with following commands, or fork it for your own development
```
git clone https://github.com/adafruit/Adafruit_nRF52_Bootloader
cd Adafruit_nRF52_Bootloader
git submodule update --init
```
In addition, there is also lots of other 3rd-party boards which are added by other makers, users and community. Check out the [complete list of all boards here](/src/boards).
## Features
@@ -129,6 +114,16 @@ You must have have a J-Link available to "unbrick" your device.
### Build:
Firstly clone this repo with following commands
```
git clone https://github.com/adafruit/Adafruit_nRF52_Bootloader
cd Adafruit_nRF52_Bootloader
git submodule update --init
```
Then build it with `make BOARD={board} all`, for example:
```
make BOARD=feather_nrf52840_express all
```
+19
View File
@@ -0,0 +1,19 @@
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 ()
+23
View File
@@ -0,0 +1,23 @@
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 ()
+46
View File
@@ -0,0 +1,46 @@
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 ()
+17
View File
@@ -0,0 +1,17 @@
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)
@@ -37,7 +37,7 @@
#define BLEGAP_EVENT_LENGTH 6
#define BLEGATT_ATT_MTU_MAX 247
#define BLEGATT_ATT_MTU_MAX 23
enum { BLE_CONN_CFG_HIGH_BANDWIDTH = 1 };
#define DFU_REV_MAJOR 0x00 /** DFU Major revision number to be exposed. */
@@ -48,14 +48,18 @@ static inline bool is_sd_existed(void)
#define CODE_PAGE_SIZE 0x1000 /**< Size of a flash codepage. Used for size of the reserved flash space in the bootloader region. Will be runtime checked against NRF_UICR->CODEPAGESIZE to ensure the region is correct. */
#if defined(NRF52832_XXAA) || defined(NRF52833_XXAA)
// Flash = 512 KB
// Flash = 512 KB, allow to be defined in debug mode
#ifndef BOOTLOADER_REGION_START
#define BOOTLOADER_REGION_START 0x00074000 /**< This field should correspond to start address of the bootloader, found in UICR.RESERVED, 0x10001014, register. This value is used for sanity check, so the bootloader will fail immediately if this value differs from runtime value. The value is used to determine max application size for updating. */
#endif
#define BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS 0x0007E000 /**< The field specifies the page location of the mbr params page address. */
#define BOOTLOADER_SETTINGS_ADDRESS 0x0007F000 /**< The field specifies the page location of the bootloader settings address. */
#elif defined(NRF52840_XXAA)
// Flash = 1024 KB
// Flash = 1024 KB, allow to be defined in debug mode
#ifndef BOOTLOADER_REGION_START
#define BOOTLOADER_REGION_START 0x000F4000 /**< This field should correspond to start address of the bootloader, found in UICR.RESERVED, 0x10001014, register. This value is used for sanity check, so the bootloader will fail immediately if this value differs from runtime value. The value is used to determine max application size for updating. */
#endif
#define BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS 0x000FE000 /**< The field specifies the page location of the mbr params page address. */
#define BOOTLOADER_SETTINGS_ADDRESS 0x000FF000 /**< The field specifies the page location of the bootloader settings address. */
+99
View File
@@ -0,0 +1,99 @@
/* Linker script to configure memory regions. */
SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)
MEMORY
{
/** Flash start address for the bootloader. This setting will also be stored in UICR to allow the
* MBR to init the bootloader when starting the system. This value must correspond to
* BOOTLOADER_REGION_START found in dfu_types.h. The system is prevented from starting up if
* those values do not match. The check is performed in main.c, see
* APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START);
*/
/* due to lack of flash for debug, we will use reserved app to extend bootloader size */
FLASH (rx) : ORIGIN = 0x74000-28K, LENGTH = 0x7E000-0x74000-2K + 28K
BOOTLOADER_CONFIG (r): ORIGIN = 0x7E000 - 2K, LENGTH = 2K
/** Location of mbr params page in flash. */
MBR_PARAMS_PAGE (rw) : ORIGIN = 0x0007E000, LENGTH = 0x1000
/** Location of bootloader setting in flash. */
BOOTLOADER_SETTINGS (rw) : ORIGIN = 0x0007F000, LENGTH = 0x1000
/** RAM Region for bootloader. */
/* Avoid conflict with NOINIT for OTA bond sharing */
RAM (rwx) : ORIGIN = 0x20008000, LENGTH = 0x20020000-0x20008000
/* Location for double reset detection, no init */
DBL_RESET (rwx) : ORIGIN = 0x20007F7C, LENGTH = 0x04
/** Location of non initialized RAM. Non initialized RAM is used for exchanging bond information
* from application to bootloader when using buttonless DFU OTA. */
NOINIT (rwx) : ORIGIN = 0x20007F80, LENGTH = 0x80
/** Location in UICR where bootloader start address is stored. */
UICR_BOOTLOADER (r) : ORIGIN = 0x10001014, LENGTH = 0x04
/** Location in UICR where mbr params page address is stored. */
UICR_MBR_PARAM_PAGE(r) : ORIGIN = 0x10001018, LENGTH = 0x04
}
SECTIONS
{
.fs_data_out ALIGN(4):
{
PROVIDE( __start_fs_data = .);
KEEP(*(fs_data))
PROVIDE( __stop_fs_data = .);
} = 0
.bootloaderConfig :
{
KEEP(*(.bootloaderConfig))
} > BOOTLOADER_CONFIG
/* Place the bootloader settings page in flash. */
.bootloaderSettings(NOLOAD) :
{
} > BOOTLOADER_SETTINGS
/* Write the bootloader address in UICR. */
.uicrBootStartAddress :
{
KEEP(*(.uicrBootStartAddress))
} > UICR_BOOTLOADER
/* Place the mbr params page in flash. */
.mbrParamsPage(NOLOAD) :
{
} > MBR_PARAMS_PAGE
/* Write the bootloader address in UICR. */
.uicrMbrParamsPageAddress :
{
KEEP(*(.uicrMbrParamsPageAddress))
} > UICR_MBR_PARAM_PAGE
.dbl_reset(NOLOAD) :
{
} > DBL_RESET
/* No init RAM section in bootloader. Used for bond information exchange. */
.noinit(NOLOAD) :
{
} > NOINIT
/* other placements follow here... */
}
INCLUDE "nrf_common.ld"
+99
View File
@@ -0,0 +1,99 @@
/* Linker script to configure memory regions. */
SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)
MEMORY
{
/** Flash start address for the bootloader. This setting will also be stored in UICR to allow the
* MBR to init the bootloader when starting the system. This value must correspond to
* BOOTLOADER_REGION_START found in dfu_types.h. The system is prevented from starting up if
* those values do not match. The check is performed in main.c, see
* APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START);
*/
/* due to lack of flash for debug, we will use reserved app to extend bootloader size */
FLASH (rx) : ORIGIN = 0xF4000-28K, LENGTH = 0xFE000-0xF4000 - 2K + 28K /* 38 KB */
BOOTLOADER_CONFIG (r): ORIGIN = 0xFE000 - 2K, LENGTH = 2K
/** Location of mbr params page in flash. */
MBR_PARAMS_PAGE (rw) : ORIGIN = 0xFE000, LENGTH = 0x1000
/** Location of bootloader setting in flash. */
BOOTLOADER_SETTINGS (rw) : ORIGIN = 0xFF000, LENGTH = 0x1000
/** RAM Region for bootloader. */
/* Avoid conflict with NOINIT for OTA bond sharing */
RAM (rwx) : ORIGIN = 0x20008000, LENGTH = 0x20040000-0x20008000
/* Location for double reset detection, no init */
DBL_RESET (rwx) : ORIGIN = 0x20007F7C, LENGTH = 0x04
/** Location of non initialized RAM. Non initialized RAM is used for exchanging bond information
* from application to bootloader when using buttonless DFU OTA. */
NOINIT (rwx) : ORIGIN = 0x20007F80, LENGTH = 0x80
/** Location in UICR where bootloader start address is stored. */
UICR_BOOTLOADER (r) : ORIGIN = 0x10001014, LENGTH = 0x04
/** Location in UICR where mbr params page address is stored. */
UICR_MBR_PARAM_PAGE(r) : ORIGIN = 0x10001018, LENGTH = 0x04
}
SECTIONS
{
.fs_data_out ALIGN(4):
{
PROVIDE( __start_fs_data = .);
KEEP(*(fs_data))
PROVIDE( __stop_fs_data = .);
} = 0
.bootloaderConfig :
{
KEEP(*(.bootloaderConfig))
} > BOOTLOADER_CONFIG
/* Place the bootloader settings page in flash. */
.bootloaderSettings(NOLOAD) :
{
} > BOOTLOADER_SETTINGS
/* Write the bootloader address in UICR. */
.uicrBootStartAddress :
{
KEEP(*(.uicrBootStartAddress))
} > UICR_BOOTLOADER
/* Place the mbr params page in flash. */
.mbrParamsPage(NOLOAD) :
{
} > MBR_PARAMS_PAGE
/* Write the bootloader address in UICR. */
.uicrMbrParamsPageAddress :
{
KEEP(*(.uicrMbrParamsPageAddress))
} > UICR_MBR_PARAM_PAGE
.dbl_reset(NOLOAD) :
{
} > DBL_RESET
/* No init RAM section in bootloader. Used for bond information exchange. */
.noinit(NOLOAD) :
{
} > NOINIT
/* other placements follow here... */
}
INCLUDE "nrf_common.ld"
+89
View File
@@ -0,0 +1,89 @@
/* Linker script to configure memory regions. */
SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)
MEMORY
{
/** Flash start address for the bootloader. This setting will also be stored in UICR to allow the
* MBR to init the bootloader when starting the system. This value must correspond to
* BOOTLOADER_REGION_START found in dfu_types.h. The system is prevented from starting up if
* those values do not match. The check is performed in main.c, see
* APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START);
*/
FLASH (rx) : ORIGIN = 0x74000-28K, LENGTH = 0x7E000-0x74000+28K /* 40 KB */
/** Location of mbr params page in flash. */
MBR_PARAMS_PAGE (rw) : ORIGIN = 0x7E000, LENGTH = 0x1000
/** Location of bootloader setting in flash. */
BOOTLOADER_SETTINGS (rw) : ORIGIN = 0x7F000, LENGTH = 0x1000
/** RAM Region for bootloader. */
RAM (rwx) : ORIGIN = 0x20008000, LENGTH = 0x20010000-0x20008000
/* Location for double reset detection, no init */
DBL_RESET (rwx) : ORIGIN = 0x20007F7C, LENGTH = 0x04
/** Location of non initialized RAM. Non initialized RAM is used for exchanging bond information
* from application to bootloader when using buttonless DFU OTA. */
NOINIT (rwx) : ORIGIN = 0x20007F80, LENGTH = 0x80
/** Location in UICR where bootloader start address is stored. */
UICR_BOOTLOADER (r) : ORIGIN = 0x10001014, LENGTH = 0x04
/** Location in UICR where mbr params page address is stored. */
UICR_MBR_PARAM_PAGE(r) : ORIGIN = 0x10001018, LENGTH = 0x04
}
SECTIONS
{
.fs_data_out ALIGN(4):
{
PROVIDE( __start_fs_data = .);
KEEP(*(fs_data))
PROVIDE( __stop_fs_data = .);
} = 0
/* Place the bootloader settings page in flash. */
.bootloaderSettings(NOLOAD) :
{
} > BOOTLOADER_SETTINGS
/* Write the bootloader address in UICR. */
.uicrBootStartAddress :
{
KEEP(*(.uicrBootStartAddress))
} > UICR_BOOTLOADER
/* Place the mbr params page in flash. */
.mbrParamsPage(NOLOAD) :
{
} > MBR_PARAMS_PAGE
/* Write the bootloader address in UICR. */
.uicrMbrParamsPageAddress :
{
KEEP(*(.uicrMbrParamsPageAddress))
} > UICR_MBR_PARAM_PAGE
.dbl_reset(NOLOAD) :
{
} > DBL_RESET
/* No init RAM section in bootloader. Used for bond information exchange. */
.noinit(NOLOAD) :
{
} > NOINIT
/* other placements follow here... */
}
INCLUDE "nrf_common.ld"
+9 -2
View File
@@ -63,7 +63,8 @@ bool button_pressed(uint32_t pin)
}
// This is declared so that a board specific init can be called from here.
void __attribute__((weak)) board_init_extra(void) { }
void __attribute__((weak)) board_init2(void) { }
void board_init(void)
{
// stop LF clock just in case we jump from application without reset
@@ -96,7 +97,7 @@ void board_init(void)
NRF_POWER->DCDCEN = 1;
#endif
// Make sure any custom inits are performed
board_init_extra();
board_init2();
// When board is supplied on VDDH (and not VDD), this specifies what voltage the GPIO should run at
// and what voltage is output at VDD. The default (0xffffffff) is 1.8V; typically you'll want
@@ -129,6 +130,9 @@ void board_init(void)
SysTick_Config(SystemCoreClock/1000);
}
// Actions at the end of board_teardown.
void __attribute__((weak)) board_teardown2(void) { }
void board_teardown(void)
{
// Disable systick, turn off LEDs
@@ -159,6 +163,9 @@ void board_teardown(void)
{
nrf_gpio_cfg_default(i);
}
// board specific teardown actions
board_teardown2();
}
static uint32_t _systick_count = 0;
+1 -1
View File
@@ -19,7 +19,7 @@ const uint32_t bootloaderConfig[] =
/* CF2 END */
};
void board_init_extra(void)
void board_init2(void)
{
// Turn LDO on
nrf_gpio_cfg_output(LDO_CONTROL_PIN);
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52840)
+6 -1
View File
@@ -43,9 +43,14 @@
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 _PINNUM(0, 27)
#define BUTTON_2 _PINNUM(1, 7)
#define BUTTON_2 _PINNUM(0, 19) // ESC
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
/*------------------------------------------------------------------*/
/* On board regulator control
*------------------------------------------------------------------*/
#define LDO_CONTROL_PIN _PINNUM(0, 28) // Enables external pwr
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
+38
View File
@@ -1,4 +1,5 @@
#include "boards.h"
#include "board.h"
#include "uf2/configkeys.h"
__attribute__((used, section(".bootloaderConfig")))
@@ -17,3 +18,40 @@ const uint32_t bootloaderConfig[] =
0, 0, 0, 0, 0, 0, 0, 0
/* CF2 END */
};
static void power_on(void)
{
// Turn on the regulator
nrf_gpio_cfg_output(LDO_CONTROL_PIN);
nrf_gpio_pin_write(LDO_CONTROL_PIN, 1);
}
void board_init2(void)
{
power_on();
// configure P0.05 for ESC/BUTTON_2
// P0.05 --- |<- --- / --- P0.19
// diode sw(esc)
// mode: output, push-pull, low
nrf_gpio_cfg(
_PINNUM(0, 5),
NRF_GPIO_PIN_DIR_OUTPUT,
NRF_GPIO_PIN_INPUT_DISCONNECT,
NRF_GPIO_PIN_NOPULL,
NRF_GPIO_PIN_H0D1,
NRF_GPIO_PIN_NOSENSE
);
nrf_gpio_pin_write(_PINNUM(0, 5), 0);
// Wait the buttons stable.
// This is mandatory, or the keyboard will enter bootloader whenever
// booted by pressing the button at back (same with BUTTON_1)
NRFX_DELAY_MS(300);
}
void board_teardown2(void)
{
// re-enable the battery
power_on();
}
+71
View File
@@ -0,0 +1,71 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2020 Yihui Xiong for Makerdiary
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef _MAKERDIARY_NRF82540_CONNECT_KIT_H_
#define _MAKERDIARY_NRF82540_CONNECT_KIT_H_
#define _PINNUM(port, pin) ((port)*32 + (pin))
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN _PINNUM(1, 15) // Green
#define LED_STATE_ON 0
#define LED_RGB_RED_PIN _PINNUM(1, 10)
#define LED_RGB_GREEN_PIN _PINNUM(1, 11)
#define LED_RGB_BLUE_PIN _PINNUM(1, 12)
#define BOARD_RGB_BRIGHTNESS 0x404040
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 _PINNUM(1, 0) // P1.00: User Button
#define BUTTON_2 _PINNUM(1, 7) // P1.07: NC
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "Makerdiary"
#define BLEDIS_MODEL "nRF52840 Connect Kit"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
#define USB_DESC_VID 0x2886
#define USB_DESC_UF2_PID 0xF00F
#define USB_DESC_CDC_ONLY_PID 0xF00F
//--------------------------------------------------------------------+
// UF2
//--------------------------------------------------------------------+
#define UF2_PRODUCT_NAME "nRF52840 Connect Kit"
#define UF2_VOLUME_LABEL "CONNECTKIT"
#define UF2_BOARD_ID "nRF52840-Connect-Kit"
#define UF2_INDEX_URL "https://wiki.makerdiary.com/nrf52840-connectkit/"
#endif /* _MAKERDIARY_NRF82540_CONNECT_KIT_H_ */
+2
View File
@@ -0,0 +1,2 @@
MCU_SUB_VARIANT = nrf52840
USE_NFCT = yes
@@ -0,0 +1,19 @@
#include "boards.h"
#include "uf2/configkeys.h"
__attribute__((used, section(".bootloaderConfig")))
const uint32_t bootloaderConfig[] =
{
/* CF2 START */
CFG_MAGIC0, CFG_MAGIC1, // magic
5, 100, // used entries, total entries
204, 0x100000, // FLASH_BYTES = 0x100000
205, 0x40000, // RAM_BYTES = 0x40000
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
209, 0xada52840, // UF2_FAMILY = 0xada52840
210, 0x20, // PINS_PORT_SIZE = PA_32
0, 0, 0, 0, 0, 0, 0, 0
/* CF2 END */
};
+1
View File
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52840)
+65
View File
@@ -0,0 +1,65 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2022 Kyle McCreery
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef _PillBug_H
#define _PillBug_H
#define _PINNUM(port, pin) ((port)*32 + (pin))
#define UICR_REGOUT0_VALUE UICR_REGOUT0_VOUT_3V3
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN _PINNUM(0, 20) // Blue
#define LED_STATE_ON 1
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2 // none connected at all
#define BUTTON_1 _PINNUM(0, 18) // unusable: RESET
#define BUTTON_2 _PINNUM(0, 21) // no connection
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "MechWild"
#define BLEDIS_MODEL "PillBug"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
#define USB_DESC_VID 0x16D0
#define USB_DESC_UF2_PID 0x10ED
#define USB_DESC_CDC_ONLY_PID 0x10ED
#define UF2_PRODUCT_NAME "PillBug"
#define UF2_VOLUME_LABEL "PillBug"
#define UF2_BOARD_ID "nRF52840-PillBug"
#define UF2_INDEX_URL "https://mechwild.com"
#endif // _PillBug_H
+1
View File
@@ -0,0 +1 @@
MCU_SUB_VARIANT = nrf52840
+19
View File
@@ -0,0 +1,19 @@
#include "boards.h"
#include "uf2/configkeys.h"
__attribute__((used, section(".bootloaderConfig")))
const uint32_t bootloaderConfig[] =
{
/* CF2 START */
CFG_MAGIC0, CFG_MAGIC1, // magic
5, 100, // used entries, total entries
204, 0x100000, // FLASH_BYTES = 0x100000
205, 0x40000, // RAM_BYTES = 0x40000
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
209, 0xada52840, // UF2_FAMILY = 0xada52840
210, 0x20, // PINS_PORT_SIZE = PA_32
0, 0, 0, 0, 0, 0, 0, 0
/* CF2 END */
};
+68
View File
@@ -0,0 +1,68 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2018 Ha Thach for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef _XIAO_BLE
#define _XIAO_BLE
#define _PINNUM(port, pin) ((port)*32 + (pin))
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
// The board has 3 leds, but changing the number here causes OTA issues.
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN _PINNUM(0, 26)
#define LED_STATE_ON 0
#define NEOPIXELS_NUMBER 0
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 _PINNUM(0, 18)
// Button 2 is defined as D1 from expansion board.
#define BUTTON_2 _PINNUM(0, 3)
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "Seeed"
#define BLEDIS_MODEL "XIAO nRF52840"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
#define USB_DESC_VID 0x2886
#define USB_DESC_UF2_PID 0x0044
#define USB_DESC_CDC_ONLY_PID 0x0044
//------------- UF2 -------------//
#define UF2_PRODUCT_NAME "Seeed XIAO nRF52840"
#define UF2_VOLUME_LABEL "XIAO-BOOT"
#define UF2_BOARD_ID "nRF52840-SeeedXiao-v1"
#define UF2_INDEX_URL "https://www.seeedstudio.com/"
#endif // _XIAO_BLE
+2
View File
@@ -0,0 +1,2 @@
MCU_SUB_VARIANT = nrf52840
SD_VERSION = 7.3.0
+19
View File
@@ -0,0 +1,19 @@
#include "boards.h"
#include "uf2/configkeys.h"
__attribute__((used, section(".bootloaderConfig")))
const uint32_t bootloaderConfig[] =
{
/* CF2 START */
CFG_MAGIC0, CFG_MAGIC1, // magic
5, 100, // used entries, total entries
204, 0x100000, // FLASH_BYTES = 0x100000
205, 0x40000, // RAM_BYTES = 0x40000
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
209, 0xada52840, // UF2_FAMILY = 0xada52840
210, 0x20, // PINS_PORT_SIZE = PA_32
0, 0, 0, 0, 0, 0, 0, 0
/* CF2 END */
};
@@ -0,0 +1,68 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2018 Ha Thach for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef _XIAO_BLE_SENSE
#define _XIAO_BLE_SENSE
#define _PINNUM(port, pin) ((port)*32 + (pin))
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
// The board has 3 leds, but changing the number here causes OTA issues.
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN _PINNUM(0, 26)
#define LED_STATE_ON 0
#define NEOPIXELS_NUMBER 0
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 _PINNUM(0, 18)
// Button 2 is defined as D1 from expansion board.
#define BUTTON_2 _PINNUM(0, 3)
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "Seeed"
#define BLEDIS_MODEL "XIAO nRF52840 Sense"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
#define USB_DESC_VID 0x2886
#define USB_DESC_UF2_PID 0x0045
#define USB_DESC_CDC_ONLY_PID 0x0045
//------------- UF2 -------------//
#define UF2_PRODUCT_NAME "Seeed XIAO nRF52840"
#define UF2_VOLUME_LABEL "XIAO-SENSE"
#define UF2_BOARD_ID "nRF52840-SeeedXiaoSense-v1"
#define UF2_INDEX_URL "https://www.seeedstudio.com/"
#endif // _XIAO_BLE_SENSE
@@ -0,0 +1,2 @@
MCU_SUB_VARIANT = nrf52840
SD_VERSION = 7.3.0
@@ -0,0 +1,19 @@
#include "boards.h"
#include "uf2/configkeys.h"
__attribute__((used, section(".bootloaderConfig")))
const uint32_t bootloaderConfig[] =
{
/* CF2 START */
CFG_MAGIC0, CFG_MAGIC1, // magic
5, 100, // used entries, total entries
204, 0x100000, // FLASH_BYTES = 0x100000
205, 0x40000, // RAM_BYTES = 0x40000
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
209, 0xada52840, // UF2_FAMILY = 0xada52840
210, 0x20, // PINS_PORT_SIZE = PA_32
0, 0, 0, 0, 0, 0, 0, 0
/* CF2 END */
};
+1 -1
View File
@@ -131,7 +131,7 @@ extern void tusb_hal_nrf_power_event(uint32_t event);
// These value must be the same with one in dfu_transport_ble.c
#define BLEGAP_EVENT_LENGTH 6
#define BLEGATT_ATT_MTU_MAX 247
#define BLEGATT_ATT_MTU_MAX 23
enum { BLE_CONN_CFG_HIGH_BANDWIDTH = 1 };
//--------------------------------------------------------------------+