From 6ec6425f5e04e2617d1257dbc8797c7a1a6331ad Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Sat, 21 May 2011 13:55:15 -0400 Subject: [PATCH 01/18] build: build opf images including firmware + version blob --- Makefile | 12 ++++++------ flight/AHRS/Makefile | 5 ++++- flight/CopterControl/Makefile | 5 ++++- flight/INS/Makefile | 8 +++++++- flight/OpenPilot/Makefile | 5 ++++- flight/PipXtreme/Makefile | 5 ++++- make/firmware-defs.mk | 28 ++++++++++++++++++++++++++++ 7 files changed, 57 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 0d2700868..57bad68b3 100644 --- a/Makefile +++ b/Makefile @@ -321,7 +321,7 @@ BL_TARGETS := $(filter-out bl_ins, $(BL_TARGETS)) BLUPD_TARGETS := $(filter-out blupd_ins, $(BLUPD_TARGETS)) .PHONY: all_fw all_fw_clean -all_fw: $(addsuffix _bin, $(FW_TARGETS)) +all_fw: $(addsuffix _opf, $(FW_TARGETS)) all_fw_clean: $(addsuffix _clean, $(FW_TARGETS)) .PHONY: all_bl all_bl_clean @@ -337,7 +337,7 @@ all_flight: all_fw all_bl all_blupd all_flight_clean: all_fw_clean all_bl_clean all_blupd_clean .PHONY: openpilot -openpilot: openpilot_bin +openpilot: openpilot_opf openpilot_%: uavobjects_flight $(V1) mkdir -p $(BUILD_DIR)/openpilot/dep @@ -385,7 +385,7 @@ blupd_openpilot_clean: $(V1) $(RM) -fr $(BUILD_DIR)/blupd_openpilot .PHONY: ahrs -ahrs: ahrs_bin +ahrs: ahrs_opf ahrs_%: uavobjects_flight $(V1) mkdir -p $(BUILD_DIR)/ahrs/dep @@ -433,7 +433,7 @@ blupd_ahrs_clean: $(V1) $(RM) -fr $(BUILD_DIR)/blupd_ahrs .PHONY: coptercontrol -coptercontrol: coptercontrol_bin +coptercontrol: coptercontrol_opf coptercontrol_%: uavobjects_flight $(V1) mkdir -p $(BUILD_DIR)/coptercontrol/dep @@ -481,7 +481,7 @@ blupd_coptercontrol_clean: $(V1) $(RM) -fr $(BUILD_DIR)/blupd_coptercontrol .PHONY: pipxtreme -pipxtreme: pipxtreme_bin +pipxtreme: pipxtreme_opf pipxtreme_%: uavobjects_flight $(V1) mkdir -p $(BUILD_DIR)/pipxtreme/dep @@ -530,7 +530,7 @@ blupd_pipxtreme_clean: .PHONY: ins -ins: ins_bin +ins: ins_opf ins_%: uavobjects_flight $(V1) mkdir -p $(BUILD_DIR)/ins/dep diff --git a/flight/AHRS/Makefile b/flight/AHRS/Makefile index d4dafd68f..5e482aaf0 100644 --- a/flight/AHRS/Makefile +++ b/flight/AHRS/Makefile @@ -382,13 +382,16 @@ $(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin -.PHONY: elf lss sym hex bin bino +$(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,0x02,0x01)) + +.PHONY: elf lss sym hex bin bino opf elf: $(OUTDIR)/$(TARGET).elf lss: $(OUTDIR)/$(TARGET).lss sym: $(OUTDIR)/$(TARGET).sym hex: $(OUTDIR)/$(TARGET).hex bin: $(OUTDIR)/$(TARGET).bin bino: $(OUTDIR)/$(TARGET).bin.o +opf: $(OUTDIR)/$(TARGET).opf # Display sizes of sections. $(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) diff --git a/flight/CopterControl/Makefile b/flight/CopterControl/Makefile index 627882539..a0d882cfe 100644 --- a/flight/CopterControl/Makefile +++ b/flight/CopterControl/Makefile @@ -576,13 +576,16 @@ $(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin -.PHONY: elf lss sym hex bin bino +$(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,0x04,0x01)) + +.PHONY: elf lss sym hex bin bino opf elf: $(OUTDIR)/$(TARGET).elf lss: $(OUTDIR)/$(TARGET).lss sym: $(OUTDIR)/$(TARGET).sym hex: $(OUTDIR)/$(TARGET).hex bin: $(OUTDIR)/$(TARGET).bin bino: $(OUTDIR)/$(TARGET).bin.o +opf: $(OUTDIR)/$(TARGET).opf # Display sizes of sections. $(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) diff --git a/flight/INS/Makefile b/flight/INS/Makefile index 1b27d8cba..0888845a0 100644 --- a/flight/INS/Makefile +++ b/flight/INS/Makefile @@ -400,12 +400,18 @@ $(eval $(call PARTIAL_COMPILE_TEMPLATE, SRC)) # Compile: create assembler files from C source files. ARM only $(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) -.PHONY: elf lss sym hex bin +$(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin + +$(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,0x05,0x01)) + +.PHONY: elf lss sym hex bin bino opf elf: $(OUTDIR)/$(TARGET).elf lss: $(OUTDIR)/$(TARGET).lss sym: $(OUTDIR)/$(TARGET).sym hex: $(OUTDIR)/$(TARGET).hex bin: $(OUTDIR)/$(TARGET).bin +bino: $(OUTDIR)/$(TARGET).bin.o +opf: $(OUTDIR)/$(TARGET).opf # Display sizes of sections. $(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) diff --git a/flight/OpenPilot/Makefile b/flight/OpenPilot/Makefile index add129e41..9d7ba36fb 100644 --- a/flight/OpenPilot/Makefile +++ b/flight/OpenPilot/Makefile @@ -556,13 +556,16 @@ $(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin -.PHONY: elf lss sym hex bin bino +$(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,0x01,0x01)) + +.PHONY: elf lss sym hex bin bino opf elf: $(OUTDIR)/$(TARGET).elf lss: $(OUTDIR)/$(TARGET).lss sym: $(OUTDIR)/$(TARGET).sym hex: $(OUTDIR)/$(TARGET).hex bin: $(OUTDIR)/$(TARGET).bin bino: $(OUTDIR)/$(TARGET).bin.o +opf: $(OUTDIR)/$(TARGET).opf # Display sizes of sections. $(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) diff --git a/flight/PipXtreme/Makefile b/flight/PipXtreme/Makefile index 3955d1929..2de5e70c9 100644 --- a/flight/PipXtreme/Makefile +++ b/flight/PipXtreme/Makefile @@ -422,13 +422,16 @@ $(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin -.PHONY: elf lss sym hex bin bino +$(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,0x03,0x01)) + +.PHONY: elf lss sym hex bin bino opf elf: $(OUTDIR)/$(TARGET).elf lss: $(OUTDIR)/$(TARGET).lss sym: $(OUTDIR)/$(TARGET).sym hex: $(OUTDIR)/$(TARGET).hex bin: $(OUTDIR)/$(TARGET).bin bino: $(OUTDIR)/$(TARGET).bin.o +opf: $(OUTDIR)/$(TARGET).opf # Display sizes of sections. $(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) diff --git a/make/firmware-defs.mk b/make/firmware-defs.mk index eee2d6e9c..5a8f0cb21 100644 --- a/make/firmware-defs.mk +++ b/make/firmware-defs.mk @@ -45,6 +45,8 @@ MSG_ASMFROMC := ${quote} AS(C) ${quote} MSG_ASMFROMC_ARM := ${quote} AS(C)-ARM ${quote} MSG_PYMITEINIT := ${quote} PY ${quote} MSG_INSTALLING := ${quote} INSTALL ${quote} +MSG_OPFIRMWARE := ${quote} OPF ${quote} +MSG_FWDESC := ${quote} FWDESC ${quote} toprel = $(subst $(realpath $(TOP))/,,$(abspath $(1))) @@ -68,6 +70,10 @@ gccversion : @echo $(MSG_LOAD_FILE) $(call toprel, $@) $(V1) $(OBJCOPY) -O binary $< $@ +%.bin: %.o + @echo $(MSG_LOAD_FILE) $(call toprel, $@) + $(V1) $(OBJCOPY) -O binary $< $@ + %.bin.o: %.bin @echo $(MSG_BIN_OBJ) $(call toprel, $@) $(V1) $(OBJCOPY) -I binary -O elf32-littlearm --binary-architecture arm \ @@ -96,6 +102,28 @@ $(1)_size: $(1) $(V1) $(SIZE) -A $$< endef +# OpenPilot firmware image template +# $(1) = path to bin file +# $(2) = boardtype in hex +# $(3) = board revision in hex +define OPF_TEMPLATE +$(1).firmwareinfo.c: $(1) $(TOP)/make/templates/firmwareinfotemplate.c + @echo $(MSG_FWDESC) $$(call toprel, $$@) + $(V1) python $(TOP)/make/scripts/version-info.py \ + --path=$(TOP) \ + --template=$(TOP)/make/templates/firmwareinfotemplate.c \ + --outfile=$$@ \ + --image=$(1) \ + --type=$(2) \ + --revision=$(3) + +$(eval $(call COMPILE_C_TEMPLATE, $(1).firmwareinfo.c)) + +$(OUTDIR)/$(notdir $(basename $(1))).opf : $(1) $(1).firmwareinfo.bin + @echo $(MSG_OPFIRMWARE) $$(call toprel, $$@) + $(V1) cat $(1) $(1).firmwareinfo.bin > $$@ +endef + # Assemble: create object files from assembler source files. define ASSEMBLE_TEMPLATE $(OUTDIR)/$(notdir $(basename $(1))).o : $(1) From 0a67730d0feb952a6db2dd55f83fa44aa4d0ecf1 Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Mon, 23 May 2011 15:11:53 -0400 Subject: [PATCH 02/18] build: refactor fw, bl and bu rules - New macros for fw, bl and bu rules in top-level make - Per-board info factored into make/board/*/board-info.mk - Per-board info now shared btw. fw, bl and blupd for each board - BOARD_TYPE, BOARD_REVISION, BOOTLOADER_VERSION, HW_TYPE - MCU, CHIP, BOARD, MODEL, MODEL_SUFFIX - START_OF_BL_CODE, START_OF_FW_CODE - blupd_* goals renamed to bu_* - all_blupd goal renamed to all_bu - firmware goals renamed to fw_*, board name goals are preserved - bu_*_program now writes updater to correct address for all boards - BL updater firmware builds now produce .opf format including version info blob. - BL updater firmware name now includes board name. - INS makefile brought up to date w.r.t. linker scripts --- Makefile | 339 +++++------------- flight/AHRS/Makefile | 30 +- flight/Bootloaders/AHRS/Makefile | 30 +- flight/Bootloaders/BootloaderUpdater/Makefile | 33 +- flight/Bootloaders/CopterControl/Makefile | 28 +- flight/Bootloaders/OpenPilot/Makefile | 28 +- flight/Bootloaders/PipXtreme/Makefile | 28 +- flight/CopterControl/Makefile | 30 +- flight/INS/Makefile | 47 +-- flight/OpenPilot/Makefile | 30 +- ...BL.ld => link_STM3210E_INS_BL_sections.ld} | 36 +- .../STM32F10x/link_STM3210E_INS_memory.ld | 13 + ...HD_NB.ld => link_STM3210E_INS_sections.ld} | 36 +- .../STM32F10x/link_STM3210E_OP_BL_sections.ld | 2 +- flight/PipXtreme/Makefile | 32 +- make/boards/ahrs/board-info.mk | 13 + make/boards/coptercontrol/board-info.mk | 13 + make/boards/ins/board-info.mk | 13 + make/boards/openpilot/board-info.mk | 13 + make/boards/pipxtreme/board-info.mk | 13 + make/firmware-defs.mk | 4 +- release/Makefile | 20 +- 22 files changed, 328 insertions(+), 503 deletions(-) rename flight/PiOS/STM32F10x/{link_STM3210E_INS_HD_BL.ld => link_STM3210E_INS_BL_sections.ld} (92%) create mode 100644 flight/PiOS/STM32F10x/link_STM3210E_INS_memory.ld rename flight/PiOS/STM32F10x/{link_STM3210E_INS_HD_NB.ld => link_STM3210E_INS_sections.ld} (93%) create mode 100644 make/boards/ahrs/board-info.mk create mode 100644 make/boards/coptercontrol/board-info.mk create mode 100644 make/boards/ins/board-info.mk create mode 100644 make/boards/openpilot/board-info.mk create mode 100644 make/boards/pipxtreme/board-info.mk diff --git a/Makefile b/Makefile index 57bad68b3..54b5c1e19 100644 --- a/Makefile +++ b/Makefile @@ -77,13 +77,13 @@ help: @echo " all_flight - Build all firmware, bootloaders and bootloader updaters" @echo " all_fw - Build only firmware for all boards" @echo " all_bl - Build only bootloaders for all boards" - @echo " all_blupd - Build only bootloader updaters for all boards" + @echo " all_bu - Build only bootloader updaters for all boards" @echo @echo " all_clean - Remove your build directory ($(BUILD_DIR))" @echo " all_flight_clean - Remove all firmware, bootloaders and bootloader updaters" @echo " all_fw_clean - Remove firmware for all boards" @echo " all_bl_clean - Remove bootlaoders for all boards" - @echo " all_blupd_clean - Remove bootloader updaters for all boards" + @echo " all_bu_clean - Remove bootloader updaters for all boards" @echo @echo " [Firmware]" @echo " - Build firmware for " @@ -98,9 +98,9 @@ help: @echo " bl__program - Use OpenOCD + JTAG to write bootloader to " @echo @echo " [Bootloader Updater]" - @echo " blupd_ - Build bootloader updater for " - @echo " supported boards are ($(BLUPD_TARGETS))" - @echo " blupd__clean - Remove bootloader updater for " + @echo " bu_ - Build bootloader updater for " + @echo " supported boards are ($(BU_TARGETS))" + @echo " bu__clean - Remove bootloader updater for " @echo @echo " [Simulation]" @echo " sim_posix - Build OpenPilot simulation firmware for" @@ -311,254 +311,113 @@ uavobjects_clean: # ############################## -FW_TARGETS := openpilot ahrs coptercontrol pipxtreme ins -BL_TARGETS := $(addprefix bl_, $(FW_TARGETS)) -BLUPD_TARGETS := $(addprefix blupd_, $(FW_TARGETS)) +# $(1) = Canonical board name all in lower case (e.g. coptercontrol) +# $(2) = Name of board used in source tree (e.g. CopterControl) +define FW_TEMPLATE +.PHONY: $(1) fw_$(1) +$(1): fw_$(1)_opf +fw_$(1): fw_$(1)_opf + +fw_$(1)_%: uavobjects_flight + $(V1) mkdir -p $(BUILD_DIR)/fw_$(1)/dep + $(V1) cd $(ROOT_DIR)/flight/$(2) && \ + $$(MAKE) -r --no-print-directory \ + BOARD_NAME=$(1) \ + TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \ + REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" \ + $$* + +.PHONY: $(1)_clean +$(1)_clean: fw_$(1)_clean +fw_$(1)_clean: + $(V0) @echo " CLEAN $$@" + $(V1) $(RM) -fr $(BUILD_DIR)/fw_$(1) +endef + +# $(1) = Canonical board name all in lower case (e.g. coptercontrol) +# $(2) = Name of board used in source tree (e.g. CopterControl) +define BL_TEMPLATE +.PHONY: bl_$(1) +bl_$(1): bl_$(1)_bin +bl_$(1)_bino: bl_$(1)_bin + +bl_$(1)_%: + $(V1) mkdir -p $(BUILD_DIR)/bl_$(1)/dep + $(V1) cd $(ROOT_DIR)/flight/Bootloaders/$(2) && \ + $$(MAKE) -r --no-print-directory \ + BOARD_NAME=$(1) \ + TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \ + REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" \ + $$* + +.PHONY: bl_$(1)_clean +bl_$(1)_clean: + $(V0) @echo " CLEAN $$@" + $(V1) $(RM) -fr $(BUILD_DIR)/bl_$(1) +endef + +# $(1) = Canonical board name all in lower case (e.g. coptercontrol) +define BU_TEMPLATE +.PHONY: bu_$(1) +bu_$(1): bu_$(1)_opf + +bu_$(1)_%: bl_$(1)_bino + $(V1) mkdir -p $(BUILD_DIR)/bu_$(1)/dep + $(V1) cd $(ROOT_DIR)/flight/Bootloaders/BootloaderUpdater && \ + $$(MAKE) -r --no-print-directory \ + BOARD_NAME=$(1) \ + TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \ + REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" \ + $$* + +.PHONY: bu_$(1)_clean +bu_$(1)_clean: + $(V0) @echo " CLEAN $$@" + $(V1) $(RM) -fr $(BUILD_DIR)/bu_$(1) +endef + +ALL_BOARDS := openpilot ahrs coptercontrol pipxtreme ins + +# Friendly names of each board (used to find source tree) +openpilot_friendly := OpenPilot +coptercontrol_friendly := CopterControl +pipxtreme_friendly := PipXtreme +ins_friendly := INS +ahrs_friendly := AHRS + +FW_TARGETS := $(addprefix fw_, $(ALL_BOARDS)) +BL_TARGETS := $(addprefix bl_, $(ALL_BOARDS)) +BU_TARGETS := $(addprefix bu_, $(ALL_BOARDS)) # FIXME: The INS build doesn't have a bootloader or bootloader # updater yet so we need to filter them out to prevent errors. -BL_TARGETS := $(filter-out bl_ins, $(BL_TARGETS)) -BLUPD_TARGETS := $(filter-out blupd_ins, $(BLUPD_TARGETS)) +BL_TARGETS := $(filter-out bl_ins, $(BL_TARGETS)) +BU_TARGETS := $(filter-out bu_ins, $(BU_TARGETS)) .PHONY: all_fw all_fw_clean -all_fw: $(addsuffix _opf, $(FW_TARGETS)) -all_fw_clean: $(addsuffix _clean, $(FW_TARGETS)) +all_fw: $(addsuffix _opf, $(FW_TARGETS)) +all_fw_clean: $(addsuffix _clean, $(FW_TARGETS)) .PHONY: all_bl all_bl_clean -all_bl: $(addsuffix _bin, $(BL_TARGETS)) -all_bl_clean: $(addsuffix _clean, $(BL_TARGETS)) +all_bl: $(addsuffix _bin, $(BL_TARGETS)) +all_bl_clean: $(addsuffix _clean, $(BL_TARGETS)) -.PHONY: all_blupd all_blupd_clean -all_blupd: $(addsuffix _bin, $(BLUPD_TARGETS)) -all_blupd_clean: $(addsuffix _clean, $(BLUPD_TARGETS)) +.PHONY: all_bu all_bu_clean +all_bu: $(addsuffix _opf, $(BU_TARGETS)) +all_bu_clean: $(addsuffix _clean, $(BU_TARGETS)) .PHONY: all_flight all_flight_clean -all_flight: all_fw all_bl all_blupd -all_flight_clean: all_fw_clean all_bl_clean all_blupd_clean +all_flight: all_fw all_bl all_bu +all_flight_clean: all_fw_clean all_bl_clean all_bu_clean -.PHONY: openpilot -openpilot: openpilot_opf +# Expand the bootloader updater rules +$(foreach board, $(ALL_BOARDS), $(eval $(call BU_TEMPLATE,$(board),$($(board)_friendly)))) -openpilot_%: uavobjects_flight - $(V1) mkdir -p $(BUILD_DIR)/openpilot/dep - $(V1) cd $(ROOT_DIR)/flight/OpenPilot && \ - $(MAKE) -r --no-print-directory \ - OUTDIR="$(BUILD_DIR)/openpilot" TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \ - REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" $* - -.PHONY: openpilot_clean -openpilot_clean: - $(V0) @echo " CLEAN $@" - $(V1) $(RM) -fr $(BUILD_DIR)/openpilot - -.PHONY: bl_openpilot -bl_openpilot: bl_openpilot_bin -bl_openpilot_bino: bl_openpilot_bin - -bl_openpilot_%: - $(V1) mkdir -p $(BUILD_DIR)/bl_openpilot/dep - $(V1) cd $(ROOT_DIR)/flight/Bootloaders/OpenPilot && \ - $(MAKE) -r --no-print-directory \ - OUTDIR="$(BUILD_DIR)/bl_openpilot" TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \ - REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" $* - -.PHONY: bl_openpilot_clean -bl_openpilot_clean: - $(V0) @echo " CLEAN $@" - $(V1) $(RM) -fr $(BUILD_DIR)/bl_openpilot - -.PHONY: blupd_openpilot -blupd_openpilot: blupd_openpilot_bin - -blupd_openpilot_%: bl_openpilot_bino - $(V1) mkdir -p $(BUILD_DIR)/blupd_openpilot/dep - $(V1) cd $(ROOT_DIR)/flight/Bootloaders/BootloaderUpdater && \ - $(MAKE) -r --no-print-directory \ - OUTDIR="$(BUILD_DIR)/blupd_openpilot" TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \ - REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" \ - BOARD=STM3210E_OP MODEL=HD MODEL_SUFFIX=_OP \ - BLOBJ=$(BUILD_DIR)/bl_openpilot/OpenPilot_BL.bin.o $* - -.PHONY: blupd_openpilot_clean -blupd_openpilot_clean: - $(V0) @echo " CLEAN $@" - $(V1) $(RM) -fr $(BUILD_DIR)/blupd_openpilot - -.PHONY: ahrs -ahrs: ahrs_opf - -ahrs_%: uavobjects_flight - $(V1) mkdir -p $(BUILD_DIR)/ahrs/dep - $(V1) cd $(ROOT_DIR)/flight/AHRS && \ - $(MAKE) -r --no-print-directory \ - OUTDIR="$(BUILD_DIR)/ahrs" TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \ - REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" $* - -.PHONY: ahrs_clean -ahrs_clean: - $(V0) @echo " CLEAN $@" - $(V1) $(RM) -fr $(BUILD_DIR)/ahrs - -.PHONY: bl_ahrs -bl_ahrs: bl_ahrs_bin -bl_ahrs_bino: bl_ahrs_bin - -bl_ahrs_%: - $(V1) mkdir -p $(BUILD_DIR)/bl_ahrs/dep - $(V1) cd $(ROOT_DIR)/flight/Bootloaders/AHRS && \ - $(MAKE) -r --no-print-directory \ - OUTDIR="$(BUILD_DIR)/bl_ahrs" TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \ - REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" $* - -.PHONY: bl_ahrs_clean -bl_ahrs_clean: - $(V0) @echo " CLEAN $@" - $(V1) $(RM) -fr $(BUILD_DIR)/bl_ahrs - -.PHONY: blupd_ahrs -blupd_ahrs: blupd_ahrs_bin - -blupd_ahrs_%: bl_ahrs_bino bl_ahrs - $(V1) mkdir -p $(BUILD_DIR)/blupd_ahrs/dep - $(V1) cd $(ROOT_DIR)/flight/Bootloaders/BootloaderUpdater && \ - $(MAKE) -r --no-print-directory \ - OUTDIR="$(BUILD_DIR)/blupd_ahrs" TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \ - REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" \ - BOARD=STM32103CB_AHRS MODEL=MD \ - BLOBJ=$(BUILD_DIR)/bl_ahrs/AHRS_BL.bin.o $* - -.PHONY: blupd_ahrs_clean -blupd_ahrs_clean: - $(V0) @echo " CLEAN $@" - $(V1) $(RM) -fr $(BUILD_DIR)/blupd_ahrs - -.PHONY: coptercontrol -coptercontrol: coptercontrol_opf - -coptercontrol_%: uavobjects_flight - $(V1) mkdir -p $(BUILD_DIR)/coptercontrol/dep - $(V1) cd $(ROOT_DIR)/flight/CopterControl && \ - $(MAKE) -r --no-print-directory \ - OUTDIR="$(BUILD_DIR)/coptercontrol" TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \ - REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" $* - -.PHONY: coptercontrol_clean -coptercontrol_clean: - $(V0) @echo " CLEAN $@" - $(V1) $(RM) -fr $(BUILD_DIR)/coptercontrol - -.PHONY: bl_coptercontrol -bl_coptercontrol: bl_coptercontrol_bin -bl_coptercontrol_bino: bl_coptercontrol_bin - -bl_coptercontrol_%: - $(V1) mkdir -p $(BUILD_DIR)/bl_coptercontrol/dep - $(V1) cd $(ROOT_DIR)/flight/Bootloaders/CopterControl && \ - $(MAKE) -r --no-print-directory \ - OUTDIR="$(BUILD_DIR)/bl_coptercontrol" TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \ - REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" $* - -.PHONY: bl_coptercontrol_clean -bl_coptercontrol_clean: - $(V0) @echo " CLEAN $@" - $(V1) $(RM) -fr $(BUILD_DIR)/bl_coptercontrol - -.PHONY: blupd_coptercontrol -blupd_coptercontrol: blupd_coptercontrol_bin - -blupd_coptercontrol_%: bl_coptercontrol_bino - $(V1) mkdir -p $(BUILD_DIR)/blupd_coptercontrol/dep - $(V1) cd $(ROOT_DIR)/flight/Bootloaders/BootloaderUpdater && \ - $(MAKE) -r --no-print-directory \ - OUTDIR="$(BUILD_DIR)/blupd_coptercontrol" TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \ - REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" \ - BOARD=STM32103CB_CC_Rev1 MODEL=MD MODEL_SUFFIX=_CC \ - BLOBJ=$(BUILD_DIR)/bl_coptercontrol/CopterControl_BL.bin.o $* - -.PHONY: blupd_coptercontrol_clean -blupd_coptercontrol_clean: - $(V0) @echo " CLEAN $@" - $(V1) $(RM) -fr $(BUILD_DIR)/blupd_coptercontrol - -.PHONY: pipxtreme -pipxtreme: pipxtreme_opf - -pipxtreme_%: uavobjects_flight - $(V1) mkdir -p $(BUILD_DIR)/pipxtreme/dep - $(V1) cd $(ROOT_DIR)/flight/PipXtreme && \ - $(MAKE) -r --no-print-directory \ - OUTDIR="$(BUILD_DIR)/pipxtreme" TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \ - REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" $* - -.PHONY: pipxtreme_clean -pipxtreme_clean: - $(V0) @echo " CLEAN $@" - $(V1) $(RM) -fr $(BUILD_DIR)/pipxtreme - -.PHONY: bl_pipxtreme -bl_pipxtreme: bl_pipxtreme_bin -bl_pipxtreme_bino: bl_pipxtreme_bin - -bl_pipxtreme_%: - $(V1) mkdir -p $(BUILD_DIR)/bl_pipxtreme/dep - $(V1) cd $(ROOT_DIR)/flight/Bootloaders/PipXtreme && \ - $(MAKE) -r --no-print-directory \ - OUTDIR="$(BUILD_DIR)/bl_pipxtreme" TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \ - REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" $* - -.PHONY: bl_pipxtreme_clean -bl_pipxtreme_clean: - $(V0) @echo " CLEAN $@" - $(V1) $(RM) -fr $(BUILD_DIR)/bl_pipxtreme - -.PHONY: blupd_pipxtreme -blupd_pipxtreme: blupd_pipxtreme_bin - -blupd_pipxtreme_%: bl_pipxtreme_bino - $(V1) mkdir -p $(BUILD_DIR)/blupd_pipxtreme/dep - $(V1) cd $(ROOT_DIR)/flight/Bootloaders/BootloaderUpdater && \ - $(MAKE) -r --no-print-directory \ - OUTDIR="$(BUILD_DIR)/blupd_pipxtreme" TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \ - REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" \ - BOARD=STM32103CB_PIPXTREME MODEL=MD MODEL_SUFFIX=_CC \ - BLOBJ=$(BUILD_DIR)/bl_pipxtreme/PipXtreme_BL.bin.o $* - -.PHONY: blupd_pipxtreme_clean -blupd_pipxtreme_clean: - $(V0) @echo " CLEAN $@" - $(V1) $(RM) -fr $(BUILD_DIR)/blupd_pipxtreme - - -.PHONY: ins -ins: ins_opf - -ins_%: uavobjects_flight - $(V1) mkdir -p $(BUILD_DIR)/ins/dep - $(V1) cd $(ROOT_DIR)/flight/INS && \ - $(MAKE) -r --no-print-directory \ - OUTDIR="$(BUILD_DIR)/ins" TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \ - REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" $* - -.PHONY: ins_clean -ins_clean: - $(V0) @echo " CLEAN $@" - $(V1) $(RM) -fr $(BUILD_DIR)/ins - -.PHONY: bl_ins -bl_ins: bl_ins_elf - -bl_ins_%: - $(V1) mkdir -p $(BUILD_DIR)/bl_ins/dep - $(V1) cd $(ROOT_DIR)/flight/Bootloaders/INS && \ - $(MAKE) -r --no-print-directory \ - OUTDIR="$(BUILD_DIR)/bl_ins" TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \ - REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" $* - -.PHONY: bl_ins_clean -bl_ins_clean: - $(V0) @echo " CLEAN $@" - $(V1) $(RM) -fr $(BUILD_DIR)/bl_ins +# Expand the firmware rules +$(foreach board, $(ALL_BOARDS), $(eval $(call FW_TEMPLATE,$(board),$($(board)_friendly)))) +# Expand the bootloader rules +$(foreach board, $(ALL_BOARDS), $(eval $(call BL_TEMPLATE,$(board),$($(board)_friendly)))) .PHONY: sim_posix sim_posix: sim_posix_elf diff --git a/flight/AHRS/Makefile b/flight/AHRS/Makefile index 5e482aaf0..3043b8937 100644 --- a/flight/AHRS/Makefile +++ b/flight/AHRS/Makefile @@ -25,6 +25,13 @@ WHEREAMI := $(dir $(lastword $(MAKEFILE_LIST))) TOP := $(realpath $(WHEREAMI)/../../) include $(TOP)/make/firmware-defs.mk +include $(TOP)/make/boards/$(BOARD_NAME)/board-info.mk + +# Target file name (without extension). +TARGET := fw_$(BOARD_NAME) + +# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.) +OUTDIR := $(TOP)/build/$(TARGET) # Set developer code and compile options # Set to YES for debugging @@ -41,21 +48,6 @@ endif FLASH_TOOL = OPENOCD -# MCU name, submodel and board -# - MCU used for compiler-option (-mcpu) -# - MODEL used for linker-script name (-T) and passed as define -# - BOARD just passed as define (optional) -MCU = cortex-m3 -CHIP = STM32F103CBT -BOARD = STM32103CB_AHRS -MODEL = MD - -# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.) -OUTDIR = $(TOP)/build/ahrs - -# Target file name (without extension). -TARGET = AHRS - # Paths AHRS = ./ AHRSINC = $(AHRS)/inc @@ -160,7 +152,7 @@ CPPSRCARM = # Even though the DOS/Win* filesystem matches both .s and .S the same, # it will preserve the spelling of the filenames, and gcc itself does # care about how the name is spelled on its command-line. -ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL).S +ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL)$(MODEL_SUFFIX).S # List Assembler source files here which must be assembled in ARM-Mode.. ASRCARM = @@ -301,9 +293,9 @@ LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_sections.ld OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).bin # Program -OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) 0x08002000 bin" +OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(START_OF_FW_CODE) bin" # Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) 0x08002000 bin" +OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(START_OF_FW_CODE) bin" # reset target OOCD_CL+=-c "reset run" # terminate OOCD after programming @@ -382,7 +374,7 @@ $(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin -$(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,0x02,0x01)) +$(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) .PHONY: elf lss sym hex bin bino opf elf: $(OUTDIR)/$(TARGET).elf diff --git a/flight/Bootloaders/AHRS/Makefile b/flight/Bootloaders/AHRS/Makefile index 4a43a6081..3c9fa9615 100644 --- a/flight/Bootloaders/AHRS/Makefile +++ b/flight/Bootloaders/AHRS/Makefile @@ -25,6 +25,13 @@ WHEREAMI := $(dir $(lastword $(MAKEFILE_LIST))) TOP := $(realpath $(WHEREAMI)/../../../) include $(TOP)/make/firmware-defs.mk +include $(TOP)/make/boards/$(BOARD_NAME)/board-info.mk + +# Target file name (without extension). +TARGET := bl_$(BOARD_NAME) + +# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.) +OUTDIR := $(TOP)/build/$(TARGET) # Set developer code and compile options # Set to YES for debugging @@ -41,23 +48,6 @@ endif FLASH_TOOL = OPENOCD -# MCU name, submodel and board -# - MCU used for compiler-option (-mcpu) -# - MODEL used for linker-script name (-T) and passed as define -# - BOARD just passed as define (optional) -MCU = cortex-m3 -CHIP = STM32F103CBT -BOARD = STM32103CB_AHRS -MODEL = MD - - - -# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.) -OUTDIR = $(TOP)/build/bl_ahrs - -# Target file name (without extension). -TARGET = AHRS_BL - # Paths AHRS_BL = ./ AHRS_BLINC = $(AHRS_BL)/inc @@ -149,7 +139,7 @@ CPPSRCARM = # Even though the DOS/Win* filesystem matches both .s and .S the same, # it will preserve the spelling of the filenames, and gcc itself does # care about how the name is spelled on its command-line. -ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL).S +ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL)$(MODEL_SUFFIX).S # List Assembler source files here which must be assembled in ARM-Mode.. ASRCARM = @@ -293,9 +283,9 @@ LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_BL_sections.ld OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).bin # Program -OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) 0x08000000 bin" +OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(START_OF_BL_CODE) bin" # Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) 0x08000000 bin" +OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(START_OF_BL_CODE) bin" # reset target OOCD_CL+=-c "reset run" # terminate OOCD after programming diff --git a/flight/Bootloaders/BootloaderUpdater/Makefile b/flight/Bootloaders/BootloaderUpdater/Makefile index 25de8140b..39cc48d71 100644 --- a/flight/Bootloaders/BootloaderUpdater/Makefile +++ b/flight/Bootloaders/BootloaderUpdater/Makefile @@ -25,6 +25,13 @@ WHEREAMI := $(dir $(lastword $(MAKEFILE_LIST))) TOP := $(realpath $(WHEREAMI)/../../../) include $(TOP)/make/firmware-defs.mk +include $(TOP)/make/boards/$(BOARD_NAME)/board-info.mk + +# Target file name (without extension). +TARGET = bu_$(BOARD_NAME) + +# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.) +OUTDIR := $(TOP)/build/$(TARGET) # Set developer code and compile options # Set to YES to compile for debugging @@ -51,21 +58,6 @@ endif FLASH_TOOL = OPENOCD -# MCU name, submodel and board -# - MCU used for compiler-option (-mcpu) -# - MODEL used for linker-script name (-T) and passed as define -# - BOARD just passed as define (optional) -MCU = cortex-m3 -CHIP = STM32F103CBT -BOARD ?= NULL -MODEL ?= NULL - -# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.) -OUTDIR = ../../../build/bootloaders/BootloaderUpdater - -# Target file name (without extension). -TARGET = BL_Updater - # Paths OPSYSTEM = . OPSYSTEMINC = $(OPSYSTEM)/inc @@ -309,9 +301,9 @@ LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_sections.ld OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).bin # Program -OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) 0x08003000 bin" +OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(START_OF_FW_CODE) bin" # Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) 0x08003000 bin" +OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(START_OF_FW_CODE) bin" # reset target OOCD_CL+=-c "reset run" # terminate OOCD after programming @@ -364,6 +356,7 @@ program: $(OUTDIR)/$(TARGET).bin endif # Link: create ELF output file from object files. +BLOBJ := $(TOP)/build/bl_$(BOARD_NAME)/bl_$(BOARD_NAME).bin.o $(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ) $(BLOBJ))) # Assemble: create object files from assembler source files. @@ -392,14 +385,16 @@ $(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin -.PHONY: elf lss sym hex bin bino +$(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) + +.PHONY: elf lss sym hex bin bino opf elf: $(OUTDIR)/$(TARGET).elf -elf.stripped: $(OUTDIR)/$(TARGET).elf.stripped lss: $(OUTDIR)/$(TARGET).lss sym: $(OUTDIR)/$(TARGET).sym hex: $(OUTDIR)/$(TARGET).hex bin: $(OUTDIR)/$(TARGET).bin bino: $(OUTDIR)/$(TARGET).bin.o +opf: $(OUTDIR)/$(TARGET).opf # Display sizes of sections. $(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) diff --git a/flight/Bootloaders/CopterControl/Makefile b/flight/Bootloaders/CopterControl/Makefile index 08b97701c..f19898d07 100644 --- a/flight/Bootloaders/CopterControl/Makefile +++ b/flight/Bootloaders/CopterControl/Makefile @@ -25,6 +25,13 @@ WHEREAMI := $(dir $(lastword $(MAKEFILE_LIST))) TOP := $(realpath $(WHEREAMI)/../../../) include $(TOP)/make/firmware-defs.mk +include $(TOP)/make/boards/$(BOARD_NAME)/board-info.mk + +# Target file name (without extension). +TARGET := bl_$(BOARD_NAME) + +# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.) +OUTDIR := $(TOP)/build/$(TARGET) # Set developer code and compile options # Set to YES to compile for debugging @@ -48,21 +55,6 @@ endif FLASH_TOOL = OPENOCD -# MCU name, submodel and board -# - MCU used for compiler-option (-mcpu) -# - MODEL used for linker-script name (-T) and passed as define -# - BOARD just passed as define (optional) -MCU = cortex-m3 -CHIP = STM32F103CBT -BOARD = STM32103CB_CC_Rev1 -MODEL = MD - -# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.) -OUTDIR = $(TOP)/build/bl_coptercontrol - -# Target file name (without extension). -TARGET = CopterControl_BL - # Paths OPSYSTEM = . OPSYSTEMINC = $(OPSYSTEM)/inc @@ -181,7 +173,7 @@ CPPSRCARM = # Even though the DOS/Win* filesystem matches both .s and .S the same, # it will preserve the spelling of the filenames, and gcc itself does # care about how the name is spelled on its command-line. -ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL).S +ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL)$(MODEL_SUFFIX).S # List Assembler source files here which must be assembled in ARM-Mode.. ASRCARM = @@ -343,9 +335,9 @@ LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_BL_sections.ld OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).bin # Program -OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) 0x08000000 bin" +OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(START_OF_BL_CODE) bin" # Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) 0x08000000 bin" +OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(START_OF_BL_CODE) bin" # reset target OOCD_CL+=-c "reset run" # terminate OOCD after programming diff --git a/flight/Bootloaders/OpenPilot/Makefile b/flight/Bootloaders/OpenPilot/Makefile index 33a7f8705..e7804b536 100644 --- a/flight/Bootloaders/OpenPilot/Makefile +++ b/flight/Bootloaders/OpenPilot/Makefile @@ -25,6 +25,13 @@ WHEREAMI := $(dir $(lastword $(MAKEFILE_LIST))) TOP := $(realpath $(WHEREAMI)/../../../) include $(TOP)/make/firmware-defs.mk +include $(TOP)/make/boards/$(BOARD_NAME)/board-info.mk + +# Target file name (without extension). +TARGET := bl_$(BOARD_NAME) + +# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.) +OUTDIR := $(TOP)/build/$(TARGET) # Set developer code and compile options # Set to YES to compile for debugging @@ -48,21 +55,6 @@ endif FLASH_TOOL = OPENOCD -# MCU name, submodel and board -# - MCU used for compiler-option (-mcpu) -# - MODEL used for linker-script name (-T) and passed as define -# - BOARD just passed as define (optional) -MCU = cortex-m3 -CHIP = STM32F103RET -BOARD = STM3210E_OP -MODEL = HD - -# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.) -OUTDIR = $(TOP)/build/bl_openpilot - -# Target file name (without extension). -TARGET = OpenPilot_BL - # Paths OPSYSTEM = . OPSYSTEMINC = $(OPSYSTEM)/inc @@ -184,7 +176,7 @@ CPPSRCARM = # Even though the DOS/Win* filesystem matches both .s and .S the same, # it will preserve the spelling of the filenames, and gcc itself does # care about how the name is spelled on its command-line. -ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL)_OP.S +ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL)$(MODEL_SUFFIX).S # List Assembler source files here which must be assembled in ARM-Mode.. ASRCARM = @@ -346,9 +338,9 @@ LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_BL_sections.ld OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).bin # Program -OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) 0x08000000 bin" +OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(START_OF_BL_CODE) bin" # Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) 0x08000000 bin" +OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(START_OF_BL_CODE) bin" # reset target OOCD_CL+=-c "reset run" # terminate OOCD after programming diff --git a/flight/Bootloaders/PipXtreme/Makefile b/flight/Bootloaders/PipXtreme/Makefile index 00fa37f81..f502a43c2 100644 --- a/flight/Bootloaders/PipXtreme/Makefile +++ b/flight/Bootloaders/PipXtreme/Makefile @@ -25,6 +25,13 @@ WHEREAMI := $(dir $(lastword $(MAKEFILE_LIST))) TOP := $(realpath $(WHEREAMI)/../../../) include $(TOP)/make/firmware-defs.mk +include $(TOP)/make/boards/$(BOARD_NAME)/board-info.mk + +# Target file name (without extension). +TARGET := bl_$(BOARD_NAME) + +# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.) +OUTDIR := $(TOP)/build/$(TARGET) # Set developer code and compile options # Set to YES to compile for debugging @@ -48,21 +55,6 @@ endif FLASH_TOOL = OPENOCD -# MCU name, submodel and board -# - MCU used for compiler-option (-mcpu) -# - MODEL used for linker-script name (-T) and passed as define -# - BOARD just passed as define (optional) -MCU = cortex-m3 -CHIP = STM32F103CBT -BOARD = STM32103CB_PIPXTREME -MODEL = MD - -# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.) -OUTDIR = $(TOP)/build/bl_pipxtreme - -# Target file name (without extension). -TARGET = PipXtreme_BL - # Paths OPSYSTEM = . OPSYSTEMINC = $(OPSYSTEM)/inc @@ -180,7 +172,7 @@ CPPSRCARM = # Even though the DOS/Win* filesystem matches both .s and .S the same, # it will preserve the spelling of the filenames, and gcc itself does # care about how the name is spelled on its command-line. -ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL).S +ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL)$(MODEL_SUFFIX).S # List Assembler source files here which must be assembled in ARM-Mode.. ASRCARM = @@ -342,9 +334,9 @@ LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_BL_sections.ld OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).bin # Program -OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) 0x08000000 bin" +OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(START_OF_BL_CODE) bin" # Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) 0x08000000 bin" +OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(START_OF_BL_CODE) bin" # reset target OOCD_CL+=-c "reset run" # terminate OOCD after programming diff --git a/flight/CopterControl/Makefile b/flight/CopterControl/Makefile index a0d882cfe..592aa77f0 100644 --- a/flight/CopterControl/Makefile +++ b/flight/CopterControl/Makefile @@ -25,6 +25,13 @@ WHEREAMI := $(dir $(lastword $(MAKEFILE_LIST))) TOP := $(realpath $(WHEREAMI)/../../) include $(TOP)/make/firmware-defs.mk +include $(TOP)/make/boards/$(BOARD_NAME)/board-info.mk + +# Target file name (without extension). +TARGET := fw_$(BOARD_NAME) + +# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.) +OUTDIR := $(TOP)/build/$(TARGET) # Set developer code and compile options # Set to YES to compile for debugging @@ -57,21 +64,6 @@ FLASH_TOOL = OPENOCD # List of modules to include MODULES = Telemetry Attitude Stabilization Actuator ManualControl FirmwareIAP -# MCU name, submodel and board -# - MCU used for compiler-option (-mcpu) -# - MODEL used for linker-script name (-T) and passed as define -# - BOARD just passed as define (optional) -MCU = cortex-m3 -CHIP = STM32F103CBT -BOARD = STM32103CB_CC_Rev1 -MODEL = MD - -# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.) -OUTDIR = $(TOP)/build/coptercontrol - -# Target file name (without extension). -TARGET = CopterControl - # Paths OPSYSTEM = ./System OPSYSTEMINC = $(OPSYSTEM)/inc @@ -299,7 +291,7 @@ CPPSRCARM = # Even though the DOS/Win* filesystem matches both .s and .S the same, # it will preserve the spelling of the filenames, and gcc itself does # care about how the name is spelled on its command-line. -ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL)_CC.S +ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL)$(MODEL_SUFFIX).S # List Assembler source files here which must be assembled in ARM-Mode.. ASRCARM = @@ -477,9 +469,9 @@ LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_sections.ld OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).bin # Program -OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) 0x08003000 bin" +OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(START_OF_FW_CODE) bin" # Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) 0x08003000 bin" +OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(START_OF_FW_CODE) bin" # reset target OOCD_CL+=-c "reset run" # terminate OOCD after programming @@ -576,7 +568,7 @@ $(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin -$(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,0x04,0x01)) +$(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) .PHONY: elf lss sym hex bin bino opf elf: $(OUTDIR)/$(TARGET).elf diff --git a/flight/INS/Makefile b/flight/INS/Makefile index 0888845a0..be2406a80 100644 --- a/flight/INS/Makefile +++ b/flight/INS/Makefile @@ -25,11 +25,17 @@ WHEREAMI := $(dir $(lastword $(MAKEFILE_LIST))) TOP := $(realpath $(WHEREAMI)/../../) include $(TOP)/make/firmware-defs.mk +include $(TOP)/make/boards/$(BOARD_NAME)/board-info.mk + +# Target file name (without extension). +TARGET := fw_$(BOARD_NAME) + +# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.) +OUTDIR := $(TOP)/build/$(TARGET) # Set developer code and compile options # Set to YES for debugging DEBUG ?= YES -USE_BOOTLOADER ?= NO # Set to YES when using Code Sourcery toolchain CODE_SOURCERY ?= YES @@ -42,26 +48,6 @@ endif FLASH_TOOL = OPENOCD -# MCU name, submodel and board -# - MCU used for compiler-option (-mcpu) -# - MODEL used for linker-script name (-T) and passed as define -# - BOARD just passed as define (optional) -MCU = cortex-m3 -CHIP = STM32F103RET -BOARD = STM3210E_INS -MODEL = HD -ifeq ($(USE_BOOTLOADER), YES) -BOOT_MODEL = $(MODEL)_BL -else -BOOT_MODEL = $(MODEL)_NB -endif - -# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.) -OUTDIR = $(TOP)/build/ins - -# Target file name (without extension). -TARGET = INS - # Paths INS = ./ INSINC = $(INS)/inc @@ -168,7 +154,7 @@ CPPSRCARM = # Even though the DOS/Win* filesystem matches both .s and .S the same, # it will preserve the spelling of the filenames, and gcc itself does # care about how the name is spelled on its command-line. -ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL).S +ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL)$(MODEL_SUFFIX).S # List Assembler source files here which must be assembled in ARM-Mode.. ASRCARM = @@ -231,9 +217,8 @@ CDEFS = -DSTM32F10X_$(MODEL) CDEFS += -DUSE_STDPERIPH_DRIVER CDEFS += -DUSE_$(BOARD) CDEFS += -DIN_INS -ifeq ($(USE_BOOTLOADER), YES) CDEFS += -DUSE_BOOTLOADER -endif + # Place project-specific -D and/or -U options for # Assembler with preprocessor here. #ADEFS = -DUSE_IRQ_ASM_WRAPPER @@ -311,7 +296,8 @@ LDFLAGS += $(MATH_LIB) LDFLAGS += -lc -lgcc # Set linker-script name depending on selected submodel name -LDFLAGS +=-T$(LINKERSCRIPTPATH)/link_$(BOARD)_$(BOOT_MODEL).ld +LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_memory.ld +LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_sections.ld OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).elf # Program @@ -359,19 +345,12 @@ endif endif # Program the device. -ifeq ($(USE_BOOTLOADER), YES) -# Program the device with OP Upload Tool". -program: $(OUTDIR)/$(TARGET).bin - @echo ${quote}Programming with OP Upload Tool${quote} - ../../ground/src/experimental/upload-build-desktop/debug/OPUploadTool -d 1 -p $(OUTDIR)/$(TARGET).bin -else ifeq ($(FLASH_TOOL),OPENOCD) # Program the device with Dominic Rath's OPENOCD in "batch-mode", needs cfg and "reset-script". -program: $(OUTDIR)/$(TARGET).elf +program: $(OUTDIR)/$(TARGET).bin @echo ${quote}Programming with OPENOCD${quote} $(OOCD_EXE) $(OOCD_CL) endif -endif # Link: create ELF output file from object files. $(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ))) @@ -402,7 +381,7 @@ $(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin -$(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,0x05,0x01)) +$(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) .PHONY: elf lss sym hex bin bino opf elf: $(OUTDIR)/$(TARGET).elf diff --git a/flight/OpenPilot/Makefile b/flight/OpenPilot/Makefile index 9d7ba36fb..dab172003 100644 --- a/flight/OpenPilot/Makefile +++ b/flight/OpenPilot/Makefile @@ -25,6 +25,13 @@ WHEREAMI := $(dir $(lastword $(MAKEFILE_LIST))) TOP := $(realpath $(WHEREAMI)/../../) include $(TOP)/make/firmware-defs.mk +include $(TOP)/make/boards/$(BOARD_NAME)/board-info.mk + +# Target file name (without extension). +TARGET := fw_$(BOARD_NAME) + +# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.) +OUTDIR := $(TOP)/build/$(TARGET) # Set developer code and compile options # Set to YES to compile for debugging @@ -59,21 +66,6 @@ PYMODULES = FlightPlan #MODULES = Telemetry #MODULES += Osd/OsdEtStd -# MCU name, submodel and board -# - MCU used for compiler-option (-mcpu) -# - MODEL used for linker-script name (-T) and passed as define -# - BOARD just passed as define (optional) -MCU = cortex-m3 -CHIP = STM32F103RET -BOARD = STM3210E_OP -MODEL = HD - -# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.) -OUTDIR = $(TOP)/build/openpilot - -# Target file name (without extension). -TARGET = OpenPilot - # Paths OPSYSTEM = ./System OPSYSTEMINC = $(OPSYSTEM)/inc @@ -287,7 +279,7 @@ CPPSRCARM = # Even though the DOS/Win* filesystem matches both .s and .S the same, # it will preserve the spelling of the filenames, and gcc itself does # care about how the name is spelled on its command-line. -ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL)_OP.S +ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL)$(MODEL_SUFFIX).S # List Assembler source files here which must be assembled in ARM-Mode.. ASRCARM = @@ -453,9 +445,9 @@ LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_sections.ld OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).bin # Program -OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) 0x08005000 bin" +OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(START_OF_FW_CODE) bin" # Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) 0x08005000 bin" +OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(START_OF_FW_CODE) bin" # reset target OOCD_CL+=-c "reset run" # terminate OOCD after programming @@ -556,7 +548,7 @@ $(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin -$(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,0x01,0x01)) +$(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) .PHONY: elf lss sym hex bin bino opf elf: $(OUTDIR)/$(TARGET).elf diff --git a/flight/PiOS/STM32F10x/link_STM3210E_INS_HD_BL.ld b/flight/PiOS/STM32F10x/link_STM3210E_INS_BL_sections.ld similarity index 92% rename from flight/PiOS/STM32F10x/link_STM3210E_INS_HD_BL.ld rename to flight/PiOS/STM32F10x/link_STM3210E_INS_BL_sections.ld index ab897621c..33f06f700 100644 --- a/flight/PiOS/STM32F10x/link_STM3210E_INS_HD_BL.ld +++ b/flight/PiOS/STM32F10x/link_STM3210E_INS_BL_sections.ld @@ -1,9 +1,9 @@ /** ****************************************************************************** * - * @file link_STM3210E_INS_HD_BL.ld + * @file link_STM3210E_INS_HD_NB.ld * @author David "Buzz" Carlson (buzz@chebuzz.com) - * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011. + * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011. * @brief PiOS linker for the OpenPilot INS board * @see The GNU Public License (GPL) Version 3 * @@ -24,26 +24,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* Memory Spaces Definitions */ -MEMORY -{ - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K - FLASH (rx) : ORIGIN = 0x08005000, LENGTH = 492K - FLASHB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0 - EXTMEMB0 (rx) : ORIGIN = 0x00000000, LENGTH = 0 - EXTMEMB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0 - EXTMEMB2 (rx) : ORIGIN = 0x00000000, LENGTH = 0 - EXTMEMB3 (rx) : ORIGIN = 0x00000000, LENGTH = 0 -} - -_estack = 0x20004FF0; - /* This is the size of the stack for early init and for all FreeRTOS IRQs */ _irq_stack_size = 0x400; /* Check valid alignment for VTOR */ -ASSERT(ORIGIN(FLASH) == ALIGN(ORIGIN(FLASH), 0x80), "Start of memory region flash not aligned for startup vector table"); +ASSERT(ORIGIN(BL_FLASH) == ALIGN(ORIGIN(BL_FLASH), 0x80), "Start of memory region flash not aligned for startup vector table"); /* this sends all unreferenced IRQHandlers to reset @@ -210,7 +195,7 @@ SECTIONS { KEEP(*(.isr_vector)) /* Startup code */ . = ALIGN(4); - } >FLASH + } > BL_FLASH /* for some STRx devices, the beginning of the startup code is stored in the .flashtext section, which goes to FLASH */ .flashtext : @@ -218,7 +203,7 @@ SECTIONS . = ALIGN(4); *(.flashtext) /* Startup code */ . = ALIGN(4); - } >FLASH + } > BL_FLASH /* init sections */ @@ -229,7 +214,7 @@ SECTIONS KEEP(*(.initcalluavobj.init)) . = ALIGN(4); __uavobj_initcall_end = .; - } >FLASH + } > BL_FLASH /* the program code is stored in the .text section, which goes to Flash */ .text : @@ -247,7 +232,7 @@ SECTIONS _etext = .; /* This is used by the startup in order to initialize the .data secion */ _sidata = _etext; - } >FLASH + } > BL_FLASH /* @@ -354,6 +339,13 @@ SECTIONS __exidx_start = .; __exidx_end = .; + .boardinfo : + { + . = ALIGN(4); + KEEP(*(.boardinfo)) + . = ALIGN(4); + } > BD_INFO + /* after that it's only debugging information. */ /* remove the debugging information from the standard libraries */ diff --git a/flight/PiOS/STM32F10x/link_STM3210E_INS_memory.ld b/flight/PiOS/STM32F10x/link_STM3210E_INS_memory.ld new file mode 100644 index 000000000..7ecb0f65d --- /dev/null +++ b/flight/PiOS/STM32F10x/link_STM3210E_INS_memory.ld @@ -0,0 +1,13 @@ +/* Memory Spaces Definitions */ +MEMORY +{ + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 0x10000 + BL_FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 0x05000 - 0x00080 + BD_INFO (r) : ORIGIN = 0x08005000 - 0x80, LENGTH = 0x00080 + FLASH (rx) : ORIGIN = 0x08005000, LENGTH = 0x80000 - 0x05000 + FLASHB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0 + EXTMEMB0 (rx) : ORIGIN = 0x00000000, LENGTH = 0 + EXTMEMB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0 + EXTMEMB2 (rx) : ORIGIN = 0x00000000, LENGTH = 0 + EXTMEMB3 (rx) : ORIGIN = 0x00000000, LENGTH = 0 +} diff --git a/flight/PiOS/STM32F10x/link_STM3210E_INS_HD_NB.ld b/flight/PiOS/STM32F10x/link_STM3210E_INS_sections.ld similarity index 93% rename from flight/PiOS/STM32F10x/link_STM3210E_INS_HD_NB.ld rename to flight/PiOS/STM32F10x/link_STM3210E_INS_sections.ld index 99a82b1e4..4ed00bb76 100644 --- a/flight/PiOS/STM32F10x/link_STM3210E_INS_HD_NB.ld +++ b/flight/PiOS/STM32F10x/link_STM3210E_INS_sections.ld @@ -24,21 +24,6 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* Memory Spaces Definitions */ -MEMORY -{ - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K - FLASHB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0 - EXTMEMB0 (rx) : ORIGIN = 0x00000000, LENGTH = 0 - EXTMEMB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0 - EXTMEMB2 (rx) : ORIGIN = 0x00000000, LENGTH = 0 - EXTMEMB3 (rx) : ORIGIN = 0x00000000, LENGTH = 0 -} - -_estack = 0x20004FF0; - /* This is the size of the stack for early init and for all FreeRTOS IRQs */ _irq_stack_size = 0x400; @@ -62,10 +47,10 @@ PROVIDE ( HardFault_Handler = 0 ) ; PROVIDE ( MemManage_Handler = 0 ) ; PROVIDE ( BusFault_Handler = 0 ) ; PROVIDE ( UsageFault_Handler = 0 ) ; -PROVIDE ( SVC_Handler = 0 ) ; +PROVIDE ( vPortSVCHandler = 0 ) ; PROVIDE ( DebugMon_Handler = 0 ) ; -PROVIDE ( PendSV_Handler = 0 ) ; -PROVIDE ( SysTick_Handler = 0 ) ; +PROVIDE ( xPortPendSVHandler = 0 ) ; +PROVIDE ( xPortSysTickHandler = 0 ) ; PROVIDE ( WWDG_IRQHandler = 0 ) ; PROVIDE ( PVD_IRQHandler = 0 ) ; @@ -204,13 +189,18 @@ PROVIDE ( SCB = (SCS_BASE + 0x0D00) ) ; SECTIONS { - + .boardinfo : + { + . = ALIGN(4); + PROVIDE(pios_board_info_blob = .); + } > BD_INFO + /* for Cortex devices, the beginning of the startup code is stored in the .isr_vector section, which goes to FLASH */ .isr_vector : { KEEP(*(.isr_vector)) /* Startup code */ . = ALIGN(4); - } >FLASH + } > FLASH /* for some STRx devices, the beginning of the startup code is stored in the .flashtext section, which goes to FLASH */ .flashtext : @@ -218,7 +208,7 @@ SECTIONS . = ALIGN(4); *(.flashtext) /* Startup code */ . = ALIGN(4); - } >FLASH + } > FLASH /* init sections */ @@ -229,7 +219,7 @@ SECTIONS KEEP(*(.initcalluavobj.init)) . = ALIGN(4); __uavobj_initcall_end = .; - } >FLASH + } > FLASH /* the program code is stored in the .text section, which goes to Flash */ .text : @@ -247,7 +237,7 @@ SECTIONS _etext = .; /* This is used by the startup in order to initialize the .data secion */ _sidata = _etext; - } >FLASH + } > FLASH /* diff --git a/flight/PiOS/STM32F10x/link_STM3210E_OP_BL_sections.ld b/flight/PiOS/STM32F10x/link_STM3210E_OP_BL_sections.ld index 3add614d6..607866a0e 100644 --- a/flight/PiOS/STM32F10x/link_STM3210E_OP_BL_sections.ld +++ b/flight/PiOS/STM32F10x/link_STM3210E_OP_BL_sections.ld @@ -2,7 +2,7 @@ _irq_stack_size = 0x400; /* Check valid alignment for VTOR */ -ASSERT(ORIGIN(FLASH) == ALIGN(ORIGIN(FLASH), 0x80), "Start of memory region flash not aligned for startup vector table"); +ASSERT(ORIGIN(BL_FLASH) == ALIGN(ORIGIN(BL_FLASH), 0x80), "Start of memory region flash not aligned for startup vector table"); /* this sends all unreferenced IRQHandlers to reset diff --git a/flight/PipXtreme/Makefile b/flight/PipXtreme/Makefile index 2de5e70c9..456963842 100644 --- a/flight/PipXtreme/Makefile +++ b/flight/PipXtreme/Makefile @@ -25,6 +25,13 @@ WHEREAMI := $(dir $(lastword $(MAKEFILE_LIST))) TOP := $(realpath $(WHEREAMI)/../../) include $(TOP)/make/firmware-defs.mk +include $(TOP)/make/boards/$(BOARD_NAME)/board-info.mk + +# Target file name (without extension). +TARGET := fw_$(BOARD_NAME) + +# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.) +OUTDIR := $(TOP)/build/$(TARGET) # Debugging (YES/NO) ? DEBUG ?= NO @@ -43,23 +50,6 @@ FLASH_TOOL = OPENOCD # Include the USB files (YES/NO) ? USE_USB = YES -# MCU name, submodel and board -# - MCU used for compiler-option (-mcpu) -# - MODEL used for linker-script name (-T) and passed as define -# - BOARD just passed as define (optional) -MCU = cortex-m3 -CHIP = STM32F103CBT -BOARD = STM32103CB_PIPXTREME -#CHIP = STM32F103C8T -#BOARD = STM32103C8_PIPXTREME -MODEL = MD - -# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.) -OUTDIR = $(TOP)/build/pipxtreme - -# Target file name (without extension). -TARGET = PipXtreme - # Paths HOME_DIR = ./ HOME_DIR_INC = $(HOME_DIR)/inc @@ -192,7 +182,7 @@ CPPSRCARM = # Even though the DOS/Win* filesystem matches both .s and .S the same, # it will preserve the spelling of the filenames, and gcc itself does # care about how the name is spelled on its command-line. -ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL).S +ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL)$(MODEL_SUFFIX).S # List Assembler source files here which must be assembled in ARM-Mode.. ASRCARM = @@ -342,9 +332,9 @@ LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_sections.ld OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).bin # Program -OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) 0x08003000 bin" +OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(START_OF_FW_CODE) bin" # Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) 0x08003000 bin" +OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(START_OF_FW_CODE) bin" # reset target OOCD_CL+=-c "reset run" # terminate OOCD after programming @@ -422,7 +412,7 @@ $(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin -$(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,0x03,0x01)) +$(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) .PHONY: elf lss sym hex bin bino opf elf: $(OUTDIR)/$(TARGET).elf diff --git a/make/boards/ahrs/board-info.mk b/make/boards/ahrs/board-info.mk new file mode 100644 index 000000000..049e27b63 --- /dev/null +++ b/make/boards/ahrs/board-info.mk @@ -0,0 +1,13 @@ +BOARD_TYPE := 0x02 +BOARD_REVISION := 0x01 +BOOTLOADER_VERSION := 0x00 +HW_TYPE := 0x00 + +MCU := cortex-m3 +CHIP := STM32F103CBT +BOARD := STM32103CB_AHRS +MODEL := MD +MODEL_SUFFIX := + +START_OF_BL_CODE := 0x08000000 +START_OF_FW_CODE := 0x08002000 diff --git a/make/boards/coptercontrol/board-info.mk b/make/boards/coptercontrol/board-info.mk new file mode 100644 index 000000000..9968b2eec --- /dev/null +++ b/make/boards/coptercontrol/board-info.mk @@ -0,0 +1,13 @@ +BOARD_TYPE := 0x04 +BOARD_REVISION := 0x01 +BOOTLOADER_VERSION := 0x00 +HW_TYPE := 0x01 + +MCU := cortex-m3 +CHIP := STM32F103CBT +BOARD := STM32103CB_CC_Rev1 +MODEL := MD +MODEL_SUFFIX := _CC + +START_OF_BL_CODE := 0x08000000 +START_OF_FW_CODE := 0x08003000 diff --git a/make/boards/ins/board-info.mk b/make/boards/ins/board-info.mk new file mode 100644 index 000000000..fa98aaeba --- /dev/null +++ b/make/boards/ins/board-info.mk @@ -0,0 +1,13 @@ +BOARD_TYPE := 0x05 +BOARD_REVISION := 0x01 +BOOTLOADER_VERSION := 0x00 +HW_TYPE := 0x00 + +MCU := cortex-m3 +CHIP := STM32F103RET +BOARD := STM3210E_INS +MODEL := HD +MODEL_SUFFIX := _OP + +START_OF_BL_CODE := 0x08000000 +START_OF_FW_CODE := 0x08002000 diff --git a/make/boards/openpilot/board-info.mk b/make/boards/openpilot/board-info.mk new file mode 100644 index 000000000..271083c89 --- /dev/null +++ b/make/boards/openpilot/board-info.mk @@ -0,0 +1,13 @@ +BOARD_TYPE := 0x01 +BOARD_REVISION := 0x01 +BOOTLOADER_VERSION := 0x00 +HW_TYPE := 0x00 + +MCU := cortex-m3 +CHIP := STM32F103RET +BOARD := STM3210E_OP +MODEL := HD +MODEL_SUFFIX := _OP + +START_OF_BL_CODE := 0x08000000 +START_OF_FW_CODE := 0x08005000 diff --git a/make/boards/pipxtreme/board-info.mk b/make/boards/pipxtreme/board-info.mk new file mode 100644 index 000000000..a2912ac37 --- /dev/null +++ b/make/boards/pipxtreme/board-info.mk @@ -0,0 +1,13 @@ +BOARD_TYPE := 0x03 +BOARD_REVISION := 0x01 +BOOTLOADER_VERSION := 0x00 +HW_TYPE := 0x00 + +MCU := cortex-m3 +CHIP := STM32F103CBT +BOARD := STM32103CB_PIPXTREME +MODEL := MD +MODEL_SUFFIX := + +START_OF_BL_CODE := 0x08000000 +START_OF_FW_CODE := 0x08003000 diff --git a/make/firmware-defs.mk b/make/firmware-defs.mk index 5a8f0cb21..9680edb16 100644 --- a/make/firmware-defs.mk +++ b/make/firmware-defs.mk @@ -46,7 +46,7 @@ MSG_ASMFROMC_ARM := ${quote} AS(C)-ARM ${quote} MSG_PYMITEINIT := ${quote} PY ${quote} MSG_INSTALLING := ${quote} INSTALL ${quote} MSG_OPFIRMWARE := ${quote} OPF ${quote} -MSG_FWDESC := ${quote} FWDESC ${quote} +MSG_FWINFO := ${quote} FWINFO ${quote} toprel = $(subst $(realpath $(TOP))/,,$(abspath $(1))) @@ -108,7 +108,7 @@ endef # $(3) = board revision in hex define OPF_TEMPLATE $(1).firmwareinfo.c: $(1) $(TOP)/make/templates/firmwareinfotemplate.c - @echo $(MSG_FWDESC) $$(call toprel, $$@) + @echo $(MSG_FWINFO) $$(call toprel, $$@) $(V1) python $(TOP)/make/scripts/version-info.py \ --path=$(TOP) \ --template=$(TOP)/make/templates/firmwareinfotemplate.c \ diff --git a/release/Makefile b/release/Makefile index 8f5af3008..a6a68fd93 100644 --- a/release/Makefile +++ b/release/Makefile @@ -18,7 +18,7 @@ RELEASE_LBL := $(shell $(VERSION_CMD) --format=\$${DATE}-\$${TAG_OR_HASH8}\$${D RELEASE_DIR := $(BUILD_DIR)/release-$(RELEASE_LBL) FW_DIR := $(RELEASE_DIR)/firmware-$(RELEASE_LBL) BL_DIR := $(FW_DIR)/bootloaders -BLUPD_DIR := $(FW_DIR)/bootloader_updaters +BU_DIR := $(FW_DIR)/bootloader_updaters # Clean build options (recommended for package testing only) ifeq ($(CLEAN_BUILD), NO) @@ -38,7 +38,7 @@ FW_TARGETS_INPUT := coptercontrol openpilot FW_TARGETS_TOOLS := coptercontrol FW_TARGETS := $(FW_TARGETS_COMMON) $(FW_TARGETS_INPUT) BL_TARGETS := $(addprefix bl_, $(FW_TARGETS)) -BLUPD_TARGETS := $(addprefix blupd_, $(FW_TARGETS)) +BU_TARGETS := $(addprefix bu_, $(FW_TARGETS)) help: @echo @@ -106,13 +106,13 @@ $(eval $(call INSTALL_TEMPLATE,fw_ppm,uavobjects,$(FW_DIR),,-ppm-$(RELEASE_LBL), $(eval $(call INSTALL_TEMPLATE,all_bl,uavobjects,$(BL_DIR),,-$(RELEASE_LBL),,,$(BL_TARGETS),bin)) # Bootloader Updaters -$(eval $(call INSTALL_TEMPLATE,blupd_coptercontrol,all_bl,$(BLUPD_DIR),CopterControl_,-$(RELEASE_LBL),,,blupd_coptercontrol,install)) -$(eval $(call INSTALL_TEMPLATE,blupd_ahrs,all_bl,$(BLUPD_DIR),AHRS_,-$(RELEASE_LBL),,,blupd_ahrs,install)) -$(eval $(call INSTALL_TEMPLATE,blupd_openpilot,all_bl,$(BLUPD_DIR),OpenPilot_,-$(RELEASE_LBL),,,blupd_openpilot,install)) -$(eval $(call INSTALL_TEMPLATE,blupd_pipxtreme,all_bl,$(BLUPD_DIR),PipXtreme_,-$(RELEASE_LBL),,,blupd_pipxtreme,install)) +$(eval $(call INSTALL_TEMPLATE,bu_coptercontrol,all_bl,$(BU_DIR),CopterControl_,-$(RELEASE_LBL),,,bu_coptercontrol,install)) +$(eval $(call INSTALL_TEMPLATE,bu_ahrs,all_bl,$(BU_DIR),AHRS_,-$(RELEASE_LBL),,,bu_ahrs,install)) +$(eval $(call INSTALL_TEMPLATE,bu_openpilot,all_bl,$(BU_DIR),OpenPilot_,-$(RELEASE_LBL),,,bu_openpilot,install)) +$(eval $(call INSTALL_TEMPLATE,bu_pipxtreme,all_bl,$(BU_DIR),PipXtreme_,-$(RELEASE_LBL),,,bu_pipxtreme,install)) # CopterControl flash eraser tool -$(eval $(call INSTALL_TEMPLATE,fw_tools,uavobjects,$(BLUPD_DIR),,-FlashEraser-$(RELEASE_LBL),ERASE_FLASH=YES,clean,$(FW_TARGETS_TOOLS),install)) +$(eval $(call INSTALL_TEMPLATE,fw_tools,uavobjects,$(BU_DIR),,-FlashEraser-$(RELEASE_LBL),ERASE_FLASH=YES,clean,$(FW_TARGETS_TOOLS),install)) # Order-only dependencies # They are bit complicated to support parallel (-j) builds and to create @@ -128,15 +128,15 @@ fw_tools: | fw_spektrum # ordered build, replace fw_spektrum by fw_ppm if uncomm release_fw: | fw_common fw_pwm fw_spektrum # fw_ppm -release_blupd: | $(BLUPD_TARGETS) +release_bu: | $(BU_TARGETS) -release_flight: | release_fw release_blupd fw_tools +release_flight: | release_fw release_bu fw_tools release_ground: | ground_package release: | release_flight release_ground -.PHONY: help uavobjects all_clean release release_flight release_fw release_blupd release_ground +.PHONY: help uavobjects all_clean release release_flight release_fw release_bu release_ground # Decide on a verbosity level based on the V= parameter export AT := @ From 9854c18c5d4302650bb47907cecccc4beb3b2017 Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Mon, 23 May 2011 15:13:30 -0400 Subject: [PATCH 03/18] version-info: allow unannotated tags Unannotated (ie. movable) tags will now influence the tag/hash reported in the version info blob attached to the firmware image (.opf). --- make/scripts/version-info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/scripts/version-info.py b/make/scripts/version-info.py index 5022cbd73..5e9fa5916 100644 --- a/make/scripts/version-info.py +++ b/make/scripts/version-info.py @@ -69,7 +69,7 @@ class Repo: def _get_tag(self): """Get and store git tag for the HEAD commit""" self._tag = None - self._exec('describe --exact-match HEAD') + self._exec('describe --tags --exact-match HEAD') if self._rc == 0: self._tag = self._out.strip(' \t\n\r') From 6e406c0232f2d31ad912bb3c04bc75b51eacbbf3 Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Mon, 23 May 2011 17:27:04 -0400 Subject: [PATCH 04/18] build: remove all remaining use of -DUSE_BOOTLOADER The USE_BOOTLOADER compile flag was only being used to determine where the ISR vector table was located. Provide this explicitly from the linker since it knows exactly where it is putting the ISR vector table. --- flight/AHRS/Makefile | 1 - flight/Bootloaders/BootloaderUpdater/Makefile | 1 - flight/CopterControl/Makefile | 1 - flight/INS/Makefile | 1 - flight/OpenPilot/Makefile | 1 - flight/PiOS/Boards/STM32103CB_AHRS.h | 5 ----- flight/PiOS/Boards/STM32103CB_CC_Rev1.h | 5 ----- flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h | 6 ------ flight/PiOS/Boards/STM3210E_INS.h | 5 ----- flight/PiOS/Boards/STM3210E_OP.h | 5 ----- flight/PiOS/STM32F10x/link_STM32103CB_AHRS_BL_sections.ld | 1 + flight/PiOS/STM32F10x/link_STM32103CB_AHRS_sections.ld | 1 + .../PiOS/STM32F10x/link_STM32103CB_CC_Rev1_BL_sections.ld | 1 + flight/PiOS/STM32F10x/link_STM32103CB_CC_Rev1_sections.ld | 1 + .../PiOS/STM32F10x/link_STM32103CB_PIPXTREME_BL_sections.ld | 1 + flight/PiOS/STM32F10x/link_STM32103CB_PIPXTREME_sections.ld | 1 + flight/PiOS/STM32F10x/link_STM3210E_INS_BL_sections.ld | 1 + flight/PiOS/STM32F10x/link_STM3210E_INS_sections.ld | 1 + flight/PiOS/STM32F10x/link_STM3210E_OP_BL_sections.ld | 1 + flight/PiOS/STM32F10x/link_STM3210E_OP_sections.ld | 1 + flight/PiOS/STM32F10x/pios_sys.c | 3 ++- flight/PipXtreme/Makefile | 1 - 22 files changed, 12 insertions(+), 33 deletions(-) diff --git a/flight/AHRS/Makefile b/flight/AHRS/Makefile index 3043b8937..903d6901f 100644 --- a/flight/AHRS/Makefile +++ b/flight/AHRS/Makefile @@ -215,7 +215,6 @@ CDEFS = -DSTM32F10X_$(MODEL) CDEFS += -DUSE_STDPERIPH_DRIVER CDEFS += -DUSE_$(BOARD) CDEFS += -DIN_AHRS -CDEFS += -DUSE_BOOTLOADER # Place project-specific -D and/or -U options for # Assembler with preprocessor here. diff --git a/flight/Bootloaders/BootloaderUpdater/Makefile b/flight/Bootloaders/BootloaderUpdater/Makefile index 39cc48d71..1488bec8e 100644 --- a/flight/Bootloaders/BootloaderUpdater/Makefile +++ b/flight/Bootloaders/BootloaderUpdater/Makefile @@ -216,7 +216,6 @@ endif ifeq ($(ENABLE_AUX_UART), YES) CDEFS += -DPIOS_ENABLE_AUX_UART endif -CDEFS += -DUSE_BOOTLOADER # Place project-specific -D and/or -U options for # Assembler with preprocessor here. diff --git a/flight/CopterControl/Makefile b/flight/CopterControl/Makefile index 592aa77f0..b56e40fe3 100644 --- a/flight/CopterControl/Makefile +++ b/flight/CopterControl/Makefile @@ -373,7 +373,6 @@ endif ifeq ($(ENABLE_AUX_UART), YES) CDEFS += -DPIOS_ENABLE_AUX_UART endif -CDEFS += -DUSE_BOOTLOADER ifeq ($(ERASE_FLASH), YES) CDEFS += -DERASE_FLASH endif diff --git a/flight/INS/Makefile b/flight/INS/Makefile index be2406a80..1af2a912a 100644 --- a/flight/INS/Makefile +++ b/flight/INS/Makefile @@ -217,7 +217,6 @@ CDEFS = -DSTM32F10X_$(MODEL) CDEFS += -DUSE_STDPERIPH_DRIVER CDEFS += -DUSE_$(BOARD) CDEFS += -DIN_INS -CDEFS += -DUSE_BOOTLOADER # Place project-specific -D and/or -U options for # Assembler with preprocessor here. diff --git a/flight/OpenPilot/Makefile b/flight/OpenPilot/Makefile index dab172003..5022ab101 100644 --- a/flight/OpenPilot/Makefile +++ b/flight/OpenPilot/Makefile @@ -361,7 +361,6 @@ endif ifeq ($(ENABLE_AUX_UART), YES) CDEFS += -DPIOS_ENABLE_AUX_UART endif -CDEFS += -DUSE_BOOTLOADER ifeq ($(USE_SPEKTRUM), YES) CDEFS += -DUSE_SPEKTRUM diff --git a/flight/PiOS/Boards/STM32103CB_AHRS.h b/flight/PiOS/Boards/STM32103CB_AHRS.h index 8262f9730..a1c4907b0 100644 --- a/flight/PiOS/Boards/STM32103CB_AHRS.h +++ b/flight/PiOS/Boards/STM32103CB_AHRS.h @@ -107,11 +107,6 @@ TIM8 | | | | //------------------------- #define PIOS_MASTER_CLOCK 72000000 #define PIOS_PERIPHERAL_CLOCK (PIOS_MASTER_CLOCK / 2) -#if defined(USE_BOOTLOADER) -#define PIOS_NVIC_VECTTAB_FLASH (START_OF_USER_CODE) -#else -#define PIOS_NVIC_VECTTAB_FLASH ((uint32_t)0x08000000) -#endif //------------------------- // Interrupt Priorities diff --git a/flight/PiOS/Boards/STM32103CB_CC_Rev1.h b/flight/PiOS/Boards/STM32103CB_CC_Rev1.h index 09405bfa3..fcc868090 100644 --- a/flight/PiOS/Boards/STM32103CB_CC_Rev1.h +++ b/flight/PiOS/Boards/STM32103CB_CC_Rev1.h @@ -117,11 +117,6 @@ TIM4 | RC In 1 | Servo 3 | Servo 2 | Servo 1 //------------------------- #define PIOS_MASTER_CLOCK 72000000 #define PIOS_PERIPHERAL_CLOCK (PIOS_MASTER_CLOCK / 2) -#if defined(USE_BOOTLOADER) -#define PIOS_NVIC_VECTTAB_FLASH (START_OF_USER_CODE) -#else -#define PIOS_NVIC_VECTTAB_FLASH ((uint32_t)0x08000000) -#endif //------------------------- // Interrupt Priorities diff --git a/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h b/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h index a4792a717..6811bfad5 100644 --- a/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h +++ b/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h @@ -81,12 +81,6 @@ TIM4 | STOPWATCH | #define PIOS_MASTER_CLOCK 72000000ul #define PIOS_PERIPHERAL_CLOCK (PIOS_MASTER_CLOCK / 2) -#if defined(USE_BOOTLOADER) - #define PIOS_NVIC_VECTTAB_FLASH (START_OF_USER_CODE) -#else - #define PIOS_NVIC_VECTTAB_FLASH ((uint32_t)0x08000000) -#endif - // ***************************************************************** // Interrupt Priorities diff --git a/flight/PiOS/Boards/STM3210E_INS.h b/flight/PiOS/Boards/STM3210E_INS.h index 22c94837b..5efb04a36 100644 --- a/flight/PiOS/Boards/STM3210E_INS.h +++ b/flight/PiOS/Boards/STM3210E_INS.h @@ -176,11 +176,6 @@ extern uint32_t pios_com_aux_id; //------------------------- #define PIOS_MASTER_CLOCK 72000000 #define PIOS_PERIPHERAL_CLOCK (PIOS_MASTER_CLOCK / 2) -#if defined(USE_BOOTLOADER) -#define PIOS_NVIC_VECTTAB_FLASH (START_OF_USER_CODE) -#else -#define PIOS_NVIC_VECTTAB_FLASH ((uint32_t)0x08000000) -#endif //------------------------- // Interrupt Priorities diff --git a/flight/PiOS/Boards/STM3210E_OP.h b/flight/PiOS/Boards/STM3210E_OP.h index 48653179c..b987ab600 100644 --- a/flight/PiOS/Boards/STM3210E_OP.h +++ b/flight/PiOS/Boards/STM3210E_OP.h @@ -203,11 +203,6 @@ extern uint32_t pios_com_spektrum_id; //------------------------- #define PIOS_MASTER_CLOCK 72000000 #define PIOS_PERIPHERAL_CLOCK (PIOS_MASTER_CLOCK / 2) -#if defined(USE_BOOTLOADER) -#define PIOS_NVIC_VECTTAB_FLASH (START_OF_USER_CODE) -#else -#define PIOS_NVIC_VECTTAB_FLASH ((uint32_t)0x08000000) -#endif //------------------------- // Interrupt Priorities diff --git a/flight/PiOS/STM32F10x/link_STM32103CB_AHRS_BL_sections.ld b/flight/PiOS/STM32F10x/link_STM32103CB_AHRS_BL_sections.ld index 4f3c77d4c..d411c3e4f 100644 --- a/flight/PiOS/STM32F10x/link_STM32103CB_AHRS_BL_sections.ld +++ b/flight/PiOS/STM32F10x/link_STM32103CB_AHRS_BL_sections.ld @@ -5,6 +5,7 @@ SECTIONS { .text : { + PROVIDE (pios_isr_vector_table_base = .); KEEP(*(.isr_vector .isr_vector.*)) *(.text .text.* .gnu.linkonce.t.*) *(.glue_7t) *(.glue_7) diff --git a/flight/PiOS/STM32F10x/link_STM32103CB_AHRS_sections.ld b/flight/PiOS/STM32F10x/link_STM32103CB_AHRS_sections.ld index 82a8ae7f4..13290908a 100644 --- a/flight/PiOS/STM32F10x/link_STM32103CB_AHRS_sections.ld +++ b/flight/PiOS/STM32F10x/link_STM32103CB_AHRS_sections.ld @@ -11,6 +11,7 @@ SECTIONS .text : { + PROVIDE (pios_isr_vector_table_base = .); KEEP(*(.isr_vector .isr_vector.*)) *(.text .text.* .gnu.linkonce.t.*) *(.glue_7t) *(.glue_7) diff --git a/flight/PiOS/STM32F10x/link_STM32103CB_CC_Rev1_BL_sections.ld b/flight/PiOS/STM32F10x/link_STM32103CB_CC_Rev1_BL_sections.ld index 13cd35df6..c16bd7af9 100644 --- a/flight/PiOS/STM32F10x/link_STM32103CB_CC_Rev1_BL_sections.ld +++ b/flight/PiOS/STM32F10x/link_STM32103CB_CC_Rev1_BL_sections.ld @@ -10,6 +10,7 @@ SECTIONS { .text : { + PROVIDE (pios_isr_vector_table_base = .); KEEP(*(.isr_vector .isr_vector.*)) *(.text .text.* .gnu.linkonce.t.*) *(.glue_7t) *(.glue_7) diff --git a/flight/PiOS/STM32F10x/link_STM32103CB_CC_Rev1_sections.ld b/flight/PiOS/STM32F10x/link_STM32103CB_CC_Rev1_sections.ld index 6e46c43c5..2df4dd6c8 100644 --- a/flight/PiOS/STM32F10x/link_STM32103CB_CC_Rev1_sections.ld +++ b/flight/PiOS/STM32F10x/link_STM32103CB_CC_Rev1_sections.ld @@ -16,6 +16,7 @@ SECTIONS .text : { + PROVIDE (pios_isr_vector_table_base = .); KEEP(*(.isr_vector .isr_vector.*)) *(.text .text.* .gnu.linkonce.t.*) *(.glue_7t) *(.glue_7) diff --git a/flight/PiOS/STM32F10x/link_STM32103CB_PIPXTREME_BL_sections.ld b/flight/PiOS/STM32F10x/link_STM32103CB_PIPXTREME_BL_sections.ld index 4b35cd71b..69eaadb8c 100644 --- a/flight/PiOS/STM32F10x/link_STM32103CB_PIPXTREME_BL_sections.ld +++ b/flight/PiOS/STM32F10x/link_STM32103CB_PIPXTREME_BL_sections.ld @@ -10,6 +10,7 @@ SECTIONS { .text : { + PROVIDE (pios_isr_vector_table_base = .); KEEP(*(.isr_vector .isr_vector.*)) *(.text .text.* .gnu.linkonce.t.*) *(.glue_7t) *(.glue_7) diff --git a/flight/PiOS/STM32F10x/link_STM32103CB_PIPXTREME_sections.ld b/flight/PiOS/STM32F10x/link_STM32103CB_PIPXTREME_sections.ld index dc09e6f1c..fc51c7c43 100644 --- a/flight/PiOS/STM32F10x/link_STM32103CB_PIPXTREME_sections.ld +++ b/flight/PiOS/STM32F10x/link_STM32103CB_PIPXTREME_sections.ld @@ -16,6 +16,7 @@ SECTIONS .text : { + PROVIDE (pios_isr_vector_table_base = .); KEEP(*(.isr_vector .isr_vector.*)) *(.text .text.* .gnu.linkonce.t.*) *(.glue_7t) *(.glue_7) diff --git a/flight/PiOS/STM32F10x/link_STM3210E_INS_BL_sections.ld b/flight/PiOS/STM32F10x/link_STM3210E_INS_BL_sections.ld index 33f06f700..1b3c11e34 100644 --- a/flight/PiOS/STM32F10x/link_STM3210E_INS_BL_sections.ld +++ b/flight/PiOS/STM32F10x/link_STM3210E_INS_BL_sections.ld @@ -193,6 +193,7 @@ SECTIONS /* for Cortex devices, the beginning of the startup code is stored in the .isr_vector section, which goes to FLASH */ .isr_vector : { + PROVIDE (pios_isr_vector_table_base = .); KEEP(*(.isr_vector)) /* Startup code */ . = ALIGN(4); } > BL_FLASH diff --git a/flight/PiOS/STM32F10x/link_STM3210E_INS_sections.ld b/flight/PiOS/STM32F10x/link_STM3210E_INS_sections.ld index 4ed00bb76..2635737a8 100644 --- a/flight/PiOS/STM32F10x/link_STM3210E_INS_sections.ld +++ b/flight/PiOS/STM32F10x/link_STM3210E_INS_sections.ld @@ -198,6 +198,7 @@ SECTIONS /* for Cortex devices, the beginning of the startup code is stored in the .isr_vector section, which goes to FLASH */ .isr_vector : { + PROVIDE (pios_isr_vector_table_base = .); KEEP(*(.isr_vector)) /* Startup code */ . = ALIGN(4); } > FLASH diff --git a/flight/PiOS/STM32F10x/link_STM3210E_OP_BL_sections.ld b/flight/PiOS/STM32F10x/link_STM3210E_OP_BL_sections.ld index 607866a0e..fa01b6c41 100644 --- a/flight/PiOS/STM32F10x/link_STM3210E_OP_BL_sections.ld +++ b/flight/PiOS/STM32F10x/link_STM3210E_OP_BL_sections.ld @@ -166,6 +166,7 @@ SECTIONS /* for Cortex devices, the beginning of the startup code is stored in the .isr_vector section, which goes to FLASH */ .isr_vector : { + PROVIDE (pios_isr_vector_table_base = .); KEEP(*(.isr_vector)) /* Startup code */ . = ALIGN(4); } > BL_FLASH diff --git a/flight/PiOS/STM32F10x/link_STM3210E_OP_sections.ld b/flight/PiOS/STM32F10x/link_STM3210E_OP_sections.ld index 2292a40e2..cdee04df3 100644 --- a/flight/PiOS/STM32F10x/link_STM3210E_OP_sections.ld +++ b/flight/PiOS/STM32F10x/link_STM3210E_OP_sections.ld @@ -172,6 +172,7 @@ SECTIONS /* for Cortex devices, the beginning of the startup code is stored in the .isr_vector section, which goes to FLASH */ .isr_vector : { + PROVIDE (pios_isr_vector_table_base = .); KEEP(*(.isr_vector)) /* Startup code */ . = ALIGN(4); } >FLASH diff --git a/flight/PiOS/STM32F10x/pios_sys.c b/flight/PiOS/STM32F10x/pios_sys.c index 2170c7811..26e748171 100644 --- a/flight/PiOS/STM32F10x/pios_sys.c +++ b/flight/PiOS/STM32F10x/pios_sys.c @@ -186,7 +186,8 @@ int32_t PIOS_SYS_SerialNumberGet(char *str) void NVIC_Configuration(void) { /* Set the Vector Table base address as specified in .ld file */ - NVIC_SetVectorTable(PIOS_NVIC_VECTTAB_FLASH, 0x0); + extern void pios_isr_vector_table_base; + NVIC_SetVectorTable((uint32_t)&pios_isr_vector_table_base, 0x0); /* 4 bits for Interrupt priorities so no sub priorities */ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); diff --git a/flight/PipXtreme/Makefile b/flight/PipXtreme/Makefile index 456963842..62ea87d73 100644 --- a/flight/PipXtreme/Makefile +++ b/flight/PipXtreme/Makefile @@ -247,7 +247,6 @@ DEBUGF = dwarf-2 CDEFS = -DSTM32F10X_$(MODEL) CDEFS += -DUSE_STDPERIPH_DRIVER CDEFS += -DUSE_$(BOARD) -CDEFS += -DUSE_BOOTLOADER # Place project-specific -D and/or -U options for # Assembler with preprocessor here. From 2d47427b05e392a0228230efb82076ea41a7b327 Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Mon, 23 May 2011 17:40:48 -0400 Subject: [PATCH 05/18] link: Use alternate declaration of pios_board_info_blob Make use of a shorter notation to allow the linker to provide the correct address for pios_board_info_blob. --- flight/PiOS/STM32F10x/link_STM32103CB_AHRS_sections.ld | 8 ++------ flight/PiOS/STM32F10x/link_STM32103CB_CC_Rev1_sections.ld | 8 ++------ .../PiOS/STM32F10x/link_STM32103CB_PIPXTREME_sections.ld | 8 ++------ flight/PiOS/STM32F10x/link_STM3210E_INS_sections.ld | 7 +------ flight/PiOS/STM32F10x/link_STM3210E_OP_sections.ld | 7 +------ 5 files changed, 8 insertions(+), 30 deletions(-) diff --git a/flight/PiOS/STM32F10x/link_STM32103CB_AHRS_sections.ld b/flight/PiOS/STM32F10x/link_STM32103CB_AHRS_sections.ld index 13290908a..dd814f561 100644 --- a/flight/PiOS/STM32F10x/link_STM32103CB_AHRS_sections.ld +++ b/flight/PiOS/STM32F10x/link_STM32103CB_AHRS_sections.ld @@ -1,14 +1,10 @@ +PROVIDE(pios_board_info_blob = ORIGIN(BD_INFO)); + _estack = 0x20004FF0; /* Section Definitions */ SECTIONS { - .boardinfo : - { - . = ALIGN(4); - PROVIDE(pios_board_info_blob = .); - } > BD_INFO - .text : { PROVIDE (pios_isr_vector_table_base = .); diff --git a/flight/PiOS/STM32F10x/link_STM32103CB_CC_Rev1_sections.ld b/flight/PiOS/STM32F10x/link_STM32103CB_CC_Rev1_sections.ld index 2df4dd6c8..e1cb0bd0f 100644 --- a/flight/PiOS/STM32F10x/link_STM32103CB_CC_Rev1_sections.ld +++ b/flight/PiOS/STM32F10x/link_STM32103CB_CC_Rev1_sections.ld @@ -3,17 +3,13 @@ PROVIDE ( vPortSVCHandler = 0 ) ; PROVIDE ( xPortPendSVHandler = 0 ) ; PROVIDE ( xPortSysTickHandler = 0 ) ; +PROVIDE(pios_board_info_blob = ORIGIN(BD_INFO)); + _estack = 0x20004FF0; /* Section Definitions */ SECTIONS { - .boardinfo : - { - . = ALIGN(4); - PROVIDE(pios_board_info_blob = .); - } > BD_INFO - .text : { PROVIDE (pios_isr_vector_table_base = .); diff --git a/flight/PiOS/STM32F10x/link_STM32103CB_PIPXTREME_sections.ld b/flight/PiOS/STM32F10x/link_STM32103CB_PIPXTREME_sections.ld index fc51c7c43..badf5f986 100644 --- a/flight/PiOS/STM32F10x/link_STM32103CB_PIPXTREME_sections.ld +++ b/flight/PiOS/STM32F10x/link_STM32103CB_PIPXTREME_sections.ld @@ -3,17 +3,13 @@ PROVIDE ( vPortSVCHandler = 0 ) ; PROVIDE ( xPortPendSVHandler = 0 ) ; PROVIDE ( xPortSysTickHandler = 0 ) ; +PROVIDE(pios_board_info_blob = ORIGIN(BD_INFO)); + _estack = 0x20004FF0; /* Section Definitions */ SECTIONS { - .boardinfo : - { - . = ALIGN(4); - PROVIDE(pios_board_info_blob = .); - } > BD_INFO - .text : { PROVIDE (pios_isr_vector_table_base = .); diff --git a/flight/PiOS/STM32F10x/link_STM3210E_INS_sections.ld b/flight/PiOS/STM32F10x/link_STM3210E_INS_sections.ld index 2635737a8..31e35b305 100644 --- a/flight/PiOS/STM32F10x/link_STM3210E_INS_sections.ld +++ b/flight/PiOS/STM32F10x/link_STM3210E_INS_sections.ld @@ -184,17 +184,12 @@ PROVIDE ( SysTick = (SCS_BASE + 0x0010) ) ; PROVIDE ( NVIC = (SCS_BASE + 0x0100) ) ; PROVIDE ( SCB = (SCS_BASE + 0x0D00) ) ; +PROVIDE(pios_board_info_blob = ORIGIN(BD_INFO)); /* Sections Definitions */ SECTIONS { - .boardinfo : - { - . = ALIGN(4); - PROVIDE(pios_board_info_blob = .); - } > BD_INFO - /* for Cortex devices, the beginning of the startup code is stored in the .isr_vector section, which goes to FLASH */ .isr_vector : { diff --git a/flight/PiOS/STM32F10x/link_STM3210E_OP_sections.ld b/flight/PiOS/STM32F10x/link_STM3210E_OP_sections.ld index cdee04df3..94aafbd78 100644 --- a/flight/PiOS/STM32F10x/link_STM3210E_OP_sections.ld +++ b/flight/PiOS/STM32F10x/link_STM3210E_OP_sections.ld @@ -158,17 +158,12 @@ PROVIDE ( SysTick = (SCS_BASE + 0x0010) ) ; PROVIDE ( NVIC = (SCS_BASE + 0x0100) ) ; PROVIDE ( SCB = (SCS_BASE + 0x0D00) ) ; +PROVIDE(pios_board_info_blob = ORIGIN(BD_INFO)); /* Sections Definitions */ SECTIONS { - .boardinfo : - { - . = ALIGN(4); - PROVIDE(pios_board_info_blob = .); - } > BD_INFO - /* for Cortex devices, the beginning of the startup code is stored in the .isr_vector section, which goes to FLASH */ .isr_vector : { From 96827eecff6222cff6ee40682ee149f865c84054 Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Mon, 23 May 2011 18:15:06 -0400 Subject: [PATCH 06/18] build: Make all flight sw use pios_board_info_blob Now that every bootloader build has a board info blob, make all fw and bl images use it. The following MACROS are removed: BOARD_TYPE, BOARD_REVISION, BOOTLOADER_VERSION, START_OF_USER_CODE, HW_TYPE These values are now ONLY available from the bootloader flash via the pios_board_info_blob symbol. These values must not be #defined or otherwise hard-coded into the firmware in any way. The bootloader flash is the only valid source for this information. NOTE: To ensure that we have an upgrade path from an old bootloader (without board_info_blob) to a new bootloader (with board_info_blob), it is essential that the bu_* targets do not depend on (or validate) the board_info_blob being present in the bootloader flash. --- flight/AHRS/ahrs.c | 11 +++++--- flight/Bootloaders/AHRS/Makefile | 12 +++++++-- flight/Bootloaders/AHRS/main.c | 25 +++++++++---------- flight/Bootloaders/CopterControl/Makefile | 12 +++++++-- flight/Bootloaders/CopterControl/main.c | 9 ++++--- flight/Bootloaders/CopterControl/op_dfu.c | 15 ++++++----- flight/Bootloaders/OpenPilot/Makefile | 8 ++++++ flight/Bootloaders/OpenPilot/main.c | 9 ++++--- flight/Bootloaders/OpenPilot/op_dfu.c | 15 ++++++----- flight/Bootloaders/PipXtreme/Makefile | 12 +++++++-- flight/Bootloaders/PipXtreme/main.c | 9 ++++--- flight/Bootloaders/PipXtreme/op_dfu.c | 15 ++++++----- flight/Modules/FirmwareIAP/firmwareiap.c | 12 ++++++--- flight/PiOS/Boards/STM32103CB_AHRS.h | 17 ------------- flight/PiOS/Boards/STM32103CB_CC_Rev1.h | 15 ----------- .../PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h | 12 --------- flight/PiOS/Boards/STM3210E_INS.h | 19 -------------- flight/PiOS/Boards/STM3210E_OP.h | 19 -------------- flight/PiOS/Common/pios_bl_helper.c | 16 +++++++----- 19 files changed, 120 insertions(+), 142 deletions(-) diff --git a/flight/AHRS/ahrs.c b/flight/AHRS/ahrs.c index 57f9e11e2..830245572 100644 --- a/flight/AHRS/ahrs.c +++ b/flight/AHRS/ahrs.c @@ -33,6 +33,7 @@ /* OpenPilot Includes */ #include "ahrs.h" +#include #include "pios.h" #include "ahrs_timer.h" #include "ahrs_spi_comm.h" @@ -1228,6 +1229,8 @@ void homelocation_callback(AhrsObjHandle obj) void firmwareiapobj_callback(AhrsObjHandle obj) { + const struct pios_board_info * bdinfo = &pios_board_info_blob; + FirmwareIAPObjData firmwareIAPObj; FirmwareIAPObjGet(&firmwareIAPObj); if(firmwareIAPObj.ArmReset==0) @@ -1235,7 +1238,7 @@ void firmwareiapobj_callback(AhrsObjHandle obj) if(firmwareIAPObj.ArmReset==1) { - if((firmwareIAPObj.BoardType==BOARD_TYPE) || (firmwareIAPObj.BoardType==0xFF)) + if((firmwareIAPObj.BoardType==bdinfo->board_type) || (firmwareIAPObj.BoardType==0xFF)) { ++reset_count; @@ -1247,11 +1250,11 @@ void firmwareiapobj_callback(AhrsObjHandle obj) } } } - else if(firmwareIAPObj.BoardType==BOARD_TYPE && firmwareIAPObj.crc!=PIOS_BL_HELPER_CRC_Memory_Calc()) + else if(firmwareIAPObj.BoardType==bdinfo->board_type && firmwareIAPObj.crc!=PIOS_BL_HELPER_CRC_Memory_Calc()) { - PIOS_BL_HELPER_FLASH_Read_Description(firmwareIAPObj.Description,SIZE_OF_DESCRIPTION); + PIOS_BL_HELPER_FLASH_Read_Description(firmwareIAPObj.Description,bdinfo->desc_size); firmwareIAPObj.crc=PIOS_BL_HELPER_CRC_Memory_Calc(); - firmwareIAPObj.BoardRevision=BOARD_REVISION; + firmwareIAPObj.BoardRevision=bdinfo->board_rev; FirmwareIAPObjSet(&firmwareIAPObj); } } diff --git a/flight/Bootloaders/AHRS/Makefile b/flight/Bootloaders/AHRS/Makefile index 3c9fa9615..10f184f96 100644 --- a/flight/Bootloaders/AHRS/Makefile +++ b/flight/Bootloaders/AHRS/Makefile @@ -199,6 +199,13 @@ CDEFS = -DSTM32F10X_$(MODEL) CDEFS += -DUSE_STDPERIPH_DRIVER CDEFS += -DUSE_$(BOARD) +# Provide (only) the bootloader with board-specific defines +BLONLY_CDEFS += -DBOARD_TYPE=$(BOARD_TYPE) +BLONLY_CDEFS += -DBOARD_REVISION=$(BOARD_REVISION) +BLONLY_CDEFS += -DHW_TYPE=$(HW_TYPE) +BLONLY_CDEFS += -DBOOTLOADER_VERSION=$(BOOTLOADER_VERSION) +BLONLY_CDEFS += -DSTART_OF_USER_CODE=$(START_OF_FW_CODE) + # Place project-specific -D and/or -U options for # Assembler with preprocessor here. #ADEFS = -DUSE_IRQ_ASM_WRAPPER @@ -233,8 +240,9 @@ CFLAGS += -O$(OPT) ifeq ($(DEBUG),NO) CFLAGS += -fdata-sections -ffunction-sections endif -CFLAGS += -mcpu=$(MCU) -mthumb +CFLAGS += -mcpu=$(MCU) CFLAGS += $(CDEFS) +CFLAGS += $(BLONLY_CDEFS) CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I. CFLAGS += -mapcs-frame @@ -256,7 +264,7 @@ CONLYFLAGS += $(CSTANDARD) # Assembler flags. # -Wa,...: tell GCC to pass this to the assembler. # -ahlns: create listing -ASFLAGS = -mcpu=$(MCU) -mthumb -I. -x assembler-with-cpp +ASFLAGS = -mcpu=$(MCU) -I. -x assembler-with-cpp ASFLAGS += $(ADEFS) ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) diff --git a/flight/Bootloaders/AHRS/main.c b/flight/Bootloaders/AHRS/main.c index 30915cef0..c7da0d439 100644 --- a/flight/Bootloaders/AHRS/main.c +++ b/flight/Bootloaders/AHRS/main.c @@ -33,6 +33,7 @@ /* OpenPilot Includes */ #include "ahrs_bl.h" +#include #include "pios_opahrs_proto.h" #include "bl_fsm.h" /* lfsm_state */ #include "stm32f10x_flash.h" @@ -108,6 +109,7 @@ static struct opahrs_msg_v0 link_rx_v0; static struct opahrs_msg_v0 user_tx_v0; static struct opahrs_msg_v0 user_rx_v0; void process_spi_request(void) { + const struct pios_board_info * bdinfo = &pios_board_info_blob; bool msg_to_process = FALSE; PIOS_IRQ_Disable(); @@ -166,15 +168,15 @@ void process_spi_request(void) { break; case OPAHRS_MSG_V0_REQ_MEM_MAP: opahrs_msg_v0_init_user_tx(&user_tx_v0, OPAHRS_MSG_V0_RSP_MEM_MAP); - user_tx_v0.payload.user.v.rsp.mem_map.density = HW_TYPE; + user_tx_v0.payload.user.v.rsp.mem_map.density = bdinfo->hw_type; user_tx_v0.payload.user.v.rsp.mem_map.rw_flags = (BOARD_READABLE | (BOARD_WRITABLA << 1)); user_tx_v0.payload.user.v.rsp.mem_map.size_of_code_memory - = SIZE_OF_CODE; + = bdinfo->fw_size; user_tx_v0.payload.user.v.rsp.mem_map.size_of_description - = SIZE_OF_DESCRIPTION; + = bdinfo->desc_size; user_tx_v0.payload.user.v.rsp.mem_map.start_of_user_code - = START_OF_USER_CODE; + = bdinfo->fw_base; lfsm_user_set_tx_v0(&user_tx_v0); break; case OPAHRS_MSG_V0_REQ_SERIAL: @@ -192,7 +194,7 @@ void process_spi_request(void) { PIOS_LED_On(LED1); opahrs_msg_v0_init_user_tx(&user_tx_v0, OPAHRS_MSG_V0_RSP_FWUP_STATUS); if (!(user_rx_v0.payload.user.v.req.fwup_data.adress - < START_OF_USER_CODE)) { + < bdinfo->fw_base)) { for (uint8_t x = 0; x < user_rx_v0.payload.user.v.req.fwup_data.size; ++x) { if (FLASH_ProgramWord( @@ -250,13 +252,10 @@ void process_spi_request(void) { return; } void jump_to_app() { - //while(TRUE) - //{ - // PIOS_LED_Toggle(LED1); - // PIOS_DELAY_WaitmS(1000); - //} + const struct pios_board_info * bdinfo = &pios_board_info_blob; + PIOS_LED_On(LED1); - if (((*(__IO uint32_t*) START_OF_USER_CODE) & 0x2FFE0000) == 0x20000000) { /* Jump to user application */ + if (((*(__IO uint32_t*) bdinfo->fw_base) & 0x2FFE0000) == 0x20000000) { /* Jump to user application */ FLASH_Lock(); RCC_APB2PeriphResetCmd(0xffffffff, ENABLE); RCC_APB1PeriphResetCmd(0xffffffff, ENABLE); @@ -265,10 +264,10 @@ void jump_to_app() { //_SetCNTR(0); // clear interrupt mask //_SetISTR(0); // clear all requests - JumpAddress = *(__IO uint32_t*) (START_OF_USER_CODE + 4); + JumpAddress = *(__IO uint32_t*) (bdinfo->fw_base + 4); Jump_To_Application = (pFunction) JumpAddress; /* Initialize user application's Stack Pointer */ - __set_MSP(*(__IO uint32_t*) START_OF_USER_CODE); + __set_MSP(*(__IO uint32_t*) bdinfo->fw_base); Jump_To_Application(); } else { boot_status = jump_failed; diff --git a/flight/Bootloaders/CopterControl/Makefile b/flight/Bootloaders/CopterControl/Makefile index f19898d07..fe83ceb66 100644 --- a/flight/Bootloaders/CopterControl/Makefile +++ b/flight/Bootloaders/CopterControl/Makefile @@ -252,6 +252,13 @@ ifeq ($(ENABLE_AUX_UART), YES) CDEFS += -DPIOS_ENABLE_AUX_UART endif +# Provide (only) the bootloader with board-specific defines +BLONLY_CDEFS += -DBOARD_TYPE=$(BOARD_TYPE) +BLONLY_CDEFS += -DBOARD_REVISION=$(BOARD_REVISION) +BLONLY_CDEFS += -DHW_TYPE=$(HW_TYPE) +BLONLY_CDEFS += -DBOOTLOADER_VERSION=$(BOOTLOADER_VERSION) +BLONLY_CDEFS += -DSTART_OF_USER_CODE=$(START_OF_FW_CODE) + # Place project-specific -D and/or -U options for # Assembler with preprocessor here. #ADEFS = -DUSE_IRQ_ASM_WRAPPER @@ -287,8 +294,9 @@ ifeq ($(DEBUG),NO) CFLAGS += -ffunction-sections endif -CFLAGS += -mcpu=$(MCU) -mthumb +CFLAGS += -mcpu=$(MCU) CFLAGS += $(CDEFS) +CFLAGS += $(BLONLY_CDEFS) CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I. CFLAGS += -mapcs-frame @@ -308,7 +316,7 @@ CONLYFLAGS += $(CSTANDARD) # Assembler flags. # -Wa,...: tell GCC to pass this to the assembler. # -ahlns: create listing -ASFLAGS = -mcpu=$(MCU) -mthumb -I. -x assembler-with-cpp +ASFLAGS = -mcpu=$(MCU) -I. -x assembler-with-cpp ASFLAGS += $(ADEFS) ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) diff --git a/flight/Bootloaders/CopterControl/main.c b/flight/Bootloaders/CopterControl/main.c index 23a8f16c1..67f6a4c32 100644 --- a/flight/Bootloaders/CopterControl/main.c +++ b/flight/Bootloaders/CopterControl/main.c @@ -27,6 +27,7 @@ */ /* Bootloader Includes */ #include +#include #include "stopwatch.h" #include "op_dfu.h" #include "usb_lib.h" @@ -163,7 +164,9 @@ int main() { } void jump_to_app() { - if (((*(__IO uint32_t*) START_OF_USER_CODE) & 0x2FFE0000) == 0x20000000) { /* Jump to user application */ + const struct pios_board_info * bdinfo = &pios_board_info_blob; + + if (((*(__IO uint32_t*) bdinfo->fw_base) & 0x2FFE0000) == 0x20000000) { /* Jump to user application */ FLASH_Lock(); RCC_APB2PeriphResetCmd(0xffffffff, ENABLE); RCC_APB1PeriphResetCmd(0xffffffff, ENABLE); @@ -171,10 +174,10 @@ void jump_to_app() { RCC_APB1PeriphResetCmd(0xffffffff, DISABLE); _SetCNTR(0); // clear interrupt mask _SetISTR(0); // clear all requests - JumpAddress = *(__IO uint32_t*) (START_OF_USER_CODE + 4); + JumpAddress = *(__IO uint32_t*) (bdinfo->fw_base + 4); Jump_To_Application = (pFunction) JumpAddress; /* Initialize user application's Stack Pointer */ - __set_MSP(*(__IO uint32_t*) START_OF_USER_CODE); + __set_MSP(*(__IO uint32_t*) bdinfo->fw_base); Jump_To_Application(); } else { DeviceState = failed_jump; diff --git a/flight/Bootloaders/CopterControl/op_dfu.c b/flight/Bootloaders/CopterControl/op_dfu.c index 854c7cb71..834c29339 100644 --- a/flight/Bootloaders/CopterControl/op_dfu.c +++ b/flight/Bootloaders/CopterControl/op_dfu.c @@ -30,6 +30,7 @@ #include "pios.h" #include "op_dfu.h" #include "pios_bl_helper.h" +#include //programmable devices Device devicesTable[10]; uint8_t numberOfDevices = 0; @@ -382,16 +383,18 @@ void processComand(uint8_t *xReceive_Buffer) { return; } void OPDfuIni(uint8_t discover) { + const struct pios_board_info * bdinfo = &pios_board_info_blob; Device dev; + dev.programmingType = Self_flash; dev.readWriteFlags = (BOARD_READABLE | (BOARD_WRITABLA << 1)); - dev.startOfUserCode = START_OF_USER_CODE; - dev.sizeOfCode = SIZE_OF_CODE; - dev.sizeOfDescription = SIZE_OF_DESCRIPTION; - dev.BL_Version = BOOTLOADER_VERSION; + dev.startOfUserCode = bdinfo->fw_base; + dev.sizeOfCode = bdinfo->fw_size; + dev.sizeOfDescription = bdinfo->desc_size; + dev.BL_Version = bdinfo->bl_rev; dev.FW_Crc = CalcFirmCRC(); - dev.devID = (BOARD_TYPE << 8) | BOARD_REVISION; - dev.devType = HW_TYPE; + dev.devID = (bdinfo->board_type << 8) | (bdinfo->board_rev); + dev.devType = bdinfo->hw_type; numberOfDevices = 1; devicesTable[0] = dev; if (discover) { diff --git a/flight/Bootloaders/OpenPilot/Makefile b/flight/Bootloaders/OpenPilot/Makefile index e7804b536..23b3ffa8b 100644 --- a/flight/Bootloaders/OpenPilot/Makefile +++ b/flight/Bootloaders/OpenPilot/Makefile @@ -255,6 +255,13 @@ ifeq ($(ENABLE_AUX_UART), YES) CDEFS += -DPIOS_ENABLE_AUX_UART endif +# Provide (only) the bootloader with board-specific defines +BLONLY_CDEFS += -DBOARD_TYPE=$(BOARD_TYPE) +BLONLY_CDEFS += -DBOARD_REVISION=$(BOARD_REVISION) +BLONLY_CDEFS += -DHW_TYPE=$(HW_TYPE) +BLONLY_CDEFS += -DBOOTLOADER_VERSION=$(BOOTLOADER_VERSION) +BLONLY_CDEFS += -DSTART_OF_USER_CODE=$(START_OF_FW_CODE) + # Place project-specific -D and/or -U options for # Assembler with preprocessor here. #ADEFS = -DUSE_IRQ_ASM_WRAPPER @@ -292,6 +299,7 @@ endif CFLAGS += -mcpu=$(MCU) CFLAGS += $(CDEFS) +CFLAGS += $(BLONLY_CDEFS) CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I. CFLAGS += -mapcs-frame diff --git a/flight/Bootloaders/OpenPilot/main.c b/flight/Bootloaders/OpenPilot/main.c index 4766caf41..3ed5a80aa 100644 --- a/flight/Bootloaders/OpenPilot/main.c +++ b/flight/Bootloaders/OpenPilot/main.c @@ -27,6 +27,7 @@ */ /* Bootloader Includes */ #include +#include #include "pios_opahrs.h" #include "stopwatch.h" #include "op_dfu.h" @@ -216,7 +217,9 @@ int main() { } void jump_to_app() { - if (((*(__IO uint32_t*) START_OF_USER_CODE) & 0x2FFE0000) == 0x20000000) { /* Jump to user application */ + const struct pios_board_info * bdinfo = &pios_board_info_blob; + + if (((*(__IO uint32_t*) bdinfo->fw_base) & 0x2FFE0000) == 0x20000000) { /* Jump to user application */ FLASH_Lock(); RCC_APB2PeriphResetCmd(0xffffffff, ENABLE); RCC_APB1PeriphResetCmd(0xffffffff, ENABLE); @@ -225,10 +228,10 @@ void jump_to_app() { _SetCNTR(0); // clear interrupt mask _SetISTR(0); // clear all requests - JumpAddress = *(__IO uint32_t*) (START_OF_USER_CODE + 4); + JumpAddress = *(__IO uint32_t*) (bdinfo->fw_base + 4); Jump_To_Application = (pFunction) JumpAddress; /* Initialize user application's Stack Pointer */ - __set_MSP(*(__IO uint32_t*) START_OF_USER_CODE); + __set_MSP(*(__IO uint32_t*) bdinfo->fw_base); Jump_To_Application(); } else { DeviceState = failed_jump; diff --git a/flight/Bootloaders/OpenPilot/op_dfu.c b/flight/Bootloaders/OpenPilot/op_dfu.c index 77b4c2c59..e15d8596b 100644 --- a/flight/Bootloaders/OpenPilot/op_dfu.c +++ b/flight/Bootloaders/OpenPilot/op_dfu.c @@ -30,6 +30,7 @@ #include "pios.h" #include "op_dfu.h" #include "pios_bl_helper.h" +#include #include "pios_opahrs.h" #include "ssp.h" /* Private typedef -----------------------------------------------------------*/ @@ -447,16 +448,18 @@ void processComand(uint8_t *xReceive_Buffer) { return; } void OPDfuIni(uint8_t discover) { + const struct pios_board_info * bdinfo = &pios_board_info_blob; Device dev; + dev.programmingType = Self_flash; dev.readWriteFlags = (BOARD_READABLE | (BOARD_WRITABLA << 1)); - dev.startOfUserCode = START_OF_USER_CODE; - dev.sizeOfCode = SIZE_OF_CODE; - dev.sizeOfDescription = SIZE_OF_DESCRIPTION; - dev.BL_Version = BOOTLOADER_VERSION; + dev.startOfUserCode = bdinfo->fw_base; + dev.sizeOfCode = bdinfo->fw_size; + dev.sizeOfDescription = bdinfo->desc_size; + dev.BL_Version = bdinfo->bl_rev; dev.FW_Crc = CalcFirmCRC(); - dev.devID = (BOARD_TYPE << 8) | BOARD_REVISION; - dev.devType = HW_TYPE; + dev.devID = (bdinfo->board_type << 8) | (bdinfo->board_rev); + dev.devType = bdinfo->hw_type; numberOfDevices = 1; devicesTable[0] = dev; if (discover) { diff --git a/flight/Bootloaders/PipXtreme/Makefile b/flight/Bootloaders/PipXtreme/Makefile index f502a43c2..dd4a1ce43 100644 --- a/flight/Bootloaders/PipXtreme/Makefile +++ b/flight/Bootloaders/PipXtreme/Makefile @@ -251,6 +251,13 @@ ifeq ($(ENABLE_AUX_UART), YES) CDEFS += -DPIOS_ENABLE_AUX_UART endif +# Provide (only) the bootloader with board-specific defines +BLONLY_CDEFS += -DBOARD_TYPE=$(BOARD_TYPE) +BLONLY_CDEFS += -DBOARD_REVISION=$(BOARD_REVISION) +BLONLY_CDEFS += -DHW_TYPE=$(HW_TYPE) +BLONLY_CDEFS += -DBOOTLOADER_VERSION=$(BOOTLOADER_VERSION)C +BLONLY_CDEFS += -DSTART_OF_USER_CODE=$(START_OF_FW_CODE) + # Place project-specific -D and/or -U options for # Assembler with preprocessor here. #ADEFS = -DUSE_IRQ_ASM_WRAPPER @@ -286,8 +293,9 @@ ifeq ($(DEBUG),NO) CFLAGS += -ffunction-sections endif -CFLAGS += -mcpu=$(MCU) -mthumb +CFLAGS += -mcpu=$(MCU) CFLAGS += $(CDEFS) +CFLAGS += $(BLONLY_CDEFS) CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I. CFLAGS += -mapcs-frame @@ -307,7 +315,7 @@ CONLYFLAGS += $(CSTANDARD) # Assembler flags. # -Wa,...: tell GCC to pass this to the assembler. # -ahlns: create listing -ASFLAGS = -mcpu=$(MCU) -mthumb -I. -x assembler-with-cpp +ASFLAGS = -mcpu=$(MCU) -I. -x assembler-with-cpp ASFLAGS += $(ADEFS) ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) diff --git a/flight/Bootloaders/PipXtreme/main.c b/flight/Bootloaders/PipXtreme/main.c index a8eb5bcc6..d1568d163 100644 --- a/flight/Bootloaders/PipXtreme/main.c +++ b/flight/Bootloaders/PipXtreme/main.c @@ -27,6 +27,7 @@ */ /* Bootloader Includes */ #include +#include #include "stopwatch.h" #include "op_dfu.h" #include "usb_lib.h" @@ -170,7 +171,9 @@ int main() { } void jump_to_app() { - if (((*(__IO uint32_t*) START_OF_USER_CODE) & 0x2FFE0000) == 0x20000000) { /* Jump to user application */ + const struct pios_board_info * bdinfo = &pios_board_info_blob; + + if (((*(__IO uint32_t*) bdinfo->fw_base) & 0x2FFE0000) == 0x20000000) { /* Jump to user application */ FLASH_Lock(); RCC_APB2PeriphResetCmd(0xffffffff, ENABLE); RCC_APB1PeriphResetCmd(0xffffffff, ENABLE); @@ -179,10 +182,10 @@ void jump_to_app() { _SetCNTR(0); // clear interrupt mask _SetISTR(0); // clear all requests - JumpAddress = *(__IO uint32_t*) (START_OF_USER_CODE + 4); + JumpAddress = *(__IO uint32_t*) (bdinfo->fw_base + 4); Jump_To_Application = (pFunction) JumpAddress; /* Initialize user application's Stack Pointer */ - __set_MSP(*(__IO uint32_t*) START_OF_USER_CODE); + __set_MSP(*(__IO uint32_t*) bdinfo->fw_base); Jump_To_Application(); } else { DeviceState = failed_jump; diff --git a/flight/Bootloaders/PipXtreme/op_dfu.c b/flight/Bootloaders/PipXtreme/op_dfu.c index c413c31ba..fa0281d52 100644 --- a/flight/Bootloaders/PipXtreme/op_dfu.c +++ b/flight/Bootloaders/PipXtreme/op_dfu.c @@ -30,6 +30,7 @@ #include "pios.h" #include "op_dfu.h" #include "pios_bl_helper.h" +#include /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ @@ -414,16 +415,18 @@ void processComand(uint8_t *xReceive_Buffer) { return; } void OPDfuIni(uint8_t discover) { + const struct pios_board_info * bdinfo = &pios_board_info_blob; Device dev; + dev.programmingType = Self_flash; dev.readWriteFlags = (BOARD_READABLE | (BOARD_WRITABLA << 1)); - dev.startOfUserCode = START_OF_USER_CODE; - dev.sizeOfCode = SIZE_OF_CODE; - dev.sizeOfDescription = SIZE_OF_DESCRIPTION; - dev.BL_Version = BOOTLOADER_VERSION; + dev.startOfUserCode = bdinfo->fw_base; + dev.sizeOfCode = bdinfo->fw_size; + dev.sizeOfDescription = bdinfo->desc_size; + dev.BL_Version = bdinfo->bl_rev; dev.FW_Crc = CalcFirmCRC(); - dev.devID = (BOARD_TYPE << 8) | BOARD_REVISION; - dev.devType = HW_TYPE; + dev.devID = (bdinfo->board_type << 8) | (bdinfo->board_rev); + dev.devType = bdinfo->hw_type; numberOfDevices = 1; devicesTable[0] = dev; if (discover) { diff --git a/flight/Modules/FirmwareIAP/firmwareiap.c b/flight/Modules/FirmwareIAP/firmwareiap.c index 11e8721fd..395ed960f 100644 --- a/flight/Modules/FirmwareIAP/firmwareiap.c +++ b/flight/Modules/FirmwareIAP/firmwareiap.c @@ -27,6 +27,7 @@ #include #include "pios.h" +#include #include "openpilot.h" #include "firmwareiap.h" #include "firmwareiapobj.h" @@ -90,10 +91,12 @@ static void resetTask(UAVObjEvent *); int32_t FirmwareIAPInitialize() { - data.BoardType= BOARD_TYPE; + const struct pios_board_info * bdinfo = &pios_board_info_blob; + + data.BoardType= bdinfo->board_type; PIOS_BL_HELPER_FLASH_Read_Description(data.Description,FIRMWAREIAPOBJ_DESCRIPTION_NUMELEM); PIOS_SYS_SerialNumberGetBinary(data.CPUSerial); - data.BoardRevision= BOARD_REVISION; + data.BoardRevision= bdinfo->board_rev; data.ArmReset=0; data.crc = 0; FirmwareIAPObjSet( &data ); @@ -112,6 +115,7 @@ int32_t FirmwareIAPInitialize() static uint8_t iap_state = IAP_STATE_READY; static void FirmwareIAPCallback(UAVObjEvent* ev) { + const struct pios_board_info * bdinfo = &pios_board_info_blob; static uint32_t last_time = 0; uint32_t this_time; uint32_t delta; @@ -125,11 +129,11 @@ static void FirmwareIAPCallback(UAVObjEvent* ev) this_time = get_time(); delta = this_time - last_time; last_time = this_time; - if((data.BoardType==BOARD_TYPE)&&(data.crc != PIOS_BL_HELPER_CRC_Memory_Calc())) + if((data.BoardType==bdinfo->board_type)&&(data.crc != PIOS_BL_HELPER_CRC_Memory_Calc())) { PIOS_BL_HELPER_FLASH_Read_Description(data.Description,FIRMWAREIAPOBJ_DESCRIPTION_NUMELEM); PIOS_SYS_SerialNumberGetBinary(data.CPUSerial); - data.BoardRevision=BOARD_REVISION; + data.BoardRevision=bdinfo->board_rev; data.crc = PIOS_BL_HELPER_CRC_Memory_Calc(); FirmwareIAPObjSet( &data ); } diff --git a/flight/PiOS/Boards/STM32103CB_AHRS.h b/flight/PiOS/Boards/STM32103CB_AHRS.h index a1c4907b0..d17799ada 100644 --- a/flight/PiOS/Boards/STM32103CB_AHRS.h +++ b/flight/PiOS/Boards/STM32103CB_AHRS.h @@ -64,23 +64,6 @@ TIM8 | | | | //------------------------ // BOOTLOADER_SETTINGS //------------------------ -//#define FUNC_ID 2 -//#define HW_VERSION 69 - -#define BOOTLOADER_VERSION 0 -#define BOARD_TYPE 0x02 -#define BOARD_REVISION 0x01 -//#define HW_VERSION (BOARD_TYPE << 8) | BOARD_REVISION - -#define MEM_SIZE 0x20000 //128K -#define SIZE_OF_DESCRIPTION 100 -#define START_OF_USER_CODE (uint32_t)0x08002000 -#define SIZE_OF_CODE (uint32_t)(MEM_SIZE-(START_OF_USER_CODE-0x08000000)-SIZE_OF_DESCRIPTION) -#ifdef STM32F10X_HD - #define HW_TYPE 0 //0=high_density 1=medium_density; -#elif STM32F10X_MD - #define HW_TYPE 1 //0=high_density 1=medium_density; -#endif #define BOARD_READABLE TRUE #define BOARD_WRITABLA TRUE #define MAX_DEL_RETRYS 3 diff --git a/flight/PiOS/Boards/STM32103CB_CC_Rev1.h b/flight/PiOS/Boards/STM32103CB_CC_Rev1.h index fcc868090..f26bd9c1c 100644 --- a/flight/PiOS/Boards/STM32103CB_CC_Rev1.h +++ b/flight/PiOS/Boards/STM32103CB_CC_Rev1.h @@ -60,21 +60,6 @@ TIM4 | RC In 1 | Servo 3 | Servo 2 | Servo 1 //------------------------ // BOOTLOADER_SETTINGS //------------------------ -//#define FUNC_ID 2 -//#define HW_VERSION 69 - -#define BOOTLOADER_VERSION 0 -#define BOARD_TYPE 0x04 -#define BOARD_REVISION 0x01 -#define MEM_SIZE 0x20000 //128K -#define SIZE_OF_DESCRIPTION 100 -#define START_OF_USER_CODE (uint32_t)0x08003000 -#define SIZE_OF_CODE (uint32_t)(MEM_SIZE-(START_OF_USER_CODE-0x08000000)-SIZE_OF_DESCRIPTION) -#ifdef STM32F10X_HD - #define HW_TYPE 0 //0=high_density 1=medium_density; -#elif STM32F10X_MD - #define HW_TYPE 1 //0=high_density 1=medium_density; -#endif #define BOARD_READABLE TRUE #define BOARD_WRITABLA TRUE #define MAX_DEL_RETRYS 3 diff --git a/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h b/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h index 6811bfad5..7114c2871 100644 --- a/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h +++ b/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h @@ -58,18 +58,6 @@ TIM4 | STOPWATCH | //------------------------ // BOOTLOADER_SETTINGS //------------------------ -#define BOOTLOADER_VERSION 0 -#define BOARD_TYPE 0x03 -#define BOARD_REVISION 0x01 -#define MEM_SIZE (0x20000 - 0x00400) // 128K - 1K (reserved for config data) -#define SIZE_OF_DESCRIPTION 100 -#define START_OF_USER_CODE (uint32_t)0x08003000 -#define SIZE_OF_CODE (uint32_t)(MEM_SIZE-(START_OF_USER_CODE-0x08000000)-SIZE_OF_DESCRIPTION) -#ifdef STM32F10X_HD - #define HW_TYPE 0 //0=high_density 1=medium_density; -#elif STM32F10X_MD - #define HW_TYPE 1 //0=high_density 1=medium_density; -#endif #define BOARD_READABLE TRUE #define BOARD_WRITABLA TRUE #define MAX_DEL_RETRYS 3 diff --git a/flight/PiOS/Boards/STM3210E_INS.h b/flight/PiOS/Boards/STM3210E_INS.h index 5efb04a36..3229de344 100644 --- a/flight/PiOS/Boards/STM3210E_INS.h +++ b/flight/PiOS/Boards/STM3210E_INS.h @@ -69,25 +69,6 @@ TIM8 | | | | //------------------------ // BOOTLOADER_SETTINGS //------------------------ - -//#define FUNC_ID 1 -//#define HW_VERSION 01 - -#define BOOTLOADER_VERSION 0 -#define BOARD_TYPE 0x05 // INS board -#define BOARD_REVISION 0x01 // Beta version -//#define HW_VERSION (BOARD_TYPE << 8) | BOARD_REVISION - -#define MEM_SIZE 524288 //512K -#define SIZE_OF_DESCRIPTION (uint8_t) 100 -#define START_OF_USER_CODE (uint32_t)0x08005000//REMEMBER SET ALSO IN link_stm32f10x_HD_BL.ld -#define SIZE_OF_CODE (uint32_t) (MEM_SIZE-(START_OF_USER_CODE-0x08000000)-SIZE_OF_DESCRIPTION) - -#ifdef STM32F10X_HD - #define HW_TYPE 0 //0=high_density 1=medium_density; -#elif STM32F10X_MD - #define HW_TYPE 1 //0=high_density 1=medium_density; -#endif #define BOARD_READABLE TRUE #define BOARD_WRITABLA TRUE #define MAX_DEL_RETRYS 3 diff --git a/flight/PiOS/Boards/STM3210E_OP.h b/flight/PiOS/Boards/STM3210E_OP.h index b987ab600..58e3fb077 100644 --- a/flight/PiOS/Boards/STM3210E_OP.h +++ b/flight/PiOS/Boards/STM3210E_OP.h @@ -68,25 +68,6 @@ TIM8 | Servo 5 | Servo 6 | Servo 7 | Servo 8 //------------------------ // BOOTLOADER_SETTINGS //------------------------ - -//#define FUNC_ID 1 -//#define HW_VERSION 01 - -#define BOOTLOADER_VERSION 0 -#define BOARD_TYPE 0x01 // OpenPilot board -#define BOARD_REVISION 0x01 // Beta version -//#define HW_VERSION (BOARD_TYPE << 8) | BOARD_REVISION - -#define MEM_SIZE 524288 //512K -#define SIZE_OF_DESCRIPTION (uint8_t) 100 -#define START_OF_USER_CODE (uint32_t)0x08005000//REMEMBER SET ALSO IN link_stm32f10x_HD_BL.ld -#define SIZE_OF_CODE (uint32_t) (MEM_SIZE-(START_OF_USER_CODE-0x08000000)-SIZE_OF_DESCRIPTION) - -#ifdef STM32F10X_HD - #define HW_TYPE 0 //0=high_density 1=medium_density; -#elif STM32F10X_MD - #define HW_TYPE 1 //0=high_density 1=medium_density; -#endif #define BOARD_READABLE TRUE #define BOARD_WRITABLA TRUE #define MAX_DEL_RETRYS 3 diff --git a/flight/PiOS/Common/pios_bl_helper.c b/flight/PiOS/Common/pios_bl_helper.c index 545a008c6..967c3c7e6 100644 --- a/flight/PiOS/Common/pios_bl_helper.c +++ b/flight/PiOS/Common/pios_bl_helper.c @@ -31,6 +31,7 @@ /* Project Includes */ #include "pios.h" #if defined(PIOS_INCLUDE_BL_HELPER) +#include #include "stm32f10x_flash.h" uint8_t *PIOS_BL_HELPER_FLASH_If_Read(uint32_t SectorAddress) @@ -47,10 +48,10 @@ uint8_t PIOS_BL_HELPER_FLASH_Ini() uint8_t PIOS_BL_HELPER_FLASH_Start() { - uint32_t pageAdress; - pageAdress = START_OF_USER_CODE; + const struct pios_board_info * bdinfo = &pios_board_info_blob; + uint32_t pageAdress = bdinfo->fw_base; uint8_t fail = FALSE; - while ((pageAdress < START_OF_USER_CODE + SIZE_OF_CODE + SIZE_OF_DESCRIPTION) + while ((pageAdress < (bdinfo->fw_base + bdinfo->fw_size + bdinfo->desc_size)) || (fail == TRUE)) { for (int retry = 0; retry < MAX_DEL_RETRYS; ++retry) { if (FLASH_ErasePage(pageAdress) == FLASH_COMPLETE) { @@ -75,17 +76,20 @@ uint8_t PIOS_BL_HELPER_FLASH_Start() uint32_t PIOS_BL_HELPER_CRC_Memory_Calc() { + const struct pios_board_info * bdinfo = &pios_board_info_blob; + PIOS_BL_HELPER_CRC_Ini(); CRC_ResetDR(); - CRC_CalcBlockCRC((uint32_t *) START_OF_USER_CODE, (SIZE_OF_CODE) >> 2); + CRC_CalcBlockCRC((uint32_t *) bdinfo->fw_base, (bdinfo->fw_size) >> 2); return CRC_GetCRC(); } void PIOS_BL_HELPER_FLASH_Read_Description(uint8_t * array, uint8_t size) { + const struct pios_board_info * bdinfo = &pios_board_info_blob; uint8_t x = 0; - if (size>SIZE_OF_DESCRIPTION) size = SIZE_OF_DESCRIPTION; - for (uint32_t i = START_OF_USER_CODE + SIZE_OF_CODE; i < START_OF_USER_CODE + SIZE_OF_CODE + size; ++i) { + if (size > bdinfo->desc_size) size = bdinfo->desc_size; + for (uint32_t i = bdinfo->fw_base + bdinfo->fw_size; i < bdinfo->fw_base + bdinfo->fw_size + size; ++i) { array[x] = *PIOS_BL_HELPER_FLASH_If_Read(i); ++x; } From 076e5660fa6e81d379abff8d607c5d864908978e Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Mon, 23 May 2011 22:04:54 -0400 Subject: [PATCH 07/18] build: Add all_ and all__clean targets Building all_ will build all available embedded images for . New targets: - all_ahrs - all_openpilot - all_coptercontrol - all_pipxtreme - all_ins and their associated _clean targets to remove the build output. --- Makefile | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 54b5c1e19..db7ed054d 100644 --- a/Makefile +++ b/Makefile @@ -85,11 +85,16 @@ help: @echo " all_bl_clean - Remove bootlaoders for all boards" @echo " all_bu_clean - Remove bootloader updaters for all boards" @echo + @echo " all_ - Build all available images for " + @echo " all__clean - Remove all available images for " + @echo @echo " [Firmware]" @echo " - Build firmware for " + @echo " supported boards are ($(ALL_BOARDS))" + @echo " fw_ - Build firmware for " @echo " supported boards are ($(FW_TARGETS))" - @echo " _clean - Remove firmware for " - @echo " _program - Use OpenOCD + JTAG to write firmware to " + @echo " fw__clean - Remove firmware for " + @echo " fw__program - Use OpenOCD + JTAG to write firmware to " @echo @echo " [Bootloader]" @echo " bl_ - Build bootloader for " @@ -376,6 +381,19 @@ bu_$(1)_clean: $(V1) $(RM) -fr $(BUILD_DIR)/bu_$(1) endef +# $(1) = Canonical board name all in lower case (e.g. coptercontrol) +define BOARD_PHONY_TEMPLATE +.PHONY: all_$(1) +all_$(1): $$(filter fw_$(1), $$(FW_TARGETS)) +all_$(1): $$(filter bl_$(1), $$(BL_TARGETS)) +all_$(1): $$(filter bu_$(1), $$(BU_TARGETS)) + +.PHONY: all_$(1)_clean +all_$(1)_clean: $$(addsuffix _clean, $$(filter fw_$(1), $$(FW_TARGETS))) +all_$(1)_clean: $$(addsuffix _clean, $$(filter bl_$(1), $$(BL_TARGETS))) +all_$(1)_clean: $$(addsuffix _clean, $$(filter bu_$(1), $$(BU_TARGETS))) +endef + ALL_BOARDS := openpilot ahrs coptercontrol pipxtreme ins # Friendly names of each board (used to find source tree) @@ -410,6 +428,8 @@ all_bu_clean: $(addsuffix _clean, $(BU_TARGETS)) all_flight: all_fw all_bl all_bu all_flight_clean: all_fw_clean all_bl_clean all_bu_clean +$(foreach board, $(ALL_BOARDS), $(eval $(call BOARD_PHONY_TEMPLATE,$(board)))) + # Expand the bootloader updater rules $(foreach board, $(ALL_BOARDS), $(eval $(call BU_TEMPLATE,$(board),$($(board)_friendly)))) From 504fe7a664e94affdbaf4aa615f1bae81b3282cb Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Mon, 23 May 2011 22:18:56 -0400 Subject: [PATCH 08/18] dfu: fix typo WRITABLA -> WRITABLE --- flight/Bootloaders/AHRS/main.c | 2 +- flight/Bootloaders/CopterControl/op_dfu.c | 2 +- flight/Bootloaders/OpenPilot/op_dfu.c | 2 +- flight/Bootloaders/PipXtreme/op_dfu.c | 2 +- flight/PiOS/Boards/STM32103CB_AHRS.h | 2 +- flight/PiOS/Boards/STM32103CB_CC_Rev1.h | 2 +- flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h | 2 +- flight/PiOS/Boards/STM3210E_INS.h | 2 +- flight/PiOS/Boards/STM3210E_OP.h | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/flight/Bootloaders/AHRS/main.c b/flight/Bootloaders/AHRS/main.c index c7da0d439..b284e6365 100644 --- a/flight/Bootloaders/AHRS/main.c +++ b/flight/Bootloaders/AHRS/main.c @@ -170,7 +170,7 @@ void process_spi_request(void) { opahrs_msg_v0_init_user_tx(&user_tx_v0, OPAHRS_MSG_V0_RSP_MEM_MAP); user_tx_v0.payload.user.v.rsp.mem_map.density = bdinfo->hw_type; user_tx_v0.payload.user.v.rsp.mem_map.rw_flags = (BOARD_READABLE - | (BOARD_WRITABLA << 1)); + | (BOARD_WRITABLE << 1)); user_tx_v0.payload.user.v.rsp.mem_map.size_of_code_memory = bdinfo->fw_size; user_tx_v0.payload.user.v.rsp.mem_map.size_of_description diff --git a/flight/Bootloaders/CopterControl/op_dfu.c b/flight/Bootloaders/CopterControl/op_dfu.c index 834c29339..b45e1e798 100644 --- a/flight/Bootloaders/CopterControl/op_dfu.c +++ b/flight/Bootloaders/CopterControl/op_dfu.c @@ -387,7 +387,7 @@ void OPDfuIni(uint8_t discover) { Device dev; dev.programmingType = Self_flash; - dev.readWriteFlags = (BOARD_READABLE | (BOARD_WRITABLA << 1)); + dev.readWriteFlags = (BOARD_READABLE | (BOARD_WRITABLE << 1)); dev.startOfUserCode = bdinfo->fw_base; dev.sizeOfCode = bdinfo->fw_size; dev.sizeOfDescription = bdinfo->desc_size; diff --git a/flight/Bootloaders/OpenPilot/op_dfu.c b/flight/Bootloaders/OpenPilot/op_dfu.c index e15d8596b..bc62fff6c 100644 --- a/flight/Bootloaders/OpenPilot/op_dfu.c +++ b/flight/Bootloaders/OpenPilot/op_dfu.c @@ -452,7 +452,7 @@ void OPDfuIni(uint8_t discover) { Device dev; dev.programmingType = Self_flash; - dev.readWriteFlags = (BOARD_READABLE | (BOARD_WRITABLA << 1)); + dev.readWriteFlags = (BOARD_READABLE | (BOARD_WRITABLE << 1)); dev.startOfUserCode = bdinfo->fw_base; dev.sizeOfCode = bdinfo->fw_size; dev.sizeOfDescription = bdinfo->desc_size; diff --git a/flight/Bootloaders/PipXtreme/op_dfu.c b/flight/Bootloaders/PipXtreme/op_dfu.c index fa0281d52..770ce8237 100644 --- a/flight/Bootloaders/PipXtreme/op_dfu.c +++ b/flight/Bootloaders/PipXtreme/op_dfu.c @@ -419,7 +419,7 @@ void OPDfuIni(uint8_t discover) { Device dev; dev.programmingType = Self_flash; - dev.readWriteFlags = (BOARD_READABLE | (BOARD_WRITABLA << 1)); + dev.readWriteFlags = (BOARD_READABLE | (BOARD_WRITABLE << 1)); dev.startOfUserCode = bdinfo->fw_base; dev.sizeOfCode = bdinfo->fw_size; dev.sizeOfDescription = bdinfo->desc_size; diff --git a/flight/PiOS/Boards/STM32103CB_AHRS.h b/flight/PiOS/Boards/STM32103CB_AHRS.h index d17799ada..b407c0f42 100644 --- a/flight/PiOS/Boards/STM32103CB_AHRS.h +++ b/flight/PiOS/Boards/STM32103CB_AHRS.h @@ -65,7 +65,7 @@ TIM8 | | | | // BOOTLOADER_SETTINGS //------------------------ #define BOARD_READABLE TRUE -#define BOARD_WRITABLA TRUE +#define BOARD_WRITABLE TRUE #define MAX_DEL_RETRYS 3 //------------------------ diff --git a/flight/PiOS/Boards/STM32103CB_CC_Rev1.h b/flight/PiOS/Boards/STM32103CB_CC_Rev1.h index f26bd9c1c..16e58b5c2 100644 --- a/flight/PiOS/Boards/STM32103CB_CC_Rev1.h +++ b/flight/PiOS/Boards/STM32103CB_CC_Rev1.h @@ -61,7 +61,7 @@ TIM4 | RC In 1 | Servo 3 | Servo 2 | Servo 1 // BOOTLOADER_SETTINGS //------------------------ #define BOARD_READABLE TRUE -#define BOARD_WRITABLA TRUE +#define BOARD_WRITABLE TRUE #define MAX_DEL_RETRYS 3 diff --git a/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h b/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h index 7114c2871..a8eead4bd 100644 --- a/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h +++ b/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h @@ -59,7 +59,7 @@ TIM4 | STOPWATCH | // BOOTLOADER_SETTINGS //------------------------ #define BOARD_READABLE TRUE -#define BOARD_WRITABLA TRUE +#define BOARD_WRITABLE TRUE #define MAX_DEL_RETRYS 3 diff --git a/flight/PiOS/Boards/STM3210E_INS.h b/flight/PiOS/Boards/STM3210E_INS.h index 3229de344..d0c988b21 100644 --- a/flight/PiOS/Boards/STM3210E_INS.h +++ b/flight/PiOS/Boards/STM3210E_INS.h @@ -70,7 +70,7 @@ TIM8 | | | | // BOOTLOADER_SETTINGS //------------------------ #define BOARD_READABLE TRUE -#define BOARD_WRITABLA TRUE +#define BOARD_WRITABLE TRUE #define MAX_DEL_RETRYS 3 //------------------------ diff --git a/flight/PiOS/Boards/STM3210E_OP.h b/flight/PiOS/Boards/STM3210E_OP.h index 58e3fb077..c042184ea 100644 --- a/flight/PiOS/Boards/STM3210E_OP.h +++ b/flight/PiOS/Boards/STM3210E_OP.h @@ -69,7 +69,7 @@ TIM8 | Servo 5 | Servo 6 | Servo 7 | Servo 8 // BOOTLOADER_SETTINGS //------------------------ #define BOARD_READABLE TRUE -#define BOARD_WRITABLA TRUE +#define BOARD_WRITABLE TRUE #define MAX_DEL_RETRYS 3 //------------------------ From 9973fda23bee81a8f1188a958d1cb4cf89e8adfb Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Tue, 24 May 2011 00:08:03 -0400 Subject: [PATCH 09/18] build: define bootloader and firmware bank spans The board-info.mk files now define the start and size of the bootloader and the firmware banks. --- flight/AHRS/Makefile | 4 ++-- flight/Bootloaders/AHRS/Makefile | 8 +++++--- flight/Bootloaders/CopterControl/Makefile | 8 +++++--- flight/Bootloaders/OpenPilot/Makefile | 8 +++++--- flight/Bootloaders/PipXtreme/Makefile | 10 ++++++---- flight/CopterControl/Makefile | 4 ++-- flight/OpenPilot/Makefile | 4 ++-- flight/PiOS/Common/pios_board_info.c | 8 ++++---- flight/PipXtreme/Makefile | 4 ++-- make/boards/ahrs/board-info.mk | 9 +++++++-- make/boards/coptercontrol/board-info.mk | 9 +++++++-- make/boards/openpilot/board-info.mk | 9 +++++++-- make/boards/pipxtreme/board-info.mk | 13 ++++++++++--- 13 files changed, 64 insertions(+), 34 deletions(-) diff --git a/flight/AHRS/Makefile b/flight/AHRS/Makefile index 903d6901f..c203fdd59 100644 --- a/flight/AHRS/Makefile +++ b/flight/AHRS/Makefile @@ -292,9 +292,9 @@ LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_sections.ld OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).bin # Program -OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(START_OF_FW_CODE) bin" +OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(FW_BANK_BASE) bin" # Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(START_OF_FW_CODE) bin" +OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(FW_BANK_BASE) bin" # reset target OOCD_CL+=-c "reset run" # terminate OOCD after programming diff --git a/flight/Bootloaders/AHRS/Makefile b/flight/Bootloaders/AHRS/Makefile index 10f184f96..1df91a1ab 100644 --- a/flight/Bootloaders/AHRS/Makefile +++ b/flight/Bootloaders/AHRS/Makefile @@ -204,7 +204,9 @@ BLONLY_CDEFS += -DBOARD_TYPE=$(BOARD_TYPE) BLONLY_CDEFS += -DBOARD_REVISION=$(BOARD_REVISION) BLONLY_CDEFS += -DHW_TYPE=$(HW_TYPE) BLONLY_CDEFS += -DBOOTLOADER_VERSION=$(BOOTLOADER_VERSION) -BLONLY_CDEFS += -DSTART_OF_USER_CODE=$(START_OF_FW_CODE) +BLONLY_CDEFS += -DFW_BANK_BASE=$(FW_BANK_BASE) +BLONLY_CDEFS += -DFW_BANK_SIZE=$(FW_BANK_SIZE) +BLONLY_CDEFS += -DFW_DESC_SIZE=$(FW_DESC_SIZE) # Place project-specific -D and/or -U options for # Assembler with preprocessor here. @@ -291,9 +293,9 @@ LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_BL_sections.ld OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).bin # Program -OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(START_OF_BL_CODE) bin" +OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(BL_BANK_BASE) bin" # Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(START_OF_BL_CODE) bin" +OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(BL_BANK_BASE) bin" # reset target OOCD_CL+=-c "reset run" # terminate OOCD after programming diff --git a/flight/Bootloaders/CopterControl/Makefile b/flight/Bootloaders/CopterControl/Makefile index fe83ceb66..413749cca 100644 --- a/flight/Bootloaders/CopterControl/Makefile +++ b/flight/Bootloaders/CopterControl/Makefile @@ -257,7 +257,9 @@ BLONLY_CDEFS += -DBOARD_TYPE=$(BOARD_TYPE) BLONLY_CDEFS += -DBOARD_REVISION=$(BOARD_REVISION) BLONLY_CDEFS += -DHW_TYPE=$(HW_TYPE) BLONLY_CDEFS += -DBOOTLOADER_VERSION=$(BOOTLOADER_VERSION) -BLONLY_CDEFS += -DSTART_OF_USER_CODE=$(START_OF_FW_CODE) +BLONLY_CDEFS += -DFW_BANK_BASE=$(FW_BANK_BASE) +BLONLY_CDEFS += -DFW_BANK_SIZE=$(FW_BANK_SIZE) +BLONLY_CDEFS += -DFW_DESC_SIZE=$(FW_DESC_SIZE) # Place project-specific -D and/or -U options for # Assembler with preprocessor here. @@ -343,9 +345,9 @@ LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_BL_sections.ld OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).bin # Program -OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(START_OF_BL_CODE) bin" +OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(BL_BANK_BASE) bin" # Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(START_OF_BL_CODE) bin" +OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(BL_BANK_BASE) bin" # reset target OOCD_CL+=-c "reset run" # terminate OOCD after programming diff --git a/flight/Bootloaders/OpenPilot/Makefile b/flight/Bootloaders/OpenPilot/Makefile index 23b3ffa8b..1167693b3 100644 --- a/flight/Bootloaders/OpenPilot/Makefile +++ b/flight/Bootloaders/OpenPilot/Makefile @@ -260,7 +260,9 @@ BLONLY_CDEFS += -DBOARD_TYPE=$(BOARD_TYPE) BLONLY_CDEFS += -DBOARD_REVISION=$(BOARD_REVISION) BLONLY_CDEFS += -DHW_TYPE=$(HW_TYPE) BLONLY_CDEFS += -DBOOTLOADER_VERSION=$(BOOTLOADER_VERSION) -BLONLY_CDEFS += -DSTART_OF_USER_CODE=$(START_OF_FW_CODE) +BLONLY_CDEFS += -DFW_BANK_BASE=$(FW_BANK_BASE) +BLONLY_CDEFS += -DFW_BANK_SIZE=$(FW_BANK_SIZE) +BLONLY_CDEFS += -DFW_DESC_SIZE=$(FW_DESC_SIZE) # Place project-specific -D and/or -U options for # Assembler with preprocessor here. @@ -346,9 +348,9 @@ LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_BL_sections.ld OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).bin # Program -OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(START_OF_BL_CODE) bin" +OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(BL_BANK_BASE) bin" # Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(START_OF_BL_CODE) bin" +OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(BL_BANK_BASE) bin" # reset target OOCD_CL+=-c "reset run" # terminate OOCD after programming diff --git a/flight/Bootloaders/PipXtreme/Makefile b/flight/Bootloaders/PipXtreme/Makefile index dd4a1ce43..c91713cd9 100644 --- a/flight/Bootloaders/PipXtreme/Makefile +++ b/flight/Bootloaders/PipXtreme/Makefile @@ -255,8 +255,10 @@ endif BLONLY_CDEFS += -DBOARD_TYPE=$(BOARD_TYPE) BLONLY_CDEFS += -DBOARD_REVISION=$(BOARD_REVISION) BLONLY_CDEFS += -DHW_TYPE=$(HW_TYPE) -BLONLY_CDEFS += -DBOOTLOADER_VERSION=$(BOOTLOADER_VERSION)C -BLONLY_CDEFS += -DSTART_OF_USER_CODE=$(START_OF_FW_CODE) +BLONLY_CDEFS += -DBOOTLOADER_VERSION=$(BOOTLOADER_VERSION) +BLONLY_CDEFS += -DFW_BANK_BASE=$(FW_BANK_BASE) +BLONLY_CDEFS += -DFW_BANK_SIZE=$(FW_BANK_SIZE) +BLONLY_CDEFS += -DFW_DESC_SIZE=$(FW_DESC_SIZE) # Place project-specific -D and/or -U options for # Assembler with preprocessor here. @@ -342,9 +344,9 @@ LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_BL_sections.ld OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).bin # Program -OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(START_OF_BL_CODE) bin" +OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(BL_BANK_BASE) bin" # Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(START_OF_BL_CODE) bin" +OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(BL_BANK_BASE) bin" # reset target OOCD_CL+=-c "reset run" # terminate OOCD after programming diff --git a/flight/CopterControl/Makefile b/flight/CopterControl/Makefile index b56e40fe3..942bc45a9 100644 --- a/flight/CopterControl/Makefile +++ b/flight/CopterControl/Makefile @@ -468,9 +468,9 @@ LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_sections.ld OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).bin # Program -OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(START_OF_FW_CODE) bin" +OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(FW_BANK_BASE) bin" # Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(START_OF_FW_CODE) bin" +OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(FW_BANK_BASE) bin" # reset target OOCD_CL+=-c "reset run" # terminate OOCD after programming diff --git a/flight/OpenPilot/Makefile b/flight/OpenPilot/Makefile index 5022ab101..c14a4381c 100644 --- a/flight/OpenPilot/Makefile +++ b/flight/OpenPilot/Makefile @@ -444,9 +444,9 @@ LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_sections.ld OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).bin # Program -OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(START_OF_FW_CODE) bin" +OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(FW_BANK_BASE) bin" # Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(START_OF_FW_CODE) bin" +OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(FW_BANK_BASE) bin" # reset target OOCD_CL+=-c "reset run" # terminate OOCD after programming diff --git a/flight/PiOS/Common/pios_board_info.c b/flight/PiOS/Common/pios_board_info.c index db9e72f9e..f94ac1f96 100644 --- a/flight/PiOS/Common/pios_board_info.c +++ b/flight/PiOS/Common/pios_board_info.c @@ -9,8 +9,8 @@ const struct pios_board_info __attribute__((__used__)) __attribute__((__section_ .board_rev = BOARD_REVISION, .bl_rev = BOOTLOADER_VERSION, .hw_type = HW_TYPE, - .fw_base = START_OF_USER_CODE, - .fw_size = SIZE_OF_CODE, - .desc_base = START_OF_USER_CODE + SIZE_OF_CODE, - .desc_size = SIZE_OF_DESCRIPTION, + .fw_base = FW_BANK_BASE, + .fw_size = FW_BANK_SIZE - FW_DESC_SIZE, + .desc_base = FW_BANK_BASE + FW_BANK_SIZE - FW_DESC_SIZE, + .desc_size = FW_DESC_SIZE, }; diff --git a/flight/PipXtreme/Makefile b/flight/PipXtreme/Makefile index 62ea87d73..57dbfb8f0 100644 --- a/flight/PipXtreme/Makefile +++ b/flight/PipXtreme/Makefile @@ -331,9 +331,9 @@ LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_sections.ld OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).bin # Program -OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(START_OF_FW_CODE) bin" +OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(FW_BANK_BASE) bin" # Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(START_OF_FW_CODE) bin" +OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(FW_BANK_BASE) bin" # reset target OOCD_CL+=-c "reset run" # terminate OOCD after programming diff --git a/make/boards/ahrs/board-info.mk b/make/boards/ahrs/board-info.mk index 049e27b63..2103357ba 100644 --- a/make/boards/ahrs/board-info.mk +++ b/make/boards/ahrs/board-info.mk @@ -9,5 +9,10 @@ BOARD := STM32103CB_AHRS MODEL := MD MODEL_SUFFIX := -START_OF_BL_CODE := 0x08000000 -START_OF_FW_CODE := 0x08002000 +# Note: These must match the values in link_$(BOARD)_memory.ld +BL_BANK_BASE := 0x08000000 # Start of bootloader flash +BL_BANK_SIZE := 0x00002000 # Should include BD_INFO region +FW_BANK_BASE := 0x08002000 # Start of firmware flash +FW_BANK_SIZE := 0x0001E000 # Should include FW_DESC_SIZE + +FW_DESC_SIZE := 0x00000064 diff --git a/make/boards/coptercontrol/board-info.mk b/make/boards/coptercontrol/board-info.mk index 9968b2eec..8d3f5d196 100644 --- a/make/boards/coptercontrol/board-info.mk +++ b/make/boards/coptercontrol/board-info.mk @@ -9,5 +9,10 @@ BOARD := STM32103CB_CC_Rev1 MODEL := MD MODEL_SUFFIX := _CC -START_OF_BL_CODE := 0x08000000 -START_OF_FW_CODE := 0x08003000 +# Note: These must match the values in link_$(BOARD)_memory.ld +BL_BANK_BASE := 0x08000000 # Start of bootloader flash +BL_BANK_SIZE := 0x00003000 # Should include BD_INFO region +FW_BANK_BASE := 0x08003000 # Start of firmware flash +FW_BANK_SIZE := 0x0001D000 # Should include FW_DESC_SIZE + +FW_DESC_SIZE := 0x00000064 diff --git a/make/boards/openpilot/board-info.mk b/make/boards/openpilot/board-info.mk index 271083c89..f1e35505c 100644 --- a/make/boards/openpilot/board-info.mk +++ b/make/boards/openpilot/board-info.mk @@ -9,5 +9,10 @@ BOARD := STM3210E_OP MODEL := HD MODEL_SUFFIX := _OP -START_OF_BL_CODE := 0x08000000 -START_OF_FW_CODE := 0x08005000 +# Note: These must match the values in link_$(BOARD)_memory.ld +BL_BANK_BASE := 0x08000000 # Start of bootloader flash +BL_BANK_SIZE := 0x00005000 # Should include BD_INFO region +FW_BANK_BASE := 0x08005000 # Start of firmware flash +FW_BANK_SIZE := 0x0007B000 # Should include FW_DESC_SIZE + +FW_DESC_SIZE := 0x00000064 diff --git a/make/boards/pipxtreme/board-info.mk b/make/boards/pipxtreme/board-info.mk index a2912ac37..f9635109e 100644 --- a/make/boards/pipxtreme/board-info.mk +++ b/make/boards/pipxtreme/board-info.mk @@ -1,7 +1,7 @@ BOARD_TYPE := 0x03 BOARD_REVISION := 0x01 BOOTLOADER_VERSION := 0x00 -HW_TYPE := 0x00 +HW_TYPE := 0x01 MCU := cortex-m3 CHIP := STM32F103CBT @@ -9,5 +9,12 @@ BOARD := STM32103CB_PIPXTREME MODEL := MD MODEL_SUFFIX := -START_OF_BL_CODE := 0x08000000 -START_OF_FW_CODE := 0x08003000 +# Note: These must match the values in link_$(BOARD)_memory.ld +BL_BANK_BASE := 0x08000000 # Start of bootloader flash +BL_BANK_SIZE := 0x00003000 # Should include BD_INFO region +FW_BANK_BASE := 0x08003000 # Start of firmware flash +FW_BANK_SIZE := 0x0001CC00 # Should include FW_DESC_SIZE +EE_BANK_BASE := 0x0801FC00 # EEPROM storage area +EE_BANK_SIZE := 0x00000400 # Size of EEPROM storage area + +FW_DESC_SIZE := 0x00000064 From 0eb92fad919a13afae1912e63f6ac53855e57716 Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Tue, 24 May 2011 01:10:31 -0400 Subject: [PATCH 10/18] build: refactor jtag program and add jtag wipe target Macros for JTAG program and wipe for each target are now provided in firmware-defs.mk. The _wipe target for each firmware and bootloader image will erase either the bootloader (bl_*_wipe) or firmware (fw_*_wipe) bank. --- flight/AHRS/Makefile | 26 ++----------- flight/Bootloaders/AHRS/Makefile | 25 ++---------- flight/Bootloaders/CopterControl/Makefile | 25 ++---------- flight/Bootloaders/OpenPilot/Makefile | 25 ++---------- flight/Bootloaders/PipXtreme/Makefile | 25 ++---------- flight/CopterControl/Makefile | 24 ++---------- flight/INS/Makefile | 25 ++---------- flight/OpenPilot/Makefile | 26 ++----------- flight/PipXtreme/Makefile | 25 ++---------- make/firmware-defs.mk | 46 +++++++++++++++++++---- 10 files changed, 75 insertions(+), 197 deletions(-) diff --git a/flight/AHRS/Makefile b/flight/AHRS/Makefile index c203fdd59..2c9f409b5 100644 --- a/flight/AHRS/Makefile +++ b/flight/AHRS/Makefile @@ -290,21 +290,8 @@ LDFLAGS += -lc -lgcc LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_memory.ld LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_sections.ld -OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).bin -# Program -OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(FW_BANK_BASE) bin" -# Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(FW_BANK_BASE) bin" -# reset target -OOCD_CL+=-c "reset run" -# terminate OOCD after programming -OOCD_CL+=-c shutdown - - # Define programs and commands. REMOVE = $(REMOVE_CMD) -f -###SHELL = sh -###COPY = cp # List of all source files. ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC) @@ -336,14 +323,6 @@ endif endif endif -# Program the device. -ifeq ($(FLASH_TOOL),OPENOCD) -# Program the device with Dominic Rath's OPENOCD in "batch-mode", needs cfg and "reset-script". -program: $(OUTDIR)/$(TARGET).bin - @echo ${quote}Programming with OPENOCD${quote} - $(OOCD_EXE) $(OOCD_CL) -endif - # Link: create ELF output file from object files. $(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ))) @@ -375,6 +354,9 @@ $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin $(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) +# Add jtag targets (program and wipe) +$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(FW_BANK_BASE),$(FW_BANK_SIZE))) + .PHONY: elf lss sym hex bin bino opf elf: $(OUTDIR)/$(TARGET).elf lss: $(OUTDIR)/$(TARGET).lss @@ -439,4 +421,4 @@ else endif # Listing of phony targets. -.PHONY : all build clean clean_list program install +.PHONY : all build clean clean_list install diff --git a/flight/Bootloaders/AHRS/Makefile b/flight/Bootloaders/AHRS/Makefile index 1df91a1ab..41518fe7d 100644 --- a/flight/Bootloaders/AHRS/Makefile +++ b/flight/Bootloaders/AHRS/Makefile @@ -291,20 +291,8 @@ LDFLAGS += -lc -lgcc LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_memory.ld LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_BL_sections.ld -OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).bin -# Program -OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(BL_BANK_BASE) bin" -# Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(BL_BANK_BASE) bin" -# reset target -OOCD_CL+=-c "reset run" -# terminate OOCD after programming -OOCD_CL+=-c shutdown - # Define programs and commands. REMOVE = $(REMOVE_CMD) -f -###SHELL = sh -###COPY = cp # List of all source files. ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC) @@ -336,14 +324,6 @@ endif endif endif -# Program the device. -ifeq ($(FLASH_TOOL),OPENOCD) -# Program the device with Dominic Rath's OPENOCD in "batch-mode", needs cfg and "reset-script". -program: $(OUTDIR)/$(TARGET).bin - @echo "Programming with OPENOCD" - $(OOCD_EXE) $(OOCD_CL) -endif - # Link: create ELF output file from object files. $(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ))) @@ -373,6 +353,9 @@ $(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin +# Add jtag targets (program and wipe) +$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BL_BANK_BASE),$(BL_BANK_SIZE))) + .PHONY: elf lss sym hex bin bino elf: $(OUTDIR)/$(TARGET).elf lss: $(OUTDIR)/$(TARGET).lss @@ -437,4 +420,4 @@ else endif # Listing of phony targets. -.PHONY : all build clean clean_list program install +.PHONY : all build clean clean_list install diff --git a/flight/Bootloaders/CopterControl/Makefile b/flight/Bootloaders/CopterControl/Makefile index 413749cca..6507c022c 100644 --- a/flight/Bootloaders/CopterControl/Makefile +++ b/flight/Bootloaders/CopterControl/Makefile @@ -343,20 +343,8 @@ LDFLAGS += -lc -lgcc LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_memory.ld LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_BL_sections.ld -OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).bin -# Program -OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(BL_BANK_BASE) bin" -# Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(BL_BANK_BASE) bin" -# reset target -OOCD_CL+=-c "reset run" -# terminate OOCD after programming -OOCD_CL+=-c shutdown - # Define programs and commands. REMOVE = $(REMOVE_CMD) -f -###SHELL = sh -###COPY = cp # List of all source files. ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC) @@ -396,14 +384,6 @@ ${OUTDIR}/InitMods.c: Makefile @echo ${quote}${foreach MOD, ${MODNAMES}, ${MOD}Initialize();}${quote} >> ${OUTDIR}/InitMods.c @echo ${quote}}${quote} >> ${OUTDIR}/InitMods.c -# Program the device. -ifeq ($(FLASH_TOOL),OPENOCD) -# Program the device with Dominic Rath's OPENOCD in "batch-mode", needs cfg and "reset-script". -program: $(OUTDIR)/$(TARGET).bin - @echo ${quote}Programming with OPENOCD${quote} - $(OOCD_EXE) $(OOCD_CL) -endif - # Link: create ELF output file from object files. $(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ))) @@ -433,6 +413,9 @@ $(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin +# Add jtag targets (program and wipe) +$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BL_BANK_BASE),$(BL_BANK_SIZE))) + .PHONY: elf lss sym hex bin bino elf: $(OUTDIR)/$(TARGET).elf lss: $(OUTDIR)/$(TARGET).lss @@ -497,4 +480,4 @@ else endif # Listing of phony targets. -.PHONY : all build clean clean_list program install +.PHONY : all build clean clean_list install diff --git a/flight/Bootloaders/OpenPilot/Makefile b/flight/Bootloaders/OpenPilot/Makefile index 1167693b3..a53479546 100644 --- a/flight/Bootloaders/OpenPilot/Makefile +++ b/flight/Bootloaders/OpenPilot/Makefile @@ -346,20 +346,8 @@ LDFLAGS += -lc -lgcc LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_memory.ld LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_BL_sections.ld -OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).bin -# Program -OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(BL_BANK_BASE) bin" -# Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(BL_BANK_BASE) bin" -# reset target -OOCD_CL+=-c "reset run" -# terminate OOCD after programming -OOCD_CL+=-c shutdown - # Define programs and commands. REMOVE = $(REMOVE_CMD) -f -###SHELL = sh -###COPY = cp # List of all source files. ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC) @@ -399,14 +387,6 @@ ${OUTDIR}/InitMods.c: Makefile @echo ${quote}${foreach MOD, ${MODNAMES}, ${MOD}Initialize();}${quote} >> ${OUTDIR}/InitMods.c @echo ${quote}}${quote} >> ${OUTDIR}/InitMods.c -# Program the device. -ifeq ($(FLASH_TOOL),OPENOCD) -# Program the device with Dominic Rath's OPENOCD in "batch-mode", needs cfg and "reset-script". -program: $(OUTDIR)/$(TARGET).bin - @echo ${quote}Programming with OPENOCD${quote} - $(OOCD_EXE) $(OOCD_CL) -endif - # Link: create ELF output file from object files. $(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ))) @@ -436,6 +416,9 @@ $(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin +# Add jtag targets (program and wipe) +$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BL_BANK_BASE),$(BL_BANK_SIZE))) + .PHONY: elf lss sym hex bin bino elf: $(OUTDIR)/$(TARGET).elf lss: $(OUTDIR)/$(TARGET).lss @@ -500,4 +483,4 @@ else endif # Listing of phony targets. -.PHONY : all build clean clean_list program install +.PHONY : all build clean clean_list install diff --git a/flight/Bootloaders/PipXtreme/Makefile b/flight/Bootloaders/PipXtreme/Makefile index c91713cd9..faf30bc37 100644 --- a/flight/Bootloaders/PipXtreme/Makefile +++ b/flight/Bootloaders/PipXtreme/Makefile @@ -342,20 +342,8 @@ LDFLAGS += -lc -lgcc LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_memory.ld LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_BL_sections.ld -OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).bin -# Program -OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(BL_BANK_BASE) bin" -# Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(BL_BANK_BASE) bin" -# reset target -OOCD_CL+=-c "reset run" -# terminate OOCD after programming -OOCD_CL+=-c shutdown - # Define programs and commands. REMOVE = $(REMOVE_CMD) -f -###SHELL = sh -###COPY = cp # List of all source files. ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC) @@ -395,14 +383,6 @@ ${OUTDIR}/InitMods.c: Makefile @echo ${quote}${foreach MOD, ${MODNAMES}, ${MOD}Initialize();}${quote} >> ${OUTDIR}/InitMods.c @echo ${quote}}${quote} >> ${OUTDIR}/InitMods.c -# Program the device. -ifeq ($(FLASH_TOOL),OPENOCD) -# Program the device with Dominic Rath's OPENOCD in "batch-mode", needs cfg and "reset-script". -program: $(OUTDIR)/$(TARGET).bin - @echo ${quote}Programming with OPENOCD${quote} - $(OOCD_EXE) $(OOCD_CL) -endif - # Link: create ELF output file from object files. $(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ))) @@ -432,6 +412,9 @@ $(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin +# Add jtag targets (program and wipe) +$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BL_BANK_BASE),$(BL_BANK_SIZE))) + .PHONY: elf lss sym hex bin bino elf: $(OUTDIR)/$(TARGET).elf lss: $(OUTDIR)/$(TARGET).lss @@ -496,4 +479,4 @@ else endif # Listing of phony targets. -.PHONY : all build clean clean_list program install +.PHONY : all build clean clean_list install diff --git a/flight/CopterControl/Makefile b/flight/CopterControl/Makefile index 942bc45a9..f6c3c6158 100644 --- a/flight/CopterControl/Makefile +++ b/flight/CopterControl/Makefile @@ -466,21 +466,9 @@ LDFLAGS += -lc -lgcc LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_memory.ld LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_sections.ld -OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).bin -# Program -OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(FW_BANK_BASE) bin" -# Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(FW_BANK_BASE) bin" -# reset target -OOCD_CL+=-c "reset run" -# terminate OOCD after programming -OOCD_CL+=-c shutdown - # Define programs and commands. REMOVE = $(REMOVE_CMD) -f PYTHON = python -###SHELL = sh -###COPY = cp # List of all source files. ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC) @@ -531,13 +519,6 @@ ${OUTDIR}/InitMods.c: Makefile # @$(PYTHON) $(PYMITETOOLS)/pmGenPmFeatures.py $(PYMITEPLAT)/pmfeatures.py > $(OUTDIR)/pmfeatures.h # @$(PYTHON) $(PYMITETOOLS)/pmImgCreator.py -f $(PYMITEPLAT)/pmfeatures.py -c -u -o $(OUTDIR)/pmlibusr_img.c --native-file=$(OUTDIR)/pmlibusr_nat.c $(FLIGHTPLANS)/test.py -ifeq ($(FLASH_TOOL),OPENOCD) -# Program the device with Dominic Rath's OPENOCD in "batch-mode", needs cfg and "reset-script". -program: $(OUTDIR)/$(TARGET).bin - @echo ${quote}Programming with OPENOCD${quote} - $(OOCD_EXE) $(OOCD_CL) -endif - # Link: create ELF output file from object files. $(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ))) @@ -569,6 +550,9 @@ $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin $(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) +# Add jtag targets (program and wipe) +$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(FW_BANK_BASE),$(FW_BANK_SIZE))) + .PHONY: elf lss sym hex bin bino opf elf: $(OUTDIR)/$(TARGET).elf lss: $(OUTDIR)/$(TARGET).lss @@ -636,4 +620,4 @@ else endif # Listing of phony targets. -.PHONY : all build clean clean_list program gencode install +.PHONY : all build clean clean_list gencode install diff --git a/flight/INS/Makefile b/flight/INS/Makefile index 1af2a912a..5691f6a7d 100644 --- a/flight/INS/Makefile +++ b/flight/INS/Makefile @@ -298,20 +298,8 @@ LDFLAGS += -lc -lgcc LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_memory.ld LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_sections.ld -OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).elf -# Program -OOCD_CL+=-c "flash write_image $(OOCD_LOADFILE)" -# Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE)" -# reset target -OOCD_CL+=-c "reset run" -# # terminate OOCD after programming -OOCD_CL+=-c shutdown - # Define programs and commands. REMOVE = $(REMOVE_CMD) -f -###SHELL = sh -###COPY = cp # List of all source files. ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC) @@ -343,14 +331,6 @@ endif endif endif -# Program the device. -ifeq ($(FLASH_TOOL),OPENOCD) -# Program the device with Dominic Rath's OPENOCD in "batch-mode", needs cfg and "reset-script". -program: $(OUTDIR)/$(TARGET).bin - @echo ${quote}Programming with OPENOCD${quote} - $(OOCD_EXE) $(OOCD_CL) -endif - # Link: create ELF output file from object files. $(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ))) @@ -382,6 +362,9 @@ $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin $(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) +# Add jtag targets (program and wipe) +$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(FW_BANK_BASE),$(FW_BANK_SIZE))) + .PHONY: elf lss sym hex bin bino opf elf: $(OUTDIR)/$(TARGET).elf lss: $(OUTDIR)/$(TARGET).lss @@ -445,4 +428,4 @@ else endif # Listing of phony targets. -.PHONY : all build clean clean_list program install +.PHONY : all build clean clean_list install diff --git a/flight/OpenPilot/Makefile b/flight/OpenPilot/Makefile index c14a4381c..91149ae57 100644 --- a/flight/OpenPilot/Makefile +++ b/flight/OpenPilot/Makefile @@ -442,22 +442,9 @@ LDFLAGS += -lc -lgcc LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_memory.ld LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_sections.ld -OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).bin -# Program -OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(FW_BANK_BASE) bin" -# Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(FW_BANK_BASE) bin" -# reset target -OOCD_CL+=-c "reset run" -# terminate OOCD after programming -OOCD_CL+=-c shutdown - - # Define programs and commands. REMOVE = $(REMOVE_CMD) -f PYTHON = python -###SHELL = sh -###COPY = cp # List of all source files. ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC) @@ -510,14 +497,6 @@ ${OUTDIR}/pmlib_img.c ${OUTDIR}/pmlib_nat.c ${OUTDIR}/pmlibusr_img.c ${OUTDIR}/p @$(PYTHON) $(PYMITETOOLS)/pmGenPmFeatures.py $(PYMITEPLAT)/pmfeatures.py > $(OUTDIR)/pmfeatures.h @$(PYTHON) $(PYMITETOOLS)/pmImgCreator.py -f $(PYMITEPLAT)/pmfeatures.py -c -u -o $(OUTDIR)/pmlibusr_img.c --native-file=$(OUTDIR)/pmlibusr_nat.c $(FLIGHTPLANS)/test.py -# Program the device. -ifeq ($(FLASH_TOOL),OPENOCD) -# Program the device with Dominic Rath's OPENOCD in "batch-mode", needs cfg and "reset-script". -program: $(OUTDIR)/$(TARGET).bin - @echo ${quote}Programming with OPENOCD${quote} - $(OOCD_EXE) $(OOCD_CL) -endif - # Link: create ELF output file from object files. $(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ))) @@ -549,6 +528,9 @@ $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin $(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) +# Add jtag targets (program and wipe) +$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(FW_BANK_BASE),$(FW_BANK_SIZE))) + .PHONY: elf lss sym hex bin bino opf elf: $(OUTDIR)/$(TARGET).elf lss: $(OUTDIR)/$(TARGET).lss @@ -616,4 +598,4 @@ else endif # Listing of phony targets. -.PHONY : all build clean clean_list program gencode install +.PHONY : all build clean clean_list gencode install diff --git a/flight/PipXtreme/Makefile b/flight/PipXtreme/Makefile index 57dbfb8f0..1e9f3c48c 100644 --- a/flight/PipXtreme/Makefile +++ b/flight/PipXtreme/Makefile @@ -329,20 +329,8 @@ LDFLAGS += -lc -lgcc LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_memory.ld LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_sections.ld -OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).bin -# Program -OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(FW_BANK_BASE) bin" -# Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(FW_BANK_BASE) bin" -# reset target -OOCD_CL+=-c "reset run" -# terminate OOCD after programming -OOCD_CL+=-c shutdown - # Define programs and commands. REMOVE = $(REMOVE_CMD) -f -###SHELL = sh -###COPY = cp # List of all source files. ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC) @@ -374,14 +362,6 @@ endif endif endif -# Program the device. -ifeq ($(FLASH_TOOL),OPENOCD) -# Program the device with Dominic Rath's OPENOCD in "batch-mode", needs cfg and "reset-script". -program: $(OUTDIR)/$(TARGET).bin - @echo ${quote}Programming with OPENOCD${quote} - $(OOCD_EXE) $(OOCD_CL) -endif - # Link: create ELF output file from object files. $(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ))) @@ -413,6 +393,9 @@ $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin $(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) +# Add jtag targets (program and wipe) +$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(FW_BANK_BASE),$(FW_BANK_SIZE))) + .PHONY: elf lss sym hex bin bino opf elf: $(OUTDIR)/$(TARGET).elf lss: $(OUTDIR)/$(TARGET).lss @@ -478,4 +461,4 @@ else endif # Listing of phony targets. -.PHONY : all build clean clean_list program install +.PHONY : all build clean clean_list install diff --git a/make/firmware-defs.mk b/make/firmware-defs.mk index 9680edb16..64a553f29 100644 --- a/make/firmware-defs.mk +++ b/make/firmware-defs.mk @@ -47,6 +47,8 @@ MSG_PYMITEINIT := ${quote} PY ${quote} MSG_INSTALLING := ${quote} INSTALL ${quote} MSG_OPFIRMWARE := ${quote} OPF ${quote} MSG_FWINFO := ${quote} FWINFO ${quote} +MSG_JTAG_PROGRAM := ${quote} JTAG-PGM ${quote} +MSG_JTAG_WIPE := ${quote} JTAG-WIPE ${quote} toprel = $(subst $(realpath $(TOP))/,,$(abspath $(1))) @@ -96,6 +98,9 @@ gccversion : $(V1) $(NM) -n $< > $@ define SIZE_TEMPLATE +.PHONY: size +size: $(1)_size + .PHONY: $(1)_size $(1)_size: $(1) @echo $(MSG_SIZE) $$(call toprel, $$<) @@ -191,21 +196,48 @@ $($(1):.c=.s) : %.s : %.c $(V1) $(CC) -S $$(CFLAGS) $$(CONLYFLAGS) $$< -o $$@ endef +# $(1) = Name of binary image to write +# $(2) = Base of flash region to write/wipe +# $(3) = Size of flash region to write/wipe +define JTAG_TEMPLATE # --------------------------------------------------------------------------- # Options for OpenOCD flash-programming # see openocd.pdf/openocd.texi for further information # if OpenOCD is in the $PATH just set OPENOCDEXE=openocd -OOCD_EXE=openocd +OOCD_EXE ?= openocd + # debug level -OOCD_CL=-d0 +OOCD_JTAG_SETUP = -d0 # interface and board/target settings (using the OOCD target-library here) -OOCD_CL+=-s $(TOP)/flight/Project/OpenOCD -OOCD_CL+=-f foss-jtag.revb.cfg -f stm32.cfg +OOCD_JTAG_SETUP += -s $(TOP)/flight/Project/OpenOCD +OOCD_JTAG_SETUP += -f foss-jtag.revb.cfg -f stm32.cfg # initialize -OOCD_CL+=-c init +OOCD_BOARD_RESET = -c init # show the targets -OOCD_CL+=-c targets +#OOCD_BOARD_RESET += -c targets # commands to prepare flash-write -OOCD_CL+= -c "reset halt" +OOCD_BOARD_RESET += -c "reset halt" + +.PHONY: program +program: $(1) + @echo $(MSG_JTAG_PROGRAM) $$(call toprel, $$<) + $(V1) $(OOCD_EXE) \ + $$(OOCD_JTAG_SETUP) \ + $$(OOCD_BOARD_RESET) \ + -c "flash write_image erase $$< $(2) bin" \ + -c "verify_image $$< $(2) bin" \ + -c "reset run" \ + -c "shutdown" + +.PHONY: wipe +wipe: + @echo $(MSG_JTAG_WIPE) wiping $(3) bytes starting from $(2) + $(V1) $(OOCD_EXE) \ + $$(OOCD_JTAG_SETUP) \ + $$(OOCD_BOARD_RESET) \ + -c "flash erase_address pad $(2) $(3)" \ + -c "reset run" \ + -c "shutdown" +endef \ No newline at end of file From 91cb2947304fd71bf9fbf9911e8b5f249d96b19a Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Tue, 24 May 2011 00:23:21 -0400 Subject: [PATCH 11/18] build: remove redundant PHONY for size target --- flight/AHRS/Makefile | 2 -- flight/Bootloaders/AHRS/Makefile | 2 -- flight/Bootloaders/CopterControl/Makefile | 2 -- flight/Bootloaders/OpenPilot/Makefile | 2 -- flight/Bootloaders/PipXtreme/Makefile | 2 -- flight/CopterControl/Makefile | 2 -- flight/INS/Makefile | 2 -- flight/OpenPilot/Makefile | 2 -- flight/PipXtreme/Makefile | 2 -- 9 files changed, 18 deletions(-) diff --git a/flight/AHRS/Makefile b/flight/AHRS/Makefile index 2c9f409b5..640634615 100644 --- a/flight/AHRS/Makefile +++ b/flight/AHRS/Makefile @@ -368,8 +368,6 @@ opf: $(OUTDIR)/$(TARGET).opf # Display sizes of sections. $(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) -.PHONY: size -size: $(OUTDIR)/$(TARGET).elf_size # Generate Doxygen documents docs: diff --git a/flight/Bootloaders/AHRS/Makefile b/flight/Bootloaders/AHRS/Makefile index 41518fe7d..18bf8a269 100644 --- a/flight/Bootloaders/AHRS/Makefile +++ b/flight/Bootloaders/AHRS/Makefile @@ -366,8 +366,6 @@ bino: $(OUTDIR)/$(TARGET).bin.o # Display sizes of sections. $(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) -.PHONY: size -size: $(OUTDIR)/$(TARGET).elf_size # Generate Doxygen documents docs: diff --git a/flight/Bootloaders/CopterControl/Makefile b/flight/Bootloaders/CopterControl/Makefile index 6507c022c..4fc2f0f08 100644 --- a/flight/Bootloaders/CopterControl/Makefile +++ b/flight/Bootloaders/CopterControl/Makefile @@ -426,8 +426,6 @@ bino: $(OUTDIR)/$(TARGET).bin.o # Display sizes of sections. $(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) -.PHONY: size -size: $(OUTDIR)/$(TARGET).elf_size # Generate Doxygen documents docs: diff --git a/flight/Bootloaders/OpenPilot/Makefile b/flight/Bootloaders/OpenPilot/Makefile index a53479546..e4285f7e0 100644 --- a/flight/Bootloaders/OpenPilot/Makefile +++ b/flight/Bootloaders/OpenPilot/Makefile @@ -429,8 +429,6 @@ bino: $(OUTDIR)/$(TARGET).bin.o # Display sizes of sections. $(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) -.PHONY: size -size: $(OUTDIR)/$(TARGET).elf_size # Generate Doxygen documents docs: diff --git a/flight/Bootloaders/PipXtreme/Makefile b/flight/Bootloaders/PipXtreme/Makefile index faf30bc37..e3e7b45a7 100644 --- a/flight/Bootloaders/PipXtreme/Makefile +++ b/flight/Bootloaders/PipXtreme/Makefile @@ -425,8 +425,6 @@ bino: $(OUTDIR)/$(TARGET).bin.o # Display sizes of sections. $(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) -.PHONY: size -size: $(OUTDIR)/$(TARGET).elf_size # Generate Doxygen documents docs: diff --git a/flight/CopterControl/Makefile b/flight/CopterControl/Makefile index f6c3c6158..2541e1cc0 100644 --- a/flight/CopterControl/Makefile +++ b/flight/CopterControl/Makefile @@ -564,8 +564,6 @@ opf: $(OUTDIR)/$(TARGET).opf # Display sizes of sections. $(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) -.PHONY: size -size: $(OUTDIR)/$(TARGET).elf_size # Generate Doxygen documents docs: diff --git a/flight/INS/Makefile b/flight/INS/Makefile index 5691f6a7d..e8c0e50ff 100644 --- a/flight/INS/Makefile +++ b/flight/INS/Makefile @@ -376,8 +376,6 @@ opf: $(OUTDIR)/$(TARGET).opf # Display sizes of sections. $(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) -.PHONY: size -size: $(OUTDIR)/$(TARGET).elf_size # Generate Doxygen documents docs: diff --git a/flight/OpenPilot/Makefile b/flight/OpenPilot/Makefile index 91149ae57..0fd6e4342 100644 --- a/flight/OpenPilot/Makefile +++ b/flight/OpenPilot/Makefile @@ -542,8 +542,6 @@ opf: $(OUTDIR)/$(TARGET).opf # Display sizes of sections. $(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) -.PHONY: size -size: $(OUTDIR)/$(TARGET).elf_size # Generate Doxygen documents docs: diff --git a/flight/PipXtreme/Makefile b/flight/PipXtreme/Makefile index 1e9f3c48c..121c5c378 100644 --- a/flight/PipXtreme/Makefile +++ b/flight/PipXtreme/Makefile @@ -407,8 +407,6 @@ opf: $(OUTDIR)/$(TARGET).opf # Display sizes of sections. $(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) -.PHONY: size -size: $(OUTDIR)/$(TARGET).elf_size # Generate Doxygen documents docs: From 8bd08e381a373f23581bcdcb75608db5f45943aa Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Tue, 24 May 2011 00:25:34 -0400 Subject: [PATCH 12/18] build: add support for EE bank on pipx boards The pipxtreme boards use a sector of the on-board flash for configuration storage. Adjust the memory maps to reflect this. The board_info_blob is also extended to include the EE bank definitions. This should be used by the pipxtreme firmware rather than determining it based on chip size. --- flight/Bootloaders/PipXtreme/Makefile | 2 ++ flight/PiOS/Common/pios_board_info.c | 4 ++++ flight/PiOS/STM32F10x/link_STM32103CB_PIPXTREME_memory.ld | 3 ++- flight/PiOS/inc/pios_board_info.h | 2 ++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/flight/Bootloaders/PipXtreme/Makefile b/flight/Bootloaders/PipXtreme/Makefile index e3e7b45a7..dbf537bab 100644 --- a/flight/Bootloaders/PipXtreme/Makefile +++ b/flight/Bootloaders/PipXtreme/Makefile @@ -259,6 +259,8 @@ BLONLY_CDEFS += -DBOOTLOADER_VERSION=$(BOOTLOADER_VERSION) BLONLY_CDEFS += -DFW_BANK_BASE=$(FW_BANK_BASE) BLONLY_CDEFS += -DFW_BANK_SIZE=$(FW_BANK_SIZE) BLONLY_CDEFS += -DFW_DESC_SIZE=$(FW_DESC_SIZE) +BLONLY_CDEFS += -DEE_BANK_BASE=$(EE_BANK_BASE) +BLONLY_CDEFS += -DEE_BANK_SIZE=$(EE_BANK_SIZE) # Place project-specific -D and/or -U options for # Assembler with preprocessor here. diff --git a/flight/PiOS/Common/pios_board_info.c b/flight/PiOS/Common/pios_board_info.c index f94ac1f96..8905a5c08 100644 --- a/flight/PiOS/Common/pios_board_info.c +++ b/flight/PiOS/Common/pios_board_info.c @@ -13,4 +13,8 @@ const struct pios_board_info __attribute__((__used__)) __attribute__((__section_ .fw_size = FW_BANK_SIZE - FW_DESC_SIZE, .desc_base = FW_BANK_BASE + FW_BANK_SIZE - FW_DESC_SIZE, .desc_size = FW_DESC_SIZE, +#ifdef EE_BANK_BASE + .ee_base = EE_BANK_BASE, + .ee_size = EE_BANK_SIZE, +#endif }; diff --git a/flight/PiOS/STM32F10x/link_STM32103CB_PIPXTREME_memory.ld b/flight/PiOS/STM32F10x/link_STM32103CB_PIPXTREME_memory.ld index fd36c31ba..04aa69ccb 100644 --- a/flight/PiOS/STM32F10x/link_STM32103CB_PIPXTREME_memory.ld +++ b/flight/PiOS/STM32F10x/link_STM32103CB_PIPXTREME_memory.ld @@ -2,6 +2,7 @@ MEMORY { BL_FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 0x03000 - 0x00080 BD_INFO (r) : ORIGIN = 0x08003000 - 0x80, LENGTH = 0x00080 - FLASH (rx) : ORIGIN = 0x08003000, LENGTH = 0x20000 - 0x03000 + FLASH (rx) : ORIGIN = 0x08003000, LENGTH = 0x20000 - 0x03000 - 0x00400 + EE_FLASH (rw) : ORIGIN = 0x0801FC00, LENGTH = 0x00400 SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x05000 } diff --git a/flight/PiOS/inc/pios_board_info.h b/flight/PiOS/inc/pios_board_info.h index 579a3ec2b..f2ff58fb4 100644 --- a/flight/PiOS/inc/pios_board_info.h +++ b/flight/PiOS/inc/pios_board_info.h @@ -10,6 +10,8 @@ struct pios_board_info { uint32_t fw_size; uint32_t desc_base; uint32_t desc_size; + uint32_t ee_base; + uint32_t ee_size; } __attribute__((packed)); extern const struct pios_board_info pios_board_info_blob; From c240a927ab74f992a34460712bc00b14d9ef3000 Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Tue, 24 May 2011 23:47:03 -0400 Subject: [PATCH 13/18] build: fixup ins board-info.mk file to match new format --- make/boards/ins/board-info.mk | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/make/boards/ins/board-info.mk b/make/boards/ins/board-info.mk index fa98aaeba..8a57661bf 100644 --- a/make/boards/ins/board-info.mk +++ b/make/boards/ins/board-info.mk @@ -9,5 +9,10 @@ BOARD := STM3210E_INS MODEL := HD MODEL_SUFFIX := _OP -START_OF_BL_CODE := 0x08000000 -START_OF_FW_CODE := 0x08002000 +# Note: These must match the values in link_$(BOARD)_memory.ld +BL_BANK_BASE := 0x08000000 # Start of bootloader flash +BL_BANK_SIZE := 0x00002000 # Should include BD_INFO region +FW_BANK_BASE := 0x08002000 # Start of firmware flash +FW_BANK_SIZE := 0x0001E000 # Should include FW_DESC_SIZE + +FW_DESC_SIZE := 0x00000064 From 66804076b8af4406b87ed0accfe0a250d5dd106f Mon Sep 17 00:00:00 2001 From: Oleg Semyonov Date: Wed, 25 May 2011 00:44:45 +0300 Subject: [PATCH 14/18] build: fix release/Makefile for *.opf files and changed targets --- flight/AHRS/Makefile | 4 +-- flight/Bootloaders/BootloaderUpdater/Makefile | 4 +-- flight/CopterControl/Makefile | 4 +-- flight/INS/Makefile | 4 +-- flight/OpenPilot/Makefile | 4 +-- flight/PipXtreme/Makefile | 4 +-- release/Makefile | 35 ++++++++++--------- 7 files changed, 30 insertions(+), 29 deletions(-) diff --git a/flight/AHRS/Makefile b/flight/AHRS/Makefile index 640634615..6c0e09f01 100644 --- a/flight/AHRS/Makefile +++ b/flight/AHRS/Makefile @@ -374,11 +374,11 @@ docs: doxygen $(DOXYGENDIR)/doxygen.cfg # Install: install binary file with prefix/suffix into install directory -install: $(OUTDIR)/$(TARGET).bin +install: $(OUTDIR)/$(TARGET).opf ifneq ($(INSTALL_DIR),) @echo $(MSG_INSTALLING) $(call toprel, $<) $(V1) mkdir -p $(INSTALL_DIR) - $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).bin + $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).opf else $(error INSTALL_DIR must be specified for $@) endif diff --git a/flight/Bootloaders/BootloaderUpdater/Makefile b/flight/Bootloaders/BootloaderUpdater/Makefile index 1488bec8e..7969a7ebe 100644 --- a/flight/Bootloaders/BootloaderUpdater/Makefile +++ b/flight/Bootloaders/BootloaderUpdater/Makefile @@ -405,11 +405,11 @@ docs: doxygen $(DOXYGENDIR)/doxygen.cfg # Install: install binary file with prefix/suffix into install directory -install: $(OUTDIR)/$(TARGET).bin +install: $(OUTDIR)/$(TARGET).opf ifneq ($(INSTALL_DIR),) @echo $(MSG_INSTALLING) $(call toprel, $<) $(V1) mkdir -p $(INSTALL_DIR) - $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).bin + $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).opf else $(error INSTALL_DIR must be specified for $@) endif diff --git a/flight/CopterControl/Makefile b/flight/CopterControl/Makefile index 2541e1cc0..33b0f8034 100644 --- a/flight/CopterControl/Makefile +++ b/flight/CopterControl/Makefile @@ -570,11 +570,11 @@ docs: doxygen $(DOXYGENDIR)/doxygen.cfg # Install: install binary file with prefix/suffix into install directory -install: $(OUTDIR)/$(TARGET).bin +install: $(OUTDIR)/$(TARGET).opf ifneq ($(INSTALL_DIR),) @echo $(MSG_INSTALLING) $(call toprel, $<) $(V1) mkdir -p $(INSTALL_DIR) - $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).bin + $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).opf else $(error INSTALL_DIR must be specified for $@) endif diff --git a/flight/INS/Makefile b/flight/INS/Makefile index e8c0e50ff..c5168158f 100644 --- a/flight/INS/Makefile +++ b/flight/INS/Makefile @@ -382,11 +382,11 @@ docs: doxygen $(DOXYGENDIR)/doxygen.cfg # Install: install binary file with prefix/suffix into install directory -install: $(OUTDIR)/$(TARGET).bin +install: $(OUTDIR)/$(TARGET).opf ifneq ($(INSTALL_DIR),) @echo $(MSG_INSTALLING) $(call toprel, $<) $(V1) mkdir -p $(INSTALL_DIR) - $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).bin + $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).opf else $(error INSTALL_DIR must be specified for $@) endif diff --git a/flight/OpenPilot/Makefile b/flight/OpenPilot/Makefile index 0fd6e4342..91c83cb10 100644 --- a/flight/OpenPilot/Makefile +++ b/flight/OpenPilot/Makefile @@ -548,11 +548,11 @@ docs: doxygen $(DOXYGENDIR)/doxygen.cfg # Install: install binary file with prefix/suffix into install directory -install: $(OUTDIR)/$(TARGET).bin +install: $(OUTDIR)/$(TARGET).opf ifneq ($(INSTALL_DIR),) @echo $(MSG_INSTALLING) $(call toprel, $<) $(V1) mkdir -p $(INSTALL_DIR) - $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).bin + $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).opf else $(error INSTALL_DIR must be specified for $@) endif diff --git a/flight/PipXtreme/Makefile b/flight/PipXtreme/Makefile index 121c5c378..c1c3ed4ce 100644 --- a/flight/PipXtreme/Makefile +++ b/flight/PipXtreme/Makefile @@ -413,11 +413,11 @@ docs: doxygen $(DOXYGENDIR)/doxygen.cfg # Install: install binary file with prefix/suffix into install directory -install: $(OUTDIR)/$(TARGET).bin +install: $(OUTDIR)/$(TARGET).opf ifneq ($(INSTALL_DIR),) @echo $(MSG_INSTALLING) $(call toprel, $<) $(V1) mkdir -p $(INSTALL_DIR) - $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).bin + $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).opf else $(error INSTALL_DIR must be specified for $@) endif diff --git a/release/Makefile b/release/Makefile index a6a68fd93..645a67758 100644 --- a/release/Makefile +++ b/release/Makefile @@ -18,7 +18,8 @@ RELEASE_LBL := $(shell $(VERSION_CMD) --format=\$${DATE}-\$${TAG_OR_HASH8}\$${D RELEASE_DIR := $(BUILD_DIR)/release-$(RELEASE_LBL) FW_DIR := $(RELEASE_DIR)/firmware-$(RELEASE_LBL) BL_DIR := $(FW_DIR)/bootloaders -BU_DIR := $(FW_DIR)/bootloader_updaters +BU_DIR := $(FW_DIR)/bootloader-updaters +FE_DIR := $(FW_DIR)/flash-erase-tools # Clean build options (recommended for package testing only) ifeq ($(CLEAN_BUILD), NO) @@ -32,13 +33,16 @@ CLEAN_GROUND := YES CLEAN_FLIGHT := YES endif -# Setup targets -FW_TARGETS_COMMON := ahrs pipxtreme -FW_TARGETS_INPUT := coptercontrol openpilot -FW_TARGETS_TOOLS := coptercontrol -FW_TARGETS := $(FW_TARGETS_COMMON) $(FW_TARGETS_INPUT) -BL_TARGETS := $(addprefix bl_, $(FW_TARGETS)) -BU_TARGETS := $(addprefix bu_, $(FW_TARGETS)) +# Set up targets +FW_STEMS_COMMON := ahrs pipxtreme +FW_STEMS_INPUT := coptercontrol openpilot +FW_STEMS_TOOLS := coptercontrol +FW_STEMS_ALL := $(FW_STEMS_COMMON) $(FW_STEMS_INPUT) +FW_TARGETS_COMMON := $(addprefix fw_, $(FW_STEMS_COMMON)) +FW_TARGETS_INPUT := $(addprefix fw_, $(FW_STEMS_INPUT)) +FW_TARGETS_TOOLS := $(addprefix fw_, $(FW_STEMS_TOOLS)) +BL_TARGETS := $(addprefix bl_, $(FW_STEMS_ALL)) +BU_TARGETS := $(addprefix bu_, $(FW_STEMS_ALL)) help: @echo @@ -102,17 +106,14 @@ $(eval $(call INSTALL_TEMPLATE,fw_pwm,uavobjects,$(FW_DIR),,-pwm-$(RELEASE_LBL), $(eval $(call INSTALL_TEMPLATE,fw_spektrum,uavobjects,$(FW_DIR),,-spektrum-$(RELEASE_LBL),USE_SPEKTRUM=YES,clean,$(FW_TARGETS_INPUT),install)) $(eval $(call INSTALL_TEMPLATE,fw_ppm,uavobjects,$(FW_DIR),,-ppm-$(RELEASE_LBL),USE_PPM=YES,clean,$(FW_TARGETS_INPUT),install)) -# Bootloaders (change 'bin' to 'install' to install bootloaders too) -$(eval $(call INSTALL_TEMPLATE,all_bl,uavobjects,$(BL_DIR),,-$(RELEASE_LBL),,,$(BL_TARGETS),bin)) +# Bootloaders (change 'install' to 'bin' if you don't want to install bootloaders) +$(eval $(call INSTALL_TEMPLATE,all_bl,uavobjects,$(BL_DIR),,-$(RELEASE_LBL),,,$(BL_TARGETS),install)) -# Bootloader Updaters -$(eval $(call INSTALL_TEMPLATE,bu_coptercontrol,all_bl,$(BU_DIR),CopterControl_,-$(RELEASE_LBL),,,bu_coptercontrol,install)) -$(eval $(call INSTALL_TEMPLATE,bu_ahrs,all_bl,$(BU_DIR),AHRS_,-$(RELEASE_LBL),,,bu_ahrs,install)) -$(eval $(call INSTALL_TEMPLATE,bu_openpilot,all_bl,$(BU_DIR),OpenPilot_,-$(RELEASE_LBL),,,bu_openpilot,install)) -$(eval $(call INSTALL_TEMPLATE,bu_pipxtreme,all_bl,$(BU_DIR),PipXtreme_,-$(RELEASE_LBL),,,bu_pipxtreme,install)) +# Bootloader updaters +$(eval $(call INSTALL_TEMPLATE,all_bu,all_bl,$(BU_DIR),,-$(RELEASE_LBL),,,$(BU_TARGETS),install)) # CopterControl flash eraser tool -$(eval $(call INSTALL_TEMPLATE,fw_tools,uavobjects,$(BU_DIR),,-FlashEraser-$(RELEASE_LBL),ERASE_FLASH=YES,clean,$(FW_TARGETS_TOOLS),install)) +$(eval $(call INSTALL_TEMPLATE,fw_tools,uavobjects,$(FE_DIR),,-flash-erase-$(RELEASE_LBL),ERASE_FLASH=YES,clean,$(FW_TARGETS_TOOLS),install)) # Order-only dependencies # They are bit complicated to support parallel (-j) builds and to create @@ -128,7 +129,7 @@ fw_tools: | fw_spektrum # ordered build, replace fw_spektrum by fw_ppm if uncomm release_fw: | fw_common fw_pwm fw_spektrum # fw_ppm -release_bu: | $(BU_TARGETS) +release_bu: | all_bu release_flight: | release_fw release_bu fw_tools From 4da671fc824a087eabc33c0dac3585fa81ebe08e Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Wed, 25 May 2011 00:20:02 -0400 Subject: [PATCH 15/18] build: change firmware files from .opf to .opfw extensions --- Makefile | 10 +++++----- flight/AHRS/Makefile | 10 +++++----- flight/Bootloaders/BootloaderUpdater/Makefile | 10 +++++----- flight/CopterControl/Makefile | 10 +++++----- flight/INS/Makefile | 10 +++++----- flight/OpenPilot/Makefile | 10 +++++----- flight/PipXtreme/Makefile | 10 +++++----- make/firmware-defs.mk | 6 +++--- 8 files changed, 38 insertions(+), 38 deletions(-) diff --git a/Makefile b/Makefile index db7ed054d..79c9cf292 100644 --- a/Makefile +++ b/Makefile @@ -320,8 +320,8 @@ uavobjects_clean: # $(2) = Name of board used in source tree (e.g. CopterControl) define FW_TEMPLATE .PHONY: $(1) fw_$(1) -$(1): fw_$(1)_opf -fw_$(1): fw_$(1)_opf +$(1): fw_$(1)_opfw +fw_$(1): fw_$(1)_opfw fw_$(1)_%: uavobjects_flight $(V1) mkdir -p $(BUILD_DIR)/fw_$(1)/dep @@ -364,7 +364,7 @@ endef # $(1) = Canonical board name all in lower case (e.g. coptercontrol) define BU_TEMPLATE .PHONY: bu_$(1) -bu_$(1): bu_$(1)_opf +bu_$(1): bu_$(1)_opfw bu_$(1)_%: bl_$(1)_bino $(V1) mkdir -p $(BUILD_DIR)/bu_$(1)/dep @@ -413,7 +413,7 @@ BL_TARGETS := $(filter-out bl_ins, $(BL_TARGETS)) BU_TARGETS := $(filter-out bu_ins, $(BU_TARGETS)) .PHONY: all_fw all_fw_clean -all_fw: $(addsuffix _opf, $(FW_TARGETS)) +all_fw: $(addsuffix _opfw, $(FW_TARGETS)) all_fw_clean: $(addsuffix _clean, $(FW_TARGETS)) .PHONY: all_bl all_bl_clean @@ -421,7 +421,7 @@ all_bl: $(addsuffix _bin, $(BL_TARGETS)) all_bl_clean: $(addsuffix _clean, $(BL_TARGETS)) .PHONY: all_bu all_bu_clean -all_bu: $(addsuffix _opf, $(BU_TARGETS)) +all_bu: $(addsuffix _opfw, $(BU_TARGETS)) all_bu_clean: $(addsuffix _clean, $(BU_TARGETS)) .PHONY: all_flight all_flight_clean diff --git a/flight/AHRS/Makefile b/flight/AHRS/Makefile index 6c0e09f01..46405ca6c 100644 --- a/flight/AHRS/Makefile +++ b/flight/AHRS/Makefile @@ -352,19 +352,19 @@ $(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin -$(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) +$(eval $(call OPFW_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) # Add jtag targets (program and wipe) $(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(FW_BANK_BASE),$(FW_BANK_SIZE))) -.PHONY: elf lss sym hex bin bino opf +.PHONY: elf lss sym hex bin bino opfw elf: $(OUTDIR)/$(TARGET).elf lss: $(OUTDIR)/$(TARGET).lss sym: $(OUTDIR)/$(TARGET).sym hex: $(OUTDIR)/$(TARGET).hex bin: $(OUTDIR)/$(TARGET).bin bino: $(OUTDIR)/$(TARGET).bin.o -opf: $(OUTDIR)/$(TARGET).opf +opfw: $(OUTDIR)/$(TARGET).opfw # Display sizes of sections. $(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) @@ -374,11 +374,11 @@ docs: doxygen $(DOXYGENDIR)/doxygen.cfg # Install: install binary file with prefix/suffix into install directory -install: $(OUTDIR)/$(TARGET).opf +install: $(OUTDIR)/$(TARGET).opfw ifneq ($(INSTALL_DIR),) @echo $(MSG_INSTALLING) $(call toprel, $<) $(V1) mkdir -p $(INSTALL_DIR) - $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).opf + $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).opfw else $(error INSTALL_DIR must be specified for $@) endif diff --git a/flight/Bootloaders/BootloaderUpdater/Makefile b/flight/Bootloaders/BootloaderUpdater/Makefile index 7969a7ebe..81aa163ec 100644 --- a/flight/Bootloaders/BootloaderUpdater/Makefile +++ b/flight/Bootloaders/BootloaderUpdater/Makefile @@ -384,16 +384,16 @@ $(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin -$(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) +$(eval $(call OPFW_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) -.PHONY: elf lss sym hex bin bino opf +.PHONY: elf lss sym hex bin bino opfw elf: $(OUTDIR)/$(TARGET).elf lss: $(OUTDIR)/$(TARGET).lss sym: $(OUTDIR)/$(TARGET).sym hex: $(OUTDIR)/$(TARGET).hex bin: $(OUTDIR)/$(TARGET).bin bino: $(OUTDIR)/$(TARGET).bin.o -opf: $(OUTDIR)/$(TARGET).opf +opfw: $(OUTDIR)/$(TARGET).opfw # Display sizes of sections. $(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) @@ -405,11 +405,11 @@ docs: doxygen $(DOXYGENDIR)/doxygen.cfg # Install: install binary file with prefix/suffix into install directory -install: $(OUTDIR)/$(TARGET).opf +install: $(OUTDIR)/$(TARGET).opfw ifneq ($(INSTALL_DIR),) @echo $(MSG_INSTALLING) $(call toprel, $<) $(V1) mkdir -p $(INSTALL_DIR) - $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).opf + $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).opfw else $(error INSTALL_DIR must be specified for $@) endif diff --git a/flight/CopterControl/Makefile b/flight/CopterControl/Makefile index 33b0f8034..2467968cb 100644 --- a/flight/CopterControl/Makefile +++ b/flight/CopterControl/Makefile @@ -548,19 +548,19 @@ $(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin -$(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) +$(eval $(call OPFW_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) # Add jtag targets (program and wipe) $(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(FW_BANK_BASE),$(FW_BANK_SIZE))) -.PHONY: elf lss sym hex bin bino opf +.PHONY: elf lss sym hex bin bino opfw elf: $(OUTDIR)/$(TARGET).elf lss: $(OUTDIR)/$(TARGET).lss sym: $(OUTDIR)/$(TARGET).sym hex: $(OUTDIR)/$(TARGET).hex bin: $(OUTDIR)/$(TARGET).bin bino: $(OUTDIR)/$(TARGET).bin.o -opf: $(OUTDIR)/$(TARGET).opf +opfw: $(OUTDIR)/$(TARGET).opfw # Display sizes of sections. $(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) @@ -570,11 +570,11 @@ docs: doxygen $(DOXYGENDIR)/doxygen.cfg # Install: install binary file with prefix/suffix into install directory -install: $(OUTDIR)/$(TARGET).opf +install: $(OUTDIR)/$(TARGET).opfw ifneq ($(INSTALL_DIR),) @echo $(MSG_INSTALLING) $(call toprel, $<) $(V1) mkdir -p $(INSTALL_DIR) - $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).opf + $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).opfw else $(error INSTALL_DIR must be specified for $@) endif diff --git a/flight/INS/Makefile b/flight/INS/Makefile index c5168158f..bd3bb52a9 100644 --- a/flight/INS/Makefile +++ b/flight/INS/Makefile @@ -360,19 +360,19 @@ $(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin -$(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) +$(eval $(call OPFW_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) # Add jtag targets (program and wipe) $(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(FW_BANK_BASE),$(FW_BANK_SIZE))) -.PHONY: elf lss sym hex bin bino opf +.PHONY: elf lss sym hex bin bino opfw elf: $(OUTDIR)/$(TARGET).elf lss: $(OUTDIR)/$(TARGET).lss sym: $(OUTDIR)/$(TARGET).sym hex: $(OUTDIR)/$(TARGET).hex bin: $(OUTDIR)/$(TARGET).bin bino: $(OUTDIR)/$(TARGET).bin.o -opf: $(OUTDIR)/$(TARGET).opf +opfw: $(OUTDIR)/$(TARGET).opfw # Display sizes of sections. $(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) @@ -382,11 +382,11 @@ docs: doxygen $(DOXYGENDIR)/doxygen.cfg # Install: install binary file with prefix/suffix into install directory -install: $(OUTDIR)/$(TARGET).opf +install: $(OUTDIR)/$(TARGET).opfw ifneq ($(INSTALL_DIR),) @echo $(MSG_INSTALLING) $(call toprel, $<) $(V1) mkdir -p $(INSTALL_DIR) - $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).opf + $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).opfw else $(error INSTALL_DIR must be specified for $@) endif diff --git a/flight/OpenPilot/Makefile b/flight/OpenPilot/Makefile index 91c83cb10..a2a8e667b 100644 --- a/flight/OpenPilot/Makefile +++ b/flight/OpenPilot/Makefile @@ -526,19 +526,19 @@ $(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin -$(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) +$(eval $(call OPFW_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) # Add jtag targets (program and wipe) $(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(FW_BANK_BASE),$(FW_BANK_SIZE))) -.PHONY: elf lss sym hex bin bino opf +.PHONY: elf lss sym hex bin bino opfw elf: $(OUTDIR)/$(TARGET).elf lss: $(OUTDIR)/$(TARGET).lss sym: $(OUTDIR)/$(TARGET).sym hex: $(OUTDIR)/$(TARGET).hex bin: $(OUTDIR)/$(TARGET).bin bino: $(OUTDIR)/$(TARGET).bin.o -opf: $(OUTDIR)/$(TARGET).opf +opfw: $(OUTDIR)/$(TARGET).opfw # Display sizes of sections. $(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) @@ -548,11 +548,11 @@ docs: doxygen $(DOXYGENDIR)/doxygen.cfg # Install: install binary file with prefix/suffix into install directory -install: $(OUTDIR)/$(TARGET).opf +install: $(OUTDIR)/$(TARGET).opfw ifneq ($(INSTALL_DIR),) @echo $(MSG_INSTALLING) $(call toprel, $<) $(V1) mkdir -p $(INSTALL_DIR) - $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).opf + $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).opfw else $(error INSTALL_DIR must be specified for $@) endif diff --git a/flight/PipXtreme/Makefile b/flight/PipXtreme/Makefile index c1c3ed4ce..9a70ac417 100644 --- a/flight/PipXtreme/Makefile +++ b/flight/PipXtreme/Makefile @@ -391,19 +391,19 @@ $(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin -$(eval $(call OPF_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) +$(eval $(call OPFW_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) # Add jtag targets (program and wipe) $(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(FW_BANK_BASE),$(FW_BANK_SIZE))) -.PHONY: elf lss sym hex bin bino opf +.PHONY: elf lss sym hex bin bino opfw elf: $(OUTDIR)/$(TARGET).elf lss: $(OUTDIR)/$(TARGET).lss sym: $(OUTDIR)/$(TARGET).sym hex: $(OUTDIR)/$(TARGET).hex bin: $(OUTDIR)/$(TARGET).bin bino: $(OUTDIR)/$(TARGET).bin.o -opf: $(OUTDIR)/$(TARGET).opf +opfw: $(OUTDIR)/$(TARGET).opfw # Display sizes of sections. $(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) @@ -413,11 +413,11 @@ docs: doxygen $(DOXYGENDIR)/doxygen.cfg # Install: install binary file with prefix/suffix into install directory -install: $(OUTDIR)/$(TARGET).opf +install: $(OUTDIR)/$(TARGET).opfw ifneq ($(INSTALL_DIR),) @echo $(MSG_INSTALLING) $(call toprel, $<) $(V1) mkdir -p $(INSTALL_DIR) - $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).opf + $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).opfw else $(error INSTALL_DIR must be specified for $@) endif diff --git a/make/firmware-defs.mk b/make/firmware-defs.mk index 64a553f29..7616594d5 100644 --- a/make/firmware-defs.mk +++ b/make/firmware-defs.mk @@ -45,7 +45,7 @@ MSG_ASMFROMC := ${quote} AS(C) ${quote} MSG_ASMFROMC_ARM := ${quote} AS(C)-ARM ${quote} MSG_PYMITEINIT := ${quote} PY ${quote} MSG_INSTALLING := ${quote} INSTALL ${quote} -MSG_OPFIRMWARE := ${quote} OPF ${quote} +MSG_OPFIRMWARE := ${quote} OPFW ${quote} MSG_FWINFO := ${quote} FWINFO ${quote} MSG_JTAG_PROGRAM := ${quote} JTAG-PGM ${quote} MSG_JTAG_WIPE := ${quote} JTAG-WIPE ${quote} @@ -111,7 +111,7 @@ endef # $(1) = path to bin file # $(2) = boardtype in hex # $(3) = board revision in hex -define OPF_TEMPLATE +define OPFW_TEMPLATE $(1).firmwareinfo.c: $(1) $(TOP)/make/templates/firmwareinfotemplate.c @echo $(MSG_FWINFO) $$(call toprel, $$@) $(V1) python $(TOP)/make/scripts/version-info.py \ @@ -124,7 +124,7 @@ $(1).firmwareinfo.c: $(1) $(TOP)/make/templates/firmwareinfotemplate.c $(eval $(call COMPILE_C_TEMPLATE, $(1).firmwareinfo.c)) -$(OUTDIR)/$(notdir $(basename $(1))).opf : $(1) $(1).firmwareinfo.bin +$(OUTDIR)/$(notdir $(basename $(1))).opfw : $(1) $(1).firmwareinfo.bin @echo $(MSG_OPFIRMWARE) $$(call toprel, $$@) $(V1) cat $(1) $(1).firmwareinfo.bin > $$@ endef From 986121d28131b9daf1b551f27f15de6483958e03 Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Wed, 25 May 2011 00:27:16 -0400 Subject: [PATCH 16/18] build: force firmwareinfo.c/bin to be regenerated on every build --- make/firmware-defs.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/make/firmware-defs.mk b/make/firmware-defs.mk index 7616594d5..901a6c454 100644 --- a/make/firmware-defs.mk +++ b/make/firmware-defs.mk @@ -112,7 +112,9 @@ endef # $(2) = boardtype in hex # $(3) = board revision in hex define OPFW_TEMPLATE -$(1).firmwareinfo.c: $(1) $(TOP)/make/templates/firmwareinfotemplate.c +FORCE: + +$(1).firmwareinfo.c: $(1) $(TOP)/make/templates/firmwareinfotemplate.c FORCE @echo $(MSG_FWINFO) $$(call toprel, $$@) $(V1) python $(TOP)/make/scripts/version-info.py \ --path=$(TOP) \ From 75d4f19d300363a38c52eb55c31e6d4002366d03 Mon Sep 17 00:00:00 2001 From: Oleg Semyonov Date: Wed, 25 May 2011 10:59:35 +0300 Subject: [PATCH 17/18] build: add FWTAG variable to the version-info.py --- make/scripts/version-info.py | 8 ++++++++ make/templates/firmwareinfotemplate.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/make/scripts/version-info.py b/make/scripts/version-info.py index 5e9fa5916..740836574 100644 --- a/make/scripts/version-info.py +++ b/make/scripts/version-info.py @@ -235,6 +235,13 @@ def sha1(file): hex_stream = lambda s:",".join(['0x'+hex(ord(c))[2:].zfill(2) for c in s]) return hex_stream(sha1.digest()) +def xtrim(string, length): + """Trim string up to length bytes, adding '+' if truncated""" + if len(string) <= length: + return string + else: + return string[:length-1] + '+' + def main(): """This utility uses git repository in the current working directory or from the given path to extract some info about it and HEAD commit. @@ -306,6 +313,7 @@ dependent targets. TAG_OR_BRANCH = r.tag(r.branch('unreleased')), TAG_OR_HASH8 = r.tag(r.hash(8, 'untagged')), DIRTY = r.dirty(), + FWTAG = xtrim(r.tag(r.branch('unreleased')) + r.dirty(), 25), UNIXTIME = r.time(), DATE = r.time('%Y%m%d'), DATETIME = r.time('%Y%m%d %H:%M'), diff --git a/make/templates/firmwareinfotemplate.c b/make/templates/firmwareinfotemplate.c index 3f3829cc6..b9297273e 100644 --- a/make/templates/firmwareinfotemplate.c +++ b/make/templates/firmwareinfotemplate.c @@ -62,7 +62,7 @@ const struct fw_version_info fw_version_blob __attribute__((used)) __attribute__ .timestamp = ${UNIXTIME}, .board_type = ${BOARD_TYPE}, .board_revision = ${BOARD_REVISION}, - .commit_tag_name = "${TAG_OR_BRANCH}${DIRTY}", + .commit_tag_name = "${FWTAG}", .sha1sum = { ${SHA1} }, }; From 41b03c92ee00e553c8cefe5747ed8545ff2f91f8 Mon Sep 17 00:00:00 2001 From: Oleg Semyonov Date: Thu, 26 May 2011 12:19:48 +0300 Subject: [PATCH 18/18] build: change FWTAG replacement to keep suffix intact and trim branch/tag only --- make/scripts/version-info.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/make/scripts/version-info.py b/make/scripts/version-info.py index 740836574..8c4fe901e 100644 --- a/make/scripts/version-info.py +++ b/make/scripts/version-info.py @@ -235,12 +235,20 @@ def sha1(file): hex_stream = lambda s:",".join(['0x'+hex(ord(c))[2:].zfill(2) for c in s]) return hex_stream(sha1.digest()) -def xtrim(string, length): - """Trim string up to length bytes, adding '+' if truncated""" - if len(string) <= length: - return string +def xtrim(string, suffix, length): + """Return string+suffix concatenated and trimmed up to length characters + + This function appends suffix to the end of string and returns the result + up to length characters. If it does not fit then the string will be + truncated and the '+' will be put between it and the suffix. + """ + + if len(string) + len(suffix) <= length: + return ''.join([string, suffix]) else: - return string[:length-1] + '+' + n = length-1-len(suffix) + assert n > 0, "length of truncated string+suffix exceeds maximum length" + return ''.join([string[:n], '+', suffix]) def main(): """This utility uses git repository in the current working directory @@ -313,7 +321,7 @@ dependent targets. TAG_OR_BRANCH = r.tag(r.branch('unreleased')), TAG_OR_HASH8 = r.tag(r.hash(8, 'untagged')), DIRTY = r.dirty(), - FWTAG = xtrim(r.tag(r.branch('unreleased')) + r.dirty(), 25), + FWTAG = xtrim(r.tag(r.branch('unreleased')), r.dirty(), 25), UNIXTIME = r.time(), DATE = r.time('%Y%m%d'), DATETIME = r.time('%Y%m%d %H:%M'),