From 0801495ce18020ed0f83b996e6edcd9a735d5139 Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Tue, 7 Jun 2011 22:42:59 -0400 Subject: [PATCH 1/4] build: fix spacing on label for clean targets Whitespace only, no functional changes. --- Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 6b0601ebb..ae295d34d 100644 --- a/Makefile +++ b/Makefile @@ -277,7 +277,7 @@ openpilotgcs: uavobjects_gcs .PHONY: openpilotgcs_clean openpilotgcs_clean: - $(V0) @echo " CLEAN $@" + $(V0) @echo " CLEAN $@" $(V1) [ ! -d "$(BUILD_DIR)/ground/openpilotgcs" ] || $(RM) -r "$(BUILD_DIR)/ground/openpilotgcs" .PHONY: uavobjgenerator @@ -307,7 +307,7 @@ uavobjects_test: $(UAVOBJ_OUT_DIR) uavobjgenerator $(V1) $(UAVOBJGENERATOR) -v -none $(UAVOBJ_XML_DIR) $(ROOT_DIR) uavobjects_clean: - $(V0) @echo " CLEAN $@" + $(V0) @echo " CLEAN $@" $(V1) [ ! -d "$(UAVOBJ_OUT_DIR)" ] || $(RM) -r "$(UAVOBJ_OUT_DIR)" ############################## @@ -335,7 +335,7 @@ fw_$(1)_%: uavobjects_flight .PHONY: $(1)_clean $(1)_clean: fw_$(1)_clean fw_$(1)_clean: - $(V0) @echo " CLEAN $$@" + $(V0) @echo " CLEAN $$@" $(V1) $(RM) -fr $(BUILD_DIR)/fw_$(1) endef @@ -357,7 +357,7 @@ bl_$(1)_%: .PHONY: bl_$(1)_clean bl_$(1)_clean: - $(V0) @echo " CLEAN $$@" + $(V0) @echo " CLEAN $$@" $(V1) $(RM) -fr $(BUILD_DIR)/bl_$(1) endef @@ -377,7 +377,7 @@ bu_$(1)_%: bl_$(1)_bino .PHONY: bu_$(1)_clean bu_$(1)_clean: - $(V0) @echo " CLEAN $$@" + $(V0) @echo " CLEAN $$@" $(V1) $(RM) -fr $(BUILD_DIR)/bu_$(1) endef From 6313a78dc90639a9fd039f77de35bb26daa573a8 Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Tue, 7 Jun 2011 22:47:07 -0400 Subject: [PATCH 2/4] build: make lists of boards with fw, bl and bu Provide unique lists of boards for each type of build (fw, bl, bu) so we can refer to them in the help text. --- Makefile | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index ae295d34d..e4ea0cdfe 100644 --- a/Makefile +++ b/Makefile @@ -92,19 +92,19 @@ help: @echo " - Build firmware for " @echo " supported boards are ($(ALL_BOARDS))" @echo " fw_ - Build firmware for " - @echo " supported boards are ($(FW_TARGETS))" + @echo " supported boards are ($(FW_BOARDS))" @echo " fw__clean - Remove firmware for " @echo " fw__program - Use OpenOCD + JTAG to write firmware to " @echo @echo " [Bootloader]" @echo " bl_ - Build bootloader for " - @echo " supported boards are ($(BL_TARGETS))" + @echo " supported boards are ($(BL_BOARDS))" @echo " bl__clean - Remove bootloader for " @echo " bl__program - Use OpenOCD + JTAG to write bootloader to " @echo @echo " [Bootloader Updater]" @echo " bu_ - Build bootloader updater for " - @echo " supported boards are ($(BU_TARGETS))" + @echo " supported boards are ($(BU_BOARDS))" @echo " bu__clean - Remove bootloader updater for " @echo @echo " [Simulation]" @@ -403,14 +403,20 @@ 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)) +# Start out assuming that we'll build fw, bl and bu for all boards +FW_BOARDS := $(ALL_BOARDS) +BL_BOARDS := $(ALL_BOARDS) +BU_BOARDS := $(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)) -BU_TARGETS := $(filter-out bu_ins, $(BU_TARGETS)) +BL_BOARDS := $(filter-out ins, $(ALL_BOARDS)) +BU_BOARDS := $(filter-out ins, $(ALL_BOARDS)) + +# Generate the targets for whatever boards are left in each list +FW_TARGETS := $(addprefix fw_, $(FW_BOARDS)) +BL_TARGETS := $(addprefix bl_, $(BL_BOARDS)) +BU_TARGETS := $(addprefix bu_, $(BU_BOARDS)) .PHONY: all_fw all_fw_clean all_fw: $(addsuffix _opfw, $(FW_TARGETS)) @@ -428,6 +434,7 @@ 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 +# Expand the groups of targets for each board $(foreach board, $(ALL_BOARDS), $(eval $(call BOARD_PHONY_TEMPLATE,$(board)))) # Expand the bootloader updater rules From 81dbd3f4c024223ba7f66baff668ca0a908d05aa Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Tue, 7 Jun 2011 22:48:46 -0400 Subject: [PATCH 3/4] build: add install rule for stm32flash utility This tool can be used as a last resort for installing a bootloader to a completely bricked board that is unresponsive to even the rescue functionality in the GCS uploader gadget. --- Makefile | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Makefile b/Makefile index e4ea0cdfe..a14cc19de 100644 --- a/Makefile +++ b/Makefile @@ -71,6 +71,7 @@ help: @echo " qt_sdk_install - Install the QT v4.6.2 tools" @echo " arm_sdk_install - Install the Code Sourcery ARM gcc toolchain" @echo " openocd_install - Install the OpenOCD JTAG daemon" + @echo " stm32flash_install - Install the stm32flash tool for unbricking boards" @echo @echo " [Big Hammer]" @echo " all - Generate UAVObjects, build openpilot firmware and gcs" @@ -226,6 +227,25 @@ openocd_install: openocd_clean openocd_clean: $(V1) [ ! -d "$(OPENOCD_DIR)" ] || $(RM) -r "$(OPENOCD_DIR)" +STM32FLASH_DIR := $(TOOLS_DIR)/stm32flash + +.PHONY: stm32flash_install +stm32flash_install: STM32FLASH_URL := http://stm32flash.googlecode.com/svn/trunk +stm32flash_install: STM32FLASH_REV := 52 +stm32flash_install: stm32flash_clean + # download the source + $(V0) @echo " DOWNLOAD $(STM32FLASH_URL) @ r$(STM32FLASH_REV)" + $(V1) svn export -q -r "$(STM32FLASH_REV)" "$(STM32FLASH_URL)" "$(STM32FLASH_DIR)" + + # build + $(V0) @echo " BUILD $(STM32FLASH_DIR)" + $(V1) $(MAKE) --silent -C $(STM32FLASH_DIR) all + +.PHONY: stm32flash_clean +stm32flash_clean: + $(V0) @echo " CLEAN $(STM32FLASH_DIR)" + $(V1) [ ! -d "$(STM32FLASH_DIR)" ] || $(RM) -r "$(STM32FLASH_DIR)" + ############################## # # Set up paths to tools From 8c4c73496bd8213e0cf010f16ddddc85ec1abd4f Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Tue, 7 Jun 2011 22:53:08 -0400 Subject: [PATCH 4/4] build: add unbrick targets Added new unbrick_ targets for each board. These targets use the stm32flash utility to install a bootloader on to the board. This is a tool of last resort and should not be used for normal firmware upgrades. Usage: make unbrick_ UNBRICK_TTY=/dev/ttyUSB0 Where: is one of coptercontrol, pipxtreme, openpilot, ins, ahrs UNBRICK_TTY is set to the serial device connected to the board. --- Makefile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Makefile b/Makefile index a14cc19de..60c918cd4 100644 --- a/Makefile +++ b/Makefile @@ -108,6 +108,10 @@ help: @echo " supported boards are ($(BU_BOARDS))" @echo " bu__clean - Remove bootloader updater for " @echo + @echo " [Unbrick a board]" + @echo " unbrick_ - Use the STM32's built in boot ROM to write a bootloader to " + @echo " supported boards are ($(BL_BOARDS))" + @echo @echo " [Simulation]" @echo " sim_posix - Build OpenPilot simulation firmware for" @echo " a POSIX compatible system (Linux, Mac OS X, ...)" @@ -375,6 +379,20 @@ bl_$(1)_%: REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" \ $$* +.PHONY: unbrick_$(1) +unbrick_$(1): bl_$(1)_hex +$(if $(filter-out undefined,$(origin UNBRICK_TTY)), + $(V0) @echo " UNBRICK $(1) via $$(UNBRICK_TTY)" + $(V1) $(STM32FLASH_DIR)/stm32flash \ + -w $(BUILD_DIR)/bl_$(1)/bl_$(1).hex \ + -g 0x0 \ + $$(UNBRICK_TTY) +, + $(V0) @echo + $(V0) @echo "ERROR: You must specify UNBRICK_TTY= to use for unbricking." + $(V0) @echo " eg. $$(MAKE) $$@ UNBRICK_TTY=/dev/ttyUSB0" +) + .PHONY: bl_$(1)_clean bl_$(1)_clean: $(V0) @echo " CLEAN $$@"