Skip to content

Commit b20af27

Browse files
authored
Merge branch 'adafruit:master' into nrf52840-bboard
2 parents 9622b4f + b545673 commit b20af27

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+19510
-439
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Bug Report
2+
description: Report a problem
3+
labels: 'Bug'
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
Thanks for taking the time to fill out this bug report!
9+
It's okay to leave some blank if it doesn't apply to your problem.
10+
11+
- type: dropdown
12+
attributes:
13+
label: Operating System
14+
options:
15+
- Linux
16+
- MacOS
17+
- RaspberryPi OS
18+
- Windows 7
19+
- Windows 10
20+
- Windows 11
21+
- Others
22+
validations:
23+
required: true
24+
25+
- type: textarea
26+
attributes:
27+
label: INFO_UF2.TXT
28+
placeholder: Paste your INFO_UF2.TXT contents here
29+
validations:
30+
required: true
31+
32+
- type: textarea
33+
attributes:
34+
label: What happened ?
35+
placeholder: A clear and concise description of what the bug is.
36+
validations:
37+
required: true
38+
39+
- type: textarea
40+
attributes:
41+
label: How to reproduce ?
42+
placeholder: |
43+
1. Go to '...'
44+
2. Click on '....'
45+
3. See error
46+
validations:
47+
required: true
48+
49+
- type: textarea
50+
attributes:
51+
label: Debug Log
52+
placeholder: Debug log attached txt file.
53+
validations:
54+
required: false
55+
56+
- type: textarea
57+
attributes:
58+
label: Screenshots
59+
description: If applicable, add screenshots to help explain your problem.
60+
validations:
61+
required: false

.github/workflows/githubci.yml

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,24 @@ jobs:
2323
- 'feather_nrf52840_sense'
2424
- 'itsybitsy_nrf52840_express'
2525
- 'metro_nrf52840_express'
26-
# Alphabetical order
26+
- 'ledglasses_nrf52840'
27+
# Other Makers (Alphabetical order)
2728
- 'adm_b_nrf52840_1'
2829
- 'ae_bl652_bo'
2930
- 'aramcon_badge_2019'
3031
- 'aramcon2_badge'
3132
- 'arcade_feather_nrf52840_express'
3233
- 'arduino_nano_33_ble'
3334
- 'bast_ble'
35+
- 'bluemicro_nrf52833'
3436
- 'bluemicro_nrf52840'
3537
- 'ebyte_e104_bt5032a'
3638
- 'ebyte_e73_tbb'
3739
- 'electronut_labs_papyr'
3840
- 'ikigaisense_vita'
3941
- 'm60_keyboard'
4042
- 'mdk_nrf52840_dongle'
43+
- 'mikoto'
4144
- 'nice_nano'
4245
- 'nrf52840_m2'
4346
- 'nrf52840_bboard'
@@ -49,6 +52,7 @@ jobs:
4952
- 'pca10059'
5053
- 'pca10100'
5154
- 'pitaya_go'
55+
- 'raytac_mdbt50q_db_40'
5256
- 'raytac_mdbt50q_rx'
5357
- 'sparkfun_nrf52840_micromod'
5458
- 'waveshare_nrf52840_eval'
@@ -63,11 +67,18 @@ jobs:
6367
- name: Checkout Code
6468
uses: actions/checkout@v1
6569
with:
66-
submodules: true
70+
submodules: true
71+
72+
- name: Checkout linkermap
73+
uses: actions/checkout@v2
74+
with:
75+
repository: hathach/linkermap
76+
path: linkermap
6777

6878
- name: Install Toolchains
6979
run: |
7080
pip3 install adafruit-nrfutil uritemplate requests intelhex
81+
pip3 install linkermap/
7182
npm install --global xpm
7283
# 9.3.1-1.2.1 is xpack modified version which significantly increased compiled size to 6-7KB and cause flash overflow.
7384
# Skip this version for now, we will try again with next official release from ARM
@@ -78,34 +89,20 @@ jobs:
7889
run: |
7990
make BOARD=${{ matrix.board }} all
8091
make BOARD=${{ matrix.board }} copy-artifact
92+
93+
- name: Linker Map
94+
run: make BOARD=${{ matrix.board }} linkermap
8195

