Skip to content

Commit e83f61c

Browse files
twcook86danielinux
authored andcommitted
Add benchmark and test capability to test-app
1 parent 8c6d6e2 commit e83f61c

8 files changed

Lines changed: 171 additions & 73 deletions

File tree

config/examples/lpc55s69.config

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,16 @@ WOLFBOOT_SECTOR_SIZE?=0x400
3434

3535
# Default configuration
3636
# 40KB boot, 44KB partitions, 1024 swap
37-
WOLFBOOT_PARTITION_SIZE?=0xB000
38-
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0xA000
39-
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x15000
40-
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x20000
37+
#WOLFBOOT_PARTITION_SIZE?=0xB000
38+
#WOLFBOOT_PARTITION_BOOT_ADDRESS?=0xD000
39+
#WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x18000
40+
#WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x23000
41+
42+
# use these for test/benchmark
43+
WOLFBOOT_PARTITION_SIZE?=0x26000
44+
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x10000
45+
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x36000
46+
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x5C000
47+
48+
WOLFCRYPT_TEST?=1
49+
WOLFCRYPT_BENCHMARK?=1

include/user_settings.h

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -493,14 +493,19 @@ extern int tolower(int c);
493493
#define NO_AES_CBC
494494
#else
495495
#if defined(WOLFCRYPT_TEST) || defined(WOLFCRYPT_BENCHMARK)
496-
/* Use custom RNG for tests/benchmarks (saves ~7KB vs HASHDRBG).
497-
* WARNING: my_rng_seed_gen is NOT cryptographically secure.
498-
* Only used in test-app builds, not in production wolfBoot. */
499-
#define WC_NO_HASHDRBG
500-
#define CUSTOM_RAND_GENERATE_SEED my_rng_seed_gen
501-
#define CUSTOM_RAND_GENERATE_BLOCK my_rng_seed_gen
502-
extern int my_rng_seed_gen(unsigned char* output, unsigned int sz);
503-
496+
#ifdef WOLFSSL_NXP_LPC55S69
497+
/* use actual rng hardware for seed, HASHDRBG for generation */
498+
#define HAVE_HASHDRBG
499+
#else
500+
/* Use custom RNG for tests/benchmarks (saves ~7KB vs HASHDRBG).
501+
* WARNING: my_rng_seed_gen is NOT cryptographically secure.
502+
* Only used in test-app builds, not in production wolfBoot. */
503+
#define WC_NO_HASHDRBG
504+
#define CUSTOM_RAND_GENERATE_SEED my_rng_seed_gen
505+
#define CUSTOM_RAND_GENERATE_BLOCK my_rng_seed_gen
506+
extern int my_rng_seed_gen(unsigned char* output, unsigned int sz);
507+
#endif
508+
504509
#define HAVE_AESGCM
505510
#define GCM_TABLE
506511
#else
@@ -575,6 +580,10 @@ extern int tolower(int c);
575580

576581
/* wolfCrypt Test/Benchmark Configuration */
577582
#ifdef WOLFCRYPT_TEST
583+
#ifdef WOLFSSL_NXP_LPC55S69
584+
/* lpc55s69 hashcrypt hw does not support interleaving */
585+
#define NO_WOLFSSL_SHA256_INTERLEAVE
586+
#endif
578587
/* Skip extended tests to save memory */
579588
#define NO_CRYPT_TEST_EXTENDED
580589
/* Use smaller certificate buffers */

test-app/ARM-lpc55s69.ld

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
_Min_Heap_Size = 0x00008000; /* minimal heap (not using malloc) */
2+
_Min_Stack_Size = 0x00008000; /* required amount of stack */
3+
14
MEMORY
25
{
36
FLASH (rx) : ORIGIN = @WOLFBOOT_TEST_APP_ADDRESS@, LENGTH = @WOLFBOOT_TEST_APP_SIZE@
4-
RAM (rwx) : ORIGIN = 0x20020000, LENGTH = 32K
7+
RAM (rwx) : ORIGIN = 0x20020000, LENGTH = 96K
58
}
69

