1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-20 14:55:21 +03:00

Fix EXST hex generation (#8698)

Fix EXST hex generation
This commit is contained in:
Michael Keller 2019-08-10 16:29:46 +12:00 committed by GitHub
commit 5103e0972d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 12 deletions

View file

@ -343,16 +343,26 @@ $(TARGET_BIN): $(TARGET_UNPATCHED_BIN)
$(V1) cat $(TARGET_UNPATCHED_BIN).md5 | awk '{printf("%08x: %s",(1024*$(FIRMWARE_SIZE))-16,$$2);}' | xxd -r - $(TARGET_BIN)
$(V1) echo $(FIRMWARE_SIZE) | awk '{printf("-s 0x%08x -l 16 -c 16 %s",(1024*$$1)-16,"$(TARGET_BIN)");}' | xargs xxd
@echo "Patching MD5 hash into exst elf" "$(STDOUT)"
$(OBJCOPY) $(TARGET_ELF) --dump-section .exst_hash=$(TARGET_EXST_HASH_SECTION_FILE)
# Note: From the objcopy manual "If you do not specify outfile, objcopy creates a temporary file and destructively renames the result with the name of infile"
# Due to this a temporary file must be created and removed, even though we're only extracting data from the input file.
# If this temporary file is NOT used the $(TARGET_ELF) is modified, and running make a second time will result in
# a) regeneration of $(TARGET_BIN), and
# b) the results of $(TARGET_BIN) will not be as expected.
@echo "Extracting HASH section from unpatched EXST elf $(TARGET_ELF)" "$(STDOUT)"
$(OBJCOPY) $(TARGET_ELF) $(TARGET_EXST_ELF).tmp --dump-section .exst_hash=$(TARGET_EXST_HASH_SECTION_FILE)
rm $(TARGET_EXST_ELF).tmp
@echo "Patching MD5 hash into HASH section" "$(STDOUT)"
$(V1) cat $(TARGET_UNPATCHED_BIN).md5 | awk '{printf("%08x: %s",64-16,$$2);}' | xxd -r - $(TARGET_EXST_HASH_SECTION_FILE)
@echo "Patching updated HASH section into $(TARGET_EXST_ELF)" "$(STDOUT)"
$(OBJCOPY) $(TARGET_ELF) $(TARGET_EXST_ELF) --update-section .exst_hash=$(TARGET_EXST_HASH_SECTION_FILE)
$(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) --gap-fill=0x00 --pad-to=$(shell echo "$(FIRMWARE_SIZE)" | awk '{printf("0x%08x", (1024*$$1) + $(EXST_ADJUST_VMA));}') $(TARGET_EXST_ELF) $@
@echo "Creating EXST HEX from patched EXST BIN $(TARGET_BIN), VMA Adjust $(EXST_ADJUST_VMA)" "$(STDOUT)"
$(V1) $(OBJCOPY) -I binary -O ihex --adjust-vma=$(EXST_ADJUST_VMA) $(TARGET_BIN) $@
endif

View file

@ -35,7 +35,8 @@ ENTRY(Reset_Handler)
For H7 EXST (External Storage) targets a binary is built that is placed on an external device.
The bootloader will then copy this entire binary to RAM, at the CODE_RAM address. The bootloader
then executes code at the CODE_RAM address.
then executes code at the CODE_RAM address. The address of CODE_RAM is fixed to 0x24010000
and must not be changed.
Currently, this is inefficient as there are two copies of some sections in RAM. e.g. .tcm_code.
@ -59,7 +60,7 @@ MEMORY
ITCM_RAM (rwx) : ORIGIN = 0x00000000, LENGTH = 64K
DTCM_RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 128K
RAM (rwx) : ORIGIN = 0x24000000, LENGTH = 64K
CODE_RAM (rx) : ORIGIN = 0x24010000, LENGTH = 448K - _exst_hash_size
CODE_RAM (rx) : ORIGIN = 0x24010000, LENGTH = 448K - _exst_hash_size /* hard coded start address, as required by SPRACINGH7 boot loader, don't change! */
EXST_HASH (rx) : ORIGIN = 0x24010000 + LENGTH(CODE_RAM), LENGTH = _exst_hash_size
D2_RAM (rwx) : ORIGIN = 0x30000000, LENGTH = 256K /* SRAM1 + SRAM2 */

View file

@ -5,8 +5,7 @@ HSE_VALUE = 8000000
FEATURES += VCP ONBOARDFLASH SDCARD_SDIO
EXST = yes
# flash address 0x97CE0000 - code_ram address (0x24010000) = 0x73CD0000
EXST_ADJUST_VMA = 0x73CD0000
EXST_ADJUST_VMA = 0x97CE0000
TARGET_SRC += \

View file

@ -3,8 +3,7 @@ H750xB_TARGETS += $(TARGET)
HSE_VALUE = 8000000
EXST = yes
# flash address 0x97CE0000 - code_ram address (0x24010000) = 0x73CD0000
EXST_ADJUST_VMA = 0x73CD0000
EXST_ADJUST_VMA = 0x97CE0000
FEATURES += VCP ONBOARDFLASH

View file

@ -3,8 +3,7 @@ H750xB_TARGETS += $(TARGET)
HSE_VALUE = 8000000
EXST = yes
# flash address 0x97CE0000 - code_ram address (0x24010000) = 0x73CD0000
EXST_ADJUST_VMA = 0x73CD0000
EXST_ADJUST_VMA = 0x97CE0000
FEATURES += VCP ONBOARDFLASH SDCARD_SDIO