From b8e8b0e099321afaa80d473af5be34a536b39009 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 10 Aug 2018 21:43:14 +0700 Subject: [PATCH] add option to flash specific release version in binary folder add dfu-flash to upgrade bootloader using DFU --- Makefile | 71 +++++++++++------- .../feather52832_bootloader_s132_6.1.0r0.hex | 0 .../feather52832_bootloader_s132_6.1.0r0.zip | Bin 168578 -> 168578 bytes .../feather52840_bootloader_s140_6.1.0r0.hex | 0 .../feather52840_bootloader_s140_6.1.0r0.zip | Bin 177490 -> 177490 bytes .../pca10056_bootloader_s140_6.1.0r0.hex | 0 .../pca10056_bootloader_s140_6.1.0r0.zip | Bin 177478 -> 177478 bytes 7 files changed, 42 insertions(+), 29 deletions(-) rename bin/feather52832/{beta => 6.1.0r0}/feather52832_bootloader_s132_6.1.0r0.hex (100%) rename bin/feather52832/{beta => 6.1.0r0}/feather52832_bootloader_s132_6.1.0r0.zip (99%) rename bin/feather52840/{beta => 6.1.0r0}/feather52840_bootloader_s140_6.1.0r0.hex (100%) rename bin/feather52840/{beta => 6.1.0r0}/feather52840_bootloader_s140_6.1.0r0.zip (99%) rename bin/pca10056/{beta => 6.1.0r0}/pca10056_bootloader_s140_6.1.0r0.hex (100%) rename bin/pca10056/{beta => 6.1.0r0}/pca10056_bootloader_s140_6.1.0r0.zip (99%) diff --git a/Makefile b/Makefile index ad272ef..ce46c88 100644 --- a/Makefile +++ b/Makefile @@ -32,9 +32,8 @@ SD_HEX = $(SD_PATH)/$(SD_FILENAME)_softdevice.hex LD_FILE = $(SRC_PATH)/linker/$(SD_NAME)_v$(SD_VER1).ld OUTPUT_FILENAME = $(BOARD)_bootloader -BOOT_SD_NAME = $(OUTPUT_FILENAME)_$(SD_NAME)_$(SD_VERSION_FULL) -BETA_DIR = bin/$(BOARD)/beta +MERGED_FNAME = $(OUTPUT_FILENAME)_$(SD_NAME)_$(SD_VERSION_FULL) RELEASE_DIR = bin/$(BOARD)/$(SD_VERSION_FULL) @@ -91,7 +90,7 @@ BOARD_LIST = $(sort $(subst .h,,$(subst src/boards/,,$(wildcard src/boards/*.h)) NRF52840_BOARDLIST = pca10056 feather52840 IS_NRF52840 = $(findstring $(BOARD),$(NRF52840_BOARDLIST)) -ifeq ($(findstring $(MAKECMDGOALS),all-board all-beta all-release),) +ifeq ($(findstring $(MAKECMDGOALS),all-board all-release),) ifeq ($(BOARD),) $(info You must provide a BOARD parameter with 'BOARD=') $(info Supported boards are: $(BOARD_LIST)) @@ -360,11 +359,6 @@ all-board: $(MAKE) -s -f $(MAKEFILE_LIST) -e BOARD=feather52840 clean all $(MAKE) -s -f $(MAKEFILE_LIST) -e BOARD=pca10056 clean all -all-beta: - $(MAKE) -s -f $(MAKEFILE_LIST) -e BOARD=feather52832 clean all beta - $(MAKE) -s -f $(MAKEFILE_LIST) -e BOARD=feather52840 clean all beta - $(MAKE) -s -f $(MAKEFILE_LIST) -e BOARD=pca10056 clean all beta - all-release: $(MAKE) -s -f $(MAKEFILE_LIST) -e BOARD=feather52832 clean all release $(MAKE) -s -f $(MAKEFILE_LIST) -e BOARD=feather52840 clean all release @@ -372,9 +366,40 @@ all-release: #******************* Flash target ******************* + +check_defined = \ + $(strip $(foreach 1,$1, \ + $(call __check_defined,$1,$(strip $(value 2))))) +__check_defined = \ + $(if $(value $1),, \ + $(error Undefined make flag: $1$(if $2, ($2)))) + +ifeq ($(VERSION),) + +# Flash the compiled flash: $(BUILD)/$(OUTPUT_FILENAME).hex @echo Flashing: $< $(NRFJPROG) --program $< --sectoranduicrerase -f nrf52 --reset + +dfu-flash: $(BUILD)/$(MERGED_FNAME).zip + @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0) + $(NRFUTIL) --verbose dfu serial --package $< -p $(SERIAL) -b 115200 --singlebank + +else + +VERSION_FPATH = bin/$(BOARD)/$(VERSION)/$(OUTPUT_FILENAME)_$(SD_NAME)_$(VERSION) + +# Flash specific version in binary release folder +flash: + @echo Flashing: $(VERSION_FPATH).hex + $(NRFJPROG) --program $(VERSION_FPATH).hex --sectoranduicrerase -f nrf52 --reset + +dfu-flash: + @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0) + $(NRFUTIL) --verbose dfu serial --package $(VERSION_FPATH).zip -p $(SERIAL) -b 115200 --singlebank + +endif + sd: @echo Flashing: $(SD_HEX) @@ -384,7 +409,6 @@ erase: @echo Erasing chip $(NRFJPROG) --eraseall -f nrf52 - #******************* Compile rules ******************* ## Create build directories @@ -416,38 +440,27 @@ size: $(BUILD)/$(OUTPUT_FILENAME).out #******************* Binary generator ******************* - -.phony: genhex genpkg beta release +.phony: genhex genpkg release ## Create binary .hex file from the .out file genhex: $(BUILD)/$(OUTPUT_FILENAME).hex $(BUILD)/$(OUTPUT_FILENAME).hex: $(BUILD)/$(OUTPUT_FILENAME).out @echo CR $(OUTPUT_FILENAME).hex - @echo CR $(BOOT_SD_NAME).hex + @echo CR $(MERGED_FNAME).hex $(QUIET)$(OBJCOPY) -O ihex $< $@ - @mergehex -q -m $@ $(SD_HEX) -o $(BUILD)/$(BOOT_SD_NAME).hex + @mergehex -q -m $@ $(SD_HEX) -o $(BUILD)/$(MERGED_FNAME).hex ## Create pkg file for bootloader+SD combo to use with DFU -genpkg: $(BUILD)/$(BOOT_SD_NAME).zip +genpkg: $(BUILD)/$(MERGED_FNAME).zip -$(BUILD)/$(BOOT_SD_NAME).zip: $(BUILD)/$(OUTPUT_FILENAME).hex +$(BUILD)/$(MERGED_FNAME).zip: $(BUILD)/$(OUTPUT_FILENAME).hex @$(NRFUTIL) dfu genpkg --dev-type 0x0052 --dev-revision $(DFU_DEV_REV) --bootloader $< --softdevice $(SD_HEX) $@ -# Create SD+bootloader combo with hex & dfu package at beta folder -beta: genhex genpkg - @echo CR $(BETA_DIR)/$(BOOT_SD_NAME).hex - @echo CR $(BETA_DIR)/$(BOOT_SD_NAME).zip - @mkdir -p $(BETA_DIR) - @cp $(BUILD)/$(BOOT_SD_NAME).hex $(BETA_DIR)/$(BOOT_SD_NAME).hex - @cp $(BUILD)/$(BOOT_SD_NAME).zip $(BETA_DIR)/$(BOOT_SD_NAME).zip - # Create SD+bootloader combo with hex & dfu package at release folder release: genhex genpkg - @echo CR $(RELEASE_DIR)/$(BOOT_SD_NAME).hex - @echo CR $(RELEASE_DIR)/$(BOOT_SD_NAME).zip + @echo CR $(RELEASE_DIR)/$(MERGED_FNAME).hex + @echo CR $(RELEASE_DIR)/$(MERGED_FNAME).zip @mkdir -p $(RELEASE_DIR) - @cp $(BUILD)/$(BOOT_SD_NAME).hex $(RELEASE_DIR)/$(BOOT_SD_NAME).hex - @cp $(BUILD)/$(BOOT_SD_NAME).zip $(RELEASE_DIR)/$(BOOT_SD_NAME).zip - - + @cp $(BUILD)/$(MERGED_FNAME).hex $(RELEASE_DIR)/$(MERGED_FNAME).hex + @cp $(BUILD)/$(MERGED_FNAME).zip $(RELEASE_DIR)/$(MERGED_FNAME).zip diff --git a/bin/feather52832/beta/feather52832_bootloader_s132_6.1.0r0.hex b/bin/feather52832/6.1.0r0/feather52832_bootloader_s132_6.1.0r0.hex similarity index 100% rename from bin/feather52832/beta/feather52832_bootloader_s132_6.1.0r0.hex rename to bin/feather52832/6.1.0r0/feather52832_bootloader_s132_6.1.0r0.hex diff --git a/bin/feather52832/beta/feather52832_bootloader_s132_6.1.0r0.zip b/bin/feather52832/6.1.0r0/feather52832_bootloader_s132_6.1.0r0.zip similarity index 99% rename from bin/feather52832/beta/feather52832_bootloader_s132_6.1.0r0.zip rename to bin/feather52832/6.1.0r0/feather52832_bootloader_s132_6.1.0r0.zip index f74d9a20ab1a617847e51b6121b58b2797dc528e..e348c58eaffddbb29183b70d500a1f86423c3e18 100644 GIT binary patch delta 74 zcmZo#%GI=#i#NcVnMH&F1YFm0P2@FV22zbqtxk+votS+3LA>n~`n~`_x diff --git a/bin/feather52840/beta/feather52840_bootloader_s140_6.1.0r0.hex b/bin/feather52840/6.1.0r0/feather52840_bootloader_s140_6.1.0r0.hex similarity index 100% rename from bin/feather52840/beta/feather52840_bootloader_s140_6.1.0r0.hex rename to bin/feather52840/6.1.0r0/feather52840_bootloader_s140_6.1.0r0.hex diff --git a/bin/feather52840/beta/feather52840_bootloader_s140_6.1.0r0.zip b/bin/feather52840/6.1.0r0/feather52840_bootloader_s140_6.1.0r0.zip similarity index 99% rename from bin/feather52840/beta/feather52840_bootloader_s140_6.1.0r0.zip rename to bin/feather52840/6.1.0r0/feather52840_bootloader_s140_6.1.0r0.zip index 54243fa5f0e7fb09fe96c8c68af3b8ffdfa55384..683e9c8ea4b8060dd3cd67ee13ee48511e579c30 100644 GIT binary patch delta 74 zcmccgitExVF5UodW)=|!5O811HIdhd8AvrcwK_3wbz+j)1mbN^+{9$Z1Y%8Jw1vq8 N%(w|-2yA6?0suQb7M=hA delta 74 zcmccgitExVF5UodW)=|!5IB^=Ig!_h8AvrcwK_3wbz+j)1mbN^+{9$Z1Y%8Jw1vq8 N%(w|-2yA6?0svwm7sLPn diff --git a/bin/pca10056/beta/pca10056_bootloader_s140_6.1.0r0.hex b/bin/pca10056/6.1.0r0/pca10056_bootloader_s140_6.1.0r0.hex similarity index 100% rename from bin/pca10056/beta/pca10056_bootloader_s140_6.1.0r0.hex rename to bin/pca10056/6.1.0r0/pca10056_bootloader_s140_6.1.0r0.hex diff --git a/bin/pca10056/beta/pca10056_bootloader_s140_6.1.0r0.zip b/bin/pca10056/6.1.0r0/pca10056_bootloader_s140_6.1.0r0.zip similarity index 99% rename from bin/pca10056/beta/pca10056_bootloader_s140_6.1.0r0.zip rename to bin/pca10056/6.1.0r0/pca10056_bootloader_s140_6.1.0r0.zip index bca603e7f027298df9a146bf7e1528b00b5c957b..a15f07c5dc1b71d8716b740fd16d19a9e3ec8be9 100644 GIT binary patch delta 74 zcmX^1itE@bF5UodW)=|!5b#{fHIdhd8AvrcwK_3wbz&0O1mbNE-Na=0st`07FGZN delta 74 zcmX^1itE@bF5UodW)=|!5IB;;Ig!_h8AvrcwK_3wbz&0O1mbNE-Na=0svRB7kmH!