move dfu-gen dfu-flash dfu-bootloader bootloader uf2 target to common Makefile since several board use it
This commit is contained in:
parent
bed7310fd7
commit
4920cc47ca
|
@ -244,6 +244,10 @@ hex: $(BUILD)/$(OUTPUT_FILENAME).hex
|
|||
$(BUILD)/$(OUTPUT_FILENAME).hex: $(BUILD)/$(OUTPUT_FILENAME).elf
|
||||
$(OBJCOPY) -O ihex $< $@
|
||||
|
||||
|
||||
#####################
|
||||
# Flash with debugger
|
||||
#####################
|
||||
FLASHER ?=
|
||||
|
||||
ifeq ($(FLASHER),)
|
||||
|
@ -283,6 +287,48 @@ sd: $(BUILD)/$(OUTPUT_FILENAME).hex
|
|||
|
||||
endif
|
||||
|
||||
|
||||
#####################
|
||||
# Flash with DFU
|
||||
#####################
|
||||
.phony: bootloader dfu-gen dfu-flash dfu-bootloader uf2
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
NRFUTIL = ../../lib/nrfutil/binaries/win32/nrfutil.exe
|
||||
else
|
||||
NRFUTIL = nrfutil
|
||||
endif
|
||||
|
||||
|
||||
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))))
|
||||
|
||||
dfu-gen:
|
||||
$(NRFUTIL) dfu genpkg --sd-req 0xFFFE --dev-type 0x0052 --application $(BUILD)/$(OUTPUT_FILENAME).hex $(BUILD)/dfu-package.zip
|
||||
|
||||
dfu-flash:
|
||||
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyUSB0)
|
||||
$(NRFUTIL) --verbose dfu serial --package $(BUILD)/dfu-package.zip -p $(SERIAL) -b 115200 --singlebank
|
||||
|
||||
dfu-bootloader:
|
||||
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
|
||||
$(NRFUTIL) --verbose dfu serial --package $(BOOT_FILE).zip -p $(SERIAL) -b 115200
|
||||
|
||||
uf2:
|
||||
$(ECHO) "Create $(OUTPUT_FILENAME).uf2"
|
||||
$(PYTHON2) $(TOP)/tools/uf2/utils/uf2conv.py -c -o "$(BUILD)/$(OUTPUT_FILENAME).uf2" "$(BUILD)/$(OUTPUT_FILENAME).hex"
|
||||
|
||||
# Flash bootloader with Jlink
|
||||
bootloader:
|
||||
nrfjprog --program $(BOOT_FILE).hex -f nrf52 --chiperase --reset
|
||||
|
||||
|
||||
|
||||
|
||||
$(BUILD)/$(OUTPUT_FILENAME).elf: $(OBJ)
|
||||
$(ECHO) "LINK $@"
|
||||
$(Q)$(CC) $(LDFLAGS) -o $@ $(OBJ) -Wl,--start-group $(LIBS) -Wl,--end-group
|
||||
|
|
|
@ -4,35 +4,8 @@ MCU_SUB_VARIANT = nrf52
|
|||
SOFTDEV_VERSION ?= 2.0.1
|
||||
|
||||
LD_FILE = boards/feather52832/custom_nrf52832_dfu_app_$(SOFTDEV_VERSION).ld
|
||||
BOOTLOADER_PKG = boards/feather52832/bootloader/feather52_bootloader_$(SOFTDEV_VERSION)_s132_single.zip
|
||||
BOOT_FILE = boards/feather52832/bootloader/feather52_bootloader_$(SOFTDEV_VERSION)_s132_single
|
||||
|
||||
BOOT_SETTING_ADDR = 0x7F000
|
||||
NRF_DEFINES += -DNRF52832_XXAA
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
NRFUTIL = ../../lib/nrfutil/binaries/win32/nrfutil.exe
|
||||
else
|
||||
NRFUTIL = nrfutil
|
||||
endif
|
||||
|
||||
CFLAGS += -DADAFRUIT_FEATHER52
|
||||
|
||||
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))))
|
||||
|
||||
.PHONY: dfu-gen dfu-flash boot-flash
|
||||
|
||||
dfu-gen:
|
||||
$(NRFUTIL) dfu genpkg --sd-req 0xFFFE --dev-type 0x0052 --application $(BUILD)/$(OUTPUT_FILENAME).hex $(BUILD)/dfu-package.zip
|
||||
|
||||
dfu-flash:
|
||||
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyUSB0)
|
||||
$(NRFUTIL) dfu serial --package $(BUILD)/dfu-package.zip -p $(SERIAL) -b 115200 --singlebank
|
||||
|
||||
dfu-bootloader:
|
||||
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyUSB0)
|
||||
$(NRFUTIL) dfu serial --package $(BOOTLOADER_PKG) -p $(SERIAL) -b 115200
|
||||
NRF_DEFINES += -DADAFRUIT_FEATHER52
|
||||
|
|
|
@ -7,41 +7,4 @@ LD_FILE = boards/feather52840/bluefruit_nrf52840_s140_$(SOFTDEV_VERSION).ld
|
|||
BOOT_FILE = boards/feather52840/bootloader/$(SOFTDEV_VERSION)/feather52840_bootloader_$(SOFTDEV_VERSION)_s140
|
||||
|
||||
NRF_DEFINES += -DNRF52840_XXAA
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
NRFUTIL = ../../lib/nrfutil/binaries/win32/nrfutil.exe
|
||||
else
|
||||
NRFUTIL = nrfutil
|
||||
endif
|
||||
|
||||
CFLAGS += -DADAFRUIT_FEATHER52840
|
||||
|
||||
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))))
|
||||
|
||||
.PHONY: dfu-gen dfu-flash dfu-bootloader uf2 bootloader
|
||||
|
||||
|
||||
uf2:
|
||||
$(ECHO) "Create $(OUTPUT_FILENAME).uf2"
|
||||
$(PYTHON2) $(TOP)/tools/uf2/utils/uf2conv.py -c -o "$(BUILD)/$(OUTPUT_FILENAME).uf2" "$(BUILD)/$(OUTPUT_FILENAME).hex"
|
||||
|
||||
# Flash with DFU
|
||||
dfu-gen:
|
||||
$(NRFUTIL) dfu genpkg --sd-req 0xFFFE --dev-type 0x0052 --application $(BUILD)/$(OUTPUT_FILENAME).hex $(BUILD)/dfu-package.zip
|
||||
|
||||
dfu-flash:
|
||||
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyUSB0)
|
||||
$(NRFUTIL) --verbose dfu serial --package $(BUILD)/dfu-package.zip -p $(SERIAL) -b 115200 --singlebank
|
||||
|
||||
dfu-bootloader:
|
||||
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
|
||||
$(NRFUTIL) --verbose dfu serial --package $(BOOT_FILE).zip -p $(SERIAL) -b 115200
|
||||
|
||||
# Flash with jlink
|
||||
bootloader:
|
||||
nrfjprog --program $(BOOT_FILE).hex -f nrf52 --chiperase --reset
|
||||
NRF_DEFINES += -DADAFRUIT_FEATHER52840
|
||||
|
|
Loading…
Reference in New Issue