From 2ddb586bdcef9a348adb3434c6579afb01ffe01d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Fri, 28 Jun 2019 10:46:31 +0200 Subject: [PATCH] [scripts] Remove EPSILON_USB_DFU_XIP flag: specify the right dfu sources for each target --- Makefile | 7 +++++- apps/Makefile | 2 -- ion/src/device/Makefile | 2 +- ion/src/device/shared/usb/Makefile | 18 +++++---------- quiz/Makefile | 6 +---- scripts/device/elf2dfu.py | 3 ++- scripts/targets.device.mak | 37 ++++++++++++------------------ scripts/targets.device.n0110.mak | 2 +- 8 files changed, 32 insertions(+), 45 deletions(-) diff --git a/Makefile b/Makefile index f20f9c956..4d91115ff 100644 --- a/Makefile +++ b/Makefile @@ -81,6 +81,12 @@ objs = $(call object_for,$(src)) # but allows correct yet optimal incremental builds. -include $(objs:.o=.d) +#define platform generic targets + +$(BUILD_DIR)/epsilon.$(EXE): $(objs) $(call object_for,$(ion_device_dfu_relocated_src) $(epsilon_src)) + +$(BUILD_DIR)/test.$(EXE): $(BUILD_DIR)/quiz/src/tests_symbols.o $(objs) $(call object_for,$(ion_device_dfu_relocated_src) $(tests) $(runner_src)) + # Load platform-specific targets # We include them before the standard ones to give them precedence. -include scripts/targets.$(PLATFORM).mak @@ -91,7 +97,6 @@ objs = $(call object_for,$(src)) executables = epsilon test define rules_for_executable -$$(BUILD_DIR)/$(1).$$(EXE): $$(objs) .PHONY: $(1).$$(EXE) $(1).$$(EXE): $$(BUILD_DIR)/$(1).$$(EXE) endef diff --git a/apps/Makefile b/apps/Makefile index 86f8fc472..48470645b 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -94,6 +94,4 @@ all_app_src = $(app_src) $(epsilon_src) $(call object_for,$(all_app_src)): $(BUILD_DIR)/apps/i18n.h $(call object_for,$(all_app_src)): $(BUILD_DIR)/python/port/genhdr/qstrdefs.generated.h -$(BUILD_DIR)/epsilon.$(EXE): $(call object_for,$(epsilon_src)) - src += $(app_src) diff --git a/ion/src/device/Makefile b/ion/src/device/Makefile index 583bb53f2..192a6fb8a 100644 --- a/ion/src/device/Makefile +++ b/ion/src/device/Makefile @@ -19,7 +19,7 @@ src += $(addprefix ion/src/shared/, \ ION_DEVICE_SFLAGS = -Iion/src/device/$(MODEL) -Iion/src/device/shared -$(call object_for,$(ion_device_src) $(dfu_src) $(flasher_src) $(usb_src) $(bench_src)): SFLAGS += $(ION_DEVICE_SFLAGS) +$(call object_for,$(ion_device_src) $(dfu_src) $(flasher_src) $(usb_src) $(bench_src) $(ion_device_dfu_xip_src) $(ion_device_dfu_relocated_src)): SFLAGS += $(ION_DEVICE_SFLAGS) src += $(ion_device_src) # When using the register.h C++ file in production mode, we expect the compiler diff --git a/ion/src/device/shared/usb/Makefile b/ion/src/device/shared/usb/Makefile index 419fa4380..4149116d4 100644 --- a/ion/src/device/shared/usb/Makefile +++ b/ion/src/device/shared/usb/Makefile @@ -29,15 +29,11 @@ usb_src += $(addprefix ion/src/device/shared/usb/stack/descriptor/, \ webusb_platform_descriptor.cpp\ ) -EPSILON_USB_DFU_XIP ?= 0 - -ifeq ($(EPSILON_USB_DFU_XIP),1) - -ion_device_src += ion/src/device/shared/usb/dfu_xip.cpp -ion_device_src += $(usb_src) - -else +# Sources required to execute DFU in place +ion_device_dfu_xip_src += ion/src/device/shared/usb/dfu_xip.cpp +ion_device_dfu_xip_src += $(usb_src) +# Sources required to execute DFU in RAM dfu_src += liba/src/assert.c dfu_src += liba/src/strlen.c dfu_src += liba/src/strlcpy.c @@ -86,7 +82,5 @@ $(BUILD_DIR)/ion/src/device/shared/usb/dfu.o: $(BUILD_DIR)/ion/src/device/shared @echo "OBJCOPY $@" $(Q) cd $(dir $<) ; $(OBJCOPY) -I binary -O elf32-littlearm -B arm --rename-section .data=.rodata.dfu_bootloader --redefine-sym _binary_dfu_bin_start=_dfu_bootloader_flash_start --redefine-sym _binary_dfu_bin_end=_dfu_bootloader_flash_end $(notdir $<) $(notdir $@) -ion_device_src += ion/src/device/shared/usb/dfu.cpp -ion_device_src += ion/src/device/shared/usb/dfu_relocated.cpp - -endif +ion_device_dfu_relocated_src += ion/src/device/shared/usb/dfu.cpp +ion_device_dfu_relocated_src += ion/src/device/shared/usb/dfu_relocated.cpp \ No newline at end of file diff --git a/quiz/Makefile b/quiz/Makefile index 59da3cd72..95bcac764 100644 --- a/quiz/Makefile +++ b/quiz/Makefile @@ -20,9 +20,5 @@ runner_src += $(addprefix quiz/src/, \ runner_src += $(symbols_file) -runner_objs = $(call object_for,$(runner_src)) -$(runner_objs): SFLAGS += -Iquiz/src +$(call object_for,$(runner_src)): SFLAGS += -Iquiz/src $(BUILD_DIR)/quiz/src/%_symbols.o: SFLAGS += -Iquiz/src - - -$(BUILD_DIR)/test.$(EXE): $(BUILD_DIR)/quiz/src/tests_symbols.o $(runner_objs) $(call object_for,$(tests)) diff --git a/scripts/device/elf2dfu.py b/scripts/device/elf2dfu.py index 7dfa0ac39..d9b5c6d9a 100644 --- a/scripts/device/elf2dfu.py +++ b/scripts/device/elf2dfu.py @@ -50,7 +50,8 @@ def elf2dfu(elf_file, usb_vid_pid, dfu_file, verbose): external_address_prefix = "9"; # External addresses start with 0x9 # We don't sort sections on their names (.external, .internal) but on their # addresses because some sections like dfu_entry_point can either be the - # internal or the external flash depending on build flags (ie EPSILON_USB_DFU_XIP) + # internal or the external flash depending on which targets is built (ie + # flasher executes dfu in place but epsilon executes dfu relocated in RAM) external_block = {'name': "external", 'sections': loadable_sections(elf_file, external_address_prefix)} internal_block = {'name': "internal", 'sections': [s for s in loadable_sections(elf_file) if s not in external_block['sections']]} blocks = [external_block, internal_block] diff --git a/scripts/targets.device.mak b/scripts/targets.device.mak index 6f9892bef..0fd110160 100644 --- a/scripts/targets.device.mak +++ b/scripts/targets.device.mak @@ -52,36 +52,29 @@ openocd: # The flasher target is defined here because otherwise $(objs) has not been # fully filled -ifeq ($(EPSILON_USB_DFU_XIP)$(EPSILON_DEVICE_BENCH),10) +ifeq ($(EPSILON_DEVICE_BENCH),0) $(BUILD_DIR)/flasher.%.$(EXE): LDFLAGS += -Lion/src/$(PLATFORM)/flasher $(BUILD_DIR)/flasher.%.$(EXE): LDSCRIPT = ion/src/$(PLATFORM)/shared/ram.ld -$(BUILD_DIR)/flasher.light.$(EXE): $(BUILD_DIR)/ion/src/$(PLATFORM)/flasher/display_light.o $(objs) $(call object_for,$(flasher_src)) -$(BUILD_DIR)/flasher.verbose.$(EXE): $(BUILD_DIR)/ion/src/$(PLATFORM)/flasher/display_verbose.o $(objs) $(call object_for,$(flasher_src)) +flasher_objs = $(objs) $(call object_for,$(flasher_src)) $(call object_for,$(ion_device_dfu_xip_src)) +$(BUILD_DIR)/flasher.light.$(EXE): $(BUILD_DIR)/ion/src/$(PLATFORM)/flasher/display_light.o $(flasher_objs) +$(BUILD_DIR)/flasher.verbose.$(EXE): $(BUILD_DIR)/ion/src/$(PLATFORM)/flasher/display_verbose.o $(flasher_objs) else $(BUILD_DIR)/flasher.%.$(EXE): - @echo "Error: flasher.elf requires EPSILON_DEVICE_BENCH=0 EPSILON_USB_DFU_XIP=1" + @echo "Error: flasher.elf requires EPSILON_DEVICE_BENCH=0" endif #TODO Do not build all apps... Put elsewhere? -ifeq ($(EPSILON_USB_DFU_XIP)$(EPSILON_DEVICE_BENCH),11) +ifeq ($(EPSILON_DEVICE_BENCH),1) $(BUILD_DIR)/bench.ram.$(EXE): LDFLAGS += -Lion/src/$(PLATFORM)/bench $(BUILD_DIR)/bench.ram.$(EXE): LDSCRIPT = ion/src/$(PLATFORM)/shared/ram.ld -$(BUILD_DIR)/bench.ram.$(EXE): $(objs) $(call object_for,$(bench_src)) +$(BUILD_DIR)/bench.flash.$(EXE): LDSCRIPT = ion/src/$(PLATFORM)/$(MODEL)/internal_flash.ld +$(BUILD_DIR)/bench.%.$(EXE): $(objs) $(call object_for,$(bench_src)) $(call object_for,$(ion_device_dfu_xip_src)) else $(BUILD_DIR)/bench.ram.$(EXE): - @echo "Error: bench.ram.bin requires EPSILON_DEVICE_BENCH=1 EPSILON_USB_DFU_XIP=1" + @echo "Error: bench.*.bin requires EPSILON_DEVICE_BENCH=1" endif -#TODO Do not build all apps... Put elsewhere? -ifeq ($(EPSILON_USB_DFU_XIP)$(EPSILON_DEVICE_BENCH),11) -$(BUILD_DIR)/bench.flash.$(EXE): LDSCRIPT = ion/src/$(PLATFORM)/$(MODEL)/internal_flash.ld -$(BUILD_DIR)/bench.flash.$(EXE): $(objs) $(call object_for,$(bench_src)) -else -$(BUILD_DIR)/bench.flash.$(EXE): - @echo "Error: bench.flash.bin requires EPSILON_DEVICE_BENCH=1 EPSILON_USB_DFU_XIP=1" -endif - -ifeq ($(EPSILON_USB_DFU_XIP)$(EPSILON_DEVICE_BENCH)$(EPSILON_ONBOARDING_APP)$(EPSILON_BOOT_PROMPT),001update) +ifeq ($(EPSILON_DEVICE_BENCH)$(EPSILON_ONBOARDING_APP)$(EPSILON_BOOT_PROMPT),01update) .PHONY: %_two_binaries %_two_binaries: %.elf @echo "Building an internal and an external binary for $<" @@ -92,7 +85,7 @@ ifeq ($(EPSILON_USB_DFU_XIP)$(EPSILON_DEVICE_BENCH)$(EPSILON_ONBOARDING_APP)$(EP $(Q) printf "\xFF\xFF\xFF\xFF" >> $(basename $<).internal.bin else %_two_binaries: - @echo "Error: two_binaries requires EPSILON_DEVICE_BENCH=0 EPSILON_USB_DFU_XIP=0 EPSILON_ONBOARDING_APP=1 EPSILON_BOOT_PROMPT=update" + @echo "Error: two_binaries requires EPSILON_DEVICE_BENCH=0 EPSILON_ONBOARDING_APP=1 EPSILON_BOOT_PROMPT=update" endif .PHONY: binpack @@ -100,14 +93,14 @@ binpack: rm -rf build/binpack mkdir -p build/binpack make clean - make -j8 EPSILON_USB_DFU_XIP=1 EPSILON_DEVICE_BENCH=0 $(BUILD_DIR)/flasher.light.bin + make -j8 EPSILON_DEVICE_BENCH=0 $(BUILD_DIR)/flasher.light.bin cp $(BUILD_DIR)/flasher.light.bin build/binpack make clean - make -j8 EPSILON_USB_DFU_XIP=1 EPSILON_DEVICE_BENCH=1 $(BUILD_DIR)/bench.flash.bin - make -j8 EPSILON_USB_DFU_XIP=1 EPSILON_DEVICE_BENCH=1 $(BUILD_DIR)/bench.ram.bin + make -j8 EPSILON_DEVICE_BENCH=1 $(BUILD_DIR)/bench.flash.bin + make -j8 EPSILON_DEVICE_BENCH=1 $(BUILD_DIR)/bench.ram.bin cp $(BUILD_DIR)/bench.ram.bin $(BUILD_DIR)/bench.flash.bin build/binpack make clean - make -j8 EPSILON_DEVICE_BENCH=0 EPSILON_USB_DFU_XIP=0 EPSILON_ONBOARDING_APP=1 EPSILON_BOOT_PROMPT=update $(BUILD_DIR)/epsilon_two_binaries + make -j8 EPSILON_DEVICE_BENCH=0 EPSILON_ONBOARDING_APP=1 EPSILON_BOOT_PROMPT=update $(BUILD_DIR)/epsilon_two_binaries cp $(BUILD_DIR)/epsilon.internal.bin $(BUILD_DIR)/epsilon.external.bin build/binpack make clean cd build && for binary in flasher.light.bin bench.flash.bin bench.ram.bin epsilon.internal.bin epsilon.external.bin; do shasum -a 256 -b binpack/$${binary} > binpack/$${binary}.sha256;done diff --git a/scripts/targets.device.n0110.mak b/scripts/targets.device.n0110.mak index d7b8f6500..29cb77214 100644 --- a/scripts/targets.device.n0110.mak +++ b/scripts/targets.device.n0110.mak @@ -1,2 +1,2 @@ $(BUILD_DIR)/test_external_flash.$(EXE): LDSCRIPT = ion/test/external_flash_tests.ld -$(BUILD_DIR)/test_external_flash.$(EXE): $(BUILD_DIR)/quiz/src/external_flash_tests_symbols.o $(runner_objs) $(call object_for,$(tests_external_flash)) +$(BUILD_DIR)/test_external_flash.$(EXE): $(BUILD_DIR)/quiz/src/external_flash_tests_symbols.o $(runner_objs) $(call object_for,$(tests_external_flash)) $(call object_for,$(ion_device_dfu_relocated_src))