diff --git a/Makefile b/Makefile index 88bde6983a..a2182ae759 100644 --- a/Makefile +++ b/Makefile @@ -758,20 +758,24 @@ bu_$(1)_clean: endef # $(1) = Canonical board name all in lower case (e.g. coptercontrol) +# $(2) = Friendly board name +# $(3) = Short board name +# $(4) = yes for bootloader, no for no bootloader define EF_TEMPLATE .PHONY: ef_$(1) -ef_$(1): ef_$(1)_bin +ef_$(1): ef_$(1)_bin ef_$(1)_hex ef_$(1)_%: TARGET=ef_$(1) ef_$(1)_%: OUTDIR=$(BUILD_DIR)/$$(TARGET) ef_$(1)_%: BOARD_ROOT_DIR=$(ROOT_DIR)/flight/targets/$(1) -ef_$(1)_%: bl_$(1)_bin fw_$(1)_tlfw +ef_$(1)_%: $(if filter(no,$(4)),fw_$(1)_tlfw,bl_$(1)_bin fw_$(1)_tlfw) $(V1) mkdir -p $$(OUTDIR)/dep $(V1) cd $(ROOT_DIR)/flight/targets/EntireFlash && \ $$(MAKE) -r --no-print-directory \ BOARD_NAME=$(1) \ BOARD_SHORT_NAME=$(3) \ BUILD_TYPE=ef \ + INCLUDE_BOOTLOADER=$(4) \ TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \ REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" \ DFU_CMD="$(DFUUTIL_DIR)/bin/dfu-util" \ @@ -863,11 +867,12 @@ all_$(1)_clean: $$(addsuffix _clean, $$(filter bu_$(1), $$(BU_TARGETS))) all_$(1)_clean: $$(addsuffix _clean, $$(filter ef_$(1), $$(EF_TARGETS))) endef -# Start out assuming that we'll build fw, bl and bu for all boards -FW_BOARDS := $(ALL_BOARDS) -BL_BOARDS := $(filter-out naze32, $(ALL_BOARDS)) -BU_BOARDS := $(BL_BOARDS) -EF_BOARDS := $(filter-out naze32, $(ALL_BOARDS)) +# Some boards don't use the bootloader +FW_BOARDS := $(ALL_BOARDS) +NOBL_BOARDS := $(strip $(foreach BOARD, $(ALL_BOARDS),$(if $(filter no,$($(BOARD)_bootloader)),$(BOARD)))) +BL_BOARDS := $(filter-out $(NOBL_BOARDS), $(ALL_BOARDS)) +BU_BOARDS := $(BL_BOARDS) +EF_BOARDS := $(ALL_BOARDS) # Sim targets are different for each host OS ifeq ($(UNAME), Linux) @@ -923,7 +928,7 @@ $(foreach board, $(FW_BOARDS), $(eval $(call FW_TEMPLATE,$(board),$($(board)_fri $(foreach board, $(BL_BOARDS), $(eval $(call BL_TEMPLATE,$(board),$($(board)_cpuarch),$($(board)_short)))) # Expand the entire-flash rules -$(foreach board, $(EF_BOARDS), $(eval $(call EF_TEMPLATE,$(board),$($(board)_friendly),$($(board)_short)))) +$(foreach board, $(EF_BOARDS), $(eval $(call EF_TEMPLATE,$(board),$($(board)_friendly),$($(board)_short),$($(board)_bootloader)))) # Expand the available simulator rules $(eval $(call SIM_TEMPLATE,simulation,Simulation,'sim ',posix,elf)) diff --git a/flight/targets/EntireFlash/Makefile b/flight/targets/EntireFlash/Makefile index 82e00d7072..5e38d94ed0 100644 --- a/flight/targets/EntireFlash/Makefile +++ b/flight/targets/EntireFlash/Makefile @@ -38,13 +38,21 @@ FORCE: .PHONY: bin bin: $(OUTDIR)/$(TARGET).bin +hex: $(OUTDIR)/$(TARGET).hex -BL_BIN := $(ROOT_DIR)/build/bl_$(BOARD_NAME)/bl_$(BOARD_NAME).bin FW_BIN := $(ROOT_DIR)/build/fw_$(BOARD_NAME)/fw_$(BOARD_NAME).bin FWINFO_BIN := $(FW_BIN).firmwareinfo.bin +INCLUDE_BOOTLOADER ?= yes -# force this target as FW_PRE_PAD could have been changed without us knowing +ifeq ($(INCLUDE_BOOTLOADER),no) +BL_BIN := +FW_PRE_PAD := $(shell echo $$[$(FW_BANK_BASE)-$(EF_BANK_BASE)]) +else +BL_BIN := $(ROOT_DIR)/build/bl_$(BOARD_NAME)/bl_$(BOARD_NAME).bin FW_PRE_PAD := $(shell echo $$[$(FW_BANK_BASE)-$(BL_BANK_BASE)-$(BL_BANK_SIZE)]) +endif # INCLUDE_BOOTLOADER + +# force this target as FW_PRE_PAD could have been changed without us knowing $(OUTDIR)/$(TARGET).fw_pre.pad: FORCE $(V0) @echo $(MSG_PADDING) $(call toprel, $@) $(V1) dd if=/dev/zero count=$(FW_PRE_PAD) bs=1 2> /dev/null | LC_CTYPE=c tr '\000' '\377' > $@ && [ $${PIPESTATUS[0]} -eq "0" ] @@ -61,6 +69,11 @@ $(OUTDIR)/$(TARGET).bin: $(BL_BIN) $(FW_BIN) $(OUTDIR)/$(TARGET).fw_pre.pad $(OU $(V0) @echo $(MSG_FLASH_IMG) $(call toprel, $@) $(V1) cat $(BL_BIN) $(OUTDIR)/$(TARGET).fw_pre.pad $(FW_BIN) $(FWINFO_BIN) $(OUTDIR)/$(TARGET).fw_post.pad $(FWINFO_BIN) > $@ +$(OUTDIR)/$(TARGET).hex: $(OUTDIR)/$(TARGET).bin + $(V0) @echo $(MSG_FLASH_IMG) $(call toprel, $@) + $(V1) $(OBJCOPY) --change-addresses=$(EF_BANK_BASE) -I binary -O ihex $^ $@ + + .PHONY: dfu dfu: $(OUTDIR)/$(TARGET).bin $(V0) @echo " DFU RESCUE $<" diff --git a/flight/targets/naze32/target-defs.mk b/flight/targets/naze32/target-defs.mk index 7bf7522392..7979aca0c0 100644 --- a/flight/targets/naze32/target-defs.mk +++ b/flight/targets/naze32/target-defs.mk @@ -8,3 +8,6 @@ naze32_cpuarch := f1 # Short name of this board (used to display board name in parallel builds) # Should be exactly 4 characters long. naze32_short := 'naze' + +# Whether the board uses the bootloader or not (some use the ST bootloader in ROM) +naze32_bootloader := no