8296
- uses: actions/upload-artifact@v2
8397
with:
8498
name: ${{ matrix.board }}
8599
path: _bin/${{ matrix.board }}
86100

87-
- name: Create Release Asset
88-
if: ${{ github.event_name == 'release' }}
89-
run: zip -jr ${{ matrix.board }}_bootloader-${{ github.event.release.tag_name }}.zip _bin/${{ matrix.board }}
90-
91101
- name: Upload Release Asset
92-
uses: actions/upload-release-asset@v1
93-
env:
94-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95-
if: ${{ github.event_name == 'release' }}
96-
with:
97-
upload_url: ${{ github.event.release.upload_url }}
98-
asset_path: ${{ matrix.board }}_bootloader-${{ github.event.release.tag_name }}.zip
99-
asset_name: ${{ matrix.board }}_bootloader-${{ github.event.release.tag_name }}.zip
100-
asset_content_type: application/zip
101-
102-
- name: Upload Release Asset for Self-Update
103-
uses: actions/upload-release-asset@v1
104-
env:
105-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
102+
uses: softprops/action-gh-release@v1
106103
if: ${{ github.event_name == 'release' }}
107104
with:
108-
upload_url: ${{ github.event.release.upload_url }}
109-
asset_path: _bin/${{ matrix.board }}/update-${{ matrix.board }}_bootloader-${{ github.event.release.tag_name }}_nosd.uf2
110-
asset_name: update-${{ matrix.board }}_bootloader-${{ github.event.release.tag_name }}_nosd.uf2
111-
asset_content_type: application/x-binary
105+
files: |
106+
_bin/${{ matrix.board }}/${{ matrix.board }}_bootloader-*.zip
107+
_bin/${{ matrix.board }}/${{ matrix.board }}_bootloader-*.hex
108+
_bin/${{ matrix.board }}/update-${{ matrix.board }}_bootloader-*.uf2

Makefile

Lines changed: 53 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ TUSB_PATH = lib/tinyusb/src
1515
NRFX_PATH = lib/nrfx
1616
SD_PATH = lib/softdevice/$(SD_FILENAME)
1717

18-
SD_VERSION = 6.1.1
18+
ifndef SD_VERSION
19+
SD_VERSION = 6.1.1
20+
endif
21+
1922
SD_FILENAME = $(SD_NAME)_nrf52_$(SD_VERSION)
2023
SD_HEX = $(SD_PATH)/$(SD_FILENAME)_softdevice.hex
2124

@@ -104,14 +107,17 @@ ifeq ($(MCU_SUB_VARIANT),nrf52)
104107
SD_NAME = s132
105108
DFU_DEV_REV = 0xADAF
106109
CFLAGS += -DNRF52 -DNRF52832_XXAA -DS132
110+
CFLAGS += -DDFU_APP_DATA_RESERVED=7*4096
107111
else ifeq ($(MCU_SUB_VARIANT),nrf52833)
108112
SD_NAME = s140
109113
DFU_DEV_REV = 52840
110114
CFLAGS += -DNRF52833_XXAA -DS140
115+
CFLAGS += -DDFU_APP_DATA_RESERVED=7*4096
111116
else ifeq ($(MCU_SUB_VARIANT),nrf52840)
112117
SD_NAME = s140
113118
DFU_DEV_REV = 52840
114119
CFLAGS += -DNRF52840_XXAA -DS140
120+
CFLAGS += -DDFU_APP_DATA_RESERVED=10*4096
115121
else
116122
$(error Sub Variant $(MCU_SUB_VARIANT) is unknown)
117123
endif
@@ -121,13 +127,14 @@ endif
121127
#------------------------------------------------------------------------------
122128

