Skip to content

Commit 6bfff29

Browse files
authored
Merge pull request #1137 from hathach/nrf52_dfu_touch1200
Nrf52 dfu touch1200, remove bootloader target
2 parents 580a191 + a516d11 commit 6bfff29

18 files changed

+86
-22156
lines changed

ports/nrf/Makefile

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
248248
$(BUILD)/$(FATFS_DIR)/ff.o: COPT += -Os
249249
$(filter $(PY_BUILD)/../extmod/vfs_fat_%.o, $(PY_O)): COPT += -Os
250250

251-
.phony: all flash sd binary hex bootloader
251+
.phony: all flash sd binary hex
252252

253253
all: binary hex uf2
254254

@@ -266,6 +266,11 @@ hex: $(BUILD)/$(OUTPUT_FILENAME).hex
266266
$(BUILD)/$(OUTPUT_FILENAME).hex: $(BUILD)/$(OUTPUT_FILENAME).elf
267267
$(OBJCOPY) -O ihex $< $@
268268

269+
## Create uf2 file
270+
uf2: $(BUILD)/$(OUTPUT_FILENAME).hex
271+
$(ECHO) "Create $(OUTPUT_FILENAME).uf2"
272+
$(PYTHON2) $(TOP)/tools/uf2/utils/uf2conv.py -f 0xADA52840 -c -o "$(BUILD)/$(OUTPUT_FILENAME).uf2" $^
273+
269274
#####################
270275
# Flash with debugger
271276
#####################
@@ -286,9 +291,6 @@ sd: $(BUILD)/$(OUTPUT_FILENAME).hex
286291
nrfjprog --program $< --sectorerase -f $(MCU_VARIANT)
287292
nrfjprog --reset -f $(MCU_VARIANT)
288293

289-
bootloader:
290-
nrfjprog --program $(BOOT_FILE).hex -f nrf52 --chiperase --reset
291-
292294
else ifeq ($(FLASHER), pyocd)
293295

294296
flash: $(BUILD)/$(OUTPUT_FILENAME).hex
@@ -303,21 +305,19 @@ sd: $(BUILD)/$(OUTPUT_FILENAME).hex
303305
pyocd-flashtool -t $(MCU_SUB_VARIANT) $< --sector_erase
304306
pyocd-tool -t $(MCU_SUB_VARIANT) reset $(BOOT_SETTING_ADDR)
305307

306-
bootloader:
307-
pyocd-flashtool -t $(MCU_SUB_VARIANT) $(BOOT_FILE).hex --chip_erase
308-
pyocd-tool -t $(MCU_SUB_VARIANT) reset
309-
310308
endif
311309

312310
#####################
313311
# Flash with DFU
314312
#####################
315-
.phony: dfu-gen dfu-flash dfu-bootloader
313+
.phony: dfu-gen dfu-flash
314+
315+
NRFUTIL = adafruit-nrfutil
316316

317-
ifeq ($(OS),Windows_NT)
318-
NRFUTIL = ../../lib/nrfutil/binaries/win32/nrfutil.exe
317+
ifeq ($(MCU_SUB_VARIANT),nrf52840)
318+
DFU_TOUCH = --touch 1200
319319
else
320-
NRFUTIL = nrfutil
320+
DFU_TOUCH =
321321
endif
322322

323323
check_defined = \
@@ -327,22 +327,16 @@ __check_defined = \
327327
$(if $(value $1),, \
328328
$(error Undefined make flag: $1$(if $2, ($2))))
329329

330-
dfu-gen: $(BUILD)/$(OUTPUT_FILENAME).hex
331-
$(NRFUTIL) dfu genpkg --sd-req 0xFFFE --dev-type 0x0052 --application $^ $(BUILD)/dfu-package.zip
332-
330+
## Flash with DFU serial
333331
dfu-flash: $(BUILD)/dfu-package.zip
334332
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyUSB0)
335-
$(NRFUTIL) --verbose dfu serial --package $^ -p $(SERIAL) -b 115200 --singlebank
336-
337-
dfu-bootloader:
338-
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
339-
$(NRFUTIL) --verbose dfu serial --package $(BOOT_FILE).zip -p $(SERIAL) -b 115200
333+
$(NRFUTIL) --verbose dfu serial --package $^ -p $(SERIAL) -b 115200 --singlebank $(DFU_TOUCH)
340334

341-
uf2: $(BUILD)/$(OUTPUT_FILENAME).hex
342-
$(ECHO) "Create $(OUTPUT_FILENAME).uf2"
343-
$(PYTHON2) $(TOP)/tools/uf2/utils/uf2conv.py -f 0xADA52840 -c -o "$(BUILD)/$(OUTPUT_FILENAME).uf2" $^
335+
## Create DFU package file
336+
dfu-gen: $(BUILD)/dfu-package.zip
344337

345-
$(BUILD)/dfu-package.zip: dfu-gen
338+
$(BUILD)/dfu-package.zip: $(BUILD)/$(OUTPUT_FILENAME).hex
339+
$(NRFUTIL) dfu genpkg --sd-req 0xFFFE --dev-type 0x0052 --application $^ $(BUILD)/dfu-package.zip
346340

347341
$(BUILD)/$(OUTPUT_FILENAME).elf: $(OBJ)
348342
$(ECHO) "LINK $@"

