diff --git a/nrf5/Makefile b/nrf5/Makefile index bedf42d0fc..73229443e7 100644 --- a/nrf5/Makefile +++ b/nrf5/Makefile @@ -198,37 +198,51 @@ OBJ += $(BUILD)/pins_gen.o $(BUILD)/$(FATFS_DIR)/ff.o: COPT += -Os $(filter $(PY_BUILD)/../extmod/vfs_fat_%.o, $(PY_O)): COPT += -Os -.phony: all flash sd +.phony: all flash sd binary hex -all: $(BUILD)/firmware.elf binary hex +all: binary hex + +OUTPUT_FILENAME = firmware + +## Create binary .bin file from the .out file +binary: $(BUILD)/$(OUTPUT_FILENAME).bin + +$(BUILD)/$(OUTPUT_FILENAME).bin: $(BUILD)/$(OUTPUT_FILENAME).elf + $(OBJCOPY) -O binary $< $@ + +## Create binary .hex file from the .out file +hex: $(BUILD)/$(OUTPUT_FILENAME).hex + +$(BUILD)/$(OUTPUT_FILENAME).hex: $(BUILD)/$(OUTPUT_FILENAME).elf + $(OBJCOPY) -O ihex $< $@ FLASHER ?= ifeq ($(FLASHER),) -flash: $(BUILD)/firmware.elf - nrfjprog --program $(BUILD)/firmware.hex --sectorerase -f $(MCU_VARIANT) +flash: $(BUILD)/$(OUTPUT_FILENAME).hex + nrfjprog --program $< --sectorerase -f $(MCU_VARIANT) nrfjprog --reset -f $(MCU_VARIANT) -sd: +sd: $(BUILD)/$(OUTPUT_FILENAME).hex nrfjprog --eraseall -f $(MCU_VARIANT) nrfjprog --program $(SOFTDEV_HEX) -f $(MCU_VARIANT) - nrfjprog --program $(BUILD)/firmware.hex --sectorerase -f $(MCU_VARIANT) + nrfjprog --program $< --sectorerase -f $(MCU_VARIANT) nrfjprog --reset -f $(MCU_VARIANT) else ifeq ($(FLASHER), pyocd) -flash: $(BUILD)/firmware.elf - pyocd-flashtool -t $(MCU_VARIANT) $(BUILD)/firmware.hex +flash: $(BUILD)/$(OUTPUT_FILENAME).hex + pyocd-flashtool -t $(MCU_VARIANT) $< -sd: +sd: $(BUILD)/$(OUTPUT_FILENAME).hex pyocd-flashtool -t $(MCU_VARIANT) --chip_erase pyocd-flashtool -t $(MCU_VARIANT) $(SOFTDEV_HEX) - pyocd-flashtool -t $(MCU_VARIANT) $(BUILD)/firmware.hex + pyocd-flashtool -t $(MCU_VARIANT) $< endif -$(BUILD)/firmware.elf: $(OBJ) +$(BUILD)/$(OUTPUT_FILENAME).elf: $(OBJ) $(ECHO) "LINK $@" $(Q)$(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) $(Q)$(SIZE) $@ @@ -280,4 +294,4 @@ CFLAGS += -DMICROPY_MODULE_FROZEN_MPY endif include ../py/mkrules.mk -include mkrules.mk + diff --git a/nrf5/mkrules.mk b/nrf5/mkrules.mk deleted file mode 100644 index 6ae98cdc8d..0000000000 --- a/nrf5/mkrules.mk +++ /dev/null @@ -1,10 +0,0 @@ -OUTPUT_FILENAME = firmware - -## Create binary .bin file from the .out file -binary: - $(OBJCOPY) -O binary $(BUILD)/$(OUTPUT_FILENAME).elf $(BUILD)/$(OUTPUT_FILENAME).bin - -## Create binary .hex file from the .out file -hex: - $(OBJCOPY) -O ihex $(BUILD)/$(OUTPUT_FILENAME).elf $(BUILD)/$(OUTPUT_FILENAME).hex -