123129
# all files in src
124-
C_SRC += $(wildcard src/*.c)
130+
C_SRC += \
131+
src/dfu_ble_svc.c \
132+
src/dfu_init.c \
133+
src/flash_nrf5x.c \
134+
src/main.c \
125135

126136
# all files in boards
127-
C_SRC += $(wildcard src/boards/*.c)
128-
129-
# all sources files in specific board
130-
C_SRC += $(wildcard src/boards/$(BOARD)/*.c)
137+
C_SRC += src/boards/boards.c
131138

132139
# nrfx
133140
C_SRC += $(NRFX_PATH)/drivers/src/nrfx_power.c
@@ -169,18 +176,25 @@ IPATH += $(SDK_PATH)/drivers_nrf/uart
169176

170177
else
171178

179+
# pinconfig is required for 840 for CF2
180+
C_SRC += src/boards/$(BOARD)/pinconfig.c
181+
172182
# USB Application ( MSC + UF2 )
173-
C_SRC += $(wildcard src/usb/*.c)
174-
C_SRC += $(wildcard src/usb/uf2/*.c)
183+
C_SRC += \
184+
src/usb/msc_uf2.c \
185+
src/usb/usb_desc.c \
186+
src/usb/usb.c \
187+
src/usb/uf2/ghostfat.c
175188

176189
# TinyUSB stack
177-
C_SRC += $(TUSB_PATH)/portable/nordic/nrf5x/dcd_nrf5x.c
178-
C_SRC += $(TUSB_PATH)/common/tusb_fifo.c
179-
C_SRC += $(TUSB_PATH)/device/usbd.c
180-
C_SRC += $(TUSB_PATH)/device/usbd_control.c
181-
C_SRC += $(TUSB_PATH)/class/cdc/cdc_device.c
182-
C_SRC += $(TUSB_PATH)/class/msc/msc_device.c
183-
C_SRC += $(TUSB_PATH)/tusb.c
190+
C_SRC += \
191+
$(TUSB_PATH)/portable/nordic/nrf5x/dcd_nrf5x.c \
192+
$(TUSB_PATH)/common/tusb_fifo.c \
193+
$(TUSB_PATH)/device/usbd.c \
194+
$(TUSB_PATH)/device/usbd_control.c \
195+
$(TUSB_PATH)/class/cdc/cdc_device.c \
196+
$(TUSB_PATH)/class/msc/msc_device.c \
197+
$(TUSB_PATH)/tusb.c
184198

185199
endif
186200

@@ -232,15 +246,6 @@ IPATH += $(SD_PATH)/$(SD_FILENAME)_API/include/nrf52
232246
# Compiler Flags
233247
#------------------------------------------------------------------------------
234248

235-
# Debug option use RTT for printf
236-
ifeq ($(DEBUG), 1)
237-
RTT_SRC = lib/SEGGER_RTT
238-
239-
CFLAGS += -DCFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
240-
IPATH += $(RTT_SRC)/RTT
241-
C_SRC += $(RTT_SRC)/RTT/SEGGER_RTT.c
242-
endif
243-
244249
#flags common to all targets
245250
CFLAGS += \
246251
-mthumb \
@@ -276,6 +281,18 @@ CFLAGS += -Wno-unused-parameter -Wno-expansion-to-defined
276281
# TinyUSB tusb_hal_nrf_power_event
277282
CFLAGS += -Wno-cast-function-type
278283

284+
# Nordic Softdevice SDK header files contains inline assembler that has
285+
# broken constraints. As a result the IPA-modref pass, introduced in gcc-11,
286+
# is able to "prove" that arguments to wrapper functions generated with
287+
# the SVCALL() macro are unused and, as a result, the optimizer will remove
288+
# code within the callers that sets up these arguments (which results in
289+
# a broken bootloader). The broken headers come from Nordic-supplied zip
290+
# files and are not trivial to patch so, for now, we'll simply disable the
291+
# new gcc-11 inter-procedural optimizations.
292+
ifeq (,$(findstring unrecognized,$(shell $(CC) $(CFLAGS) -fno-ipa-modref 2>&1)))
293+
CFLAGS += -fno-ipa-modref
294+
endif
295+
279296
# Defined Symbol (MACROS)
280297
CFLAGS += -D__HEAP_SIZE=0
281298
CFLAGS += -DCONFIG_GPIO_AS_PINRESET
@@ -286,14 +303,20 @@ ifneq ($(USE_NFCT),yes)
286303
endif
287304

288305
CFLAGS += -DSOFTDEVICE_PRESENT
289-
CFLAGS += -DDFU_APP_DATA_RESERVED=7*4096
290-
291306
CFLAGS += -DUF2_VERSION='"$(GIT_VERSION) $(GIT_SUBMODULE_VERSIONS)"'
292307
CFLAGS += -DBLEDIS_FW_VERSION='"$(GIT_VERSION) $(SD_NAME) $(SD_VERSION)"'
293308

294309
_VER = $(subst ., ,$(word 1, $(subst -, ,$(GIT_VERSION))))
295310
CFLAGS += -DMK_BOOTLOADER_VERSION='($(word 1,$(_VER)) << 16) + ($(word 2,$(_VER)) << 8) + $(word 3,$(_VER))'
296311

312+
# Debug option use RTT for printf
313+
ifeq ($(DEBUG), 1)
314+
CFLAGS += -DCFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
315+
RTT_SRC = lib/SEGGER_RTT
316+
IPATH += $(RTT_SRC)/RTT
317+
C_SRC += $(RTT_SRC)/RTT/SEGGER_RTT.c
318+
endif
319+
297320
#------------------------------------------------------------------------------
298321
# Linker Flags
299322
#------------------------------------------------------------------------------
@@ -353,6 +376,10 @@ clean:
353376
@$(RM) $(BUILD)
354377
@$(RM) $(BIN)
355378

379+
# linkermap must be install previously at https://github.com/hathach/linkermap
380+
linkermap: $(BUILD)/$(OUT_NAME).out
381+
@linkermap -v $<.map
382+
356383
# Create objects from C SRC files
357384
$(BUILD)/%.o: %.c
358385
@echo CC $(notdir $<)

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This is a CDC/DFU/UF2 bootloader for nRF52 boards.
1010
- [Adafruit Feather nRF52840 Express](https://www.adafruit.com/product/4062)
1111
- [Adafruit Feather nRF52840 Sense](https://www.adafruit.com/product/4516)
1212
- [Adafruit ItsyBitsy nRF52840 Express](https://www.adafruit.com/product/4481)
13+
- [Adafruit LED Glasses Driver nRF52840](https://www.adafruit.com/product/5217)
1314
- Adafruit Metro nRF52840 Express
1415
- [Akizukidenshi AE-BL652-BO](https://akizukidenshi.com/catalog/g/gK-15567/)
1516
- [Electronut Labs Papyr](https://docs.electronut.in/papyr/)
@@ -78,16 +79,24 @@ For other boards, please check the board definition for details.
7879
7980
### Making your own UF2
8081
81-
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
82+
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** (nRF52840) or **0x621E937A** (nRF52833).
8283
83-
To create a UF2 image from a .bin file:
8484
```
85-
uf2conv.py firmware.bin -c -b 0x26000 -f 0xADA52840
85+
nRF52840
86+
uf2conv.py firmware.hex -c -f 0xADA52840
87+
88+
nRF52833
89+
uf2conv.py firmware.hex -c -f 0x621E937A
8690
```
8791
88-
To create a UF2 image from a .hex file:
92+
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, v7 is 0x27000
93+
8994
```
90-
uf2conv.py firmware.hex -c -f 0xADA52840
95+
nRF52840
96+
uf2conv.py firmware.bin -c -b 0x26000 -f 0xADA52840
97+
98+
nRF52833
99+
uf2conv.py firmware.bin -c -b 0x27000 -f 0x621E937A
91100
```
92101
93102
To create a UF2 image for bootloader from a .hex file using separated family of **0xd663823c**

changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Adafruit nRF52 Bootloader Changelog
22

3+
## 0.6.2 - 2021.09.10
4+
5+
- Add new board "LED Glasses Driver nRF52840"
6+
7+
## 0.6.1 - 2021.08.04
8+
9+
- Fix failed to upgrade ssue when flashing uf2 with more than 512KB payload
10+
- Increased application reserved from 28KB to 40KB for nrf52840 to match circuitpython usage.
11+
312
## 0.6.0 - 2021.06.19
413

514
- Update tinyusb to latest to fix the race condition with control transfer, which could cause failed to connect to DFU Serial occasionally.

0 commit comments

Comments
 (0)