mirror of
https://github.com/oltaco/Adafruit_nRF52_Bootloader_OTAFIX.git
synced 2026-10-24 15:03:41 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f40a6076e | ||
|
|
f9c032fbd7 | ||
|
|
941b1ddfeb | ||
|
|
f6c9614976 | ||
|
|
68959e00c4 | ||
|
|
1d85a000e2 | ||
|
|
05fcc9f32d | ||
|
|
527aa4df08 | ||
|
|
7211d3847c | ||
|
|
d02d6c8114 | ||
|
|
993ac762ca | ||
|
|
d099cda94c | ||
|
|
569e64f504 | ||
|
|
4946c0388f | ||
|
|
d6743ea8a1 | ||
|
|
f205fcd6fb | ||
|
|
41db95f28e | ||
|
|
66b6712682 | ||
|
|
0d97c2108d | ||
|
|
0889a68a7a | ||
|
|
38a67d1896 | ||
|
|
0fc9f2f4bd | ||
|
|
3791f9376e | ||
|
|
0f052bcee0 | ||
|
|
3d04d61bc6 | ||
|
|
58e756e6cc | ||
|
|
5e1fe6aeb8 | ||
|
|
235c0fac5b | ||
|
|
f82d1bc4b6 | ||
|
|
90f163f6d8 | ||
|
|
a427853ae0 | ||
|
|
d7d084673f | ||
|
|
1a6d8eae97 | ||
|
|
a2b3ae4970 | ||
|
|
97fbda552d | ||
|
|
142ed6057a | ||
|
|
2f9ed3e447 | ||
|
|
9e188d7370 | ||
|
|
dedbb74562 | ||
|
|
eae198000c | ||
|
|
80fca98113 | ||
|
|
a7fe7c98a3 | ||
|
|
6e33825e9f | ||
|
|
b1e0d2fd72 | ||
|
|
42d9d9fe9d | ||
|
|
3f528bae0b | ||
|
|
13118196d8 | ||
|
|
6126d1192e | ||
|
|
627ce5d9a9 | ||
|
|
a754296a8a | ||
|
|
881dac1486 | ||
|
|
20a5b93402 | ||
|
|
2577833136 | ||
|
|
0ec25a7add | ||
|
|
81240bfdb9 | ||
|
|
7a728eeaa6 | ||
|
|
398ede8f90 | ||
|
|
cef07b4eeb | ||
|
|
0c086c2a4c | ||
|
|
566410a7e2 | ||
|
|
0e87ce6e3e | ||
|
|
4c1344c612 | ||
|
|
4e54deb050 | ||
|
|
6755bd101c | ||
|
|
7255b55ffe | ||
|
|
12d36857c2 | ||
|
|
a40d98dca2 | ||
|
|
f33fdd2e5a | ||
|
|
0edf5175a9 | ||
|
|
0a677620ab | ||
|
|
fc487794b3 | ||
|
|
4f74d41871 | ||
|
|
77c7b7f6dc | ||
|
|
488c6c4463 | ||
|
|
f1b4740579 | ||
|
|
0098324683 | ||
|
|
26bafdcf24 | ||
|
|
5e6690e296 | ||
|
|
78d0c3ae27 | ||
|
|
3895ffbda6 | ||
|
|
a4b5aa4ad1 | ||
|
|
84e843ac86 | ||
|
|
0299cfedb5 | ||
|
|
b404dabe15 | ||
|
|
d88ab7427a | ||
|
|
d481de3e00 | ||
|
|
1a5df60739 | ||
|
|
cb916d3087 | ||
|
|
0670265be0 | ||
|
|
6f7dc38d3c | ||
|
|
91f16ade72 | ||
|
|
81da515ae6 | ||
|
|
3aaef724b2 | ||
|
|
ba5d783c20 | ||
|
|
755cfa95e4 | ||
|
|
b37c078213 | ||
|
|
ba5977d679 | ||
|
|
4ba802d127 | ||
|
|
f9125593b2 | ||
|
|
8ba551c07e |
No files matched your search
@@ -1,32 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: "[Bug]"
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**Set up (please complete the following information)**
|
||||
- Your Board and BSP version
|
||||
- Your OS (mac/windows/linux) and its version
|
||||
- Serial debug log (enable IDE's Debug Mode Level to 1 or 2)
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
@@ -0,0 +1,61 @@
|
||||
name: Bug Report
|
||||
description: Report a problem
|
||||
labels: 'Bug'
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to fill out this bug report!
|
||||
It's okay to leave some blank if it doesn't apply to your problem.
|
||||
|
||||
- type: dropdown
|
||||
attributes:
|
||||
label: Operating System
|
||||
options:
|
||||
- Linux
|
||||
- MacOS
|
||||
- RaspberryPi OS
|
||||
- Windows 7
|
||||
- Windows 10
|
||||
- Windows 11
|
||||
- Others
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: INFO_UF2.TXT
|
||||
placeholder: Paste your INFO_UF2.TXT contents here
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: What happened ?
|
||||
placeholder: A clear and concise description of what the bug is.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: How to reproduce ?
|
||||
placeholder: |
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. See error
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Debug Log
|
||||
placeholder: Debug log attached txt file.
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Screenshots
|
||||
description: If applicable, add screenshots to help explain your problem.
|
||||
validations:
|
||||
required: false
|
||||
@@ -0,0 +1,4 @@
|
||||
contact_links:
|
||||
- name: Adafruit Support Forum
|
||||
url: https://forums.adafruit.com
|
||||
about: If you have other questions or need help, post it here.
|
||||
@@ -23,16 +23,22 @@ jobs:
|
||||
- 'feather_nrf52840_sense'
|
||||
- 'itsybitsy_nrf52840_express'
|
||||
- 'metro_nrf52840_express'
|
||||
# Alphabetical order
|
||||
- 'ADM_B_NRF52840_1'
|
||||
- 'ledglasses_nrf52840'
|
||||
# Other Makers (Alphabetical order)
|
||||
- 'adm_b_nrf52840_1'
|
||||
- 'ae_bl652_bo'
|
||||
- 'aramcon_badge_2019'
|
||||
- 'aramcon2_badge'
|
||||
- 'arcade_feather_nrf52840_express'
|
||||
- 'arduino_nano_33_ble'
|
||||
- 'bast_ble'
|
||||
- 'bluemicro_nrf52833'
|
||||
- 'bluemicro_nrf52840'
|
||||
- 'ebyte_e104_bt5032a'
|
||||
- 'ebyte_e73_tbb'
|
||||
- 'electronut_labs_papyr'
|
||||
- 'ikigaisense_vita'
|
||||
- 'm60_keyboard'
|
||||
- 'mdk_nrf52840_dongle'
|
||||
- 'nice_nano'
|
||||
- 'nrf52840_m2'
|
||||
@@ -44,7 +50,9 @@ jobs:
|
||||
- 'pca10059'
|
||||
- 'pca10100'
|
||||
- 'pitaya_go'
|
||||
- 'raytac_mdbt50q_db_40'
|
||||
- 'raytac_mdbt50q_rx'
|
||||
- 'sparkfun_nrf52840_micromod'
|
||||
- 'waveshare_nrf52840_eval'
|
||||
|
||||
steps:
|
||||
@@ -57,40 +65,42 @@ jobs:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
submodules: true
|
||||
submodules: true
|
||||
|
||||
- name: Checkout linkermap
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: hathach/linkermap
|
||||
path: linkermap
|
||||
|
||||
- name: Install Toolchains
|
||||
run: |
|
||||
pip3 install adafruit-nrfutil uritemplate requests intelhex
|
||||
pip3 install linkermap/
|
||||
npm install --global xpm
|
||||
# 9.3.1-1.2.1 is xpack modified version which significantly increased compiled size to 6-7KB and cause flash overflow.
|
||||
# Skip this version for now, we will try again with next official release from ARM
|
||||
xpm install --global @xpack-dev-tools/arm-none-eabi-gcc@9.3.1-1.1.1
|
||||
echo `echo $HOME/opt/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/*/.content/bin` >> $GITHUB_PATH
|
||||
echo `echo $HOME/.local/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/*/.content/bin` >> $GITHUB_PATH
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
make BOARD=${{ matrix.board }} all
|
||||
make BOARD=${{ matrix.board }} copy-artifact
|
||||
|
||||
- name: Linker Map
|
||||
run: make BOARD=${{ matrix.board }} linkermap
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ${{ matrix.board }}
|
||||
path: _bin/${{ matrix.board }}
|
||||
|
||||
- name: Creat Release Asset
|
||||
if: ${{ github.event_name == 'release' }}
|
||||
run: zip -jr ${{ matrix.board }}_bootloader-${{ github.event.release.tag_name }}.zip _bin/${{ matrix.board }}
|
||||
|
||||
- name: Upload Release Asset
|
||||
id: upload-release-asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: ${{ github.event_name == 'release' }}
|
||||
with:
|
||||
upload_url: ${{ github.event.release.upload_url }}
|
||||
asset_path: ${{ matrix.board }}_bootloader-${{ github.event.release.tag_name }}.zip
|
||||
asset_name: ${{ matrix.board }}_bootloader-${{ github.event.release.tag_name }}.zip
|
||||
asset_content_type: application/zip
|
||||
|
||||
files: |
|
||||
_bin/${{ matrix.board }}/${{ matrix.board }}_bootloader-*.zip
|
||||
_bin/${{ matrix.board }}/${{ matrix.board }}_bootloader-*.hex
|
||||
_bin/${{ matrix.board }}/update-${{ matrix.board }}_bootloader-*.uf2
|
||||
@@ -104,14 +104,17 @@ ifeq ($(MCU_SUB_VARIANT),nrf52)
|
||||
SD_NAME = s132
|
||||
DFU_DEV_REV = 0xADAF
|
||||
CFLAGS += -DNRF52 -DNRF52832_XXAA -DS132
|
||||
CFLAGS += -DDFU_APP_DATA_RESERVED=7*4096
|
||||
else ifeq ($(MCU_SUB_VARIANT),nrf52833)
|
||||
SD_NAME = s140
|
||||
DFU_DEV_REV = 52840
|
||||
CFLAGS += -DNRF52833_XXAA -DS140
|
||||
CFLAGS += -DDFU_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
|
||||
else
|
||||
$(error Sub Variant $(MCU_SUB_VARIANT) is unknown)
|
||||
endif
|
||||
@@ -121,13 +124,14 @@ endif
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# all files in src
|
||||
C_SRC += $(wildcard src/*.c)
|
||||
C_SRC += \
|
||||
src/dfu_ble_svc.c \
|
||||
src/dfu_init.c \
|
||||
src/flash_nrf5x.c \
|
||||
src/main.c \
|
||||
|
||||
# all files in boards
|
||||
C_SRC += $(wildcard src/boards/*.c)
|
||||
|
||||
# all sources files in specific board
|
||||
C_SRC += $(wildcard src/boards/$(BOARD)/*.c)
|
||||
C_SRC += src/boards/boards.c
|
||||
|
||||
# nrfx
|
||||
C_SRC += $(NRFX_PATH)/drivers/src/nrfx_power.c
|
||||
@@ -169,18 +173,25 @@ IPATH += $(SDK_PATH)/drivers_nrf/uart
|
||||
|
||||
else
|
||||
|
||||
# pinconfig is required for 840 for CF2
|
||||
C_SRC += src/boards/$(BOARD)/pinconfig.c
|
||||
|
||||
# USB Application ( MSC + UF2 )
|
||||
C_SRC += $(wildcard src/usb/*.c)
|
||||
C_SRC += $(wildcard src/usb/uf2/*.c)
|
||||
C_SRC += \
|
||||
src/usb/msc_uf2.c \
|
||||
src/usb/usb_desc.c \
|
||||
src/usb/usb.c \
|
||||
src/usb/uf2/ghostfat.c
|
||||
|
||||
# TinyUSB stack
|
||||
C_SRC += $(TUSB_PATH)/portable/nordic/nrf5x/dcd_nrf5x.c
|
||||
C_SRC += $(TUSB_PATH)/common/tusb_fifo.c
|
||||
C_SRC += $(TUSB_PATH)/device/usbd.c
|
||||
C_SRC += $(TUSB_PATH)/device/usbd_control.c
|
||||
C_SRC += $(TUSB_PATH)/class/cdc/cdc_device.c
|
||||
C_SRC += $(TUSB_PATH)/class/msc/msc_device.c
|
||||
C_SRC += $(TUSB_PATH)/tusb.c
|
||||
C_SRC += \
|
||||
$(TUSB_PATH)/portable/nordic/nrf5x/dcd_nrf5x.c \
|
||||
$(TUSB_PATH)/common/tusb_fifo.c \
|
||||
$(TUSB_PATH)/device/usbd.c \
|
||||
$(TUSB_PATH)/device/usbd_control.c \
|
||||
$(TUSB_PATH)/class/cdc/cdc_device.c \
|
||||
$(TUSB_PATH)/class/msc/msc_device.c \
|
||||
$(TUSB_PATH)/tusb.c
|
||||
|
||||
endif
|
||||
|
||||
@@ -232,15 +243,6 @@ IPATH += $(SD_PATH)/$(SD_FILENAME)_API/include/nrf52
|
||||
# Compiler Flags
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Debug option use RTT for printf
|
||||
ifeq ($(DEBUG), 1)
|
||||
RTT_SRC = lib/SEGGER_RTT
|
||||
|
||||
CFLAGS += -DCFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
|
||||
IPATH += $(RTT_SRC)/RTT
|
||||
C_SRC += $(RTT_SRC)/RTT/SEGGER_RTT.c
|
||||
endif
|
||||
|
||||
#flags common to all targets
|
||||
CFLAGS += \
|
||||
-mthumb \
|
||||
@@ -276,6 +278,18 @@ CFLAGS += -Wno-unused-parameter -Wno-expansion-to-defined
|
||||
# TinyUSB tusb_hal_nrf_power_event
|
||||
CFLAGS += -Wno-cast-function-type
|
||||
|
||||
# Nordic Softdevice SDK header files contains inline assembler that has
|
||||
# broken constraints. As a result the IPA-modref pass, introduced in gcc-11,
|
||||
# is able to "prove" that arguments to wrapper functions generated with
|
||||
# the SVCALL() macro are unused and, as a result, the optimizer will remove
|
||||
# code within the callers that sets up these arguments (which results in
|
||||
# a broken bootloader). The broken headers come from Nordic-supplied zip
|
||||
# files and are not trivial to patch so, for now, we'll simply disable the
|
||||
# new gcc-11 inter-procedural optimizations.
|
||||
ifeq (,$(findstring unrecognized,$(shell $(CC) $(CFLAGS) -fno-ipa-modref 2>&1)))
|
||||
CFLAGS += -fno-ipa-modref
|
||||
endif
|
||||
|
||||
# Defined Symbol (MACROS)
|
||||
CFLAGS += -D__HEAP_SIZE=0
|
||||
CFLAGS += -DCONFIG_GPIO_AS_PINRESET
|
||||
@@ -286,14 +300,20 @@ ifneq ($(USE_NFCT),yes)
|
||||
endif
|
||||
|
||||
CFLAGS += -DSOFTDEVICE_PRESENT
|
||||
CFLAGS += -DDFU_APP_DATA_RESERVED=7*4096
|
||||
|
||||
CFLAGS += -DUF2_VERSION='"$(GIT_VERSION) $(GIT_SUBMODULE_VERSIONS)"'
|
||||
CFLAGS += -DBLEDIS_FW_VERSION='"$(GIT_VERSION) $(SD_NAME) $(SD_VERSION)"'
|
||||
|
||||
_VER = $(subst ., ,$(word 1, $(subst -, ,$(GIT_VERSION))))
|
||||
CFLAGS += -DMK_BOOTLOADER_VERSION='($(word 1,$(_VER)) << 16) + ($(word 2,$(_VER)) << 8) + $(word 3,$(_VER))'
|
||||
|
||||
# Debug option use RTT for printf
|
||||
ifeq ($(DEBUG), 1)
|
||||
CFLAGS += -DCFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
|
||||
RTT_SRC = lib/SEGGER_RTT
|
||||
IPATH += $(RTT_SRC)/RTT
|
||||
C_SRC += $(RTT_SRC)/RTT/SEGGER_RTT.c
|
||||
endif
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Linker Flags
|
||||
#------------------------------------------------------------------------------
|
||||
@@ -353,6 +373,10 @@ clean:
|
||||
@$(RM) $(BUILD)
|
||||
@$(RM) $(BIN)
|
||||
|
||||
# linkermap must be install previously at https://github.com/hathach/linkermap
|
||||
linkermap: $(BUILD)/$(OUT_NAME).out
|
||||
@linkermap -v $<.map
|
||||
|
||||
# Create objects from C SRC files
|
||||
$(BUILD)/%.o: %.c
|
||||
@echo CC $(notdir $<)
|
||||
|
||||
@@ -10,6 +10,7 @@ This is a CDC/DFU/UF2 bootloader for nRF52 boards.
|
||||
- [Adafruit Feather nRF52840 Express](https://www.adafruit.com/product/4062)
|
||||
- [Adafruit Feather nRF52840 Sense](https://www.adafruit.com/product/4516)
|
||||
- [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/)
|
||||
@@ -20,6 +21,7 @@ This is a CDC/DFU/UF2 bootloader for nRF52 boards.
|
||||
- Particle Argon
|
||||
- Particle Boron
|
||||
- Particle Xenon
|
||||
- [SparkFun MicroMod nRF52840](https://www.sparkfun.com/products/16984)
|
||||
|
||||
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.
|
||||
@@ -57,6 +59,14 @@ There are two pins, `DFU` and `FRST` that bootloader will check upon reset/power
|
||||
- The `GPREGRET` register can also be set to force the bootloader can enter any of above modes (plus a CDC-only mode for Arduino).
|
||||
`GPREGRET` is set by the application before performing a soft reset.
|
||||
|
||||
```c
|
||||
#include "nrf_nvic.h"
|
||||
void reset_to_uf2(void) {
|
||||
NRF_POWER->GPREGRET = 0x57; // 0xA8 OTA, 0x4e Serial
|
||||
NVIC_SystemReset(); // or sd_nvic_SystemReset();
|
||||
}
|
||||
```
|
||||
|
||||
On the Nordic PCA10056 DK board, `DFU` is connected to **Button1**, and `FRST` is connected to **Button2**.
|
||||
So holding down **Button1** while clicking **RESET** will put the board into USB bootloader mode, with UF2 and CDC support.
|
||||
Holding down **Button2** while clicking **RESET** will put the board into OTA (over-the-air) bootloader mode.
|
||||
@@ -69,7 +79,7 @@ For other boards, please check the board definition for details.
|
||||
|
||||
### Making your own UF2
|
||||
|
||||
To create your own UF2 DFU update image, simply use the [Python conversion script](https://github.com/Microsoft/uf2/blob/master/utils/uf2conv.py) on a .bin file or .hex file, specifying the family as **0xADA52840**. If using a .bin file with the conversion script you must specify application address with the -b switch, this address depend on the SoftDevice size/version e.g S140 v6 is 0x26000
|
||||
To create your own UF2 DFU update image, simply use the [Python conversion script](https://github.com/Microsoft/uf2/blob/master/utils/uf2conv.py) on a .bin file or .hex file, specifying the family as **0xADA52840**. If using a .bin file with the conversion script you must specify application address with the -b switch, this address depend on the SoftDevice size/version e.g S140 v6 is 0x26000
|
||||
|
||||
To create a UF2 image from a .bin file:
|
||||
```
|
||||
@@ -105,6 +115,15 @@ You must have have a J-Link available to "unbrick" your device.
|
||||
Prerequisites
|
||||
|
||||
- ARM GCC
|
||||
|
||||
To install for macos
|
||||
|
||||
```bash
|
||||
brew tap ArmMbed/homebrew-formulae
|
||||
brew install arm-none-eabi-gcc
|
||||
brew link --overwrite arm-none-eabi-gcc # if a prior version was present
|
||||
```
|
||||
|
||||
- Nordic's [nRF5x Command Line Tools](https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Command-Line-Tools)
|
||||
- [Python IntelHex](https://pypi.org/project/IntelHex/)
|
||||
|
||||
@@ -148,7 +167,7 @@ Makefile:90: *** BOARD not defined. Stop
|
||||
If you get the following error ...
|
||||
|
||||
```
|
||||
$ make BOARD=feather_nrf52840_express all
|
||||
$ make BOARD=feather_nrf52840_express all
|
||||
Compiling file: main.c
|
||||
/bin/sh: /usr/bin/arm-none-eabi-gcc: No such file or directory
|
||||
make: *** [_build/main.o] Error 127
|
||||
@@ -160,6 +179,8 @@ the variable `CROSS_COMPILE` as below:
|
||||
$ make CROSS_COMPILE=/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi- BOARD=feather_nrf52832 all
|
||||
```
|
||||
|
||||
For other compile errors, check the gcc version with `arm-none-eabi-gcc --version` to insure it is at least 9.x.
|
||||
|
||||
#### 2. `ModuleNotFoundError: No module named 'intelhex'`
|
||||
|
||||
Install python-intelhex with
|
||||
@@ -169,9 +190,6 @@ pip install intelhex
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### 3. `make: nrfjprog: No such file or directory`
|
||||
|
||||
Make sure that `nrfjprog` is available from the command-line. This binary is
|
||||
|
||||
@@ -1,5 +1,35 @@
|
||||
# Adafruit nRF52 Bootloader Changelog
|
||||
|
||||
## 0.6.2 - 2021.09.10
|
||||
|
||||
- Add new board "LED Glasses Driver nRF52840"
|
||||
|
||||
## 0.6.1 - 2021.08.04
|
||||
|
||||
- Fix failed to upgrade ssue when flashing uf2 with more than 512KB payload
|
||||
- Increased application reserved from 28KB to 40KB for nrf52840 to match circuitpython usage.
|
||||
|
||||
## 0.6.0 - 2021.06.19
|
||||
|
||||
- Update tinyusb to latest to fix the race condition with control transfer, which could cause failed to connect to DFU Serial occasionally.
|
||||
|
||||
## 0.5.1 - 2021.06.02
|
||||
|
||||
- more boards support
|
||||
|
||||
## 0.5.0 - 2021.04.04
|
||||
|
||||
- Update tinyusb to latest to fix the race condition causing cdc out dropping packet. Which cause DFU failed occasionally
|
||||
- Add support for Dotstar LED (APA102)
|
||||
- Add sparkfun_nrf52840_micromod board
|
||||
- Allow skipping DFU entirely when reset or wakeup from deep sleep
|
||||
- Fix an issue with OTA when using shared bond with application
|
||||
|
||||
## 0.4.1 - 2021.02.17
|
||||
|
||||
- Add USB connect timeout for app reset to UF2 or Serial via GPREGRET
|
||||
- Fix pollution of REGOUT0 reserved bits
|
||||
|
||||
## 0.4.0 - 2021.01.19
|
||||
|
||||
- Decouple bootloader and softdevice i.e bootloader will always work with and/or without softdevice present. This allows application to pack firmware + softdevice into an uf2/serial for DFU.
|
||||
|
||||
@@ -463,7 +463,7 @@ uint32_t ble_dfu_init(ble_dfu_t * p_dfu, ble_dfu_init_t * p_dfu_init)
|
||||
|
||||
p_dfu->conn_handle = BLE_CONN_HANDLE_INVALID;
|
||||
|
||||
ble_uuid_t service_uuid;
|
||||
ble_uuid_t service_uuid = {0};
|
||||
uint32_t err_code;
|
||||
|
||||
const ble_uuid128_t base_uuid128 =
|
||||
|
||||
@@ -207,153 +207,151 @@ void bootloader_dfu_update_process(dfu_update_status_t update_status)
|
||||
__attribute__((aligned(4))) static bootloader_settings_t settings;
|
||||
bootloader_settings_t const * p_bootloader_settings;
|
||||
|
||||
bootloader_util_settings_get(&p_bootloader_settings);
|
||||
bootloader_util_settings_get(&p_bootloader_settings);
|
||||
|
||||
if (update_status.status_code == DFU_UPDATE_APP_COMPLETE)
|
||||
if (update_status.status_code == DFU_UPDATE_APP_COMPLETE)
|
||||
{
|
||||
settings.bank_0_crc = update_status.app_crc;
|
||||
settings.bank_0_size = update_status.app_size;
|
||||
settings.bank_0 = BANK_VALID_APP;
|
||||
settings.bank_1 = BANK_INVALID_APP;
|
||||
|
||||
m_update_status = BOOTLOADER_SETTINGS_SAVING;
|
||||
bootloader_settings_save(&settings);
|
||||
}
|
||||
else if (update_status.status_code == DFU_UPDATE_SD_COMPLETE)
|
||||
{
|
||||
settings.bank_0_crc = update_status.app_crc;
|
||||
settings.bank_0_size = update_status.sd_size + update_status.bl_size + update_status.app_size;
|
||||
settings.bank_0 = BANK_VALID_SD;
|
||||
settings.bank_1 = BANK_INVALID_APP;
|
||||
settings.sd_image_size = update_status.sd_size;
|
||||
settings.bl_image_size = update_status.bl_size;
|
||||
settings.app_image_size = update_status.app_size;
|
||||
settings.sd_image_start = update_status.sd_image_start;
|
||||
|
||||
m_update_status = BOOTLOADER_SETTINGS_SAVING;
|
||||
bootloader_settings_save(&settings);
|
||||
}
|
||||
else if (update_status.status_code == DFU_UPDATE_BOOT_COMPLETE)
|
||||
{
|
||||
settings.bank_0 = p_bootloader_settings->bank_0;
|
||||
settings.bank_0_crc = p_bootloader_settings->bank_0_crc;
|
||||
settings.bank_0_size = p_bootloader_settings->bank_0_size;
|
||||
settings.bank_1 = BANK_VALID_BOOT;
|
||||
settings.sd_image_size = update_status.sd_size;
|
||||
settings.bl_image_size = update_status.bl_size;
|
||||
settings.app_image_size = update_status.app_size;
|
||||
|
||||
m_update_status = BOOTLOADER_SETTINGS_SAVING;
|
||||
bootloader_settings_save(&settings);
|
||||
}
|
||||
else if (update_status.status_code == DFU_UPDATE_SD_SWAPPED)
|
||||
{
|
||||
if (p_bootloader_settings->bank_0 == BANK_VALID_SD)
|
||||
{
|
||||
settings.bank_0_crc = update_status.app_crc;
|
||||
settings.bank_0_size = update_status.app_size;
|
||||
settings.bank_0 = BANK_VALID_APP;
|
||||
settings.bank_1 = BANK_INVALID_APP;
|
||||
|
||||
m_update_status = BOOTLOADER_SETTINGS_SAVING;
|
||||
bootloader_settings_save(&settings);
|
||||
}
|
||||
else if (update_status.status_code == DFU_UPDATE_SD_COMPLETE)
|
||||
{
|
||||
settings.bank_0_crc = update_status.app_crc;
|
||||
settings.bank_0_size = update_status.sd_size +
|
||||
update_status.bl_size +
|
||||
update_status.app_size;
|
||||
settings.bank_0 = BANK_VALID_SD;
|
||||
settings.bank_1 = BANK_INVALID_APP;
|
||||
settings.sd_image_size = update_status.sd_size;
|
||||
settings.bl_image_size = update_status.bl_size;
|
||||
settings.app_image_size = update_status.app_size;
|
||||
settings.sd_image_start = update_status.sd_image_start;
|
||||
|
||||
m_update_status = BOOTLOADER_SETTINGS_SAVING;
|
||||
bootloader_settings_save(&settings);
|
||||
}
|
||||
else if (update_status.status_code == DFU_UPDATE_BOOT_COMPLETE)
|
||||
{
|
||||
settings.bank_0 = p_bootloader_settings->bank_0;
|
||||
settings.bank_0_crc = p_bootloader_settings->bank_0_crc;
|
||||
settings.bank_0_size = p_bootloader_settings->bank_0_size;
|
||||
settings.bank_1 = BANK_VALID_BOOT;
|
||||
settings.sd_image_size = update_status.sd_size;
|
||||
settings.bl_image_size = update_status.bl_size;
|
||||
settings.app_image_size = update_status.app_size;
|
||||
|
||||
m_update_status = BOOTLOADER_SETTINGS_SAVING;
|
||||
bootloader_settings_save(&settings);
|
||||
}
|
||||
else if (update_status.status_code == DFU_UPDATE_SD_SWAPPED)
|
||||
{
|
||||
if (p_bootloader_settings->bank_0 == BANK_VALID_SD)
|
||||
{
|
||||
settings.bank_0_crc = 0;
|
||||
settings.bank_0_size = 0;
|
||||
settings.bank_0 = BANK_INVALID_APP;
|
||||
}
|
||||
// This handles cases where SoftDevice was not updated, hence bank0 keeps its settings.
|
||||
else
|
||||
{
|
||||
settings.bank_0 = p_bootloader_settings->bank_0;
|
||||
settings.bank_0_crc = p_bootloader_settings->bank_0_crc;
|
||||
settings.bank_0_size = p_bootloader_settings->bank_0_size;
|
||||
}
|
||||
|
||||
settings.bank_1 = BANK_INVALID_APP;
|
||||
settings.sd_image_size = 0;
|
||||
settings.bl_image_size = 0;
|
||||
settings.app_image_size = 0;
|
||||
|
||||
m_update_status = BOOTLOADER_SETTINGS_SAVING;
|
||||
bootloader_settings_save(&settings);
|
||||
}
|
||||
else if (update_status.status_code == DFU_TIMEOUT)
|
||||
{
|
||||
// Timeout has occurred. Close the connection with the DFU Controller.
|
||||
uint32_t err_code;
|
||||
if ( is_ota() )
|
||||
{
|
||||
err_code = dfu_transport_ble_close();
|
||||
}else
|
||||
{
|
||||
err_code = dfu_transport_serial_close();
|
||||
}
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
m_update_status = BOOTLOADER_TIMEOUT;
|
||||
}
|
||||
else if (update_status.status_code == DFU_BANK_0_ERASED)
|
||||
{
|
||||
settings.bank_0_crc = 0;
|
||||
settings.bank_0_size = 0;
|
||||
settings.bank_0 = BANK_INVALID_APP;
|
||||
settings.bank_1 = p_bootloader_settings->bank_1;
|
||||
|
||||
bootloader_settings_save(&settings);
|
||||
}
|
||||
else if (update_status.status_code == DFU_RESET)
|
||||
{
|
||||
m_update_status = BOOTLOADER_RESET;
|
||||
settings.bank_0_crc = 0;
|
||||
settings.bank_0_size = 0;
|
||||
settings.bank_0 = BANK_INVALID_APP;
|
||||
}
|
||||
// This handles cases where SoftDevice was not updated, hence bank0 keeps its settings.
|
||||
else
|
||||
{
|
||||
// No implementation needed.
|
||||
settings.bank_0 = p_bootloader_settings->bank_0;
|
||||
settings.bank_0_crc = p_bootloader_settings->bank_0_crc;
|
||||
settings.bank_0_size = p_bootloader_settings->bank_0_size;
|
||||
}
|
||||
|
||||
settings.bank_1 = BANK_INVALID_APP;
|
||||
settings.sd_image_size = 0;
|
||||
settings.bl_image_size = 0;
|
||||
settings.app_image_size = 0;
|
||||
|
||||
m_update_status = BOOTLOADER_SETTINGS_SAVING;
|
||||
bootloader_settings_save(&settings);
|
||||
}
|
||||
else if (update_status.status_code == DFU_TIMEOUT)
|
||||
{
|
||||
// Timeout has occurred. Close the connection with the DFU Controller.
|
||||
uint32_t err_code;
|
||||
if ( is_ota() )
|
||||
{
|
||||
err_code = dfu_transport_ble_close();
|
||||
}else
|
||||
{
|
||||
err_code = dfu_transport_serial_close();
|
||||
}
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
m_update_status = BOOTLOADER_TIMEOUT;
|
||||
}
|
||||
else if (update_status.status_code == DFU_BANK_0_ERASED)
|
||||
{
|
||||
settings.bank_0_crc = 0;
|
||||
settings.bank_0_size = 0;
|
||||
settings.bank_0 = BANK_INVALID_APP;
|
||||
settings.bank_1 = p_bootloader_settings->bank_1;
|
||||
|
||||
bootloader_settings_save(&settings);
|
||||
}
|
||||
else if (update_status.status_code == DFU_RESET)
|
||||
{
|
||||
m_update_status = BOOTLOADER_RESET;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No implementation needed.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint32_t bootloader_init(void)
|
||||
{
|
||||
uint32_t err_code;
|
||||
pstorage_module_param_t storage_params = {.cb = pstorage_callback_handler};
|
||||
uint32_t err_code;
|
||||
pstorage_module_param_t storage_params = {.cb = pstorage_callback_handler};
|
||||
|
||||
err_code = pstorage_init();
|
||||
VERIFY_SUCCESS(err_code);
|
||||
err_code = pstorage_init();
|
||||
VERIFY_SUCCESS(err_code);
|
||||
|
||||
m_bootsettings_handle.block_id = BOOTLOADER_SETTINGS_ADDRESS;
|
||||
err_code = pstorage_register(&storage_params, &m_bootsettings_handle);
|
||||
m_bootsettings_handle.block_id = BOOTLOADER_SETTINGS_ADDRESS;
|
||||
err_code = pstorage_register(&storage_params, &m_bootsettings_handle);
|
||||
|
||||
return err_code;
|
||||
return err_code;
|
||||
}
|
||||
|
||||
|
||||
uint32_t bootloader_dfu_start(bool ota, uint32_t timeout_ms, bool cancel_timeout_on_usb)
|
||||
{
|
||||
uint32_t err_code;
|
||||
uint32_t err_code;
|
||||
|
||||
m_cancel_timeout_on_usb = cancel_timeout_on_usb && !ota;
|
||||
m_cancel_timeout_on_usb = cancel_timeout_on_usb && !ota;
|
||||
|
||||
// Clear swap if banked update is used.
|
||||
err_code = dfu_init();
|
||||
VERIFY_SUCCESS(err_code);
|
||||
// Clear swap if banked update is used.
|
||||
err_code = dfu_init();
|
||||
VERIFY_SUCCESS(err_code);
|
||||
|
||||
if ( ota )
|
||||
if ( ota )
|
||||
{
|
||||
err_code = dfu_transport_ble_update_start();
|
||||
}else
|
||||
{
|
||||
// DFU mode with timeout can be
|
||||
// - Forced startup DFU for nRF52832 or
|
||||
// - Makecode single tap reset but no enumerated (battery power)
|
||||
if ( timeout_ms )
|
||||
{
|
||||
err_code = dfu_transport_ble_update_start();
|
||||
}else
|
||||
{
|
||||
// DFU mode with timeout can be
|
||||
// - Forced startup DFU for nRF52832 or
|
||||
// - Makecode single tap reset but no enumerated (battery power)
|
||||
if ( timeout_ms )
|
||||
{
|
||||
dfu_startup_packet_received = false;
|
||||
dfu_startup_packet_received = false;
|
||||
|
||||
app_timer_create(&_dfu_startup_timer, APP_TIMER_MODE_SINGLE_SHOT, dfu_startup_timer_handler);
|
||||
app_timer_start(_dfu_startup_timer, APP_TIMER_TICKS(timeout_ms), NULL);
|
||||
}
|
||||
|
||||
err_code = dfu_transport_serial_update_start();
|
||||
app_timer_create(&_dfu_startup_timer, APP_TIMER_MODE_SINGLE_SHOT, dfu_startup_timer_handler);
|
||||
app_timer_start(_dfu_startup_timer, APP_TIMER_TICKS(timeout_ms), NULL);
|
||||
}
|
||||
|
||||
wait_for_events();
|
||||
err_code = dfu_transport_serial_update_start();
|
||||
}
|
||||
|
||||
return err_code;
|
||||
wait_for_events();
|
||||
|
||||
return err_code;
|
||||
}
|
||||
|
||||
void bootloader_app_start(void)
|
||||
@@ -408,55 +406,55 @@ bool bootloader_dfu_sd_in_progress(void)
|
||||
{
|
||||
bootloader_settings_t const * p_bootloader_settings;
|
||||
|
||||
bootloader_util_settings_get(&p_bootloader_settings);
|
||||
bootloader_util_settings_get(&p_bootloader_settings);
|
||||
|
||||
if (p_bootloader_settings->bank_0 == BANK_VALID_SD ||
|
||||
p_bootloader_settings->bank_1 == BANK_VALID_BOOT)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (p_bootloader_settings->bank_0 == BANK_VALID_SD ||
|
||||
p_bootloader_settings->bank_1 == BANK_VALID_BOOT)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
uint32_t bootloader_dfu_sd_update_continue(void)
|
||||
{
|
||||
uint32_t err_code;
|
||||
uint32_t err_code;
|
||||
|
||||
if ((dfu_sd_image_validate() == NRF_SUCCESS) &&
|
||||
(dfu_bl_image_validate() == NRF_SUCCESS))
|
||||
{
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
if ((dfu_sd_image_validate() == NRF_SUCCESS) &&
|
||||
(dfu_bl_image_validate() == NRF_SUCCESS))
|
||||
{
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
// Ensure that flash operations are not executed within the first 100 ms seconds to allow
|
||||
// a debugger to be attached.
|
||||
NRFX_DELAY_MS(100);
|
||||
// Ensure that flash operations are not executed within the first 100 ms seconds to allow
|
||||
// a debugger to be attached.
|
||||
NRFX_DELAY_MS(100);
|
||||
|
||||
err_code = dfu_sd_image_swap();
|
||||
APP_ERROR_CHECK(err_code);
|
||||
err_code = dfu_sd_image_swap();
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
err_code = dfu_sd_image_validate();
|
||||
APP_ERROR_CHECK(err_code);
|
||||
err_code = dfu_sd_image_validate();
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
err_code = dfu_bl_image_swap();
|
||||
APP_ERROR_CHECK(err_code);
|
||||
err_code = dfu_bl_image_swap();
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
return err_code;
|
||||
return err_code;
|
||||
}
|
||||
|
||||
|
||||
uint32_t bootloader_dfu_sd_update_finalize(void)
|
||||
{
|
||||
dfu_update_status_t update_status = { 0 };
|
||||
update_status.status_code = DFU_UPDATE_SD_SWAPPED;
|
||||
dfu_update_status_t update_status = { 0 };
|
||||
update_status.status_code = DFU_UPDATE_SD_SWAPPED;
|
||||
|
||||
bootloader_dfu_update_process(update_status);
|
||||
bootloader_dfu_update_process(update_status);
|
||||
|
||||
wait_for_events();
|
||||
wait_for_events();
|
||||
|
||||
return NRF_SUCCESS;
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -464,14 +462,14 @@ void bootloader_settings_get(bootloader_settings_t * const p_settings)
|
||||
{
|
||||
bootloader_settings_t const * p_bootloader_settings;
|
||||
|
||||
bootloader_util_settings_get(&p_bootloader_settings);
|
||||
bootloader_util_settings_get(&p_bootloader_settings);
|
||||
|
||||
p_settings->bank_0 = p_bootloader_settings->bank_0;
|
||||
p_settings->bank_0_crc = p_bootloader_settings->bank_0_crc;
|
||||
p_settings->bank_0_size = p_bootloader_settings->bank_0_size;
|
||||
p_settings->bank_1 = p_bootloader_settings->bank_1;
|
||||
p_settings->sd_image_size = p_bootloader_settings->sd_image_size;
|
||||
p_settings->bl_image_size = p_bootloader_settings->bl_image_size;
|
||||
p_settings->app_image_size = p_bootloader_settings->app_image_size;
|
||||
p_settings->sd_image_start = p_bootloader_settings->sd_image_start;
|
||||
p_settings->bank_0 = p_bootloader_settings->bank_0;
|
||||
p_settings->bank_0_crc = p_bootloader_settings->bank_0_crc;
|
||||
p_settings->bank_0_size = p_bootloader_settings->bank_0_size;
|
||||
p_settings->bank_1 = p_bootloader_settings->bank_1;
|
||||
p_settings->sd_image_size = p_bootloader_settings->sd_image_size;
|
||||
p_settings->bl_image_size = p_bootloader_settings->bl_image_size;
|
||||
p_settings->app_image_size = p_bootloader_settings->app_image_size;
|
||||
p_settings->sd_image_start = p_bootloader_settings->sd_image_start;
|
||||
}
|
||||
@@ -101,8 +101,7 @@ static void dfu_prepare_func_app_erase(uint32_t image_size)
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t page_count = m_image_size / CODE_PAGE_SIZE;
|
||||
if ( m_image_size % CODE_PAGE_SIZE ) page_count++;
|
||||
uint32_t const page_count = NRFX_CEIL_DIV(m_image_size, CODE_PAGE_SIZE);
|
||||
|
||||
for ( uint32_t i = 0; i < page_count; i++ )
|
||||
{
|
||||
|
||||
@@ -148,6 +148,7 @@ static uint32_t service_change_indicate()
|
||||
|
||||
err_code = sd_ble_gatts_service_changed(m_conn_handle, DFU_SERVICE_HANDLE, BLE_HANDLE_MAX);
|
||||
if ((err_code == BLE_ERROR_INVALID_CONN_HANDLE) ||
|
||||
(err_code == BLE_ERROR_INVALID_ATTR_HANDLE) ||
|
||||
(err_code == NRF_ERROR_INVALID_STATE) ||
|
||||
(err_code == NRF_ERROR_BUSY))
|
||||
{
|
||||
@@ -735,8 +736,8 @@ static void on_ble_evt(ble_evt_t * p_ble_evt)
|
||||
ble_gatts_rw_authorize_reply_params_t auth_reply;
|
||||
|
||||
#ifdef CFG_DEBUG
|
||||
extern const char* dbg_ble_event_str(uint16_t evt_id);
|
||||
PRINTF("BLE %s\r\n", dbg_ble_event_str(p_ble_evt->header.evt_id));
|
||||
extern void print_ble_event(uint16_t evt_id);
|
||||
print_ble_event(p_ble_evt->header.evt_id);
|
||||
#endif
|
||||
|
||||
switch (p_ble_evt->header.evt_id)
|
||||
@@ -1084,6 +1085,7 @@ uint32_t dfu_transport_ble_close()
|
||||
|
||||
#ifdef CFG_DEBUG
|
||||
|
||||
#if 0
|
||||
typedef struct
|
||||
{
|
||||
uint32_t key;
|
||||
@@ -1172,18 +1174,22 @@ lookup_table_t const _strevt_table =
|
||||
.items = _strevt_lookup
|
||||
};
|
||||
|
||||
const char* dbg_ble_event_str(uint16_t evt_id)
|
||||
{
|
||||
const char * str = (const char *) lookup_find(&_strevt_table, evt_id);
|
||||
static char unknown_str[7] = {0};
|
||||
#endif
|
||||
|
||||
void print_ble_event(uint16_t evt_id)
|
||||
{
|
||||
// const char * str = (const char *) lookup_find(&_strevt_table, evt_id);
|
||||
const char * str = NULL;
|
||||
PRINTF("BLE event: ");
|
||||
if ( str == NULL )
|
||||
{
|
||||
sprintf(unknown_str, "0x%04X", evt_id);
|
||||
str = unknown_str;
|
||||
PRINTF("0x%04X", evt_id);
|
||||
}else
|
||||
{
|
||||
PRINTF(str);
|
||||
}
|
||||
|
||||
return str;
|
||||
PRINTF("\r\n");
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -47,14 +47,14 @@ static inline bool is_sd_existed(void)
|
||||
#define SOFTDEVICE_REGION_START MBR_SIZE /**< 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. */
|
||||
#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. */
|
||||
|
||||
// Flash = 512 KB
|
||||
#if defined(NRF52832_XXAA) || defined(NRF52833_XXAA)
|
||||
// Flash = 512 KB
|
||||
#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. */
|
||||
#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. */
|
||||
|
||||
// Flash = 1024 KB
|
||||
#elif defined(NRF52840_XXAA)
|
||||
// Flash = 1024 KB
|
||||
#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. */
|
||||
#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. */
|
||||
@@ -66,18 +66,12 @@ static inline bool is_sd_existed(void)
|
||||
#define DFU_REGION_TOTAL_SIZE (BOOTLOADER_REGION_START - CODE_REGION_1_START) /**< Total size of the region between SD and Bootloader. */
|
||||
|
||||
#ifndef DFU_APP_DATA_RESERVED
|
||||
#define DFU_APP_DATA_RESERVED CODE_PAGE_SIZE*7 /**< Size of Application Data that must be preserved between application updates. This value must be a multiple of page size. Page size is 0x400 (1024d) bytes, thus this value must be 0x0000, 0x0400, 0x0800, 0x0C00, 0x1000, etc. */
|
||||
#error "DFU_APP_DATA_RESERVED is not defined"
|
||||
#endif
|
||||
|
||||
#define DFU_IMAGE_MAX_SIZE_FULL (DFU_REGION_TOTAL_SIZE - DFU_APP_DATA_RESERVED) /**< Maximum size of an application, excluding save data from the application. */
|
||||
|
||||
#define DFU_IMAGE_MAX_SIZE_BANKED (((DFU_IMAGE_MAX_SIZE_FULL) - \
|
||||
(DFU_IMAGE_MAX_SIZE_FULL % (2 * CODE_PAGE_SIZE)))/2) /**< Maximum size of an application, excluding save data from the application. */
|
||||
|
||||
#define DFU_BL_IMAGE_MAX_SIZE (BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS - BOOTLOADER_REGION_START) /**< Maximum size of a bootloader, excluding save data from the current bootloader. */
|
||||
|
||||
#define DFU_BL_IMAGE_MAX_SIZE (BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS - BOOTLOADER_REGION_START) /**< Maximum size of a bootloader, excluding save data from the current bootloader. */
|
||||
#define DFU_BANK_0_REGION_START CODE_REGION_1_START /**< Bank 0 region start. */
|
||||
#define DFU_BANK_1_REGION_START (DFU_BANK_0_REGION_START + DFU_IMAGE_MAX_SIZE_BANKED) /**< Bank 1 region start. */
|
||||
|
||||
#define EMPTY_FLASH_MASK 0xFFFFFFFF /**< Bit mask that defines an empty address in flash. */
|
||||
|
||||
|
||||
Binary file not shown.
+1
-1
Submodule lib/tinyusb updated: 4e6aa0d81d...9775e76910.
+2
-2
@@ -11,9 +11,9 @@ MEMORY
|
||||
* 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 = 0xF4000, LENGTH = 0xFE000-0xF4000-2048 /* 38 KB */
|
||||
FLASH (rx) : ORIGIN = 0xF4000, LENGTH = 0xFE000-0xF4000 - 2K /* 38 KB */
|
||||
|
||||
BOOTLOADER_CONFIG (r): ORIGIN = 0xFE000 - 2048, LENGTH = 2048
|
||||
BOOTLOADER_CONFIG (r): ORIGIN = 0xFE000 - 2K, LENGTH = 2K
|
||||
|
||||
/** Location of mbr params page in flash. */
|
||||
MBR_PARAMS_PAGE (rw) : ORIGIN = 0xFE000, LENGTH = 0x1000
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2021 Benjamin Meisels
|
||||
*
|
||||
* 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 _ARAMCON2_BADGE_H
|
||||
#define _ARAMCON2_BADGE_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 1
|
||||
#define LED_PRIMARY_PIN _PINNUM(1, 11) // Red
|
||||
|
||||
#define LED_NEOPIXEL _PINNUM(0, 8)
|
||||
#define NEOPIXELS_NUMBER 2
|
||||
#define BOARD_RGB_BRIGHTNESS 0x040404
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
#define BUTTON_1 _PINNUM(0, 2) // left Button
|
||||
#define BUTTON_2 _PINNUM(0, 29) // middle button
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
// Used as model string in OTA mode
|
||||
#define BLEDIS_MANUFACTURER "ARAMCON Badge Team"
|
||||
#define BLEDIS_MODEL "ARAMCON2 Badge"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x007B
|
||||
#define USB_DESC_CDC_ONLY_PID 0x007B
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "ARAMCON2 Badge"
|
||||
#define UF2_VOLUME_LABEL "ARAMBOOT"
|
||||
#define UF2_BOARD_ID "nrf52840-ARAMCON2-Badge"
|
||||
#define UF2_INDEX_URL "https://github.com/aramcon-badge"
|
||||
|
||||
#endif // _ARAMCON2_BADGE_H
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -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,69 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Pierre Constantineau
|
||||
*
|
||||
* 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 _BLUEMICRO_NRF52833_H
|
||||
#define _BLUEMICRO_NRF52833_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 2
|
||||
#define LED_PRIMARY_PIN _PINNUM(1, 4)
|
||||
#define LED_SECONDARY_PIN _PINNUM(0, 25)
|
||||
#define LED_STATE_ON 1
|
||||
|
||||
#define LED_NEOPIXEL _PINNUM(0, 7)
|
||||
#define NEOPIXELS_NUMBER 1
|
||||
#define BOARD_RGB_BRIGHTNESS 0x040404
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2 // none connected at all
|
||||
#define BUTTON_1 _PINNUM(0, 18) // unusable: RESET
|
||||
#define BUTTON_2 _PINNUM(1, 1) // no connection on E73-2G4M08S1E Module
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "BlueMicro"
|
||||
#define BLEDIS_MODEL "BlueMicro 833"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB PID from openmoko:
|
||||
// PR https://github.com/openmoko/openmoko-usb-oui/pull/34
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x1d50
|
||||
#define USB_DESC_UF2_PID 0x616f
|
||||
#define USB_DESC_CDC_ONLY_PID 0x616f
|
||||
|
||||
#define UF2_PRODUCT_NAME "BlueMicro"
|
||||
#define UF2_VOLUME_LABEL "BLUEMICRO"
|
||||
#define UF2_BOARD_ID "nRF52833-BlueMicro-v1"
|
||||
#define UF2_INDEX_URL "http://bluemicro.jpconstantineau.com/"
|
||||
|
||||
#endif // _BLUEMICRO_H
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52833
|
||||
@@ -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 */
|
||||
};
|
||||
+103
-9
@@ -27,13 +27,17 @@
|
||||
#include "app_scheduler.h"
|
||||
#include "app_timer.h"
|
||||
|
||||
#ifdef LED_APA102
|
||||
#include "nrf_spim.h"
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
|
||||
//--------------------------------------------------------------------+
|
||||
#define SCHED_MAX_EVENT_DATA_SIZE sizeof(app_timer_event_t) /**< Maximum size of scheduler events. */
|
||||
#define SCHED_QUEUE_SIZE 30 /**< Maximum number of events in the scheduler queue. */
|
||||
|
||||
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN)
|
||||
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN) || defined(LED_APA102)
|
||||
void neopixel_init(void);
|
||||
void neopixel_write(uint8_t *pixels);
|
||||
void neopixel_teardown(void);
|
||||
@@ -71,14 +75,15 @@ void board_init(void)
|
||||
button_init(BUTTON_FRESET);
|
||||
NRFX_DELAY_US(100); // wait for the pin state is stable
|
||||
|
||||
#if LEDS_NUMBER > 0
|
||||
// use PMW0 for LED RED
|
||||
led_pwm_init(LED_PRIMARY, LED_PRIMARY_PIN);
|
||||
#if LEDS_NUMBER > 1
|
||||
led_pwm_init(LED_SECONDARY, LED_SECONDARY_PIN);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
// use neopixel for use enumeration
|
||||
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN)
|
||||
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN) || defined(LED_APA102)
|
||||
neopixel_init();
|
||||
#endif
|
||||
|
||||
@@ -94,11 +99,13 @@ void board_init(void)
|
||||
// #define UICR_REGOUT0_VALUE UICR_REGOUT0_VOUT_3V3
|
||||
// in board.h when using that power configuration.
|
||||
#ifdef UICR_REGOUT0_VALUE
|
||||
if (NRF_UICR->REGOUT0 != UICR_REGOUT0_VALUE)
|
||||
if ((NRF_UICR->REGOUT0 & UICR_REGOUT0_VOUT_Msk) !=
|
||||
(UICR_REGOUT0_VALUE << UICR_REGOUT0_VOUT_Pos))
|
||||
{
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||
NRF_UICR->REGOUT0 = UICR_REGOUT0_VALUE;
|
||||
NRF_UICR->REGOUT0 = (NRF_UICR->REGOUT0 & ~((uint32_t)UICR_REGOUT0_VOUT_Msk)) |
|
||||
(UICR_REGOUT0_VALUE << UICR_REGOUT0_VOUT_Pos);
|
||||
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||
@@ -124,9 +131,11 @@ void board_teardown(void)
|
||||
SysTick->CTRL = 0;
|
||||
|
||||
// Disable and reset PWM for LEDs
|
||||
#if LEDS_NUMBER > 0
|
||||
led_pwm_teardown();
|
||||
#endif
|
||||
|
||||
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN)
|
||||
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN) || defined(LED_APA102)
|
||||
neopixel_teardown();
|
||||
#endif
|
||||
|
||||
@@ -315,13 +324,14 @@ void led_state(uint32_t state)
|
||||
} else if (temp_color_active) {
|
||||
final_color = (uint8_t*)&rgb_color;
|
||||
}
|
||||
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN)
|
||||
|
||||
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN) || defined(LED_APA102)
|
||||
if (final_color != NULL) {
|
||||
neopixel_write(final_color);
|
||||
}
|
||||
#else
|
||||
#else
|
||||
(void) final_color;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef LED_NEOPIXEL
|
||||
@@ -430,6 +440,90 @@ void neopixel_write (uint8_t *pixels)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LED_APA102
|
||||
#define BYTE_PER_PIXEL 4
|
||||
|
||||
// 4 zero bytes are required to initiate update
|
||||
#define PATTERN_SIZE() ((APA102_NUMBER*BYTE_PER_PIXEL) + 4)
|
||||
// N/2 * 1 bits are required at the end
|
||||
static uint8_t pixels_pattern[PATTERN_SIZE() + 4];
|
||||
|
||||
// use SPIM1 for dotstar
|
||||
void neopixel_init(void)
|
||||
{
|
||||
NRF_SPIM_Type* spi = NRF_SPIM1;
|
||||
|
||||
nrf_spim_disable(spi);
|
||||
|
||||
nrf_gpio_pin_set(LED_APA102_CLK);
|
||||
|
||||
nrf_gpio_cfg(LED_APA102_CLK,
|
||||
NRF_GPIO_PIN_DIR_OUTPUT,
|
||||
NRF_GPIO_PIN_INPUT_CONNECT,
|
||||
NRF_GPIO_PIN_NOPULL,
|
||||
NRF_GPIO_PIN_S0S1,
|
||||
NRF_GPIO_PIN_NOSENSE);
|
||||
|
||||
nrf_gpio_pin_clear(LED_APA102_DATA);
|
||||
nrf_gpio_cfg_output(LED_APA102_DATA);
|
||||
|
||||
nrf_spim_pins_set(spi, LED_APA102_CLK, LED_APA102_DATA, 0xFFFFFFFF);
|
||||
nrf_spim_frequency_set(spi, NRF_SPIM_FREQ_4M);
|
||||
nrf_spim_configure(spi, NRF_SPIM_MODE_3, NRF_SPIM_BIT_ORDER_MSB_FIRST);
|
||||
|
||||
nrf_spim_orc_set(spi, 0);
|
||||
nrf_spim_tx_list_disable(spi);
|
||||
|
||||
// Enable the spi
|
||||
nrf_spim_enable(spi);
|
||||
|
||||
uint8_t rgb[3] = {0, 0, 0 };
|
||||
neopixel_write(rgb);
|
||||
}
|
||||
|
||||
void neopixel_teardown(void)
|
||||
{
|
||||
uint8_t rgb[3] = {0, 0, 0 };
|
||||
neopixel_write(rgb);
|
||||
|
||||
NRF_SPIM_Type* spi = NRF_SPIM1;
|
||||
nrf_spim_disable(spi);
|
||||
}
|
||||
|
||||
// write 3 bytes color RGB to built-in neopixel
|
||||
void neopixel_write (uint8_t *pixels)
|
||||
{
|
||||
NRF_SPIM_Type* spi = NRF_SPIM1;
|
||||
|
||||
//brightness, blue, green, red
|
||||
uint8_t bbgr[BYTE_PER_PIXEL] = {0xE0 | LED_APA102_BRIGHTNESS, pixels[0], pixels[1], pixels[2]};
|
||||
pixels_pattern[0] = 0;
|
||||
pixels_pattern[1] = 0;
|
||||
pixels_pattern[2] = 0;
|
||||
pixels_pattern[3] = 0;
|
||||
|
||||
for (uint8_t i = 4; i < PATTERN_SIZE(); i+=4) {
|
||||
pixels_pattern[i] = bbgr[0];
|
||||
pixels_pattern[i+1] = bbgr[1];
|
||||
pixels_pattern[i+2] = bbgr[2];
|
||||
pixels_pattern[i+3] = bbgr[3];
|
||||
}
|
||||
|
||||
pixels_pattern[PATTERN_SIZE()] = 0xff;
|
||||
pixels_pattern[PATTERN_SIZE()+1] = 0xff;
|
||||
pixels_pattern[PATTERN_SIZE()+2] = 0xff;
|
||||
pixels_pattern[PATTERN_SIZE()+3] = 0xff;
|
||||
|
||||
nrf_spim_tx_buffer_set(spi, pixels_pattern, PATTERN_SIZE() + 4);
|
||||
nrf_spim_event_clear(spi, NRF_SPIM_EVENT_ENDTX);
|
||||
|
||||
nrf_spim_task_trigger(spi, NRF_SPIM_TASK_START);
|
||||
|
||||
while(!nrf_spim_event_check(spi, NRF_SPIM_EVENT_ENDTX));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(LED_RGB_RED_PIN) && defined(LED_RGB_GREEN_PIN) && defined(LED_RGB_BLUE_PIN)
|
||||
|
||||
#ifdef LED_SECONDARY_PIN
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2021 Pierre Constantineau
|
||||
*
|
||||
* 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 _EBYTE_E104_BT5032A_H
|
||||
#define _EBYTE_E104_BT5032A_H
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 2
|
||||
#define LED_PRIMARY_PIN 31 // Red - named "Data"
|
||||
#define LED_SECONDARY_PIN 30 // Blue - named "Link" (also a red one on the Test Board)
|
||||
#define LED_STATE_ON 0
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
#define BUTTON_1 29 // DISC Button on E104-BT5032A-TB Test Board
|
||||
// BUTTON_1 is DFU. The module does not have reset circuitry.
|
||||
// The Test Board from Ebyte (E104-BT5032A-TB) also does not have reset circuitry
|
||||
// To be able to upload using the Arduino IDE, (To enter DFU mode)
|
||||
// Press "DISC", press and release "RST", then release "DISC"
|
||||
#define BUTTON_2 28 // No button - WKP pin
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* UART (only used by nRF52832)
|
||||
*------------------------------------------------------------------*/
|
||||
#define RX_PIN_NUMBER 14
|
||||
#define TX_PIN_NUMBER 18
|
||||
#define CTS_PIN_NUMBER 20
|
||||
#define RTS_PIN_NUMBER 19
|
||||
#define HWFC false // leaving it false to make GPIO available
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "CDEBYTE"
|
||||
#define BLEDIS_MODEL "E104-BT5032A"
|
||||
|
||||
#define UF2_PRODUCT_NAME "Ebyte E104-BT5032A nRF52832"
|
||||
#define UF2_INDEX_URL "https://www.ebyte.com/en/product-view-news.html?id=756"
|
||||
|
||||
#endif // _EBYTE_E104_BT5032A_H
|
||||
@@ -0,0 +1,2 @@
|
||||
# nrf52 is nrf52832
|
||||
MCU_SUB_VARIANT = nrf52
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2021 Pierre Constantineau
|
||||
*
|
||||
* 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 _EBYTE_E73_TBB_H
|
||||
#define _EBYTE_E73_TBB_H
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 2
|
||||
#define LED_PRIMARY_PIN 17 // Red - named "LED1"
|
||||
#define LED_SECONDARY_PIN 18 // Blue - named "LED2" (also a red one on the Test Board)
|
||||
#define LED_STATE_ON 0
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
#define BUTTON_1 14 // BUTTON_1 is DFU. SW1 on E73-TBB Test Board.
|
||||
// This Test board uses the E73-2G4M04S1B module which contains a nrf52832.
|
||||
// The module does not have reset circuitry.
|
||||
// The Test Board from Ebyte (E73-TBB) also does not have reset circuitry
|
||||
// To be able to upload using the Arduino IDE, (To enter DFU mode)
|
||||
// Press "SW1", momentarily ground "RST/P0.21", then release "SW1"
|
||||
#define BUTTON_2 13 // SW2 on board
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* UART (only used by nRF52832)
|
||||
*------------------------------------------------------------------*/
|
||||
#define RX_PIN_NUMBER 8
|
||||
#define TX_PIN_NUMBER 6
|
||||
#define CTS_PIN_NUMBER 5
|
||||
#define RTS_PIN_NUMBER 7
|
||||
#define HWFC false // leaving it false to make GPIO available
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "CDEBYTE"
|
||||
#define BLEDIS_MODEL "E73-TBB"
|
||||
|
||||
#define UF2_PRODUCT_NAME "Ebyte E73-TBB nRF52832"
|
||||
#define UF2_INDEX_URL "https://www.ebyte.com/en/product-view-news.aspx?id=889"
|
||||
|
||||
#endif // _EBYTE_E73_TBB_H
|
||||
@@ -0,0 +1,2 @@
|
||||
# nrf52 is nrf52832
|
||||
MCU_SUB_VARIANT = nrf52
|
||||
@@ -60,7 +60,8 @@
|
||||
#define UF2_BOARD_ID "nRF52840-Papyr-v1"
|
||||
#define UF2_INDEX_URL "https://docs.electronut.in/papyr"
|
||||
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x003B
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x003B
|
||||
#define USB_DESC_CDC_ONLY_PID 0x003B
|
||||
|
||||
#endif // PPAPYR_H
|
||||
@@ -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 _LEDGLASSES_NRF52840_H
|
||||
#define _LEDGLASSES_NRF52840_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 1
|
||||
#define LED_PRIMARY_PIN _PINNUM(0, 31)
|
||||
#define LED_STATE_ON 1
|
||||
|
||||
#define LED_NEOPIXEL _PINNUM(1, 15)
|
||||
#define NEOPIXELS_NUMBER 1
|
||||
#define BOARD_RGB_BRIGHTNESS 0x040404
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
#define BUTTON_1 _PINNUM(0, 30) // user switch
|
||||
#define BUTTON_2 _PINNUM(0, 28) // NC
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "Adafruit Industries"
|
||||
#define BLEDIS_MODEL "LED Glasses Driver nRF52840"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x010D
|
||||
#define USB_DESC_CDC_ONLY_PID 0x010E
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "Adafruit LED Glasses Driver nRF52840"
|
||||
#define UF2_VOLUME_LABEL "GLASSESBOOT"
|
||||
#define UF2_BOARD_ID "nRF52840-LedGlasses-revA"
|
||||
#define UF2_INDEX_URL "https://www.adafruit.com/product/5217"
|
||||
|
||||
#endif // _LEDGLASSES_NRF52840_H
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -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,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_M60_KEYBOARD_H_
|
||||
#define _MAKERDIARY_M60_KEYBOARD_H_
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 1
|
||||
#define LED_PRIMARY_PIN _PINNUM(0, 30) // Red
|
||||
#define LED_STATE_ON 0
|
||||
|
||||
#define LED_RGB_RED_PIN _PINNUM(0, 30)
|
||||
#define LED_RGB_GREEN_PIN _PINNUM(0, 29)
|
||||
#define LED_RGB_BLUE_PIN _PINNUM(0, 31)
|
||||
#define BOARD_RGB_BRIGHTNESS 0x404040
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
#define BUTTON_1 _PINNUM(0, 27)
|
||||
#define BUTTON_2 _PINNUM(1, 7)
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "Makerdiary"
|
||||
#define BLEDIS_MODEL "M60 Mechanical Keyboard"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x2886
|
||||
#define USB_DESC_UF2_PID 0xF00F
|
||||
#define USB_DESC_CDC_ONLY_PID 0xF00F
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// UF2
|
||||
//--------------------------------------------------------------------+
|
||||
#define UF2_PRODUCT_NAME "MakerDiary M60 Mechanical Keyboard"
|
||||
#define UF2_VOLUME_LABEL "M60KEYBOARD"
|
||||
#define UF2_BOARD_ID "M60KEYBOARD"
|
||||
#define UF2_INDEX_URL "https://wiki.makerdiary.com/m60/"
|
||||
|
||||
|
||||
#endif /* _MAKERDIARY_M60_KEYBOARD_H_ */
|
||||
@@ -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 */
|
||||
};
|
||||
@@ -27,6 +27,8 @@
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
#define UICR_REGOUT0_VALUE UICR_REGOUT0_VOUT_3V3
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
@@ -57,7 +59,7 @@
|
||||
|
||||
#define UF2_PRODUCT_NAME "nice!nano"
|
||||
#define UF2_VOLUME_LABEL "NICENANO"
|
||||
#define UF2_BOARD_ID "nRF52840-nicenano-v1"
|
||||
#define UF2_INDEX_URL "https://docs.nicekeyboards.com/#/nice!nano/"
|
||||
#define UF2_BOARD_ID "nRF52840-nicenano"
|
||||
#define UF2_INDEX_URL "https://nicekeyboards.com/docs/nice-nano"
|
||||
|
||||
#endif // _NICENANO_H
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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 RAYTAC_MDBT50Q_DB_40_H
|
||||
#define RAYTAC_MDBT50Q_DB_40_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 3
|
||||
/* This is the Green led marked D1 on the board */
|
||||
#define LED_PRIMARY_PIN _PINNUM(1, 13)
|
||||
/* This is the Red led marked D2 on the board */
|
||||
#define LED_SECONDARY_PIN _PINNUM(1, 14)
|
||||
/* This is the Blue led marked D3 on the board */
|
||||
#define LED_TERTIARY_PIN _PINNUM(1, 15)
|
||||
/* There are one more unpopulated LEDs, but for the purposes of bootloader that
|
||||
* doesn't matter. */
|
||||
#define LED_STATE_ON 0
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 4
|
||||
|
||||
#define BUTTON_1 _PINNUM(0, 11)
|
||||
#define BUTTON_2 _PINNUM(0, 12)
|
||||
#define BUTTON_3 _PINNUM(0, 24)
|
||||
#define BUTTON_4 _PINNUM(0, 25)
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "Raytac"
|
||||
#define BLEDIS_MODEL "MDBT50Q-DB-40"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x00BB
|
||||
#define USB_DESC_CDC_ONLY_PID 0x00BB
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "Raytac MDBT50Q Demo Board 40"
|
||||
#define UF2_VOLUME_LABEL "MDBT50QBOOT"
|
||||
#define UF2_BOARD_ID "nRF52840-MDBT50Q-1MV2"
|
||||
#define UF2_INDEX_URL "https://www.raytac.com/product/ins.php?index_id=81"
|
||||
|
||||
#endif // RAYTAC_MDBT50Q_DB_40_H
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -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 */
|
||||
};
|
||||
@@ -53,15 +53,14 @@
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// 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 0x010B
|
||||
#define USB_DESC_CDC_ONLY_PID 0x010B
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "Raytac MDBT50Q-RX"
|
||||
#define UF2_VOLUME_LABEL "MDBT50QBOOT"
|
||||
#define UF2_BOARD_ID "nRF52840-MDBT50Q_RX-verD"
|
||||
#define UF2_INDEX_URL "https://www.raytac.com/product/ins.php?index_id=89"
|
||||
#define UF2_INDEX_URL "https://www.adafruit.com/product/5199"
|
||||
|
||||
#endif // RAYTAC_MDBT50Q_RX_H
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 Ha Thach for Adafruit Industries
|
||||
* Copyright (c) 2021 Chris Marc Dailey
|
||||
*
|
||||
* 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 _SPARKFUN_NRF52840_MICROMOD_H_
|
||||
#define _SPARKFUN_NRF52840_MICROMOD_H_
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 1
|
||||
#define LED_PRIMARY_PIN _PINNUM(0, 13)
|
||||
#define LED_STATE_ON 1
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
#define BUTTON_1 _PINNUM(0, 7)
|
||||
#define BUTTON_2 _PINNUM(0, 10)
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "SparkFun"
|
||||
#define BLEDIS_MODEL "MicroMod nRF52840"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x1B4F
|
||||
#define USB_DESC_UF2_PID 0x0022
|
||||
#define USB_DESC_CDC_ONLY_PID 0x0023
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "SparkFun MicroMod nRF52840"
|
||||
#define UF2_VOLUME_LABEL "SFMM852BOOT"
|
||||
#define UF2_BOARD_ID "nRF52840-micromod-v10"
|
||||
|
||||
#define UF2_INDEX_URL "https://www.sparkfun.com/products/16984"
|
||||
|
||||
#endif /* _SPARKFUN_NRF52840_MICROMOD_H_ */
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -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 */
|
||||
};
|
||||
+154
-125
@@ -97,18 +97,21 @@ void usb_teardown(void);
|
||||
*/
|
||||
|
||||
/* Magic that written to NRF_POWER->GPREGRET by application when it wish to go into DFU
|
||||
* - DFU_MAGIC_OTA_APPJUM used by BLEDfu service : SD is already init
|
||||
* - DFU_MAGIC_OTA_RESET entered by soft reset : SD is not init
|
||||
* - DFU_MAGIC_SERIAL_ONLY_RESET with CDC interface only
|
||||
* - DFU_MAGIC_UF2_RESET with CDC and MSC interfaces
|
||||
* - DFU_MAGIC_OTA_APPJUM : used by BLEDfu service, SD is already inited
|
||||
* - DFU_MAGIC_OTA_RESET : entered by soft reset, SD is not inited yet
|
||||
* - DFU_MAGIC_SERIAL_ONLY_RESET : with CDC interface only
|
||||
* - DFU_MAGIC_UF2_RESET : with CDC and MSC interfaces
|
||||
* - DFU_MAGIC_SKIP : skip DFU entirely including double reset delay,
|
||||
* Can be used with systemoff or quick reset to app
|
||||
*
|
||||
* Note: for DFU_MAGIC_OTA_APPJUM Softdevice must not initialized.
|
||||
* since it is already in application. In all other case of OTA SD must be initialized
|
||||
*/
|
||||
#define DFU_MAGIC_OTA_APPJUM BOOTLOADER_DFU_START // 0xB1
|
||||
#define DFU_MAGIC_OTA_APPJUM BOOTLOADER_DFU_START // 0xB1
|
||||
#define DFU_MAGIC_OTA_RESET 0xA8
|
||||
#define DFU_MAGIC_SERIAL_ONLY_RESET 0x4e
|
||||
#define DFU_MAGIC_UF2_RESET 0x57
|
||||
#define DFU_MAGIC_SKIP 0x6d
|
||||
|
||||
#define DFU_DBL_RESET_MAGIC 0x5A1AD5 // SALADS
|
||||
#define DFU_DBL_RESET_APP 0x4ee5677e
|
||||
@@ -120,6 +123,7 @@ void usb_teardown(void);
|
||||
|
||||
// Allow for using reset button essentially to swap between application and bootloader.
|
||||
// This is controlled by a flag in the app and is the behavior of CPX and all Arcade boards when using MakeCode.
|
||||
// DFU_DBL_RESET magic is used to determined which mode is entered
|
||||
#define APP_ASKS_FOR_SINGLE_TAP_RESET() (*((uint32_t*)(DFU_BANK_0_REGION_START + 0x200)) == 0x87eeb07c)
|
||||
|
||||
// These value must be the same with one in dfu_transport_ble.c
|
||||
@@ -130,20 +134,24 @@ enum { BLE_CONN_CFG_HIGH_BANDWIDTH = 1 };
|
||||
//--------------------------------------------------------------------+
|
||||
//
|
||||
//--------------------------------------------------------------------+
|
||||
static uint32_t softdev_init(bool init_softdevice);
|
||||
|
||||
uint32_t* dbl_reset_mem = ((uint32_t*) DFU_DBL_RESET_MEM );
|
||||
|
||||
// true if ble, false if serial
|
||||
bool _ota_dfu = false;
|
||||
bool _ota_connected = false;
|
||||
bool _sd_inited = false;
|
||||
|
||||
bool is_ota(void)
|
||||
{
|
||||
return _ota_dfu;
|
||||
}
|
||||
|
||||
void softdev_mbr_init(void)
|
||||
static void check_dfu_mode(void);
|
||||
static uint32_t ble_stack_init(void);
|
||||
|
||||
// The SoftDevice must only be initialized if a chip reset has occurred.
|
||||
// Soft reset (jump ) from application must not reinitialize the SoftDevice.
|
||||
static void mbr_init_sd(void)
|
||||
{
|
||||
PRINTF("SD_MBR_COMMAND_INIT_SD\r\n");
|
||||
sd_mbr_command_t com = { .command = SD_MBR_COMMAND_INIT_SD };
|
||||
@@ -155,29 +163,11 @@ void softdev_mbr_init(void)
|
||||
//--------------------------------------------------------------------+
|
||||
int main(void)
|
||||
{
|
||||
PRINTF("Bootlaoder Start\r\n");
|
||||
|
||||
// Populate Boot Address and MBR Param into MBR if not already
|
||||
// MBR_BOOTLOADER_ADDR/MBR_PARAM_PAGE_ADDR are used if available, else UICR registers are used
|
||||
// Note: skip it for now since this will prevent us to change the size of bootloader in the future
|
||||
// bootloader_mbr_addrs_populate();
|
||||
|
||||
// SD is already Initialized in case of BOOTLOADER_DFU_OTA_MAGIC
|
||||
bool sd_inited = (NRF_POWER->GPREGRET == DFU_MAGIC_OTA_APPJUM);
|
||||
|
||||
// Start Bootloader in BLE OTA mode
|
||||
_ota_dfu = (NRF_POWER->GPREGRET == DFU_MAGIC_OTA_APPJUM) || (NRF_POWER->GPREGRET == DFU_MAGIC_OTA_RESET);
|
||||
|
||||
// Serial only mode
|
||||
bool serial_only_dfu = (NRF_POWER->GPREGRET == DFU_MAGIC_SERIAL_ONLY_RESET);
|
||||
|
||||
// start either serial, uf2 or ble
|
||||
bool dfu_start = _ota_dfu || serial_only_dfu || (NRF_POWER->GPREGRET == DFU_MAGIC_UF2_RESET) ||
|
||||
(((*dbl_reset_mem) == DFU_DBL_RESET_MAGIC) && (NRF_POWER->RESETREAS & POWER_RESETREAS_RESETPIN_Msk));
|
||||
|
||||
// Clear GPREGRET if it is our values
|
||||
if (dfu_start) NRF_POWER->GPREGRET = 0;
|
||||
|
||||
// Save bootloader version to pre-defined register, retrieved by application
|
||||
// TODO move to CF2
|
||||
BOOTLOADER_VERSION_REGISTER = (MK_BOOTLOADER_VERSION);
|
||||
@@ -185,6 +175,8 @@ int main(void)
|
||||
board_init();
|
||||
bootloader_init();
|
||||
|
||||
PRINTF("Bootloader Start\r\n");
|
||||
|
||||
led_state(STATE_BOOTLOADER_STARTED);
|
||||
|
||||
// When updating SoftDevice, bootloader will reset before swapping SD
|
||||
@@ -192,86 +184,17 @@ int main(void)
|
||||
{
|
||||
led_state(STATE_WRITING_STARTED);
|
||||
|
||||
APP_ERROR_CHECK( bootloader_dfu_sd_update_continue() );
|
||||
APP_ERROR_CHECK( bootloader_dfu_sd_update_finalize() );
|
||||
bootloader_dfu_sd_update_continue();
|
||||
bootloader_dfu_sd_update_finalize();
|
||||
|
||||
led_state(STATE_WRITING_FINISHED);
|
||||
}
|
||||
|
||||
/*------------- Determine DFU mode (Serial, OTA, FRESET or normal) -------------*/
|
||||
// DFU button pressed
|
||||
dfu_start = dfu_start || button_pressed(BUTTON_DFU);
|
||||
// Check all inputs and enter DFU if needed
|
||||
// Return when DFU process is complete (or not entered at all)
|
||||
check_dfu_mode();
|
||||
|
||||
// DFU + FRESET are pressed --> OTA
|
||||
_ota_dfu = _ota_dfu || ( button_pressed(BUTTON_DFU) && button_pressed(BUTTON_FRESET) ) ;
|
||||
|
||||
bool const valid_app = bootloader_app_is_valid();
|
||||
bool const just_start_app = valid_app && !dfu_start && (*dbl_reset_mem) == DFU_DBL_RESET_APP;
|
||||
|
||||
if (!just_start_app && APP_ASKS_FOR_SINGLE_TAP_RESET())
|
||||
dfu_start = 1;
|
||||
|
||||
// App mode: register 1st reset and DFU startup (nrf52832)
|
||||
if ( ! (just_start_app || dfu_start || !valid_app) )
|
||||
{
|
||||
// Register our first reset for double reset detection
|
||||
(*dbl_reset_mem) = DFU_DBL_RESET_MAGIC;
|
||||
|
||||
#ifdef NRF52832_XXAA
|
||||
/* Even DFU is not active, we still force an 1000 ms dfu serial mode when startup
|
||||
* to support auto programming from Arduino IDE
|
||||
*
|
||||
* Note: Supposedly during this time if RST is press, it will count as double reset.
|
||||
* However Double Reset WONT work with nrf52832 since its SRAM got cleared anyway.
|
||||
*/
|
||||
bootloader_dfu_start(false, DFU_SERIAL_STARTUP_INTERVAL, false);
|
||||
#else
|
||||
// if RST is pressed during this delay --> if will enter dfu
|
||||
NRFX_DELAY_MS(DFU_DBL_RESET_DELAY);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (APP_ASKS_FOR_SINGLE_TAP_RESET())
|
||||
(*dbl_reset_mem) = DFU_DBL_RESET_APP;
|
||||
else
|
||||
(*dbl_reset_mem) = 0;
|
||||
|
||||
if ( dfu_start || !valid_app )
|
||||
{
|
||||
if ( _ota_dfu )
|
||||
{
|
||||
led_state(STATE_BLE_DISCONNECTED);
|
||||
softdev_init(!sd_inited);
|
||||
sd_inited = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
led_state(STATE_USB_UNMOUNTED);
|
||||
usb_init(serial_only_dfu);
|
||||
}
|
||||
|
||||
// Initiate an update of the firmware.
|
||||
if (APP_ASKS_FOR_SINGLE_TAP_RESET())
|
||||
{
|
||||
// If USB is not enumerated in 3s (eg. because we're running on battery), we restart into app.
|
||||
APP_ERROR_CHECK( bootloader_dfu_start(_ota_dfu, 3000, true) );
|
||||
}
|
||||
else
|
||||
{
|
||||
// No timeout if bootloader requires user action (double-reset).
|
||||
APP_ERROR_CHECK( bootloader_dfu_start(_ota_dfu, 0, false) );
|
||||
}
|
||||
|
||||
if ( _ota_dfu )
|
||||
{
|
||||
sd_softdevice_disable();
|
||||
}else
|
||||
{
|
||||
usb_teardown();
|
||||
}
|
||||
}
|
||||
|
||||
// Reset Board
|
||||
// Reset peripherals
|
||||
board_teardown();
|
||||
|
||||
/* Jump to application if valid
|
||||
@@ -288,7 +211,7 @@ int main(void)
|
||||
if ( is_sd_existed() )
|
||||
{
|
||||
// MBR forward IRQ to SD (if not already)
|
||||
if ( !sd_inited ) softdev_mbr_init();
|
||||
if ( !_sd_inited ) mbr_init_sd();
|
||||
|
||||
// Make sure SD is disabled
|
||||
sd_softdevice_disable();
|
||||
@@ -304,20 +227,124 @@ int main(void)
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the SotdDevice by following SD specs section
|
||||
* "Master Boot Record and SoftDevice initializaton procedure"
|
||||
*
|
||||
* @param[in] init_softdevice true if SoftDevice should be initialized. The SoftDevice must only
|
||||
* be initialized if a chip reset has occured. Soft reset (jump ) from
|
||||
* application must not reinitialize the SoftDevice.
|
||||
*/
|
||||
static uint32_t softdev_init(bool init_softdevice)
|
||||
static void check_dfu_mode(void)
|
||||
{
|
||||
if (init_softdevice) softdev_mbr_init();
|
||||
uint32_t const gpregret = NRF_POWER->GPREGRET;
|
||||
|
||||
// SD is already Initialized in case of BOOTLOADER_DFU_OTA_MAGIC
|
||||
_sd_inited = (gpregret == DFU_MAGIC_OTA_APPJUM);
|
||||
|
||||
// Start Bootloader in BLE OTA mode
|
||||
_ota_dfu = (gpregret == DFU_MAGIC_OTA_APPJUM) || (gpregret == DFU_MAGIC_OTA_RESET);
|
||||
|
||||
// Serial only mode
|
||||
bool const serial_only_dfu = (gpregret == DFU_MAGIC_SERIAL_ONLY_RESET);
|
||||
bool const uf2_dfu = (gpregret == DFU_MAGIC_UF2_RESET);
|
||||
bool const dfu_skip = (gpregret == DFU_MAGIC_SKIP);
|
||||
|
||||
bool const reason_reset_pin = (NRF_POWER->RESETREAS & POWER_RESETREAS_RESETPIN_Msk) ? true : false;
|
||||
|
||||
// start either serial, uf2 or ble
|
||||
bool dfu_start = _ota_dfu || serial_only_dfu || uf2_dfu ||
|
||||
(((*dbl_reset_mem) == DFU_DBL_RESET_MAGIC) && reason_reset_pin);
|
||||
|
||||
// Clear GPREGRET if it is our values
|
||||
if (dfu_start || dfu_skip) NRF_POWER->GPREGRET = 0;
|
||||
|
||||
// skip dfu entirely
|
||||
if (dfu_skip) return;
|
||||
|
||||
/*------------- Determine DFU mode (Serial, OTA, FRESET or normal) -------------*/
|
||||
// DFU button pressed
|
||||
dfu_start = dfu_start || button_pressed(BUTTON_DFU);
|
||||
|
||||
// DFU + FRESET are pressed --> OTA
|
||||
_ota_dfu = _ota_dfu || ( button_pressed(BUTTON_DFU) && button_pressed(BUTTON_FRESET) ) ;
|
||||
|
||||
bool const valid_app = bootloader_app_is_valid();
|
||||
bool const just_start_app = valid_app && !dfu_start && (*dbl_reset_mem) == DFU_DBL_RESET_APP;
|
||||
|
||||
if (!just_start_app && APP_ASKS_FOR_SINGLE_TAP_RESET()) dfu_start = 1;
|
||||
|
||||
// App mode: Double Reset detection or DFU startup for nrf52832
|
||||
if ( ! (just_start_app || dfu_start || !valid_app) )
|
||||
{
|
||||
#ifdef NRF52832_XXAA
|
||||
/* Even DFU is not active, we still force an 1000 ms dfu serial mode when startup
|
||||
* to support auto programming from Arduino IDE
|
||||
*
|
||||
* Note: Double Reset WONT work with nrf52832 since all its SRAM got cleared with GPIO reset.
|
||||
*/
|
||||
bootloader_dfu_start(false, DFU_SERIAL_STARTUP_INTERVAL, false);
|
||||
#else
|
||||
// Note: RESETREAS is not clear by bootloader, it should be cleared by application upon init()
|
||||
if (reason_reset_pin)
|
||||
{
|
||||
// Register our first reset for double reset detection
|
||||
(*dbl_reset_mem) = DFU_DBL_RESET_MAGIC;
|
||||
|
||||
// if RST is pressed during this delay (double reset)--> if will enter dfu
|
||||
NRFX_DELAY_MS(DFU_DBL_RESET_DELAY);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (APP_ASKS_FOR_SINGLE_TAP_RESET())
|
||||
{
|
||||
(*dbl_reset_mem) = DFU_DBL_RESET_APP;
|
||||
}
|
||||
else
|
||||
{
|
||||
(*dbl_reset_mem) = 0;
|
||||
}
|
||||
|
||||
// Enter DFU mode accordingly to input
|
||||
if ( dfu_start || !valid_app )
|
||||
{
|
||||
if ( _ota_dfu )
|
||||
{
|
||||
led_state(STATE_BLE_DISCONNECTED);
|
||||
|
||||
if (!_sd_inited ) mbr_init_sd();
|
||||
_sd_inited = true;
|
||||
|
||||
ble_stack_init();
|
||||
}
|
||||
else
|
||||
{
|
||||
led_state(STATE_USB_UNMOUNTED);
|
||||
usb_init(serial_only_dfu);
|
||||
}
|
||||
|
||||
// Initiate an update of the firmware.
|
||||
if (APP_ASKS_FOR_SINGLE_TAP_RESET() || uf2_dfu || serial_only_dfu)
|
||||
{
|
||||
// If USB is not enumerated in 3s (eg. because we're running on battery), we restart into app.
|
||||
bootloader_dfu_start(_ota_dfu, 3000, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// No timeout if bootloader requires user action (double-reset).
|
||||
bootloader_dfu_start(_ota_dfu, 0, false);
|
||||
}
|
||||
|
||||
if ( _ota_dfu )
|
||||
{
|
||||
sd_softdevice_disable();
|
||||
}else
|
||||
{
|
||||
usb_teardown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Initializes the SotdDevice by following SD specs section
|
||||
// "Master Boot Record and SoftDevice initializaton procedure"
|
||||
static uint32_t ble_stack_init(void)
|
||||
{
|
||||
// Forward vector table to bootloader address so that we can handle BLE events
|
||||
APP_ERROR_CHECK( sd_softdevice_vector_table_base_set(BOOTLOADER_REGION_START) );
|
||||
sd_softdevice_vector_table_base_set(BOOTLOADER_REGION_START);
|
||||
|
||||
// Enable Softdevice, Use Internal OSC to compatible with all boards
|
||||
nrf_clock_lf_cfg_t clock_cfg =
|
||||
@@ -328,7 +355,7 @@ static uint32_t softdev_init(bool init_softdevice)
|
||||
.accuracy = NRF_CLOCK_LF_ACCURACY_250_PPM
|
||||
};
|
||||
|
||||
APP_ERROR_CHECK( sd_softdevice_enable(&clock_cfg, app_error_fault_handler) );
|
||||
sd_softdevice_enable(&clock_cfg, app_error_fault_handler);
|
||||
sd_nvic_EnableIRQ(SD_EVT_IRQn);
|
||||
|
||||
/*------------- Configure BLE params -------------*/
|
||||
@@ -343,35 +370,35 @@ static uint32_t softdev_init(bool init_softdevice)
|
||||
blecfg.gap_cfg.role_count_cfg.periph_role_count = 1;
|
||||
blecfg.gap_cfg.role_count_cfg.central_role_count = 0;
|
||||
blecfg.gap_cfg.role_count_cfg.central_sec_count = 0;
|
||||
APP_ERROR_CHECK( sd_ble_cfg_set(BLE_GAP_CFG_ROLE_COUNT, &blecfg, ram_start) );
|
||||
sd_ble_cfg_set(BLE_GAP_CFG_ROLE_COUNT, &blecfg, ram_start);
|
||||
|
||||
// NRF_DFU_BLE_REQUIRES_BONDS
|
||||
varclr(&blecfg);
|
||||
blecfg.gatts_cfg.service_changed.service_changed = 1;
|
||||
APP_ERROR_CHECK( sd_ble_cfg_set(BLE_GATTS_CFG_SERVICE_CHANGED, &blecfg, ram_start) );
|
||||
sd_ble_cfg_set(BLE_GATTS_CFG_SERVICE_CHANGED, &blecfg, ram_start);
|
||||
|
||||
// ATT MTU
|
||||
varclr(&blecfg);
|
||||
blecfg.conn_cfg.conn_cfg_tag = BLE_CONN_CFG_HIGH_BANDWIDTH;
|
||||
blecfg.conn_cfg.params.gatt_conn_cfg.att_mtu = BLEGATT_ATT_MTU_MAX;
|
||||
APP_ERROR_CHECK( sd_ble_cfg_set(BLE_CONN_CFG_GATT, &blecfg, ram_start) );
|
||||
sd_ble_cfg_set(BLE_CONN_CFG_GATT, &blecfg, ram_start);
|
||||
|
||||
// Event Length + HVN queue + WRITE CMD queue setting affecting bandwidth
|
||||
varclr(&blecfg);
|
||||
blecfg.conn_cfg.conn_cfg_tag = BLE_CONN_CFG_HIGH_BANDWIDTH;
|
||||
blecfg.conn_cfg.params.gap_conn_cfg.conn_count = 1;
|
||||
blecfg.conn_cfg.params.gap_conn_cfg.event_length = BLEGAP_EVENT_LENGTH;
|
||||
APP_ERROR_CHECK( sd_ble_cfg_set(BLE_CONN_CFG_GAP, &blecfg, ram_start) );
|
||||
sd_ble_cfg_set(BLE_CONN_CFG_GAP, &blecfg, ram_start);
|
||||
|
||||
// Enable BLE stack.
|
||||
// Note: Interrupt state (enabled, forwarding) is not work properly if not enable ble
|
||||
APP_ERROR_CHECK( sd_ble_enable(&ram_start) );
|
||||
sd_ble_enable(&ram_start);
|
||||
|
||||
#if 0
|
||||
ble_opt_t opt;
|
||||
varclr(&opt);
|
||||
opt.common_opt.conn_evt_ext.enable = 1; // enable Data Length Extension
|
||||
APP_ERROR_CHECK( sd_ble_opt_set(BLE_COMMON_OPT_CONN_EVT_EXT, &opt) );
|
||||
sd_ble_opt_set(BLE_COMMON_OPT_CONN_EVT_EXT, &opt);
|
||||
#endif
|
||||
|
||||
return NRF_SUCCESS;
|
||||
@@ -403,14 +430,16 @@ uint32_t proc_ble(void)
|
||||
__ALIGN(4) uint8_t ev_buf[ BLE_EVT_LEN_MAX(BLEGATT_ATT_MTU_MAX) ];
|
||||
uint16_t ev_len = BLE_EVT_LEN_MAX(BLEGATT_ATT_MTU_MAX);
|
||||
|
||||
// Init header
|
||||
ble_evt_t* evt = (ble_evt_t*) ev_buf;
|
||||
evt->header.evt_id = BLE_EVT_INVALID;
|
||||
|
||||
// Get BLE Event
|
||||
uint32_t err = sd_ble_evt_get(ev_buf, &ev_len);
|
||||
|
||||
// Handle valid event, ignore error
|
||||
if( NRF_SUCCESS == err)
|
||||
{
|
||||
ble_evt_t* evt = (ble_evt_t*) ev_buf;
|
||||
|
||||
switch (evt->header.evt_id)
|
||||
{
|
||||
case BLE_GAP_EVT_CONNECTED:
|
||||
@@ -437,7 +466,7 @@ uint32_t proc_ble(void)
|
||||
// process SOC event from SD
|
||||
uint32_t proc_soc(void)
|
||||
{
|
||||
uint32_t soc_evt;
|
||||
uint32_t soc_evt = 0;
|
||||
uint32_t err = sd_evt_get(&soc_evt);
|
||||
|
||||
if (NRF_SUCCESS == err)
|
||||
@@ -458,7 +487,7 @@ uint32_t proc_soc(void)
|
||||
return err;
|
||||
}
|
||||
|
||||
void ada_sd_task(void* evt_data, uint16_t evt_size)
|
||||
void proc_sd_task(void* evt_data, uint16_t evt_size)
|
||||
{
|
||||
(void) evt_data;
|
||||
(void) evt_size;
|
||||
@@ -473,7 +502,7 @@ void ada_sd_task(void* evt_data, uint16_t evt_size)
|
||||
void SD_EVT_IRQHandler(void)
|
||||
{
|
||||
// Use App Scheduler to defer handling code in non-isr context
|
||||
app_sched_event_put(NULL, 0, ada_sd_task);
|
||||
app_sched_event_put(NULL, 0, proc_sd_task);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+25
-8
@@ -31,6 +31,7 @@
|
||||
#include "flash_nrf5x.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "bootloader_settings.h"
|
||||
#include "bootloader.h"
|
||||
@@ -119,7 +120,8 @@ STATIC_ASSERT(FAT_ENTRIES_PER_SECTOR == 256); // FAT
|
||||
char infoUf2File[128*3] =
|
||||
"UF2 Bootloader " UF2_VERSION "\r\n"
|
||||
"Model: " UF2_PRODUCT_NAME "\r\n"
|
||||
"Board-ID: " UF2_BOARD_ID "\r\n";
|
||||
"Board-ID: " UF2_BOARD_ID "\r\n"
|
||||
"Date: " __DATE__ "\r\n";
|
||||
|
||||
const char indexFile[] =
|
||||
"<!doctype html>\n"
|
||||
@@ -250,17 +252,33 @@ void uf2_init(void)
|
||||
uint32_t const sd_id = SD_ID_GET(MBR_SIZE);
|
||||
uint32_t const sd_version = SD_VERSION_GET(MBR_SIZE);
|
||||
|
||||
uint32_t const ver1 = sd_version / 1000000;
|
||||
uint32_t const ver2 = (sd_version % 1000000)/1000;
|
||||
uint32_t const ver3 = sd_version % 1000;
|
||||
uint32_t ver[3];
|
||||
ver[0] = sd_version / 1000000;
|
||||
ver[1] = (sd_version - ver[0]*1000000)/1000;
|
||||
ver[2] = (sd_version - ver[0]*1000000 - ver[1]*1000);
|
||||
|
||||
sprintf(infoUf2File + strlen(infoUf2File), "S%lu version %lu.%lu.%lu\r\n", sd_id, ver1, ver2, ver3);
|
||||
char str[10];
|
||||
utoa(sd_id, str, 10);
|
||||
|
||||
strcat(infoUf2File, "S");
|
||||
strcat(infoUf2File, str);
|
||||
strcat(infoUf2File, " ");
|
||||
|
||||
utoa(ver[0], str, 10);
|
||||
strcat(infoUf2File, str);
|
||||
strcat(infoUf2File, ".");
|
||||
|
||||
utoa(ver[1], str, 10);
|
||||
strcat(infoUf2File, str);
|
||||
strcat(infoUf2File, ".");
|
||||
|
||||
utoa(ver[2], str, 10);
|
||||
strcat(infoUf2File, str);
|
||||
strcat(infoUf2File, "\r\n");
|
||||
}else
|
||||
{
|
||||
strcat(infoUf2File, "not found\r\n");
|
||||
}
|
||||
|
||||
strcat(infoUf2File, "Date: " __DATE__ "\r\n");
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
@@ -587,6 +605,5 @@ int write_block (uint32_t block_no, uint8_t *data, WriteState *state)
|
||||
}
|
||||
}
|
||||
|
||||
STATIC_ASSERT(BPB_SECTOR_SIZE == 512); // if sector size changes, may need to re-validate this code
|
||||
return BPB_SECTOR_SIZE;
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
// Application Address Space
|
||||
#define USER_FLASH_START MBR_SIZE // skip MBR included in SD hex
|
||||
#define USER_FLASH_END 0xAD000
|
||||
#define USER_FLASH_END (BOOTLOADER_REGION_START - DFU_APP_DATA_RESERVED)
|
||||
|
||||
// Bootloader start address
|
||||
#define BOOTLOADER_ADDR_START BOOTLOADER_REGION_START
|
||||
|
||||
+27
-15
@@ -25,12 +25,12 @@
|
||||
#include "usb_desc.h"
|
||||
|
||||
enum {
|
||||
ITF_STR_LANGUAGE = 0 ,
|
||||
ITF_STR_MANUFACTURER ,
|
||||
ITF_STR_PRODUCT ,
|
||||
ITF_STR_SERIAL ,
|
||||
ITF_STR_CDC ,
|
||||
ITF_STR_MSC
|
||||
STRID_LANGUAGE = 0 ,
|
||||
STRID_MANUFACTURER ,
|
||||
STRID_PRODUCT ,
|
||||
STRID_SERIAL ,
|
||||
STRID_CDC ,
|
||||
STRID_MSC
|
||||
};
|
||||
|
||||
// CDC + MSC or CDC only mode
|
||||
@@ -84,25 +84,25 @@ enum {
|
||||
ITF_NUM_TOTAL
|
||||
};
|
||||
|
||||
uint8_t const desc_configuration_cdc_msc[] =
|
||||
uint8_t desc_configuration_cdc_msc[] =
|
||||
{
|
||||
// Interface count, string index, total length, attribute, power in mA
|
||||
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN + TUD_MSC_DESC_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
|
||||
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN + TUD_MSC_DESC_LEN, 0, 100),
|
||||
|
||||
// Interface number, string index, EP notification address and size, EP data address (out, in) and size.
|
||||
TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, ITF_STR_CDC, 0x81, 8, 0x02, 0x82, 64),
|
||||
TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, STRID_CDC, 0x81, 8, 0x02, 0x82, 64),
|
||||
|
||||
// Interface number, string index, EP Out & EP In address, EP size
|
||||
TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, ITF_STR_MSC, 0x03, 0x83, 64),
|
||||
TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, STRID_MSC, 0x03, 0x83, 64),
|
||||
};
|
||||
|
||||
uint8_t const desc_configuration_cdc_only[] =
|
||||
uint8_t desc_configuration_cdc_only[] =
|
||||
{
|
||||
// Interface count, string index, total length, attribute, power in mA
|
||||
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL-1, 0, TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
|
||||
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL-1, 0, TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN, 0, 100),
|
||||
|
||||
// Interface number, string index, EP notification address and size, EP data address (out, in) and size.
|
||||
TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, ITF_STR_CDC, 0x81, 8, 0x02, 0x82, 64),
|
||||
TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, STRID_CDC, 0x81, 8, 0x02, 0x82, 64),
|
||||
};
|
||||
|
||||
|
||||
@@ -127,7 +127,19 @@ void usb_desc_init(bool cdc_only)
|
||||
}
|
||||
|
||||
// Create Serial string descriptor
|
||||
sprintf(desc_str_serial, "%08lX%08lX", NRF_FICR->DEVICEID[1], NRF_FICR->DEVICEID[0]);
|
||||
uint8_t const* device_id = (uint8_t const*) &NRF_FICR->DEVICEID;
|
||||
|
||||
for ( uint8_t i = 0; i < 8; i++ )
|
||||
{
|
||||
for ( uint8_t j = 0; j < 2; j++ )
|
||||
{
|
||||
const char nibble_to_hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||
|
||||
uint8_t nibble = (device_id[i] >> (j * 4)) & 0xf;
|
||||
desc_str_serial[15 - (i * 2 + j)] = nibble_to_hex[nibble]; // memory is little endian
|
||||
}
|
||||
}
|
||||
desc_str_serial[16] = 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
@@ -156,7 +168,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
|
||||
|
||||
uint8_t chr_count;
|
||||
|
||||
if ( index == 0)
|
||||
if ( index == STRID_LANGUAGE )
|
||||
{
|
||||
memcpy(&_desc_str[1], string_desc_arr[0], 2);
|
||||
chr_count = 1;
|
||||
|
||||
@@ -30,16 +30,4 @@
|
||||
|
||||
void usb_desc_init(bool cdc_only);
|
||||
|
||||
#ifndef USB_DESC_VID
|
||||
#define USB_DESC_VID 0x239A
|
||||
#endif
|
||||
|
||||
#ifndef USB_DESC_UF2_PID
|
||||
#define USB_DESC_UF2_PID 0x0029
|
||||
#endif
|
||||
|
||||
#ifndef USB_DESC_CDC_ONLY_PID
|
||||
#define USB_DESC_CDC_ONLY_PID 0x002A
|
||||
#endif
|
||||
|
||||
#endif /* USB_DESC_H_ */
|
||||
Reference in new issue
Block a user