Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions arch.mk
Original file line number Diff line number Diff line change
Expand Up @@ -1199,9 +1199,11 @@ ifeq ($(TARGET),lpc55s69)
-I$(MCUXPRESSO_DRIVERS)/drivers \
-I$(MCUXPRESSO_DRIVERS)/../periph \
-I$(MCUXPRESSO)/drivers \
-I$(MCUXPRESSO)/drivers/casper \
-I$(MCUXPRESSO)/drivers/common \
-I$(MCUXPRESSO)/drivers/flexcomm \
-I$(MCUXPRESSO)/drivers/flexcomm/usart \
-I$(MCUXPRESSO)/drivers/hashcrypt \
-I$(MCUXPRESSO)/drivers/iap1 \
-I$(MCUXPRESSO)/drivers/lpc_gpio \
-I$(MCUXPRESSO)/drivers/lpc_iocon \
Expand All @@ -1219,16 +1221,24 @@ 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
ifeq ($(WOLFCRYPT_TZ),1)
OBJS+=$(MCUXPRESSO)/drivers/rng_1/fsl_rng.o
endif
$(MCUXPRESSO)/drivers/lpc_gpio/fsl_gpio.o \
$(MCUXPRESSO)/drivers/rng_1/fsl_rng.o
ifeq ($(DEBUG_UART),1)
OBJS+=\
$(MCUXPRESSO_DRIVERS)/drivers/fsl_reset.o \
$(MCUXPRESSO)/drivers/flexcomm/fsl_flexcomm.o \
$(MCUXPRESSO)/drivers/flexcomm/usart/fsl_usart.o
endif
ifeq ($(PKA),1)
CFLAGS+=-DWOLFSSL_NXP_LPC55S69_WITH_HWACCEL
OBJS+=\
$(MCUXPRESSO)/drivers/casper/fsl_casper.o \
$(MCUXPRESSO)/drivers/hashcrypt/fsl_hashcrypt.o \
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/nxp/casper_port.o \
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/nxp/hashcrypt_port.o
else
CFLAGS+=-DWOLFSSL_NXP_LPC55S69_NO_HWACCEL
endif
endif

ifeq ($(TARGET),psoc6)
Expand Down
9 changes: 5 additions & 4 deletions config/examples/lpc55s69-tz.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ARCH?=ARM
TZEN?=1
TARGET?=lpc55s69
SIGN?=ECC384
HASH?=SHA384
HASH?=SHA256
MCUXSDK?=1
MCUXPRESSO?=$(PWD)/../NXP/mcuxpresso-sdk/mcuxsdk
MCUXPRESSO_CMSIS?=$(PWD)/../NXP/CMSIS_5/CMSIS
Expand All @@ -26,15 +26,16 @@ V?=0
SPMATH?=1
RAM_CODE?=1
DUALBANK_SWAP?=0
PKA?=1
PKA?=0
FLASH_MULTI_SECTOR_ERASE?=1
WOLFCRYPT_TZ?=1
WOLFCRYPT_TZ_PKCS11?=1

# 512-byte pages erasable/writeable
# use 1024-byte sector to accommodate RSA4096 signature
# WOLFBOOT_SECTOR_SIZE?=0x400
WOLFBOOT_SECTOR_SIZE?=0x200

# 200KB boot, 80KB keyvault, 8KB NSC, 56KB partitions, 512 swap
# 200KB boot, 80KB keyvault, 8KB NSC, 56KB partitions, 512/1024 swap
WOLFBOOT_KEYVAULT_ADDRESS?=0x10032000
WOLFBOOT_KEYVAULT_SIZE?=0x14000
WOLFBOOT_NSC_ADDRESS?=0x10046000
Expand Down
24 changes: 17 additions & 7 deletions config/examples/lpc55s69.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ARCH?=ARM
TZEN?=0
TARGET?=lpc55s69
SIGN?=ECC384
HASH?=SHA384
HASH?=SHA256
MCUXSDK?=1
MCUXPRESSO?=$(PWD)/../NXP/mcuxpresso-sdk/mcuxsdk
MCUXPRESSO_CMSIS?=$(PWD)/../NXP/CMSIS_5/CMSIS
Expand All @@ -26,15 +26,25 @@ V?=0
SPMATH?=1
RAM_CODE?=1
DUALBANK_SWAP?=0
PKA?=1
PKA?=0
FLASH_MULTI_SECTOR_ERASE?=1

