address several pr issues

pull/765/head
Thomas Cook 2026-04-23 03:14:49 -04:00 committed by Daniele Lacamera
parent 8742af6cb4
commit b545979da0
7 changed files with 56 additions and 36 deletions

View File

@ -1236,7 +1236,9 @@ ifeq ($(TARGET),lpc55s69)
$(MCUXPRESSO_DRIVERS)/drivers/fsl_power.o \
$(MCUXPRESSO)/drivers/common/fsl_common_arm.o \
$(MCUXPRESSO)/drivers/iap1/fsl_iap.o \
$(MCUXPRESSO)/drivers/lpc_gpio/fsl_gpio.o
$(MCUXPRESSO)/drivers/lpc_gpio/fsl_gpio.o \
$(MCUXPRESSO)/drivers/rng_1/fsl_rng.o \
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/nxp/rng_port.o
ifeq ($(DEBUG_UART),1)
OBJS+=\
$(MCUXPRESSO_DRIVERS)/drivers/fsl_reset.o \
@ -1248,10 +1250,8 @@ ifeq ($(TARGET),lpc55s69)
OBJS+=\
$(MCUXPRESSO)/drivers/casper/fsl_casper.o \
$(MCUXPRESSO)/drivers/hashcrypt/fsl_hashcrypt.o \
$(MCUXPRESSO)/drivers/rng_1/fsl_rng.o \
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/nxp/casper_port.o \
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/nxp/hashcrypt_port.o \
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/nxp/rng_port.o
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/nxp/hashcrypt_port.o
else
CFLAGS+=-DWOLFSSL_NXP_LPC55S69_NO_HWACCEL
endif

View File

@ -31,7 +31,7 @@ FLASH_MULTI_SECTOR_ERASE?=1
WOLFCRYPT_TZ?=1
WOLFCRYPT_TZ_PKCS11?=1
# use 1024-byte sector to accomodate RSA4096 signature
# use 1024-byte sector to accommodate RSA4096 signature
# WOLFBOOT_SECTOR_SIZE?=0x400
WOLFBOOT_SECTOR_SIZE?=0x200

View File

@ -29,7 +29,7 @@ DUALBANK_SWAP?=0
PKA?=0
FLASH_MULTI_SECTOR_ERASE?=1
# use 1024-byte sector to accomodate RSA4096 signature
# use 1024-byte sector to accommodate RSA4096 signature
# WOLFBOOT_SECTOR_SIZE?=0x400
WOLFBOOT_SECTOR_SIZE?=0x200

View File

@ -71,10 +71,8 @@ static void hal_sau_init(void)
static void periph_unsecure(void)
{
#ifndef WOLFSSL_NXP_LPC55S69_NO_HWACCEL
CLOCK_EnableClock(kCLOCK_Rng);
RESET_PeripheralReset(kRNG_RST_SHIFT_RSTn);
#endif
CLOCK_EnableClock(kCLOCK_Iocon);
CLOCK_EnableClock(kCLOCK_Gpio1);
}
@ -113,12 +111,9 @@ void hal_init(void)
uart_write("lpc55s69 init\n", 14);
# endif
# ifndef WOLFSSL_NXP_LPC55S69_NO_HWACCEL
# ifdef WOLFSSL_NXP_LPC55S69_WITH_HWACCEL
CLOCK_EnableClock(kCLOCK_HashCrypt);
wc_hashcrypt_init();
# endif
# ifndef WOLFSSL_NXP_LPC55S69_NO_HWACCEL
CLOCK_EnableClock(kCLOCK_Casper);
wc_casper_init();
# endif
@ -229,13 +224,11 @@ int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
#ifdef WOLFCRYPT_SECURE_MODE
void hal_trng_init(void)
{
#ifndef WOLFSSL_NXP_LPC55S69_NO_HWACCEL
# ifdef __WOLFBOOT
CLOCK_EnableClock(kCLOCK_Rng);
RESET_PeripheralReset(kRNG_RST_SHIFT_RSTn);
# endif
RNG_Init(RNG);
#endif
}
void hal_trng_fini(void)
@ -244,10 +237,8 @@ void hal_trng_fini(void)
int hal_trng_get_entropy(unsigned char *out, unsigned int len)
{
#ifndef WOLFSSL_NXP_LPC55S69_NO_HWACCEL
if (RNG_GetRandomData(RNG, out, len) == kStatus_Success)
return 0;
#endif
return -1;
}

View File

