Skip to content

Commit 47ad6c2

Browse files
committed
Updated benchmark to run on rpi + stm32h563
1 parent 5b43fcc commit 47ad6c2

12 files changed

Lines changed: 217 additions & 47 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
ARCH?=ARM
2+
TZEN?=0
3+
TARGET?=stm32h5
4+
SIGN?=ECC256
5+
HASH?=SHA256
6+
DEBUG?=0
7+
VTOR?=1
8+
CORTEX_M0?=0
9+
CORTEX_M33?=1
10+
NO_ASM?=0
11+
NO_MPU=1
12+
EXT_FLASH?=0
13+
SPI_FLASH?=0
14+
ALLOW_DOWNGRADE?=0
15+
NVM_FLASH_WRITEONCE?=1
16+
WOLFBOOT_VERSION?=1
17+
V?=0
18+
SPMATH?=1
19+
RAM_CODE?=0
20+
DUALBANK_SWAP?=0
21+
WOLFBOOT_PARTITION_SIZE?=0xA0000
22+
#Double sector size to fit header in ML-DSA-87
23+
WOLFBOOT_SECTOR_SIZE?=0x4000
24+
WOLFBOOT_KEYVAULT_ADDRESS?=0x0C040000
25+
WOLFBOOT_KEYVAULT_SIZE?=0x1C000
26+
WOLFBOOT_NSC_ADDRESS?=0x0C05C000
27+
WOLFBOOT_NSC_SIZE?=0x4000
28+
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x08060000
29+
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x08100000
30+
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x081A0000
31+
FLAGS_HOME=0
32+
DISABLE_BACKUP=0
33+
IMAGE_HEADER_SIZE?=1024
34+
ARMORED=1

include/image.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ static void __attribute__((noinline)) wolfBoot_image_clear_signature_ok(
444444
asm volatile("bne hnope"); \
445445
/* Repeat memcmp call */ \
446446
compare_res = XMEMCMP(digest, img->sha_hash, WOLFBOOT_SHA_DIGEST_SIZE); \
447+
compare_res; \
447448
/* Redundant checks that ensure the function actually returned 0 */ \
448449
asm volatile("cmp r0, #0":::"cc"); \
449450
asm volatile("cmp r0, #0":::"cc"); \

options.mk

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
WOLFCRYPT_OBJS+=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/asn.o
22
USE_GCC?=1
3+
WOLFBOOT_TEST_FILLER?=0
4+
WOLFBOOT_TIME_TEST?=0
35

46
# Support for Built-in ROT into OTP flash memory
57
ifeq ($(FLASH_OTP_KEYSTORE),1)
68
CFLAGS+=-D"FLASH_OTP_KEYSTORE"
79
endif
810

11+
ifeq ($(WOLFBOOT_TEST_FILLER),1)
12+
CFLAGS+=-D"WOLFBOOT_TEST_FILLER"
13+
endif
14+
15+
ifeq ($(WOLFBOOT_TIME_TEST),1)
16+
CFLAGS+=-D"WOLFBOOT_TIME_TEST"
17+
endif
18+
919
# Support for TPM signature verification
1020
ifeq ($(WOLFBOOT_TPM_VERIFY),1)
1121
WOLFTPM:=1
@@ -200,7 +210,7 @@ ifeq ($(SIGN),ECC521)
200210
ifneq ($(SPMATH),1)
201211
STACK_USAGE=11256
202212
else
203-
STACK_USAGE=8288
213+
STACK_USAGE=8480
204214
endif
205215
endif
206216
endif

src/image.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2202,6 +2202,7 @@ int wolfBoot_verify_authenticity(struct wolfBoot_image *img)
22022202
wolfBoot_printf("Verification of hybrid signature\n");
22032203
wolfBoot_verify_signature_secondary(key_slot, img,
22042204
stored_secondary_signature);
2205+
(void)stored_secondary_signature_size;
22052206
wolfBoot_printf("Done.\n");
22062207
}
22072208
}

test-app/ARM-stm32h5-ns.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
MEMORY
22
{
33
FLASH (rx) : ORIGIN = @WOLFBOOT_TEST_APP_ADDRESS@, LENGTH = @WOLFBOOT_TEST_APP_SIZE@
4-
RAM (rwx) : ORIGIN = 0x20050000, LENGTH = 0x40000
4+
RAM (rwx) : ORIGIN = 0x20050000, LENGTH = 0x50000
55
}
66

77
SECTIONS

test-app/ARM-stm32h5.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
MEMORY
22
{
33
FLASH (rx) : ORIGIN = @WOLFBOOT_TEST_APP_ADDRESS@, LENGTH = @WOLFBOOT_TEST_APP_SIZE@
4-
RAM (rwx) : ORIGIN = 0x30000000, LENGTH = 64K /* Run in lowmem */
4+
RAM (rwx) : ORIGIN = 0x30000000, LENGTH = 256K
55
}
66

77
SECTIONS

test-app/Makefile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,12 @@ ifeq ($(TARGET),stm32h5)
289289
LDFLAGS+=-Wl,-gc-sections -Wl,-Map=image.map
290290
CFLAGS+=-I..
291291
APP_OBJS+=../hal/uart/uart_drv_$(UART_TARGET).o
292-
ifeq ($(FLASH_OTP_KEYSTORE),1)
293-
APP_OBJS+=../src/flash_otp_keystore.o
294-
else
295-
APP_OBJS+=../src/keystore.o
292+
ifneq ($(SIGN),NONE)
293+
ifeq ($(FLASH_OTP_KEYSTORE),1)
294+
APP_OBJS+=../src/flash_otp_keystore.o
295+
else
296+
APP_OBJS+=../src/keystore.o
297+
endif
296298
endif
297299
endif
298300

