Skip to content

Commit 0cc0289

Browse files
committed
update dfu-flash for upgrading bootloader
clean up makefile
1 parent 992229c commit 0cc0289

File tree

2 files changed

+11
-44
lines changed

2 files changed

+11
-44
lines changed

Makefile

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ SD_HEX = $(SD_PATH)/$(SD_FILENAME)_softdevice.hex
2828
LD_FILE = $(SRC_PATH)/linker/$(SD_NAME)_v$(SD_VER1).ld
2929

3030
MERGED_FNAME = $(OUTPUT_FILENAME)_$(SD_NAME)_$(SD_VERSION)
31-
RELEASE_DIR = bin/$(BOARD)
3231

3332

3433
MK_DIS_FIRMWARE = "$(SD_NAME) $(SD_VERSION)"
@@ -86,7 +85,7 @@ BOARD_LIST = $(sort $(subst .h,,$(subst src/boards/,,$(wildcard src/boards/*.h))
8685
NRF52832_BOARDLIST = feather_nrf52832
8786
IS_52832 = $(filter $(BOARD),$(NRF52832_BOARDLIST))
8887

89-
ifeq ($(filter $(MAKECMDGOALS),all-board all-release help),)
88+
ifeq ($(filter $(MAKECMDGOALS),all-board help),)
9089
ifeq ($(BOARD),)
9190
$(info You must provide a BOARD parameter with 'BOARD=')
9291
$(info Supported boards are: $(BOARD_LIST))
@@ -360,20 +359,11 @@ _make_all_board = $(foreach b,$(BOARD_LIST), $(call _make_board,$b,$1))
360359
all-board:
361360
$(call _make_all_board,clean all)
362361

363-
all-release:
364-
$(call _make_all_board,clean all release)
365-
366362
help:
367-
@echo To flash (with jlink) a pre-built binary with a specific version to a board
368-
@echo $$ make BOARD=feather_nrf52840_express VERSION=6.1.1r0 flash
369-
@echo
370-
@echo To flash (with dfu) a pre-built binary with a specific version to a board
371-
@echo $$ make BOARD=feather_nrf52840_express VERSION=6.1.1r0 SERIAL=/dev/ttyACM0 dfu0-flash
372-
@echo
373363
@echo To compile and build the current code for a board
374364
@echo $$ make BOARD=feather_nrf52840_express all
375365
@echo
376-
@echo To flash current code using jlink
366+
@echo To flash current code using Jlink
377367
@echo $$ make BOARD=feather_nrf52840_express flash
378368
@echo
379369
@echo To flash current code using existing bootloader dfu
@@ -388,35 +378,14 @@ __check_defined = \
388378
$(if $(value $1),, \
389379
$(error Undefined make flag: $1$(if $2, ($2))))
390380

391-
ifeq ($(VERSION),)
392-
393381
# Flash the compiled
394382
flash: $(BUILD)/$(OUTPUT_FILENAME)-nosd.hex
395383
@echo Flashing: $<
396384
$(NRFJPROG) --program $< --sectoranduicrerase -f nrf52 --reset
397385

398386
dfu-flash: $(BUILD)/$(MERGED_FNAME).zip
399387
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
400-
$(NRFUTIL) --verbose dfu serial --package $< -p $(SERIAL) -b 115200 --singlebank
401-
402-
else
403-
404-
ifeq ($(VERSION),latest)
405-
VERSION_FPATH = $(RELEASE_DIR)/$(MERGED_FNAME)
406-
else
407-
VERSION_FPATH = bin/$(BOARD)/$(VERSION)/$(OUTPUT_FILENAME)_$(SD_NAME)_$(VERSION)
408-
endif
409-
410-
# Flash specific version in binary release folder
411-
flash:
412-
@echo Flashing: $(VERSION_FPATH).hex
413-
$(NRFJPROG) --program $(VERSION_FPATH).hex --chiperase -f nrf52 --reset
414-
415-
dfu-flash:
416-
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
417-
$(NRFUTIL) --verbose dfu serial --package $(VERSION_FPATH).zip -p $(SERIAL) -b 115200 --singlebank
418-
419-
endif
388+
$(NRFUTIL) --verbose dfu serial --package $< -p $(SERIAL) -b 115200 --singlebank --touch 1200
420389

421390
sd:
422391
@echo Flashing: $(SD_HEX)
@@ -457,7 +426,7 @@ size: $(BUILD)/$(OUTPUT_FILENAME)-nosd.out
457426

458427

459428
#******************* Binary generator *******************
460-
.phony: genhex genpkg release
429+
.phony: genhex genpkg
461430

462431
## Create binary .hex file from the .out file
463432
genhex: $(BUILD)/$(OUTPUT_FILENAME)-nosd.hex
@@ -478,11 +447,3 @@ genpkg: $(BUILD)/$(MERGED_FNAME).zip
478447

479448
$(BUILD)/$(MERGED_FNAME).zip: $(BUILD)/$(OUTPUT_FILENAME)-nosd.hex
480449
@$(NRFUTIL) dfu genpkg --dev-type 0x0052 --dev-revision $(DFU_DEV_REV) --bootloader $< --softdevice $(SD_HEX) $@
481-
482-
# Create SD+bootloader combo with hex & dfu package at release folder
483-
release: combinehex genpkg
484-
@echo CR $(RELEASE_DIR)/$(MERGED_FNAME).hex
485-
@echo CR $(RELEASE_DIR)/$(MERGED_FNAME).zip
486-
@mkdir -p $(RELEASE_DIR)
487-
@cp $(BUILD)/$(MERGED_FNAME).hex $(RELEASE_DIR)/$(MERGED_FNAME).hex
488-
@cp $(BUILD)/$(MERGED_FNAME).zip $(RELEASE_DIR)/$(MERGED_FNAME).zip

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,18 @@ To build:
9797
make BOARD=feather_nrf52840_express all combinehex
9898
```
9999

100-
To flash the bootloader:
100+
To flash the bootloader with JLink:
101101

102102
```
103103
make BOARD=feather_nrf52840_express flash
104104
```
105105

106+
To upgrade the bootloader using DFU Serial via port /dev/ttyACM0
107+
108+
```
109+
make BOARD=feather_nrf52840_express SERIAL=/dev/ttyACM0 dfu-flash
110+
```
111+
106112
To flash SoftDevice (and chip erase):
107113

108114
```

0 commit comments

Comments
 (0)