710
SECTIONS
@@ -44,15 +47,23 @@ SECTIONS
4447
*(COMMON)
4548
. = ALIGN(4);
4649
_end_bss = .;
47-
_end = .;
4850
} > RAM
51+
52+
._user_heap_stack :
53+
{
54+
. = ALIGN(8);
55+
PROVIDE ( end = . );
56+
PROVIDE ( _end = . );
57+
PROVIDE ( _start_heap = . );
58+
. = . + _Min_Heap_Size;
59+
. = . + _Min_Stack_Size;
60+
. = ALIGN(8);
61+
PROVIDE ( END_STACK = . );
62+
PROVIDE ( _end_stack = . );
63+
} > RAM
4964
}
5065

5166
_wolfboot_partition_boot_address = @WOLFBOOT_PARTITION_BOOT_ADDRESS@;
5267
_wolfboot_partition_size = @WOLFBOOT_PARTITION_SIZE@;
5368
_wolfboot_partition_update_address = @WOLFBOOT_PARTITION_UPDATE_ADDRESS@;
5469
_wolfboot_partition_swap_address = @WOLFBOOT_PARTITION_SWAP_ADDRESS@;
55-
56-
PROVIDE(_start_heap = _end);
57-
PROVIDE(end = _end);
58-
PROVIDE(_end_stack = ORIGIN(RAM) + LENGTH(RAM));

test-app/Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,7 @@ ifeq ($(TARGET),mcxn)
710710
endif
711711

712712
ifeq ($(TARGET),lpc55s69)
713+
CFLAGS+=-ffunction-sections -fdata-sections
713714
ifeq ($(TZEN),1)
714715
LSCRIPT_TEMPLATE=ARM-lpc55s69-ns.ld
715716
CFLAGS:=$(filter-out -mcmse, $(CFLAGS))
@@ -737,10 +738,16 @@ ifeq ($(TARGET),lpc55s69)
737738
else
738739
CFLAGS+=-DWOLFSSL_NXP_LPC55S69_NO_HWACCEL
739740
endif
740-
ifeq (,$(findstring nosys.specs,$(LDFLAGS)))
741+
LIBS+=--specs=nano.specs
742+
ifneq ($(WOLFCRYPT_SUPPORT),1)
743+
# Only use nosys stubs when not providing our own syscalls
741744
LDFLAGS+=--specs=nosys.specs
742745
endif
743-
LDFLAGS+=-Wl,--no-warn-rwx-segments
746+
ifeq ($(WOLFCRYPT_BENCHMARK),1)
747+
# Benchmark needs float printf for results
748+
LDFLAGS+=-Wl,-u_printf_float
749+
endif
750+
LDFLAGS+=-Wl,--no-warn-rwx-segments -Wl,--allow-multiple-definition
744751
endif
745752

746753
ifeq ($(TARGET),nxp_lpc54s0xx)

test-app/app_lpc55s69.c

Lines changed: 104 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,39 @@
2828
#include "wolfboot/wolfboot.h"
2929
#include "printf.h"
3030

31+
/* wolfCrypt test/benchmark support */
32+
#ifdef WOLFCRYPT_TEST
33+
#include <wolfssl/wolfcrypt/settings.h>
34+
#include <wolfcrypt/test/test.h>
35+
int wolfcrypt_test(void *args);
36+
#endif
37+
38+
#ifdef WOLFCRYPT_BENCHMARK
39+
#include <wolfssl/wolfcrypt/settings.h>
40+
#include <wolfcrypt/benchmark/benchmark.h>
41+
int benchmark_test(void *args);
42+
#endif
43+
3144
#define RED_LED 6
3245
#define GREEN_LED 7
3346
#define BLUE_LED 4
3447

