diff --git a/hal/stm32f4.ld b/hal/stm32f4.ld index 18b9d63c..b7aa7fa8 100644 --- a/hal/stm32f4.ld +++ b/hal/stm32f4.ld @@ -12,18 +12,10 @@ SECTIONS KEEP(*(.isr_vector)) *(.text*) *(.rodata*) - *(.init*) - *(.fini*) . = ALIGN(4); _end_text = .; } > FLASH - .edidx : - { - . = ALIGN(4); - *(.ARM.exidx*) - } > FLASH - _stored_data = .; .data : AT (_stored_data) { diff --git a/include/image.h b/include/image.h index 3428b341..9a4acd9e 100644 --- a/include/image.h +++ b/include/image.h @@ -6,9 +6,9 @@ #if defined(__WOLFBOOT) && defined(RAM_CODE) # if defined(ARCH_ARM) -# define RAMFUNCTION __attribute__((section(".ramcode"),long_call)) +# define RAMFUNCTION __attribute__((used,section(".ramcode"),long_call)) # else -# define RAMFUNCTION __attribute__((section(".ramcode"))) +# define RAMFUNCTION __attribute__((used,section(".ramcode"))) # endif #else # define RAMFUNCTION diff --git a/src/loader.c b/src/loader.c index ab5da108..2f731262 100644 --- a/src/loader.c +++ b/src/loader.c @@ -26,7 +26,7 @@ #ifdef RAM_CODE extern unsigned int _start_text; -static volatile const uint32_t wolfboot_version = WOLFBOOT_VERSION; +static volatile const uint32_t __attribute__((used)) wolfboot_version = WOLFBOOT_VERSION; extern void (** const IV_RAM)(void); #endif diff --git a/tools/test.mk b/tools/test.mk index 6b453322..70013925 100644 --- a/tools/test.mk +++ b/tools/test.mk @@ -52,12 +52,18 @@ test-update: test-app/image.bin FORCE (make test-reset && sleep 1 && st-flash --reset write test-update.bin 0x08040000) test-self-update: wolfboot.bin test-app/image.bin FORCE + mv $(PRIVATE_KEY) private_key.old + @make clean + @rm src/*_pub_key.c + @make factory.bin RAM_CODE=1 WOLFBOOT_VERSION=$(WOLFBOOT_VERSION) + @$(SIGN_TOOL) test-app/image.bin $(PRIVATE_KEY) $(TEST_UPDATE_VERSION) + @st-flash --reset write test-app/image_v2_signed.bin 0x08020000 || \ + (make test-reset && sleep 1 && st-flash --reset write test-app/image_v2_signed.bin 0x08020000) || \ + (make test-reset && sleep 1 && st-flash --reset write test-app/image_v2_signed.bin 0x08020000) @dd if=/dev/zero bs=131067 count=1 2>/dev/null | tr "\000" "\377" > test-self-update.bin - @python3 $(SIGN_TOOL) --wolfboot-update wolfboot.bin $(PRIVATE_KEY) $(WOLFBOOT_VERSION) + @python3 $(SIGN_TOOL) --wolfboot-update wolfboot.bin private_key.old $(WOLFBOOT_VERSION) @dd if=wolfboot_v$(WOLFBOOT_VERSION)_signed.bin of=test-self-update.bin bs=1 conv=notrunc @printf "pBOOT" >> test-self-update.bin - @make test-reset - @sleep 2 @st-flash --reset write test-self-update.bin 0x08040000 || \ (make test-reset && sleep 1 && st-flash --reset write test-self-update.bin 0x08040000) || \ (make test-reset && sleep 1 && st-flash --reset write test-self-update.bin 0x08040000) @@ -211,4 +217,19 @@ test-23-rollback-SPI: $(EXPVER) FORCE @make clean @echo TEST PASSED -test-all: clean test-01-forward-update-no-downgrade test-02-forward-update-allow-downgrade test-03-rollback test-11-forward-update-no-downgrade-ECC test-13-rollback-ECC test-21-forward-update-no-downgrade-SPI test-23-rollback-SPI +test-34-forward-self-update: $(EXPVER) FORCE + @make test-erase-ext + @echo Creating and uploading factory image... + @make test-factory RAM_CODE=1 + @echo Expecting version '1' + @$$(test `$(EXPVER)` -eq 1) + @echo + @echo Updating keys, firmware, bootloader + @make test-self-update WOLFBOOT_VERSION=4 RAM_CODE=1 + @sleep 2 + @$$(test `$(EXPVER)` -eq 2) + @make clean + @echo TEST PASSED + + +test-all: clean test-01-forward-update-no-downgrade test-02-forward-update-allow-downgrade test-03-rollback test-11-forward-update-no-downgrade-ECC test-13-rollback-ECC test-21-forward-update-no-downgrade-SPI test-23-rollback-SPI test-34-forward-self-update