ports/nrf/README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ Target Board (BOARD) | Bluetooth Stack (SD) | Bluetooth Support | Flash
7979
pca10040 | s132 | Peripheral and Scanner | [Segger](#segger-targets)
8080
feather52832 | s132 | Peripheral and Scanner | [UART DFU](#dfu-targets)
8181
pca10056 | s140 | Peripheral and Scanner | [Segger](#segger-targets)
82+
feather52840 | s140 | Peripheral and Scanner | [UART DFU](#dfu-targets)
8283

8384
## Segger Targets
8485

@@ -98,11 +99,9 @@ note: On Linux it might be required to link SEGGER's `libjlinkarm.so` inside nrf
9899

99100
## DFU Targets
100101

101-
sudo apt-get install build-essential libffi-dev pkg-config gcc-arm-none-eabi git python python-pip
102-
git clone https://github.com/adafruit/Adafruit_nRF52_Arduino.git
103-
cd Adafruit_nRF52_Arduino/tools/nrfutil-0.5.2/
104-
sudo pip install -r requirements.txt
105-
sudo python setup.py install
102+
run follow command to install [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil) from PyPi
103+
104+
$ pip3 install --user adafruit-nrfutil
106105

107106
**make flash** and **make sd** will not work with DFU targets. Hence, **dfu-gen** and **dfu-flash** must be used instead.
108107
* dfu-gen: Generates a Firmware zip to be used by the DFU flash application.
@@ -111,8 +110,7 @@ note: On Linux it might be required to link SEGGER's `libjlinkarm.so` inside nrf
111110
Example on how to generate and flash feather52832 target:
112111

113112
make BOARD=feather52832 SD=s132
114-
make BOARD=feather52832 SD=s132 dfu-gen
115-
make BOARD=feather52832 SD=s132 dfu-flash
113+
make BOARD=feather52832 SD=s132 dfu-gen dfu-flash
116114

117115
## Bluetooth LE REPL
118116

ports/nrf/boards/feather52832/README.md

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,15 @@ $ cd ports/nrf
2121
$ ./drivers/bluetooth/download_ble_stack.sh
2222
```
2323

24-
## Installing `nrfutil`
24+
## Installing `adafruit-nrfutil`
2525

2626
The Adafruit Bluefruit nRF52 Feather ships with a serial and OTA BLE bootloader
2727
that can be used to flash firmware images over a simple serial connection,
2828
using the on-board USB serial converter.
2929

30-
If you haven't installed this command-line tool yet, go to the `/libs/nrfutil`
31-
folder (where nrfutil 0.5.2 is installed as a sub-module) and run the following
32-
commands:
30+
run following command to install [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil) from PyPi
3331

34-
> If you get a 'sudo: pip: command not found' error running 'sudo pip install',
35-
you can install pip via 'sudo easy_install pip'
36-
37-
```
38-
$ cd ../../lib/nrfutil
39-
$ sudo pip install -r requirements.txt
40-
$ sudo python setup.py install
41-
```
32+
$ pip3 install --user adafruit-nrfutil
4233

4334
# Building and flashing firmware images
4435

@@ -75,7 +66,7 @@ You can then connect over BLE UART using an application like Bluefruit LE
7566
Connect, available for Android, iOS and OS X, or any other application that
7667
supports the NUS service and allows you to send the corrent EOL sequence.
7768

78-
## Flashing binaries with `nrfutil`
69+
## Flashing binaries with `adafruit-nrfutil`
7970

8071
### 1. **Update bootloader** to single-bank version
8172

@@ -90,20 +81,25 @@ Due to the size of CircuitPython, we must migrate this bootloader to a
9081
bootloader from the dual-bank version that ships on Arduino-based Adafruit
9182
Feather52 boards to a single-bank CircuitPython compatible version:
9283

84+
Firstly clone the [Adafruit_nRF52_Bootloader](https://github.com/adafruit/Adafruit_nRF52_Bootloader.git) and enter its directory
85+
86+
$ git clone https://github.com/adafruit/Adafruit_nRF52_Bootloader.git
87+
$ cd Adafruit_nRF52_Bootloader
88+
9389
#### S132 v2.0.1 single-bank (recommended):
9490

95-
By default s132 v2.0.1 is used when no `SOFTDEV_VERSION` field is passed in:
91+
To flash bootloader with s132 v2.0.1
9692

9793
```
98-
$ make BOARD=feather52832 SERIAL=/dev/tty.SLAB_USBtoUART boot-flash
94+
$ make BOARD=feather_nrf52832 VERSION=2.0.1 SERIAL=/dev/tty.SLAB_USBtoUART dfu-flash
9995
```
10096

10197
#### S132 v5.0.0 (BLE5, experimental):
10298

103-
To enable BLE5 support and the latest S132 release, flash the v5.0.0 bootloader via:
99+
To flash bootloader with s132 v5.0.0
104100

105101
```
106-
$ make BOARD=feather52832 SERIAL=/dev/tty.SLAB_USBtoUART SOFTDEV_VERSION=5.0.0 boot-flash
102+
$ make BOARD=feather52832 VERSION=5.0.0 SERIAL=/dev/tty.SLAB_USBtoUART dfu-flash
107103
```
108104

109105
### 2. Generate and flash a CircuitPython DFU .zip package over serial

ports/nrf/boards/feather52832/bootloader/.gitattributes

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

ports/nrf/boards/feather52832/bootloader/README.md

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

ports/nrf/boards/feather52832/mpconfigboard.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ SD ?= s132
55
SOFTDEV_VERSION ?= 2.0.1
66

77
LD_FILE = boards/feather52832/custom_nrf52832_dfu_app_$(SOFTDEV_VERSION).ld
8-
BOOT_FILE = boards/feather52832/bootloader/feather52_bootloader_$(SOFTDEV_VERSION)_s132_single
98

109
BOOT_SETTING_ADDR = 0x7F000
1110
NRF_DEFINES += -DNRF52832_XXAA

0 commit comments

Comments
 (0)