Added test for bootloader update

pull/7/head
Daniele Lacamera 2019-04-29 16:10:40 +02:00
parent 738730c982
commit 2ef5e47d61
4 changed files with 28 additions and 15 deletions

View File

@ -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)
{

View File

@ -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

View File

@ -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

View File

@ -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