3548
extern void hal_init(void);
3649

50+
51+
volatile uint64_t SysTick_time_ms;
52+
53+
void SysTick_Handler(void)
54+
{
55+
SysTick_time_ms++;
56+
}
57+
58+
static void systick_init(void)
59+
{
60+
SysTick_Config(CLOCK_GetCoreSysClkFreq() / 1000U); /* 1 ms period */
61+
}
62+
63+
3764
#define IOCON_PIO_FUNC0 0x00u /*!<@brief Selects pin function 0 */
3865
#define IOCON_PIO_MODE_PULLUP 0x20u /*!<@brief Selects pull-up function */
3966
#define IOCON_PIO_SLEW_STANDARD 0x00u /*!<@brief Standard mode, output slew rate control is enabled */
@@ -106,7 +133,14 @@ void main(void)
106133
uint8_t boot_state, update_state;
107134

108135
hal_init();
136+
systick_init();
109137
leds_init();
138+
__enable_irq();
139+
140+
wolfBoot_printf("\n==================================\n");
141+
wolfBoot_printf("LPC55S69 wolfBoot demo Application\n");
142+
wolfBoot_printf("Copyright 2026 wolfSSL Inc\n");
143+
wolfBoot_printf("==================================\n");
110144

111145
check_parts(&boot_ver, &update_ver, &boot_state, &update_state);
112146

@@ -147,69 +181,87 @@ void main(void)
147181
GPIO_PinWrite(GPIO, 1, GREEN_LED, 0);
148182
}
149183

184+
#if defined(WOLFCRYPT_TEST) || defined(WOLFCRYPT_BENCHMARK)
185+
wolfCrypt_Init();
186+
187+
# ifdef WOLFCRYPT_TEST
188+
wolfBoot_printf("\nRunning wolfCrypt tests...\n");
189+
wolfcrypt_test(NULL);
190+
wolfBoot_printf("Tests complete.\n\n");
191+
# endif
192+
193+
# ifdef WOLFCRYPT_BENCHMARK
194+
wolfBoot_printf("\nRunning wolfCrypt benchmarks...\n");
195+
benchmark_test(NULL);
196+
wolfBoot_printf("Benchmarks complete.\n\n");
197+
# endif
198+
199+
wolfCrypt_Cleanup();
200+
#endif
201+
150202
while (1) {
151203
__asm__ volatile ("wfi");
152204
}
153205
}
154206

155207

156-
#include "sys/stat.h"
157-
int _getpid(void)
158-
{
159-
return 1;
160-
}
208+
// #include "sys/stat.h"
209+
// int _getpid(void)
210+
// {
211+
// return 1;
212+
// }
161213

162-
int _kill(int pid, int sig)
163-
{
164-
(void)pid;
165-
(void)sig;
166-
return -1;
167-
}
214+
// int _kill(int pid, int sig)
215+
// {
216+
// (void)pid;
217+
// (void)sig;
218+
// return -1;
219+
// }
168220

169-
void _exit(int status)
170-
{
171-
_kill(status, -1);
172-
while (1) {}
173-
}
221+
// void _exit(int status)
222+
// {
223+
// _kill(status, -1);
224+
// while (1) {}
225+
// }
174226

175-
int _read(int file, char *ptr, int len)
176-
{
177-
(void)file;
178-
(void)ptr;
179-
(void)len;
180-
return -1;
181-
}
227+
// int _read(int file, char *ptr, int len)
228+
// {
229+
// (void)file;
230+
// (void)ptr;
231+
// (void)len;
232+
// return -1;
233+
// }
182234

183-
int _write(int file, char *ptr, int len)
184-
{
185-
(void)file;
186-
(void)ptr;
187-
return len;
188-
}
235+
// int _write(int file, char *ptr, int len)
236+
// {
237+
// (void)file;
238+
// (void)ptr;
239+
// return len;
240+
// }
189241

