EXST - Use the .bin file as the source for the hex file.

* This bypasses the problem introduced when the .data section was moved
from RAM to DTCM_RAM.
* This also ensures that the hash in the .hex file will be valid when
the hex is flashed to a NAND chip as the hash is generated from the .bin
file content.  If the hex contains gaps between sections and the gaps
are erased on the NAND flash then erased sectors are full of 0xFF, not
0x00, which will mean the computed hash won't match.

EXST - Add note regarding currently supported bootloader requirements
regarding the CODE_RAM address.

EXST - Fix make 'dirty' file issue.

When `make` is run twice, the TARGET_BIN is recreated incorrectly.

Root cause was that objcopy actually modifies the INPUT file when no
output file is specified, even when the operation is to extract a
section from the input file...

EXST - Improve messaging when generating EXST bin files.

This should help with understanding of the exact operations required for
EXST bin file generation.

Added warning about hard coded start address.
This commit is contained in:
Dominic Clifton 2019-08-09 20:53:26 +02:00 committed by mikeller
parent 41a0b59380
commit a76e0bccfc
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