Skip to content

Commit

Permalink
Merge pull request #168 from tracernz/ef_naze32
Browse files Browse the repository at this point in the history
Make: Add EF target for Naze, make Intel hex of EF image
  • Loading branch information
mlyle committed Dec 6, 2015
2 parents 66d9ff7 + 5dab284 commit 0d597f7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
21 changes: 13 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down
17 changes: 15 additions & 2 deletions flight/targets/EntireFlash/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Expand All @@ -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 $<"
Expand Down
3 changes: 3 additions & 0 deletions flight/targets/naze32/target-defs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0d597f7

Please sign in to comment.