From 871486527b3b02947b9dde7d5fe39d7592825127 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Wed, 7 Aug 2019 15:22:34 +0200 Subject: [PATCH 1/2] EXST - Allow targets to specify VMA offset. The hex file must have the correct address in order for it to be uploaded via flashing tools (configurator). However, the objcopy tool only appears to support an INCREMENT address, so the increment is determined by subtracting the load address from the flash address. For the current SPRacing H7 boards, the bootloader DFU descriptor string has a start address of 0x9000000 for the external flash, the firmware partition begins at offset 0x07CE0000, required resulting flash address is 0x97CE0000. --- Makefile | 6 ++++-- src/main/target/SPRACINGH7EXTREME/target.mk | 3 +++ src/main/target/SPRACINGH7NANO/target.mk | 2 ++ src/main/target/SPRACINGH7ZERO/target.mk | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index daf4aaf65e..0c6212e381 100644 --- a/Makefile +++ b/Makefile @@ -349,8 +349,10 @@ $(TARGET_BIN): $(TARGET_UNPATCHED_BIN) $(OBJCOPY) $(TARGET_ELF) $(TARGET_EXST_ELF) --update-section .exst_hash=$(TARGET_EXST_HASH_SECTION_FILE) $(TARGET_HEX): $(TARGET_BIN) - @echo "Creating EXST HEX from patched EXST ELF $(TARGET_HEX)" "$(STDOUT)" - $(V1) $(OBJCOPY) -O ihex --set-start 0x8000000 $(TARGET_EXST_ELF) $@ + $(if $(EXST_ADJUST_VMA),,$(error "EXST_ADJUST_VMA not specified")) + + @echo "Creating EXST HEX from patched EXST ELF $(TARGET_HEX), VMA Adjust $(EXST_ADJUST_VMA)" "$(STDOUT)" + $(V1) $(OBJCOPY) -O ihex --adjust-vma $(EXST_ADJUST_VMA) $(TARGET_EXST_ELF) $@ endif diff --git a/src/main/target/SPRACINGH7EXTREME/target.mk b/src/main/target/SPRACINGH7EXTREME/target.mk index 28025721b6..6530f82a36 100644 --- a/src/main/target/SPRACINGH7EXTREME/target.mk +++ b/src/main/target/SPRACINGH7EXTREME/target.mk @@ -5,6 +5,9 @@ HSE_VALUE = 8000000 FEATURES += VCP ONBOARDFLASH SDCARD_SDIO EXST = yes +# flash address 0x97CE0000 - code_ram address (0x24010000) = 0x73CD0000 +EXST_ADJUST_VMA = 0x73CD0000 + TARGET_SRC += \ drivers/bus_quadspi_hal.c \ diff --git a/src/main/target/SPRACINGH7NANO/target.mk b/src/main/target/SPRACINGH7NANO/target.mk index 3560f6f401..68a9f25b02 100644 --- a/src/main/target/SPRACINGH7NANO/target.mk +++ b/src/main/target/SPRACINGH7NANO/target.mk @@ -3,6 +3,8 @@ H750xB_TARGETS += $(TARGET) HSE_VALUE = 8000000 EXST = yes +# flash address 0x97CE0000 - code_ram address (0x24010000) = 0x73CD0000 +EXST_ADJUST_VMA = 0x73CD0000 FEATURES += VCP ONBOARDFLASH diff --git a/src/main/target/SPRACINGH7ZERO/target.mk b/src/main/target/SPRACINGH7ZERO/target.mk index 8296e1d016..5b6cb7ccb6 100644 --- a/src/main/target/SPRACINGH7ZERO/target.mk +++ b/src/main/target/SPRACINGH7ZERO/target.mk @@ -3,6 +3,8 @@ H750xB_TARGETS += $(TARGET) HSE_VALUE = 8000000 EXST = yes +# flash address 0x97CE0000 - code_ram address (0x24010000) = 0x73CD0000 +EXST_ADJUST_VMA = 0x73CD0000 FEATURES += VCP ONBOARDFLASH SDCARD_SDIO From 577d57ea7028b395f22932aaa5834ce68a44c74c Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Thu, 8 Aug 2019 01:26:34 +0200 Subject: [PATCH 2/2] EXST - Ensure HEX files are suitable for flashing using the configurator. Without the padding and length the HASH in the HEX will be invalid since erased flash defaults to 0xFF but the hash is created on the binary file which has a default of 0x00 for un-filled data. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0c6212e381..9e663fc9ad 100644 --- a/Makefile +++ b/Makefile @@ -352,7 +352,7 @@ $(TARGET_HEX): $(TARGET_BIN) $(if $(EXST_ADJUST_VMA),,$(error "EXST_ADJUST_VMA not specified")) @echo "Creating EXST HEX from patched EXST ELF $(TARGET_HEX), VMA Adjust $(EXST_ADJUST_VMA)" "$(STDOUT)" - $(V1) $(OBJCOPY) -O ihex --adjust-vma $(EXST_ADJUST_VMA) $(TARGET_EXST_ELF) $@ + $(V1) $(OBJCOPY) -O ihex --adjust-vma=$(EXST_ADJUST_VMA) --gap-fill=0x00 --pad-to=$(shell echo "$(FIRMWARE_SIZE)" | awk '{printf("0x%08x", (1024*$$1) + $(EXST_ADJUST_VMA));}') $(TARGET_EXST_ELF) $@ endif