From cbcf1262d6e4d410255c668263f6f978e7122a5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Th=C3=A9baudeau?= Date: Tue, 17 Nov 2015 23:28:38 +0100 Subject: [PATCH] cc2538: upload: Support .bin not starting at beginning of flash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Depending on the linker script, the generated .bin file may start beyond the beginning of the flash memory. However, no target address was passed to cc2538-bsl.py by the upload make target, so it used the beginning of the flash memory in all cases. The load address of the lowest loadable output section is now passed to cc2538-bsl.py. The start address of the .text output section or the address of the _text symbol could have been used too, but this would not have been compatible with all the possible custom linker scripts. Signed-off-by: Benoît Thébaudeau --- platform/cc2538dk/Makefile.cc2538dk | 4 ++-- platform/remote/Makefile.remote | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/cc2538dk/Makefile.cc2538dk b/platform/cc2538dk/Makefile.cc2538dk index 5c3fd77ec..f962a0fa7 100644 --- a/platform/cc2538dk/Makefile.cc2538dk +++ b/platform/cc2538dk/Makefile.cc2538dk @@ -30,9 +30,9 @@ MODULES += core/net core/net/mac \ BSL = $(CONTIKI)/tools/cc2538-bsl/cc2538-bsl.py -%.upload: %.bin +%.upload: %.bin %.elf ifeq ($(wildcard $(BSL)), ) @echo "ERROR: Could not find the cc2538-bsl script. Did you run 'git submodule update --init' ?" else - python $(BSL) -e -w -v $< + python $(BSL) -e -w -v -a $$($(OBJDUMP) -h $*.elf | sed -n '/\/{g;1!p;};h' | awk '{print "0x" $$5}' | sort -g | head -1) $< endif diff --git a/platform/remote/Makefile.remote b/platform/remote/Makefile.remote index a9acc1dbc..3d351bfdd 100644 --- a/platform/remote/Makefile.remote +++ b/platform/remote/Makefile.remote @@ -38,9 +38,9 @@ MODULES += core/net core/net/mac \ BSL = $(CONTIKI)/tools/cc2538-bsl/cc2538-bsl.py -%.upload: %.bin +%.upload: %.bin %.elf ifeq ($(wildcard $(BSL)), ) @echo "ERROR: Could not find the cc2538-bsl script. Did you run 'git submodule update --init' ?" else - $(PYTHON) $(BSL) $(BSL_FLAGS) $< + $(PYTHON) $(BSL) $(BSL_FLAGS) -a $$($(OBJDUMP) -h $*.elf | sed -n '/\/{g;1!p;};h' | awk '{print "0x" $$5}' | sort -g | head -1) $< endif