@@ -330,7 +332,9 @@ endif
330332
ifeq ($(TARGET),va416x0)
331333
APP_OBJS+=$(SDK_OBJS)
332334
LSCRIPT_TEMPLATE=ARM-va416x0.ld
333-
APP_OBJS+=../src/keystore.o
335+
ifneq ($(SIGN),NONE)
336+
APP_OBJS+=../src/keystore.o
337+
endif
334338
endif
335339

336340
ifeq ($(TARGET),sim)

test-app/app_stm32h5.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
#include "hal/stm32h5.h"
3232
#include "uart_drv.h"
3333
#include "wolfboot/wolfboot.h"
34+
#ifndef WOLFBOOT_NO_SIGN
3435
#include "keystore.h"
36+
#endif
3537
#include "target.h"
3638

3739
#ifdef WOLFBOOT_TPM
@@ -76,9 +78,20 @@ static int uart_poll(void);
7678
#define LED_BOOT_PIN (4) /* PG4 - Nucleo - Red Led */
7779
#define LED_USR_PIN (0) /* PB0 - Nucleo - Green Led */
7880
#define LED_EXTRA_PIN (4) /* PF4 - Nucleo - Orange Led */
81+
#define BOOT_TIME_PIN (13) /* PA13 - scope trigger */
82+
83+
#ifdef WOLFBOOT_TEST_FILLER
84+
#define FILLER_SIZE (64 * 1024)
85+
static volatile uint8_t filler_data[FILLER_SIZE] = { 0x01, 0x02, 0x03 };
86+
#endif
7987

8088
#define NVIC_USART3_IRQN (60)
8189

90+
#ifndef GPIOA_MODER
91+
#define GPIOA_MODER (*(volatile uint32_t *)(GPIOA_BASE + 0x00))
92+
#define GPIOA_PUPDR (*(volatile uint32_t *)(GPIOA_BASE + 0x0C))
93+
#define GPIOA_BSRR (*(volatile uint32_t *)(GPIOA_BASE + 0x18))
94+
#endif
8295

8396
/* SysTick */
8497
static uint32_t cpu_freq = 250000000;
@@ -119,6 +132,21 @@ static void boot_led_on(void)
119132
GPIOG_BSRR |= (1 << (pin));
120133
}
121134

135+
void boot_time_pin_on_early(void)
136+
{
137+
uint32_t reg;
138+
uint32_t pin = BOOT_TIME_PIN;
139+
140+
RCC_AHB2ENR_CLOCK_ER |= GPIOA_AHB2ENR1_CLOCK_ER;
141+
/* Delay after an RCC peripheral clock enabling */
142+
reg = RCC_AHB2ENR_CLOCK_ER;
143+
144+
reg = GPIOA_MODER & ~(0x03 << (pin * 2));
145+
GPIOA_MODER = reg | (1 << (pin * 2));
146+
GPIOA_PUPDR &= ~(0x03 << (pin * 2));
147+
GPIOA_BSRR |= (1 << (pin));
148+
}
149+
122150
static void boot_led_off(void)
123151
{
124152
GPIOG_BSRR |= (1 << (LED_BOOT_PIN + 16));
@@ -542,6 +570,7 @@ static int cmd_info(const char *args)
542570
printf("No image in update partition.\r\n");
543571
}
544572

573+
#ifndef WOLFBOOT_NO_SIGN
545574
printf("\r\n");
546575
printf("Bootloader OTP keystore information\r\n");
547576
printf("====================================\r\n");
@@ -559,6 +588,10 @@ static int cmd_info(const char *args)
559588
printf(" ====================================\r\n ");
560589
print_hex(keybuf, size, 0);
561590
}
591+
#else
592+
printf("\r\n");
593+
printf("Signing disabled (SIGN=NONE)\r\n");
594+
#endif
562595
return 0;
563596
}
564597

@@ -1295,6 +1328,10 @@ void main(void)
12951328
/* Turn on boot LED */
12961329
boot_led_on();
12971330

1331+
#ifdef WOLFBOOT_TEST_FILLER
1332+
filler_data[FILLER_SIZE - 1] = 0xAA;
1333+
#endif
1334+
12981335
/* Enable SysTick */
12991336
systick_enable();
13001337

test-app/app_stm32h7.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,10 @@ void uart_print(const char *s)
363363
}
364364
}
365365

366-
#define FILLER_SIZE (100 * 1024)
366+
#ifdef WOLFBOOT_TEST_FILLER
367+
#define FILLER_SIZE (64 * 1024)
367368
static volatile uint8_t filler_data[FILLER_SIZE] = { 0x01, 0x02, 0x03 };
369+
#endif
368370

369371
void main(void)
370372
{
@@ -377,7 +379,9 @@ void main(void)
377379
if (FIRMWARE_A)
378380
ld3_write(LED_INIT);
379381

382+
#ifdef WOLFBOOT_TEST_FILLER
380383
filler_data[FILLER_SIZE - 1] = 0xAA;
384+
#endif
381385
/* LED Indicator of successful UART initialization. SUCCESS = ON, FAIL = OFF */
382386
if (uart_setup(115200) < 0)
383387
ld2_write(LED_OFF);

test-app/startup_arm.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ extern void main(void);
6363

6464
void isr_reset(void) {
6565
register unsigned int *src, *dst;
66+
67+
#if defined(WOLFBOOT_TIME_TEST) && defined(TARGET_stm32h5)
68+
extern void boot_time_pin_on_early(void);
69+
boot_time_pin_on_early();
70+
#endif
71+
6672
src = (unsigned int *) &_stored_data;
6773
dst = (unsigned int *) &_start_data;
6874
while (dst < (unsigned int *)&_end_data) {

0 commit comments

Comments
 (0)