From cd5a0ef29156e959f0124edbfe225721f85ec468 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 14 May 2016 19:16:43 +0100 Subject: [PATCH] Consolidate .upload for all CC26xx/CC13xx boards The block that controls the `.upload` target is unnecessarily replicated in multiple sub-board Makefiles. This was originally done because the SmartRF and the Launchpad can be programmed with the c2538-bsl script, whereas the sensortag cannot. This commit moves the `cc2538-bsl` / `.upload` target logic to the top level cpu Makefile (`cpu/cc26xx-cc13xx/Makefile.cc26xx-cc13xx`). Board makefiles simply set the make variable `BOARD_SUPPORTS_BSL` to 1 to signal that they can be programmed by the BSL script. If `BOARD_SUPPORTS_BSL` is not equal to 1, trying to use the `.upload` target will return an error message. For example: ``` $ make BOARD=sensortag/cc2650 cc26xx-demo.upload using saved target 'srf06-cc26xx' This board cannot be programmed with the ROM bootloader and therefore does not support the .upload target. ``` --- cpu/cc26xx-cc13xx/Makefile.cc26xx-cc13xx | 20 +++++++++++++++++++ .../srf06-cc26xx/launchpad/Makefile.launchpad | 17 ++-------------- platform/srf06-cc26xx/srf06/Makefile.srf06 | 17 ++-------------- 3 files changed, 24 insertions(+), 30 deletions(-) diff --git a/cpu/cc26xx-cc13xx/Makefile.cc26xx-cc13xx b/cpu/cc26xx-cc13xx/Makefile.cc26xx-cc13xx index f6ac275da..d0cf1cf31 100644 --- a/cpu/cc26xx-cc13xx/Makefile.cc26xx-cc13xx +++ b/cpu/cc26xx-cc13xx/Makefile.cc26xx-cc13xx @@ -81,6 +81,15 @@ CONTIKI_SOURCEFILES += $(CONTIKI_CPU_SOURCEFILES) $(DEBUG_IO_SOURCEFILES) TARGET_START_SOURCEFILES += fault-handlers.c $(TI_XXWARE_STARTUP_SRCS) TARGET_STARTFILES = $(addprefix $(OBJECTDIR)/,$(call oname, $(TARGET_START_SOURCEFILES))) +PYTHON = python +BSL_FLAGS += -e -w -v + +ifdef PORT + BSL_FLAGS += -p $(PORT) +endif + +BSL = $(CONTIKI)/tools/cc2538-bsl/cc2538-bsl.py + ### Don't treat the .elf as intermediate .PRECIOUS: %.elf %.hex %.bin @@ -125,3 +134,14 @@ STACK_SIZE = 0 @$(SIZE) -A $< | egrep "data|bss" | awk '{s+=$$2} END {s=s+$(STACK_SIZE); f=$(RAM_SIZE)-s; printf "[RAM] used %6d, free %6d\n",s,f;}' @$(SIZE) -A $< | egrep "text|isr_vector" | awk '{s+=$$2} END {f=$(FLASH_SIZE)-s; printf "[Flash] used %6d, free %6d\n",s,f;}' +ifeq ($(BOARD_SUPPORTS_BSL),1) +%.upload: %.bin +ifeq ($(wildcard $(BSL)), ) + @echo "ERROR: Could not find the cc2538-bsl script. Did you run 'git submodule update --init' ?" +else + $(PYTHON) $(BSL) $(BSL_FLAGS) $< +endif +else +%.upload: + @echo "This board cannot be programmed through the ROM bootloader and therefore does not support the .upload target." +endif diff --git a/platform/srf06-cc26xx/launchpad/Makefile.launchpad b/platform/srf06-cc26xx/launchpad/Makefile.launchpad index 853450142..54bd81ced 100644 --- a/platform/srf06-cc26xx/launchpad/Makefile.launchpad +++ b/platform/srf06-cc26xx/launchpad/Makefile.launchpad @@ -5,18 +5,5 @@ CONTIKI_TARGET_DIRS += launchpad common BOARD_SOURCEFILES += board.c launchpad-sensors.c leds-arch.c button-sensor.c BOARD_SOURCEFILES += ext-flash.c board-spi.c -PYTHON = python -BSL_FLAGS += -e -w -v - -ifdef PORT - BSL_FLAGS += -p $(PORT) -endif - -BSL = $(CONTIKI)/tools/cc2538-bsl/cc2538-bsl.py - -%.upload: %.bin -ifeq ($(wildcard $(BSL)), ) - @echo "ERROR: Could not find the cc2538-bsl script. Did you run 'git submodule update --init' ?" -else - $(PYTHON) $(BSL) $(BSL_FLAGS) $< -endif +### Signal that we can be programmed with cc2538-bsl +BOARD_SUPPORTS_BSL=1 diff --git a/platform/srf06-cc26xx/srf06/Makefile.srf06 b/platform/srf06-cc26xx/srf06/Makefile.srf06 index 3459cbadc..afdeeddec 100644 --- a/platform/srf06-cc26xx/srf06/Makefile.srf06 +++ b/platform/srf06-cc26xx/srf06/Makefile.srf06 @@ -4,18 +4,5 @@ CONTIKI_TARGET_DIRS += srf06 BOARD_SOURCEFILES += leds-arch.c srf06-sensors.c button-sensor.c board.c -PYTHON = python -BSL_FLAGS += -e -w -v - -ifdef PORT - BSL_FLAGS += -p $(PORT) -endif - -BSL = $(CONTIKI)/tools/cc2538-bsl/cc2538-bsl.py - -%.upload: %.bin -ifeq ($(wildcard $(BSL)), ) - @echo "ERROR: Could not find the cc2538-bsl script. Did you run 'git submodule update --init' ?" -else - $(PYTHON) $(BSL) $(BSL_FLAGS) $< -endif +### Signal that we can be programmed with cc2538-bsl +BOARD_SUPPORTS_BSL=1