# 512-byte pages erasable/writeable
# use 1024-byte sector to accommodate RSA4096 signature
# WOLFBOOT_SECTOR_SIZE?=0x400
WOLFBOOT_SECTOR_SIZE?=0x200

# Default configuration
# 40KB boot, 44KB partitions, 512 swap
# 44KB boot, 52KB partitions, 512/1024 swap
WOLFBOOT_PARTITION_SIZE?=0xB000
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0xA000
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x15000
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x20000
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0xD000
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x18000
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x23000

# use these for test/benchmark
#WOLFBOOT_PARTITION_SIZE?=0x2b000
#WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x10000
#WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x3b000
#WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x66000

#WOLFCRYPT_TEST?=1
#WOLFCRYPT_BENCHMARK?=1
30 changes: 22 additions & 8 deletions hal/lpc55s69.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,35 @@ static void hal_flash_fix_ecc(void)
}
}


extern int wc_hashcrypt_init(void);
extern int wc_casper_init(void);

void hal_init(void)
{
#ifdef __WOLFBOOT
/* lpc55s69 must run < 100 MHz for flash write/erase to work */
BOARD_BootClockFROHF96M();
// BOARD_BootClockPLL150M();
#ifdef DEBUG_UART

# ifdef DEBUG_UART
uart_init();
uart_write("lpc55s69 init\n", 14);
#endif
#endif
# endif

# ifdef WOLFSSL_NXP_LPC55S69_WITH_HWACCEL
CLOCK_EnableClock(kCLOCK_HashCrypt);
wc_hashcrypt_init();
CLOCK_EnableClock(kCLOCK_Casper);
wc_casper_init();
# endif

CLOCK_EnableClock(kCLOCK_Rng);
RESET_PeripheralReset(kRNG_RST_SHIFT_RSTn);

#endif /* __WOLFBOOT */

RNG_Init(RNG);

#if defined(__WOLFBOOT) || !defined(TZEN)
memset(&pflash, 0, sizeof(pflash));
Expand Down Expand Up @@ -209,11 +227,7 @@ int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
#ifdef WOLFCRYPT_SECURE_MODE
void hal_trng_init(void)
{
#ifdef __WOLFBOOT
CLOCK_EnableClock(kCLOCK_Rng);
RESET_PeripheralReset(kRNG_RST_SHIFT_RSTn);
#endif
RNG_Init(RNG);
/* handled in hal_init() regardless */
}
Comment thread
twcook86 marked this conversation as resolved.

void hal_trng_fini(void)
Expand Down
31 changes: 23 additions & 8 deletions include/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -493,14 +493,25 @@ extern int tolower(int c);
#define NO_AES_CBC
#else
#if defined(WOLFCRYPT_TEST) || defined(WOLFCRYPT_BENCHMARK)
/* Use custom RNG for tests/benchmarks (saves ~7KB vs HASHDRBG).
* WARNING: my_rng_seed_gen is NOT cryptographically secure.
* Only used in test-app builds, not in production wolfBoot. */
#define WC_NO_HASHDRBG
#define CUSTOM_RAND_GENERATE_SEED my_rng_seed_gen
#define CUSTOM_RAND_GENERATE_BLOCK my_rng_seed_gen
extern int my_rng_seed_gen(unsigned char* output, unsigned int sz);

#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.
* Only used in test-app builds, not in production wolfBoot. */
#define WC_NO_HASHDRBG
#define CUSTOM_RAND_GENERATE_SEED my_rng_seed_gen
#define CUSTOM_RAND_GENERATE_BLOCK my_rng_seed_gen
extern int my_rng_seed_gen(unsigned char* output, unsigned int sz);
#endif

#define HAVE_AESGCM
#define GCM_TABLE
#else
Expand Down Expand Up @@ -575,6 +586,10 @@ extern int tolower(int c);

/* wolfCrypt Test/Benchmark Configuration */
#ifdef WOLFCRYPT_TEST
#ifdef WOLFSSL_NXP_LPC55S69_WITH_HWACCEL
/* lpc55s69 hashcrypt hw does not support interleaving */
#define NO_WOLFSSL_SHA256_INTERLEAVE
#endif
/* Skip extended tests to save memory */
#define NO_CRYPT_TEST_EXTENDED
/* Use smaller certificate buffers */
Expand Down
23 changes: 17 additions & 6 deletions test-app/ARM-lpc55s69.ld
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
_Min_Heap_Size = 0x00000100; /* minimal heap (not using malloc) */
_Min_Stack_Size = 0x00008000; /* required amount of stack */

MEMORY
{
FLASH (rx) : ORIGIN = @WOLFBOOT_TEST_APP_ADDRESS@, LENGTH = @WOLFBOOT_TEST_APP_SIZE@
RAM (rwx) : ORIGIN = 0x20020000, LENGTH = 32K
RAM (rwx) : ORIGIN = 0x20020000, LENGTH = 160K
}

SECTIONS
Expand Down Expand Up @@ -44,15 +47,23 @@ SECTIONS
*(COMMON)
. = ALIGN(4);
_end_bss = .;
_end = .;
} > RAM