190-
int _close(int file)
191-
{
192-
(void)file;
193-
return -1;
194-
}
242+
// int _close(int file)
243+
// {
244+
// (void)file;
245+
// return -1;
246+
// }
195247

196-
int _isatty(int file)
197-
{
198-
(void)file;
199-
return 1;
200-
}
248+
// int _isatty(int file)
249+
// {
250+
// (void)file;
251+
// return 1;
252+
// }
201253

202-
int _lseek(int file, int ptr, int dir)
203-
{
204-
(void)file;
205-
(void)ptr;
206-
(void)dir;
207-
return 0;
208-
}
254+
// int _lseek(int file, int ptr, int dir)
255+
// {
256+
// (void)file;
257+
// (void)ptr;
258+
// (void)dir;
259+
// return 0;
260+
// }
209261

210-
int _fstat(int file, struct stat *st)
211-
{
212-
(void)file;
213-
st->st_mode = S_IFCHR;
214-
return 0;
215-
}
262+
// int _fstat(int file, struct stat *st)
263+
// {
264+
// (void)file;
265+
// st->st_mode = S_IFCHR;
266+
// return 0;
267+
// }

test-app/startup_arm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extern void isr_usart3(void);
4343
extern void isr_lpuart1(void);
4444
#endif
4545

46-
#ifdef TARGET_va416x0
46+
#if defined(TARGET_va416x0) || defined(TARGET_lpc55s69)
4747
#define isr_systick SysTick_Handler
4848
#elif !defined(APP_HAS_SYSTICK)
4949
#define isr_systick isr_empty

test-app/syscalls.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ int _getpid(void)
141141
* other OS facilities that don't exist in bare-metal.
142142
* wolfCrypt test/benchmark code calls standard printf, not wolfBoot_printf.
143143
*/
144+
int vsnprintf(char *buf, unsigned int size, const char *fmt, va_list argp);
144145

145146
/* Route all printf-family functions through our vsnprintf (in this file)
146147
* rather than uart_vprintf (in string.c). This ensures float formatting

test-app/wolfcrypt_support.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
#elif defined(TARGET_va416x0)
4343
/* Use Vorago SDK HAL_time_ms (incremented by SysTick_Handler every 1ms) */
4444
extern volatile uint64_t HAL_time_ms;
45+
#elif defined(TARGET_lpc55s69)
46+
extern volatile uint64_t SysTick_time_ms;
4547
#elif defined(TARGET_nxp_t2080) || defined(TARGET_nxp_t1024)
4648
/* PPC timebase register for accurate timing.
4749
* Timebase frequency = platform_clock / 16. */
@@ -96,6 +98,10 @@ unsigned long my_time(unsigned long* timer)
9698
unsigned long t = (unsigned long)(HAL_time_ms / 1000);
9799
if (timer) *timer = t;
98100
return t;
101+
#elif defined(TARGET_lpc55s69)
102+
unsigned long t = (unsigned long)(SysTick_time_ms / 1000);
103+
if (timer) *timer = t;
104+
return t;
99105
#elif defined(TARGET_nxp_t2080) || defined(TARGET_nxp_t1024)
100106
if (ppc_tb_hz == 0)
101107
ppc_tb_hz = ppc_get_timebase_hz();
@@ -125,6 +131,9 @@ double current_time(int reset)
125131
(void)reset;
126132
/* Use Vorago SDK SysTick-based millisecond counter */
127133
return (double)HAL_time_ms / 1000.0;
134+
#elif defined(TARGET_lpc55s69)
135+
(void)reset;
136+
return (double)SysTick_time_ms / 1000.0;
128137
#elif defined(TARGET_nxp_t2080) || defined(TARGET_nxp_t1024)
129138
if (ppc_tb_hz == 0)
130139
ppc_tb_hz = ppc_get_timebase_hz();

0 commit comments

Comments
 (0)