@ -493,9 +493,15 @@ extern int tolower(int c);
#define NO_AES_CBC
#else
#if defined(WOLFCRYPT_TEST) || defined(WOLFCRYPT_BENCHMARK)
#ifdef WOLFSSL_NXP_LPC55S69
#if defined(WOLFSSL_NXP_LPC55S69_WITH_HWACCEL) \
|| defined(WOLFSSL_NXP_LPC55S69_NO_HWACCEL)
/* use actual rng hardware for seed, HASHDRBG for generation */
#define HAVE_HASHDRBG
#define HAVE_AES_ECB
#define WOLFSSL_AES_OFB
#define WOLFSSL_AES_CFB
#define WOLFSSL_AES_COUNTER
#define WOLFSSL_STATIC_MEMORY_TEST_SZ (30 * 1024)
#else
/* Use custom RNG for tests/benchmarks (saves ~7KB vs HASHDRBG).
* WARNING: my_rng_seed_gen is NOT cryptographically secure.
@ -508,14 +514,6 @@ extern int tolower(int c);
#define HAVE_AESGCM
#define GCM_TABLE
#if defined(WOLFSSL_NXP_LPC55S69) || defined(WOLFSSL_NXP_LPC55S69_NO_HWACCEL)
#define HAVE_AES_ECB
#define WOLFSSL_AES_OFB
#define WOLFSSL_AES_CFB
#define WOLFSSL_AES_COUNTER
#define WOLFSSL_STATIC_MEMORY_TEST_SZ (30 * 1024)
#endif
#else
#define HAVE_HASHDRBG
#define WOLFSSL_AES_CFB
@ -588,7 +586,7 @@ extern int tolower(int c);
/* wolfCrypt Test/Benchmark Configuration */
#ifdef WOLFCRYPT_TEST
#ifdef WOLFSSL_NXP_LPC55S69
#ifdef WOLFSSL_NXP_LPC55S69_WITH_HWACCEL
/* lpc55s69 hashcrypt hw does not support interleaving */
#define NO_WOLFSSL_SHA256_INTERLEAVE
#endif

View File

@ -182,7 +182,7 @@ ifeq ($(WOLFCRYPT_SUPPORT),1)
# Add SP C math (all architectures)
APP_OBJS+=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/sp_c32.o
# Add RSA support (needed by test suite)
# Add RSA support
APP_OBJS+=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/rsa.o
ifneq ($(NO_ASM),1)
@ -728,16 +728,16 @@ ifeq ($(TARGET),lpc55s69)
$(MCUXPRESSO)/drivers/flexcomm/fsl_flexcomm.o \
$(MCUXPRESSO)/drivers/flexcomm/usart/fsl_usart.o \
$(MCUXPRESSO)/drivers/iap1/fsl_iap.o \
$(MCUXPRESSO)/drivers/lpc_gpio/fsl_gpio.o
$(MCUXPRESSO)/drivers/lpc_gpio/fsl_gpio.o \
$(MCUXPRESSO)/drivers/rng_1/fsl_rng.o \
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/nxp/rng_port.o
ifeq ($(PKA),1)
CFLAGS+=-DWOLFSSL_NXP_LPC55S69
CFLAGS+=-DWOLFSSL_NXP_LPC55S69_WITH_HWACCEL
APP_OBJS+=\
$(MCUXPRESSO)/drivers/casper/fsl_casper.o \
$(MCUXPRESSO)/drivers/hashcrypt/fsl_hashcrypt.o \
$(MCUXPRESSO)/drivers/rng_1/fsl_rng.o \
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/nxp/casper_port.o \
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/nxp/hashcrypt_port.o \
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/nxp/rng_port.o
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/nxp/hashcrypt_port.o
else
CFLAGS+=-DWOLFSSL_NXP_LPC55S69_NO_HWACCEL
endif

View File

@ -55,11 +55,12 @@ void SysTick_Handler(void)
SysTick_time_ms++;
}
#ifdef WOLFCRYPT_BENCHMARK
static void systick_init(void)
{
SysTick_Config(CLOCK_GetCoreSysClkFreq() / 1000U); /* 1 ms period */
}
#endif
#define IOCON_PIO_FUNC0 0x00u /*!<@brief Selects pin function 0 */
#define IOCON_PIO_MODE_PULLUP 0x20u /*!<@brief Selects pull-up function */
@ -134,7 +135,7 @@ void main(void)
hal_init();
leds_init();
#ifndef TZEN
#ifdef WOLFCRYPT_BENCHMARK
systick_init();
__enable_irq();
#endif
@ -206,6 +207,16 @@ void main(void)
}
}
#ifndef ENOMEM
#define ENOMEM 12
#endif
#ifndef EBADF
#define EBADF 9
#endif
#ifndef EINVAL
#define EINVAL 22
#endif
int errno;
#include "sys/stat.h"
int WEAKFUNCTION _getpid(void)
@ -268,8 +279,28 @@ int WEAKFUNCTION _fstat(int file, struct stat *st)
return 0;
}
/* Heap management */
extern char _end; /* Defined by linker */
extern char _Min_Heap_Size; /* Linker symbol: address is the value */
void WEAKFUNCTION *_sbrk(int incr)
{
(void)incr;
return 0;
static char *heap_end = 0;
char *prev_heap_end;
char *heap_limit;
if (heap_end == 0) {
heap_end = &_end;
}
prev_heap_end = heap_end;
heap_limit = &_end + (uintptr_t)&_Min_Heap_Size;
if (heap_end + incr > heap_limit) {
errno = ENOMEM;
return (void *)-1;
}
heap_end += incr;
return prev_heap_end;
}