From 937e9d46fbcb77d2dc2af09445d34f2d810cd9c8 Mon Sep 17 00:00:00 2001 From: Daniele Lacamera Date: Fri, 19 Apr 2019 08:59:31 +0200 Subject: [PATCH 1/6] Introducing RAMCODE tag to transfer functions to RAM - Moved functions in the flash write path to RAM, so their execution does not depend on flash access - RAMCODE can be enabled via "make RAM_CODE=1" --- Makefile | 5 +++ hal/cc26x2.c | 9 ++-- hal/hifive1.c | 9 ++-- hal/hifive1.ld | 4 +- hal/kinetis.c | 9 ++-- hal/nrf52.c | 11 ++--- hal/samr21.c | 9 ++-- hal/stm32f4.c | 17 ++++---- hal/stm32f4.ld | 103 +++++++++++++++++++++++----------------------- include/image.h | 12 +++++- src/libwolfboot.c | 33 ++++++++------- 11 files changed, 122 insertions(+), 99 deletions(-) diff --git a/Makefile b/Makefile index 27e4026487..32c45adbb5 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,7 @@ ALLOW_DOWNGRADE?=0 NVM_FLASH_WRITEONCE?=0 V?=0 SPMATH?=1 +RAM_CODE?=0 @@ -80,6 +81,10 @@ CFLAGS+=-Wall -Wextra -Wno-main -Wstack-usage=1024 -ffreestanding -Wno-unused \ -DWOLFSSL_USER_SETTINGS \ -DPLATFORM_$(TARGET) +ifeq ($(RAM_CODE),1) + CFLAGS+= -DRAM_CODE +endif + ifeq ($(SPI_FLASH),1) EXT_FLASH=1 CFLAGS+= -DSPI_FLASH=1 diff --git a/hal/cc26x2.c b/hal/cc26x2.c index 3d2831deeb..e0962c0e98 100644 --- a/hal/cc26x2.c +++ b/hal/cc26x2.c @@ -25,6 +25,7 @@ #include "ti-lib.h" #include "target.h" /* For WOLFBOOT_SECTOR_SIZE */ +#include "image.h" extern void clock_init(void); char uart_read(void) @@ -42,7 +43,7 @@ int uart_read_nonblock(char *c) } -int hal_flash_write(uint32_t address, const uint8_t *data, int len) +int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len) { FlashProgram(data, address, len); while(FlashCheckFsmForReady() != FAPI_STATUS_FSM_READY) @@ -50,16 +51,16 @@ int hal_flash_write(uint32_t address, const uint8_t *data, int len) return 0; } -void hal_flash_unlock(void) +void RAMFUNCTION hal_flash_unlock(void) { } -void hal_flash_lock(void) +void RAMFUNCTION hal_flash_lock(void) { } -int hal_flash_erase(uint32_t address, int len) +int RAMFUNCTION hal_flash_erase(uint32_t address, int len) { int i = 0; while (len > 0) { diff --git a/hal/hifive1.c b/hal/hifive1.c index af0a75121d..cb32a49e08 100644 --- a/hal/hifive1.c +++ b/hal/hifive1.c @@ -21,6 +21,7 @@ #include #include +#include "image.h" #ifndef ARCH_RISCV # error "wolfBoot hifive1 HAL: wrong architecture selected. Please compile with ARCH=RISCV." #endif @@ -37,21 +38,21 @@ void hal_prepare_boot(void) #endif -int hal_flash_write(uint32_t address, const uint8_t *data, int len) +int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len) { return 0; } -void hal_flash_unlock(void) +void RAMFUNCTION hal_flash_unlock(void) { } -void hal_flash_lock(void) +void RAMFUNCTION hal_flash_lock(void) { } -int hal_flash_erase(uint32_t address, int len) +int RAMFUNCTION hal_flash_erase(uint32_t address, int len) { return 0; } diff --git a/hal/hifive1.ld b/hal/hifive1.ld index 4db313e03f..b33ea6c038 100644 --- a/hal/hifive1.ld +++ b/hal/hifive1.ld @@ -33,10 +33,12 @@ SECTIONS _global_pointer = . + 0x800; *(.sdata*) . = ALIGN(4); + KEEP(*(.ramcode*)) + . = ALIGN(4); _end_data = .; } > RAM - .bss : + .bss (NOLOAD) : { _start_bss = .; *(.bss*) diff --git a/hal/kinetis.c b/hal/kinetis.c index 5c0beea09a..ce04726e0e 100644 --- a/hal/kinetis.c +++ b/hal/kinetis.c @@ -21,6 +21,7 @@ #include #include +#include "image.h" #include "fsl_common.h" #include "fsl_flash.h" #include "fsl_ftfx_cache.h" @@ -300,7 +301,7 @@ static void do_flash_init(void) FTFx_CACHE_ClearCachePrefetchSpeculation(&pcache, 1); } -int hal_flash_write(uint32_t address, const uint8_t *data, int len) +int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len) { int w = 0; int ret; @@ -336,16 +337,16 @@ int hal_flash_write(uint32_t address, const uint8_t *data, int len) return 0; } -void hal_flash_unlock(void) +void RAMFUNCTION hal_flash_unlock(void) { } -void hal_flash_lock(void) +void RAMFUNCTION hal_flash_lock(void) { } -int hal_flash_erase(uint32_t address, int len) +int RAMFUNCTION hal_flash_erase(uint32_t address, int len) { int idx = 0; do_flash_init(); diff --git a/hal/nrf52.c b/hal/nrf52.c index 166bb6ddc9..5d973e6103 100644 --- a/hal/nrf52.c +++ b/hal/nrf52.c @@ -20,6 +20,7 @@ */ #include +#include "image.h" /* Assembly helpers */ #define DMB() __asm__ volatile ("dmb") @@ -45,13 +46,13 @@ #define TASKS_HFCLKSTOP *((volatile uint32_t *)(CLOCK_CONTROL_BASE + 0x004)) #define TASKS_HFCLKSTARTED *((volatile uint32_t *)(CLOCK_CONTROL_BASE + 0x100)) -static void flash_wait_complete(void) +static void RAMFUNCTION flash_wait_complete(void) { while (NVMC_READY == 0) ; } -int hal_flash_write(uint32_t address, const uint8_t *data, int len) +int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len) { int i = 0; uint32_t *src, *dst; @@ -82,16 +83,16 @@ int hal_flash_write(uint32_t address, const uint8_t *data, int len) return 0; } -void hal_flash_unlock(void) +void RAMFUNCTION hal_flash_unlock(void) { } -void hal_flash_lock(void) +void RAMFUNCTION hal_flash_lock(void) { } -int hal_flash_erase(uint32_t address, int len) +int RAMFUNCTION hal_flash_erase(uint32_t address, int len) { uint32_t end = address + len - 1; uint32_t p; diff --git a/hal/samr21.c b/hal/samr21.c index ea1eb71ba2..6f7cc6408e 100644 --- a/hal/samr21.c +++ b/hal/samr21.c @@ -20,6 +20,7 @@ */ #include +#include "image.h" /* Clock settings for cpu samd21g18a @ 48MHz */ #define CPU_FREQ (48000000) @@ -154,7 +155,7 @@ void hal_prepare_boot(void) } -int hal_flash_write(uint32_t address, const uint8_t *data, int len) +int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len) { int i = 0; uint32_t *src, *dst; @@ -191,17 +192,17 @@ int hal_flash_write(uint32_t address, const uint8_t *data, int len) return 0; } -void hal_flash_unlock(void) +void RAMFUNCTION hal_flash_unlock(void) { PAC1_WPCLR |= (PAC_WP_NVMCTL); } -void hal_flash_lock(void) +void RAMFUNCTION hal_flash_lock(void) { PAC1_WPSET |= (PAC_WP_NVMCTL); } -int hal_flash_erase(uint32_t address, int len) +int RAMFUNCTION hal_flash_erase(uint32_t address, int len) { while (len > 0) { NVMCTRL_ADDR = (address >> 1); /* This register holds the address of a 16-bit row */ diff --git a/hal/stm32f4.c b/hal/stm32f4.c index 6c7a5d3c55..ebea9d4377 100644 --- a/hal/stm32f4.c +++ b/hal/stm32f4.c @@ -20,6 +20,7 @@ */ #include +#include /* STM32 F4 register configuration */ /* Assembly helpers */ @@ -135,12 +136,12 @@ const uint32_t flash_sector[FLASH_SECTORS + 1] = { FLASH_TOP }; -static void flash_set_waitstates(int waitstates) +static void RAMFUNCTION flash_set_waitstates(int waitstates) { FLASH_ACR |= waitstates | FLASH_ACR_ENABLE_DATA_CACHE | FLASH_ACR_ENABLE_INST_CACHE; } -static void flash_wait_complete(void) +static RAMFUNCTION void flash_wait_complete(void) { while ((FLASH_SR & FLASH_SR_BSY) == FLASH_SR_BSY) ; @@ -155,7 +156,7 @@ static void mass_erase(void) } */ -static void flash_erase_sector(uint32_t sec) +static void RAMFUNCTION flash_erase_sector(uint32_t sec) { uint32_t reg = FLASH_CR & (~(FLASH_CR_SNB_MASK << FLASH_CR_SNB_SHIFT)); FLASH_CR = reg | (sec & FLASH_CR_SNB_MASK) << FLASH_CR_SNB_SHIFT; @@ -166,12 +167,12 @@ static void flash_erase_sector(uint32_t sec) FLASH_CR &= ~(FLASH_CR_SNB_MASK << FLASH_CR_SNB_SHIFT); } -static void clear_errors(void) +static void RAMFUNCTION clear_errors(void) { FLASH_SR |= ( FLASH_SR_PGSERR | FLASH_SR_PGPERR | FLASH_SR_PGAERR | FLASH_SR_WRPERR | FLASH_SR_OPERR | FLASH_SR_EOP ); } -int hal_flash_write(uint32_t address, const uint8_t *data, int len) +int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len) { int i; uint32_t val; @@ -188,20 +189,20 @@ int hal_flash_write(uint32_t address, const uint8_t *data, int len) return 0; } -void hal_flash_unlock(void) +void RAMFUNCTION hal_flash_unlock(void) { FLASH_CR |= FLASH_CR_LOCK; FLASH_KEYR = FLASH_KEY1; FLASH_KEYR = FLASH_KEY2; } -void hal_flash_lock(void) +void RAMFUNCTION hal_flash_lock(void) { FLASH_CR |= FLASH_CR_LOCK; } -int hal_flash_erase(uint32_t address, int len) +int RAMFUNCTION hal_flash_erase(uint32_t address, int len) { int start = -1, end = -1; uint32_t end_address; diff --git a/hal/stm32f4.ld b/hal/stm32f4.ld index 30c37971f5..18b9d63c75 100644 --- a/hal/stm32f4.ld +++ b/hal/stm32f4.ld @@ -1,51 +1,52 @@ -MEMORY -{ - FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x001FFE0 - RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00010000 -} - -SECTIONS -{ - .text : - { - _start_text = .; - KEEP(*(.isr_vector)) - *(.text*) - *(.rodata*) - *(.init*) - *(.fini*) - . = ALIGN(4); - _end_text = .; - } > FLASH - - .edidx : - { - . = ALIGN(4); - *(.ARM.exidx*) - } > FLASH - - _stored_data = .; - - .data : AT (_stored_data) - { - _start_data = .; - KEEP(*(.data*)) - . = ALIGN(4); - _end_data = .; - } > RAM - - .bss (NOLOAD) : - { - _start_bss = .; - __bss_start__ = .; - *(.bss*) - *(COMMON) - . = ALIGN(4); - _end_bss = .; - __bss_end__ = .; - _end = .; - } > RAM - . = ALIGN(4); -} - -END_STACK = ORIGIN(RAM) + LENGTH(RAM); +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x001FFE0 + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00010000 +} + +SECTIONS +{ + .text : + { + _start_text = .; + KEEP(*(.isr_vector)) + *(.text*) + *(.rodata*) + *(.init*) + *(.fini*) + . = ALIGN(4); + _end_text = .; + } > FLASH + + .edidx : + { + . = ALIGN(4); + *(.ARM.exidx*) + } > FLASH + + _stored_data = .; + .data : AT (_stored_data) + { + _start_data = .; + KEEP(*(.data*)) + . = ALIGN(4); + KEEP(*(.ramcode)) + . = ALIGN(4); + _end_data = .; + } > RAM + + .bss (NOLOAD) : + { + _start_bss = .; + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + _end_bss = .; + __bss_end__ = .; + _end = .; + } > RAM + . = ALIGN(4); +} + +END_STACK = ORIGIN(RAM) + LENGTH(RAM); diff --git a/include/image.h b/include/image.h index 5446d4f23b..652334e711 100644 --- a/include/image.h +++ b/include/image.h @@ -3,7 +3,16 @@ #include #include #include -#include "image.h" + +#if defined(__WOLFBOOT) && defined(RAM_CODE) +# if defined(ARCH_ARM) +# define RAMFUNCTION __attribute__((section(".ramcode"),long_call)) +# else +# define RAMFUNCTION __attribute__((section(".ramcode"))) +# endif +#else +# define RAMFUNCTION +#endif #define SECT_FLAG_NEW 0x0F @@ -12,7 +21,6 @@ #define SECT_FLAG_UPDATED 0x00 - struct wolfBoot_image { uint8_t *hdr; uint8_t *trailer; diff --git a/src/libwolfboot.c b/src/libwolfboot.c index f26e4ce5fa..899c80de0a 100644 --- a/src/libwolfboot.c +++ b/src/libwolfboot.c @@ -21,7 +21,8 @@ #include #include #include -#include +#include "wolfboot/wolfboot.h" +#include "image.h" #ifndef NULL # define NULL (void *)0 @@ -37,7 +38,7 @@ uint32_t ext_cache; #ifdef NVM_FLASH_WRITEONCE static uint8_t NVM_CACHE[WOLFBOOT_SECTOR_SIZE]; -int hal_trailer_write(uint32_t addr, uint8_t val) { +int RAMFUNCTION hal_trailer_write(uint32_t addr, uint8_t val) { uint32_t addr_align = addr & (~(WOLFBOOT_SECTOR_SIZE - 1)); uint32_t addr_off = addr & (WOLFBOOT_SECTOR_SIZE - 1); int ret = 0; @@ -54,7 +55,7 @@ int hal_trailer_write(uint32_t addr, uint8_t val) { #endif #if defined PART_UPDATE_EXT -static uint8_t *get_trailer_at(uint8_t part, uint32_t at) +static uint8_t* get_trailer_at(uint8_t part, uint32_t at) { if (part == PART_BOOT) return (void *)(PART_BOOT_ENDFLAGS - (sizeof(uint32_t) + at)); @@ -87,7 +88,7 @@ static void set_partition_magic(uint8_t part) } #else -static uint8_t *get_trailer_at(uint8_t part, uint32_t at) +static uint8_t* get_trailer_at(uint8_t part, uint32_t at) { if (part == PART_BOOT) return (void *)(PART_BOOT_ENDFLAGS - (sizeof(uint32_t) + at)); @@ -97,7 +98,7 @@ static uint8_t *get_trailer_at(uint8_t part, uint32_t at) return NULL; } -static void set_trailer_at(uint8_t part, uint32_t at, uint8_t val) +static void RAMFUNCTION set_trailer_at(uint8_t part, uint32_t at, uint8_t val) { if (part == PART_BOOT) { hal_trailer_write(PART_BOOT_ENDFLAGS - (sizeof(uint32_t) + at), val); @@ -107,7 +108,7 @@ static void set_trailer_at(uint8_t part, uint32_t at, uint8_t val) } } -static void set_partition_magic(uint8_t part) +static void RAMFUNCTION set_partition_magic(uint8_t part) { uint32_t wolfboot_magic_trail = WOLFBOOT_MAGIC_TRAIL; if (part == PART_BOOT) { @@ -121,32 +122,32 @@ static void set_partition_magic(uint8_t part) -static uint32_t *get_partition_magic(uint8_t part) +static uint32_t* get_partition_magic(uint8_t part) { return (uint32_t *)get_trailer_at(part, 0); } -static uint8_t *get_partition_state(uint8_t part) +static uint8_t* get_partition_state(uint8_t part) { return (uint8_t *)get_trailer_at(part, 1); } -static uint8_t *get_sector_flags(uint8_t part, uint32_t pos) +static uint8_t* get_sector_flags(uint8_t part, uint32_t pos) { return (uint8_t *)get_trailer_at(part, 2 + pos); } -static void set_partition_state(uint8_t part, uint8_t val) +static void RAMFUNCTION set_partition_state(uint8_t part, uint8_t val) { set_trailer_at(part, 1, val); } -static void set_sector_flags(uint8_t part, uint32_t pos, uint8_t val) +static void RAMFUNCTION set_sector_flags(uint8_t part, uint32_t pos, uint8_t val) { set_trailer_at(part, 2 + pos, val); } -int wolfBoot_set_partition_state(uint8_t part, uint8_t newst) +int RAMFUNCTION wolfBoot_set_partition_state(uint8_t part, uint8_t newst) { uint32_t *magic; uint8_t *state; @@ -159,7 +160,7 @@ int wolfBoot_set_partition_state(uint8_t part, uint8_t newst) return 0; } -int wolfBoot_set_sector_flag(uint8_t part, uint8_t sector, uint8_t newflag) +int RAMFUNCTION wolfBoot_set_sector_flag(uint8_t part, uint8_t sector, uint8_t newflag) { uint32_t *magic; uint8_t *flags; @@ -207,7 +208,7 @@ int wolfBoot_get_sector_flag(uint8_t part, uint8_t sector, uint8_t *flag) return 0; } -void wolfBoot_erase_partition(uint8_t part) +void RAMFUNCTION wolfBoot_erase_partition(uint8_t part) { if (part == PART_BOOT) hal_flash_erase(WOLFBOOT_PARTITION_BOOT_ADDRESS, WOLFBOOT_PARTITION_SIZE); @@ -224,7 +225,7 @@ void wolfBoot_erase_partition(uint8_t part) hal_flash_erase(WOLFBOOT_PARTITION_SWAP_ADDRESS, WOLFBOOT_SECTOR_SIZE); } -void wolfBoot_update_trigger(void) +void RAMFUNCTION wolfBoot_update_trigger(void) { uint8_t st = IMG_STATE_UPDATING; #ifdef PART_UPDATE_EXT @@ -238,7 +239,7 @@ void wolfBoot_update_trigger(void) #endif } -void wolfBoot_success(void) +void RAMFUNCTION wolfBoot_success(void) { uint8_t st = IMG_STATE_SUCCESS; hal_flash_unlock(); From fc547e4a25a413f79802d25a3c1948405e42952a Mon Sep 17 00:00:00 2001 From: Daniele Lacamera Date: Wed, 24 Apr 2019 00:15:04 +0200 Subject: [PATCH 2/6] wolfBoot can update itself when compiled with RAM_CODE=1 - Added wolfBoot version - Added extra 16bit header tag to identify the image type and authentication - Implemented optional in-ram self-update of the bootloader, with version control and authentication mechanism (not fail-safe) --- Makefile | 6 ++- hal/hifive1.ld | 1 + include/hal.h | 7 +++ include/image.h | 3 ++ include/wolfboot/wolfboot.h | 19 ++++++++ src/boot_arm.c | 25 ++++++++-- src/boot_riscv.c | 34 ++++++++++++++ src/image.c | 20 ++++++-- src/loader.c | 93 ++++++++++++++++++++++++++++++++++++- tools/keytools/sign.py | 56 ++++++++++++++++------ tools/test.mk | 14 +++++- 11 files changed, 249 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index 32c45adbb5..48332d59ad 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,7 @@ EXT_FLASH?=0 SPI_FLASH?=0 ALLOW_DOWNGRADE?=0 NVM_FLASH_WRITEONCE?=0 +WOLFBOOT_VERSION?=0 V?=0 SPMATH?=1 RAM_CODE?=0 @@ -28,7 +29,7 @@ RAM_CODE?=0 ## Initializers -CFLAGS:=-D__WOLFBOOT +CFLAGS:=-D__WOLFBOOT -DWOLFBOOT_VERSION=$(WOLFBOOT_VERSION)UL LSCRIPT:=hal/$(TARGET).ld LDFLAGS:=-T $(LSCRIPT) -Wl,-gc-sections -Wl,-Map=wolfboot.map -ffreestanding -nostartfiles OBJS:= \ @@ -147,7 +148,8 @@ wolfboot-align.bin: wolfboot.bin @echo test-app/image.bin: - @make -C test-app TARGET=$(TARGET) EXT_FLASH=$(EXT_FLASH) SPI_FLASH=$(SPI_FLASH) ARCH=$(ARCH) V=$(V) \ + @make -C test-app TARGET=$(TARGET) EXT_FLASH=$(EXT_FLASH) SPI_FLASH=$(SPI_FLASH) ARCH=$(ARCH) \ + V=$(V) RAM_CODE=$(RAM_CODE) WOLFBOOT_VERSION=$(WOLFBOOT_VERSION)\ KINETIS=$(KINETIS) KINETIS_CPU=$(KINETIS_CPU) KINETIS_DRIVERS=$(KINETIS_DRIVERS) \ KINETIS_CMSIS=$(KINETIS_CMSIS) NVM_FLASH_WRITEONCE=$(NVM_FLASH_WRITEONCE) \ FREEDOM_E_SDK=$(FREEDOM_E_SDK) diff --git a/hal/hifive1.ld b/hal/hifive1.ld index b33ea6c038..0707554bfe 100644 --- a/hal/hifive1.ld +++ b/hal/hifive1.ld @@ -19,6 +19,7 @@ SECTIONS KEEP(*(.isr_vector)) *(.text*) *(.rodata*) + *(.srodata*) . = ALIGN(4); _end_text = .; } > FLASH diff --git a/include/hal.h b/include/hal.h index 359c7c98e8..6ec61d3f13 100644 --- a/include/hal.h +++ b/include/hal.h @@ -4,6 +4,13 @@ #include #include "target.h" + +/* Architecture specific calls */ +extern void do_boot(const uint32_t *app_offset); +extern void arch_reboot(void); + + + void hal_init(void); int hal_flash_write(uint32_t address, const uint8_t *data, int len); int hal_flash_erase(uint32_t address, int len); diff --git a/include/image.h b/include/image.h index 652334e711..3428b34117 100644 --- a/include/image.h +++ b/include/image.h @@ -41,6 +41,9 @@ int wolfBoot_set_sector_flag(uint8_t part, uint8_t sector, uint8_t newflag); int wolfBoot_get_partition_state(uint8_t part, uint8_t *st); int wolfBoot_get_sector_flag(uint8_t part, uint8_t sector, uint8_t *flag); +/* Defined in libwolfboot */ +uint8_t wolfBoot_find_header(uint8_t *haystack, uint8_t type, uint8_t **ptr); + #ifdef EXT_FLASH # ifdef PART_UPDATE_EXT # define UPDATE_EXT 1 diff --git a/include/wolfboot/wolfboot.h b/include/wolfboot/wolfboot.h index dd682a6f08..a26ab5625e 100644 --- a/include/wolfboot/wolfboot.h +++ b/include/wolfboot/wolfboot.h @@ -13,10 +13,27 @@ #define HDR_VERSION 0x01 #define HDR_TIMESTAMP 0x02 #define HDR_SHA256 0x03 +#define HDR_IMG_TYPE 0x04 #define HDR_PUBKEY 0x10 #define HDR_SIGNATURE 0x20 #define HDR_PADDING 0xFF +#define HDR_IMG_TYPE_AUTH_ED25519 0x0100 +#define HDR_IMG_TYPE_AUTH_ECC256 0x0200 +#define HDR_IMG_TYPE_WOLFBOOT 0x0000 +#define HDR_IMG_TYPE_APP 0x0001 + + +#ifdef __WOLFBOOT + #if defined(WOLFBOOT_SIGN_ED25519) + # define HDR_IMG_TYPE_AUTH HDR_IMG_TYPE_AUTH_ED25519 + #elif defined(WOLFBOOT_SIGN_ECC256) + # define HDR_IMG_TYPE_AUTH HDR_IMG_TYPE_AUTH_ECC256 + #else + # error "no valid authentication mechanism selected. Please define WOLFBOOT_SIGN_ED25519 or WOLFBOOT_SIGN_ECC256" + #endif /* defined WOLFBOOT_SIGN_ECC256 || WOLFBOOT_SIGN_ED25519 */ +#endif /* defined WOLFBOOT */ + #define PART_BOOT 0 #define PART_UPDATE 1 #define PART_SWAP 2 @@ -26,6 +43,8 @@ #define IMG_STATE_TESTING 0x10 #define IMG_STATE_SUCCESS 0x00 + + void wolfBoot_erase_partition(uint8_t part); void wolfBoot_update_trigger(void); void wolfBoot_success(void); diff --git a/src/boot_arm.c b/src/boot_arm.c index de1ab6a717..54e85d909d 100644 --- a/src/boot_arm.c +++ b/src/boot_arm.c @@ -1,4 +1,4 @@ -/* boot_arm.c +/* boot_arm.c * * Copyright (C) 2018 wolfSSL Inc. * @@ -18,9 +18,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ -#include +#include "image.h" +#include "loader.h" #include -#include +#include "wolfboot/wolfboot.h" extern unsigned int _stored_data; extern unsigned int _start_data; extern unsigned int _end_data; @@ -33,7 +34,7 @@ extern void main(void); void isr_reset(void) { register unsigned int *src, *dst; -#ifdef PLATFORM_kinetis +#ifdef PLATFORM_kinetis /* Immediately disable Watchdog after boot */ /* Write Keys to unlock register */ *((volatile unsigned short *)0x4005200E) = 0xC520; @@ -86,6 +87,7 @@ void isr_empty(void) static void *app_entry; static uint32_t app_end_stack; + void do_boot(const uint32_t *app_offset) { @@ -171,3 +173,18 @@ void (* const IV[])(void) = isr_empty, isr_empty, }; + +#ifdef RAM_CODE + +#define AIRCR *(volatile uint32_t *)(0xE000ED0C) +#define AIRCR_VKEY (0x05FA << 16) +# define AIRCR_SYSRESETREQ (1 << 2) + +void RAMFUNCTION arch_reboot(void) +{ + AIRCR = AIRCR_SYSRESETREQ | AIRCR_VKEY; + while(1) + ; + +} +#endif diff --git a/src/boot_riscv.c b/src/boot_riscv.c index e1b8379532..d991d7a44c 100644 --- a/src/boot_riscv.c +++ b/src/boot_riscv.c @@ -20,6 +20,7 @@ */ #include +#include "image.h" extern void trap_entry(void); extern void trap_exit(void); @@ -36,6 +37,12 @@ extern uint32_t _global_pointer; extern void (* const IV[])(void); extern void main(void); +void RAMFUNCTION reloc_iv(uint32_t *address) +{ + asm volatile("csrw mtvec, %0":: "r"(address + 1)); +} + + void __attribute__((naked,section(".init"))) _reset(void) { register uint32_t *src, *dst; asm volatile("la gp, _global_pointer"); @@ -83,4 +90,31 @@ void isr_empty(void) } +#ifdef RAM_CODE + +#define AON_WDOGCFG *(volatile uint32_t *)(0x10000000UL) +#define AON_WDOGKEY *(volatile uint32_t *)(0x1000001CUL) +#define AON_WDOGFEED *(volatile uint32_t *)(0x10000018UL) +#define AON_WDOGCMP *(volatile uint32_t *)(0x10000020UL) + +#define AON_WDOGKEY_VALUE 0x0051F15E +#define AON_WDOGCFG_SCALE 0x0000000F +#define AON_WDOGCFG_RSTEN 0x00000100 +#define AON_WDOGCFG_ZEROCMP 0x00000200 +#define AON_WDOGCFG_ENALWAYS 0x00001000 + + +void RAMFUNCTION arch_reboot(void) +{ + AON_WDOGKEY = AON_WDOGKEY_VALUE; + AON_WDOGCMP = 0; + //wdogconfig: : wdogrsten | enablealways | reset to 0 | max scale + AON_WDOGKEY = AON_WDOGKEY_VALUE; + AON_WDOGCFG |= (AON_WDOGCFG_RSTEN | AON_WDOGCFG_ENALWAYS | AON_WDOGCFG_ZEROCMP | AON_WDOGCFG_SCALE) ; + AON_WDOGKEY = AON_WDOGKEY_VALUE; + AON_WDOGFEED = 1; + while(1) + ; +} +#endif diff --git a/src/image.c b/src/image.c index 8388ec8cba..c3ca1bae29 100644 --- a/src/image.c +++ b/src/image.c @@ -18,18 +18,16 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ -#include -#include +#include "loader.h" +#include "image.h" +#include "hal.h" #include #include -#include #ifdef WOLFBOOT_SIGN_ED25519 #include -extern uint8_t wolfBoot_find_header(uint8_t *haystack, uint8_t type, uint8_t **ptr); - static int wolfBoot_verify_signature(uint8_t *hash, uint8_t *sig) { int ret, res; @@ -266,6 +264,9 @@ int wolfBoot_verify_authenticity(struct wolfBoot_image *img) uint8_t stored_signature_size; uint8_t *pubkey_hint; uint8_t pubkey_hint_size; + uint8_t *image_type_buf; + uint16_t image_type; + uint8_t image_type_size; stored_signature_size = get_header(img, HDR_SIGNATURE, &stored_signature); if (stored_signature_size != IMAGE_SIGNATURE_SIZE) @@ -276,6 +277,15 @@ int wolfBoot_verify_authenticity(struct wolfBoot_image *img) if (memcmp(digest, pubkey_hint, SHA256_DIGEST_SIZE) != 0) return -1; } + image_type_size = get_header(img, HDR_IMG_TYPE, &image_type_buf); + if (image_type_size != sizeof(uint16_t)) + return -1; + image_type = (uint16_t)(image_type_buf[0] + (image_type_buf[1] << 8)); + + if ((image_type & 0xFF00) != HDR_IMG_TYPE_AUTH) + return -1; + + if (image_hash(img, digest) != 0) return -1; if (wolfBoot_verify_signature(digest, stored_signature) != 0) diff --git a/src/loader.c b/src/loader.c index 6bdffc469c..ab5da108bf 100644 --- a/src/loader.c +++ b/src/loader.c @@ -22,8 +22,13 @@ #include "image.h" #include "hal.h" #include "spi_flash.h" +#include "wolfboot/wolfboot.h" -extern void do_boot(const uint32_t *app_offset); +#ifdef RAM_CODE +extern unsigned int _start_text; +static volatile const uint32_t wolfboot_version = WOLFBOOT_VERSION; +extern void (** const IV_RAM)(void); +#endif #define FLASHBUFFER_SIZE 256 static int wolfBoot_copy_sector(struct wolfBoot_image *src, struct wolfBoot_image *dst, uint32_t sector) @@ -87,10 +92,16 @@ static int wolfBoot_update(int fallback_allowed) /* Check the first sector to detect interrupted update */ if ((wolfBoot_get_sector_flag(PART_UPDATE, 0, &flag) < 0) || (flag == SECT_FLAG_NEW)) { + uint8_t *update_type; /* In case this is a new update, do the required * checks on the firmware update * before starting the swap */ + + if (wolfBoot_find_header(update.hdr + IMAGE_HEADER_OFFSET, HDR_IMG_TYPE, &update_type) == sizeof(uint16_t)) { + if ((update_type[0] != HDR_IMG_TYPE_APP) || update_type[1] != (HDR_IMG_TYPE_AUTH >> 8)) + return -1; + } if (!update.hdr_ok || (wolfBoot_verify_integrity(&update) < 0) || (wolfBoot_verify_authenticity(&update) < 0)) { return -1; @@ -153,11 +164,89 @@ static int wolfBoot_update(int fallback_allowed) return 0; } + +#ifdef RAM_CODE + +static void RAMFUNCTION wolfBoot_erase_bootloader(void) +{ + uint32_t *start = (uint32_t *)&_start_text; + uint32_t len = WOLFBOOT_PARTITION_BOOT_ADDRESS - (uint32_t)start; + hal_flash_erase((uint32_t)start, len); + +} + +static void RAMFUNCTION wolfBoot_self_update(struct wolfBoot_image *src) +{ + uint32_t pos = 0; + uint32_t src_offset = IMAGE_HEADER_SIZE; + + hal_flash_unlock(); + wolfBoot_erase_bootloader(); +#ifdef EXT_FLASH + while (pos < src->fw_size) { + if (PART_IS_EXT(src)) { + uint8_t buffer[FLASHBUFFER_SIZE]; + if (src_offset + pos < (src->fw_size + IMAGE_HEADER_SIZE + FLASHBUFFER_SIZE)) { + ext_flash_read((uint32_t)(src->hdr) + src_offset + pos, (void *)buffer, FLASHBUFFER_SIZE); + hal_flash_write(pos + (uint32_t)&_start_text, buffer, FLASHBUFFER_SIZE); + } + pos += FLASHBUFFER_SIZE; + } + goto lock_and_reset; + } +#endif + while (pos < src->fw_size) { + if (src_offset + pos < (src->fw_size + IMAGE_HEADER_SIZE + FLASHBUFFER_SIZE)) { + uint8_t *orig = (uint8_t*)(src->hdr + src_offset + pos); + hal_flash_write(pos + (uint32_t)&_start_text, orig, FLASHBUFFER_SIZE); + } + pos += FLASHBUFFER_SIZE; + } + +lock_and_reset: + hal_flash_lock(); + arch_reboot(); +} + +static void wolfBoot_check_self_update(void) +{ + uint8_t st; + struct wolfBoot_image update; + uint8_t *update_type; + uint32_t update_version; + + /* Check for self update in the UPDATE partition */ + if ((wolfBoot_get_partition_state(PART_UPDATE, &st) == 0) && (st == IMG_STATE_UPDATING) && + (wolfBoot_open_image(&update, PART_UPDATE) == 0) && + (wolfBoot_find_header(update.hdr + IMAGE_HEADER_OFFSET, HDR_IMG_TYPE, &update_type) == sizeof(uint16_t)) && + update_type[0] == HDR_IMG_TYPE_WOLFBOOT && + update_type[1] == (HDR_IMG_TYPE_AUTH >> 8)) { + uint32_t update_version = wolfBoot_update_firmware_version(); + if (update_version <= wolfboot_version) { + hal_flash_unlock(); + wolfBoot_erase_partition(PART_UPDATE); + hal_flash_lock(); + return; + } + if (wolfBoot_verify_integrity(&update) < 0) + return; + if (wolfBoot_verify_authenticity(&update) < 0) + return; + wolfBoot_self_update(&update); + } +} +#endif /* RAM_CODE for self_update */ + static void wolfBoot_start(void) { uint8_t st; struct wolfBoot_image boot, update; - /* First, check if the BOOT partition is still in TESTING, + +#ifdef RAM_CODE + wolfBoot_check_self_update(); +#endif + + /* Check if the BOOT partition is still in TESTING, * to trigger fallback. */ if ((wolfBoot_get_partition_state(PART_BOOT, &st) == 0) && (st == IMG_STATE_TESTING)) { diff --git a/tools/keytools/sign.py b/tools/keytools/sign.py index 71d83ba769..d34f0d0f03 100755 --- a/tools/keytools/sign.py +++ b/tools/keytools/sign.py @@ -30,37 +30,48 @@ HDR_VERSION = 0x01 HDR_TIMESTAMP = 0x02 HDR_SHA256 = 0x03 +HDR_IMG_TYPE = 0x04 HDR_PUBKEY = 0x10 HDR_SIGNATURE = 0x20 HDR_PADDING = 0xFF + HDR_VERSION_LEN = 4 HDR_TIMESTAMP_LEN = 8 HDR_SHA256_LEN = 32 +HDR_IMG_TYPE_LEN = 2 HDR_PUBKEY_LEN = 32 HDR_SIGNATURE_LEN = 64 +HDR_IMG_TYPE_AUTH_ED25519 = 0x0100 +HDR_IMG_TYPE_AUTH_ECC256 = 0x0200 + +HDR_IMG_TYPE_WOLFBOOT = 0x0000 +HDR_IMG_TYPE_APP = 0x0001 + sign="auto" +self_update=False argc = len(sys.argv) argv = sys.argv -if (argc < 4) or (argc > 5): - print("Usage: %s [--ed25519 | --ecc256 ] image key.der fw_version\n" % sys.argv[0]) +if (argc < 4) or (argc > 6): + print("Usage: %s [--ed25519 | --ecc256 ] [--wolfboot-update] image key.der fw_version\n" % sys.argv[0]) sys.exit(1) +for i in range(1, len(argv)): + if (argv[i] == '--ed25519'): + sign='ed25519' + elif (argv[i] == '--ecc256'): + sign='ecc256' + elif (argv[i] == '--wolfboot-update'): + self_update = True + else: + i-=1 + break -if argc == 5: - if argv[1] != '--ed25519' and argv[1] != '--ecc256': - print("Usage: %s [--ed25519 | --ecc256 ] image key.der fw_version\n" % sys.argv[0]) - sys.exit(1) - sign=argv[1][2:] - image_file = argv[2] - key_file = argv[3] - fw_version = int(argv[4]) -else: - image_file = argv[1] - key_file = argv[2] - fw_version = int(argv[3]) +image_file = argv[i+1] +key_file = argv[i+2] +fw_version = int(argv[i+3]) if '.' in image_file: tokens = image_file.split('.') @@ -69,6 +80,11 @@ else: output_image_file = image_file + "_v" + str(fw_version) + "_signed.bin" +if (self_update): + print("Update type: wolfBoot") +else: + print("Update type: Firmware") + print ("Selected cipher: " + sign) print ("Private key: " + key_file) print ("Input image: " + image_file) @@ -130,6 +146,18 @@ header += struct.pack('BB', HDR_TIMESTAMP, HDR_TIMESTAMP_LEN) header += struct.pack('/sys/class/gpio/gpio10/direction @echo "in" >/sys/class/gpio/gpio11/direction - test-update: test-app/image.bin FORCE @dd if=/dev/zero bs=131067 count=1 2>/dev/null | tr "\000" "\377" > test-update.bin @python3 $(SIGN_TOOL) test-app/image.bin $(PRIVATE_KEY) $(TEST_UPDATE_VERSION) @@ -52,6 +51,17 @@ test-update: test-app/image.bin FORCE (make test-reset && sleep 1 && st-flash --reset write test-update.bin 0x08040000) || \ (make test-reset && sleep 1 && st-flash --reset write test-update.bin 0x08040000) +test-self-update: wolfboot.bin test-app/image.bin FORCE + @dd if=/dev/zero bs=131067 count=1 2>/dev/null | tr "\000" "\377" > test-self-update.bin + @$(SIGN_TOOL) --wolfboot-update wolfboot.bin $(PRIVATE_KEY) $(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) + test-update-ext: test-app/image.bin FORCE @python3 $(SIGN_TOOL) test-app/image.bin $(PRIVATE_KEY) $(TEST_UPDATE_VERSION) @$$(dd if=/dev/zero bs=1M count=1 | tr '\000' '\377' > test-update.rom) From 738730c982c9d0ebafaafe8b2bdb207a337fcde4 Mon Sep 17 00:00:00 2001 From: Daniele Lacamera Date: Wed, 24 Apr 2019 20:06:50 +0200 Subject: [PATCH 3/6] Making python3 a requirement for keytools + fixes for MacOS --- tools/test.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test.mk b/tools/test.mk index 6d3e758618..6b4533229f 100644 --- a/tools/test.mk +++ b/tools/test.mk @@ -53,7 +53,7 @@ test-update: test-app/image.bin FORCE test-self-update: wolfboot.bin test-app/image.bin FORCE @dd if=/dev/zero bs=131067 count=1 2>/dev/null | tr "\000" "\377" > test-self-update.bin - @$(SIGN_TOOL) --wolfboot-update wolfboot.bin $(PRIVATE_KEY) $(WOLFBOOT_VERSION) + @python3 $(SIGN_TOOL) --wolfboot-update wolfboot.bin $(PRIVATE_KEY) $(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 From 2ef5e47d6177cef6aa4e42b8e1874d53f1bb9009 Mon Sep 17 00:00:00 2001 From: Daniele Lacamera Date: Mon, 29 Apr 2019 16:10:40 +0200 Subject: [PATCH 4/6] Added test for bootloader update --- hal/stm32f4.ld | 8 -------- include/image.h | 4 ++-- src/loader.c | 2 +- tools/test.mk | 29 +++++++++++++++++++++++++---- 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/hal/stm32f4.ld b/hal/stm32f4.ld index 18b9d63c75..b7aa7fa83c 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 3428b34117..9a4acd9e8c 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 ab5da108bf..2f731262c0 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 6b4533229f..7001392571 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 From 558441650c7e496a842ca26b146f70d8515140e5 Mon Sep 17 00:00:00 2001 From: Daniele Lacamera Date: Mon, 29 Apr 2019 16:20:00 +0200 Subject: [PATCH 5/6] Added ECC self-update test code --- tools/test.mk | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tools/test.mk b/tools/test.mk index 7001392571..743ef1274d 100644 --- a/tools/test.mk +++ b/tools/test.mk @@ -52,10 +52,10 @@ 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 + @mv $(PRIVATE_KEY) private_key.old @make clean @rm src/*_pub_key.c - @make factory.bin RAM_CODE=1 WOLFBOOT_VERSION=$(WOLFBOOT_VERSION) + @make factory.bin RAM_CODE=1 WOLFBOOT_VERSION=$(WOLFBOOT_VERSION) SIGN=$(SIGN) @$(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) || \ @@ -218,18 +218,25 @@ test-23-rollback-SPI: $(EXPVER) FORCE @echo TEST PASSED test-34-forward-self-update: $(EXPVER) FORCE - @make test-erase-ext @echo Creating and uploading factory image... - @make test-factory RAM_CODE=1 + @make clean + @make distclean + @make test-factory RAM_CODE=1 SIGN=$(SIGN) @echo Expecting version '1' @$$(test `$(EXPVER)` -eq 1) @echo @echo Updating keys, firmware, bootloader - @make test-self-update WOLFBOOT_VERSION=4 RAM_CODE=1 + @make test-self-update WOLFBOOT_VERSION=4 RAM_CODE=1 SIGN=$(SIGN) @sleep 2 @$$(test `$(EXPVER)` -eq 2) @make clean @echo TEST PASSED +test-44-forward-self-update-ECC: $(EXPVER) FORCE + @make test-34-forward-self-update SIGN=ECC256 + -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 +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 \ + test-44-forward-self-update-ECC From b75f6bbdc2bc6ad622d448d6708b27531b3ac4a2 Mon Sep 17 00:00:00 2001 From: David Garske Date: Mon, 29 Apr 2019 11:54:08 -0700 Subject: [PATCH 6/6] Added missing macro on Mac for `B115200`. --- tools/test-expect-version/test-expect-version.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/test-expect-version/test-expect-version.c b/tools/test-expect-version/test-expect-version.c index 42db0146be..1d0ce90c18 100644 --- a/tools/test-expect-version/test-expect-version.c +++ b/tools/test-expect-version/test-expect-version.c @@ -42,7 +42,11 @@ #include #define MSGLEN (4 + 4 + 8) -#define PORT "/dev/ttyS0" +#define PORT "/dev/ttyS0" + +#ifndef B115200 +#define B115200 115200 +#endif void alarm_handler(int signo) {