Skip to content

Commit 2ef5e47

Browse files
committed
Added test for bootloader update
1 parent 738730c commit 2ef5e47

4 files changed

Lines changed: 28 additions & 15 deletions

File tree

hal/stm32f4.ld

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,10 @@ SECTIONS
1212
KEEP(*(.isr_vector))
1313
*(.text*)
1414
*(.rodata*)
15-
*(.init*)
16-
*(.fini*)
1715
. = ALIGN(4);
1816
_end_text = .;
1917
} > FLASH
2018

21-
.edidx :
22-
{
23-
. = ALIGN(4);
24-
*(.ARM.exidx*)
25-
} > FLASH
26-
2719
_stored_data = .;
2820
.data : AT (_stored_data)
2921
{

include/image.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
#if defined(__WOLFBOOT) && defined(RAM_CODE)
88
# if defined(ARCH_ARM)
9-
# define RAMFUNCTION __attribute__((section(".ramcode"),long_call))
9+
# define RAMFUNCTION __attribute__((used,section(".ramcode"),long_call))
1010
# else
11-
# define RAMFUNCTION __attribute__((section(".ramcode")))
11+
# define RAMFUNCTION __attribute__((used,section(".ramcode")))
1212
# endif
1313
#else
1414
# define RAMFUNCTION

src/loader.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#ifdef RAM_CODE
2828
extern unsigned int _start_text;
29-
static volatile const uint32_t wolfboot_version = WOLFBOOT_VERSION;
29+
static volatile const uint32_t __attribute__((used)) wolfboot_version = WOLFBOOT_VERSION;
3030
extern void (** const IV_RAM)(void);
3131
#endif
3232

tools/test.mk

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,18 @@ test-update: test-app/image.bin FORCE
5252
(make test-reset && sleep 1 && st-flash --reset write test-update.bin 0x08040000)
5353

5454
test-self-update: wolfboot.bin test-app/image.bin FORCE
55+
mv $(PRIVATE_KEY) private_key.old
56+
@make clean
57+
@rm src/*_pub_key.c
58+
@make factory.bin RAM_CODE=1 WOLFBOOT_VERSION=$(WOLFBOOT_VERSION)
59+
@$(SIGN_TOOL) test-app/image.bin $(PRIVATE_KEY) $(TEST_UPDATE_VERSION)
60+
@st-flash --reset write test-app/image_v2_signed.bin 0x08020000 || \
61+
(make test-reset && sleep 1 && st-flash --reset write test-app/image_v2_signed.bin 0x08020000) || \
62+
(make test-reset && sleep 1 && st-flash --reset write test-app/image_v2_signed.bin 0x08020000)
5563
@dd if=/dev/zero bs=131067 count=1 2>/dev/null | tr "\000" "\377" > test-self-update.bin
56-
@python3 $(SIGN_TOOL) --wolfboot-update wolfboot.bin $(PRIVATE_KEY) $(WOLFBOOT_VERSION)
64+
@python3 $(SIGN_TOOL) --wolfboot-update wolfboot.bin private_key.old $(WOLFBOOT_VERSION)
5765
@dd if=wolfboot_v$(WOLFBOOT_VERSION)_signed.bin of=test-self-update.bin bs=1 conv=notrunc
5866
@printf "pBOOT" >> test-self-update.bin
59-
@make test-reset
60-
@sleep 2
6167
@st-flash --reset write test-self-update.bin 0x08040000 || \
6268
(make test-reset && sleep 1 && st-flash --reset write test-self-update.bin 0x08040000) || \
6369
(make test-reset && sleep 1 && st-flash --reset write test-self-update.bin 0x08040000)
@@ -211,4 +217,19 @@ test-23-rollback-SPI: $(EXPVER) FORCE
211217
@make clean
212218
@echo TEST PASSED
213219

214-
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
220+
test-34-forward-self-update: $(EXPVER) FORCE
221+
@make test-erase-ext
222+
@echo Creating and uploading factory image...
223+
@make test-factory RAM_CODE=1
224+
@echo Expecting version '1'
225+
@$$(test `$(EXPVER)` -eq 1)
226+
@echo
227+
@echo Updating keys, firmware, bootloader
228+
@make test-self-update WOLFBOOT_VERSION=4 RAM_CODE=1
229+
@sleep 2
230+
@$$(test `$(EXPVER)` -eq 2)
231+
@make clean
232+
@echo TEST PASSED
233+
234+
235+
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

0 commit comments

Comments
 (0)