._user_heap_stack :
{
. = ALIGN(8);
PROVIDE ( end = . );
PROVIDE ( _end = . );
PROVIDE ( _start_heap = . );
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(8);
PROVIDE ( END_STACK = . );
PROVIDE ( _end_stack = . );
} > RAM
}

_wolfboot_partition_boot_address = @WOLFBOOT_PARTITION_BOOT_ADDRESS@;
_wolfboot_partition_size = @WOLFBOOT_PARTITION_SIZE@;
_wolfboot_partition_update_address = @WOLFBOOT_PARTITION_UPDATE_ADDRESS@;
_wolfboot_partition_swap_address = @WOLFBOOT_PARTITION_SWAP_ADDRESS@;

PROVIDE(_start_heap = _end);
PROVIDE(end = _end);
PROVIDE(_end_stack = ORIGIN(RAM) + LENGTH(RAM));
28 changes: 22 additions & 6 deletions test-app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ ifeq ($(WOLFCRYPT_SUPPORT),1)
# Add SP C math (all architectures)
APP_OBJS+=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/sp_c32.o

# Add RSA support
APP_OBJS+=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/rsa.o
Comment thread
twcook86 marked this conversation as resolved.

ifneq ($(NO_ASM),1)
# SP Cortex M
ifneq ($(filter ARM ARM_BE,$(ARCH)),)
Expand Down Expand Up @@ -675,6 +678,7 @@ ifeq ($(TARGET),mcxn)
endif

ifeq ($(TARGET),lpc55s69)
CFLAGS+=-ffunction-sections -fdata-sections
ifeq ($(TZEN),1)
LSCRIPT_TEMPLATE=ARM-lpc55s69-ns.ld
CFLAGS:=$(filter-out -mcmse, $(CFLAGS))
Expand All @@ -689,14 +693,26 @@ 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
ifeq ($(WOLFCRYPT_TZ),1)
APP_OBJS+=$(MCUXPRESSO)/drivers/rng_1/fsl_rng.o
$(MCUXPRESSO)/drivers/lpc_gpio/fsl_gpio.o \
$(MCUXPRESSO)/drivers/rng_1/fsl_rng.o
ifeq ($(PKA),1)
CFLAGS+=-DWOLFSSL_NXP_LPC55S69_WITH_HWACCEL
APP_OBJS+=\
$(MCUXPRESSO)/drivers/casper/fsl_casper.o \
$(MCUXPRESSO)/drivers/hashcrypt/fsl_hashcrypt.o \
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/nxp/casper_port.o \
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/nxp/hashcrypt_port.o
else
CFLAGS+=-DWOLFSSL_NXP_LPC55S69_NO_HWACCEL
endif
ifeq (,$(findstring nosys.specs,$(LDFLAGS)))
LDFLAGS+=--specs=nosys.specs
ifeq ($(WOLFCRYPT_SUPPORT),1)
LIBS+=--specs=nano.specs
endif
ifeq ($(WOLFCRYPT_BENCHMARK),1)
# Benchmark needs float printf for results
LDFLAGS+=-Wl,-u_printf_float
endif
LDFLAGS+=-Wl,--no-warn-rwx-segments
LDFLAGS+=-Wl,--no-warn-rwx-segments -Wl,--allow-multiple-definition
Comment thread
twcook86 marked this conversation as resolved.
endif

ifeq ($(TARGET),imx_rt)
Expand Down
Loading
Loading