diff --git a/arch.mk b/arch.mk index e943e29d69..e257f94462 100644 --- a/arch.mk +++ b/arch.mk @@ -96,3 +96,15 @@ ifeq ($(TARGET),kinetis) ## ECC_EXTRA_OBJS+=./lib/wolfssl/wolfcrypt/src/port/nxp/ksdk_port.o $(KINETIS_DRIVERS)/drivers/fsl_ltc.o ##endif endif + +ifeq ($(TARGET),stm32wb) + ifneq ($(PKA),0) + ECC_EXTRA_OBJS+= $(STM32CUBE)/Drivers/STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_pka.o ./lib/wolfssl/wolfcrypt/src/port/st/stm32.o + ECC_EXTRA_CFLAGS+=-DWOLFSSL_STM32_PKA -I$(STM32CUBE)/Drivers/STM32WBxx_HAL_Driver/Inc \ + -Isrc -I$(STM32CUBE)/Drivers/BSP/P-NUCLEO-WB55.Nucleo/ -I$(STM32CUBE)/Drivers/CMSIS/Device/ST/STM32WBxx/Include \ + -I$(STM32CUBE)/Drivers/STM32WBxx_HAL_Driver/Inc/ \ + -I$(STM32CUBE)/Drivers/CMSIS/Include \ + -Ihal \ + -DSTM32WB55xx + endif +endif diff --git a/config/examples/kinetis-k82f.config b/config/examples/kinetis-k82f.config new file mode 100644 index 0000000000..8cc469b3fa --- /dev/null +++ b/config/examples/kinetis-k82f.config @@ -0,0 +1,27 @@ +ARCH?=ARM +TARGET?=kinetis +SIGN?=ECC256 +KINETIS?=$(HOME)/src/FRDM-K82F +KINETIS_CPU?=MK82FN256VLL15 +KINETIS_DRIVERS?=$(KINETIS)/devices/MK82F25615 +KINETIS_CMSIS?=$(HOME)/src/FRDM-K64F/CMSIS +FREEDOM_E_SDK?=$(HOME)/src/freedom-e-sdk +DEBUG?=0 +VTOR?=1 +CORTEX_M0?=0 +NO_ASM?=0 +EXT_FLASH?=0 +SPI_FLASH?=0 +ALLOW_DOWNGRADE?=0 +NVM_FLASH_WRITEONCE?=1 +WOLFBOOT_VERSION?=0 +V?=0 +SPMATH?=1 +RAM_CODE?=0 +DUALBANK_SWAP?=0 +IMAGE_HEADER_SIZE?=256 +WOLFBOOT_PARTITION_SIZE?=0x7A000 +WOLFBOOT_SECTOR_SIZE?=0x1000 +WOLFBOOT_PARTITION_BOOT_ADDRESS?=0xA000 +WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x84000 +WOLFBOOT_PARTITION_SWAP_ADDRESS?=0xff000 diff --git a/config/examples/stm32wb-small.config b/config/examples/stm32wb-small.config index ac6f5e5646..e7de69c1ce 100644 --- a/config/examples/stm32wb-small.config +++ b/config/examples/stm32wb-small.config @@ -2,3 +2,4 @@ TARGET=stm32wb SIGN=ECC256 WOLFBOOT_PARTITION_BOOT_ADDRESS=0xA000 WOLFBOOT_PARTITION_SIZE=0x4000 +PKA=1 diff --git a/docs/Targets.md b/docs/Targets.md index b0819a4f05..f9336ea7d2 100644 --- a/docs/Targets.md +++ b/docs/Targets.md @@ -94,7 +94,7 @@ Example partitioning on Nucleo-68 board: - Sector size: 4KB - Wolfboot partition size: 32 KB -- Applicatiobn partition size: 128 KB +- Application partition size: 128 KB ```C #define WOLFBOOT_SECTOR_SIZE 0x1000 /* 4 KB */ @@ -260,7 +260,7 @@ reset halt ``` -OpenOCD can be either run in background (to allow remote GDB and monitor terminal connections), or +OpenOCD can be either run in background (to allow remote GDB and monitor terminal connections), or directly from command line, to execute terminal scripts. If OpenOCD is running, local TCP port 4444 can be used to access an interactive terminal prompt. @@ -293,7 +293,7 @@ Upon reboot, wolfboot will elect the best candidate (version 2 in this case) and If the accepted candidate image resides on BANK B (like in this case), wolfBoot will perform one bank swap before booting. -The bank-swap operation is immediate and a SWAP image is not required in this case. Fallback mechanism can rely on +The bank-swap operation is immediate and a SWAP image is not required in this case. Fallback mechanism can rely on a second choice (older firmware) in the other bank. @@ -309,5 +309,3 @@ From another console, connect using gdb, e.g.: arm-none-eabi-gdb (gdb) target remote:3333 ``` - - diff --git a/hal/stm32wb.c b/hal/stm32wb.c index 332bc86905..eb8a781631 100644 --- a/hal/stm32wb.c +++ b/hal/stm32wb.c @@ -20,7 +20,12 @@ */ #include -#include +#include "image.h" +#ifdef WOLFSSL_STM32_PKA +#include "stm32wbxx_hal.h" +PKA_HandleTypeDef hpka = { }; +#endif + /* STM32 WB register configuration */ /* Assembly helpers */ @@ -286,6 +291,11 @@ static void clock_pll_on(void) void hal_init(void) { clock_pll_on(); +#ifdef WOLFSSL_STM32_PKA + __HAL_RCC_PKA_CLK_ENABLE(); + hpka.Instance = PKA; + HAL_PKA_Init(&hpka); +#endif } void hal_prepare_boot(void) @@ -297,3 +307,26 @@ void hal_prepare_boot(void) clock_pll_off(); } +#ifdef WOLFSSL_STM32_PKA + + +void HAL_PKA_MspInit(PKA_HandleTypeDef* hpka) +{ + if(hpka->Instance==PKA) + { + /* Peripheral clock enable */ + __HAL_RCC_PKA_CLK_ENABLE(); + } +} + +/* This value is unused, the function is never called + * as long as the timeout is 0xFFFFFFFF. + * It is defined here only to avoid a compiler error + * for a missing symbol in hal_pka_driver. + */ +uint32_t HAL_GetTick(void) +{ + return 0; +} + +#endif diff --git a/lib/wolfssl b/lib/wolfssl index 50fbdb961f..0fe5d40507 160000 --- a/lib/wolfssl +++ b/lib/wolfssl @@ -1 +1 @@ -Subproject commit 50fbdb961fd8c2d8123064e567ae8ec44167732d +Subproject commit 0fe5d40507e42945d5bc9aefb653ebb0b9f32cf3 diff --git a/test-app/app_stm32f7.c b/test-app/app_stm32f7.c index a2c0ced5dc..9df75f1722 100644 --- a/test-app/app_stm32f7.c +++ b/test-app/app_stm32f7.c @@ -30,8 +30,8 @@ /* UART module */ #define UART1_PIN_AF 7 -#define UART1_RX_PIN 10 -#define UART1_TX_PIN 9 +#define UART1_RX_PIN 10 +#define UART1_TX_PIN 9 #define UART1 (0x40011000) #define UART1_CR1 (*(volatile uint32_t *)(UART1 + 0x00)) #define UART1_CR2 (*(volatile uint32_t *)(UART1 + 0x04)) @@ -278,7 +278,7 @@ void uart_update_mgr(void) #define LED_BOOT_PIN (4) #define LED_USR_PIN (12) -void boot_led_on(void) +static void boot_led_on(void) { uint32_t reg; uint32_t pin = LED_BOOT_PIN; @@ -290,7 +290,7 @@ void boot_led_on(void) GPIOD_BSRR |= (1 << pin); } -void boot_led_off(void) +static void boot_led_off(void) { GPIOD_BSRR |= (1 << (LED_BOOT_PIN + 16)); } diff --git a/test-app/app_stm32wb.c b/test-app/app_stm32wb.c index c91f9dca9f..48f999407b 100644 --- a/test-app/app_stm32wb.c +++ b/test-app/app_stm32wb.c @@ -29,6 +29,7 @@ #ifdef PLATFORM_stm32wb +volatile uint32_t time_elapsed = 0; void main(void) { boot_led_on(); /* Wait for reboot */ @@ -36,4 +37,3 @@ void main(void) { ; } #endif /** PLATFROM_stm32wb **/ - diff --git a/tools/config.mk b/tools/config.mk index a93b8ea3e0..f350a7b2a6 100644 --- a/tools/config.mk +++ b/tools/config.mk @@ -8,6 +8,7 @@ ifeq ($(ARCH),) KINETIS_DRIVERS?=$(KINETIS)/devices/MK64F12 KINETIS_CMSIS?=$(KINETIS)/CMSIS FREEDOM_E_SDK?=$(HOME)/src/freedom-e-sdk + STM32CUBE?=$(HOME)/src/STM32CubeWB/STM32Cube_FW_WB_V1.2.0 DEBUG?=0 VTOR?=1 CORTEX_M0?=0 @@ -31,7 +32,7 @@ endif CONFIG_VARS:= ARCH TARGET SIGN KINETIS KINETIS_CPU KINETIS_DRIVERS \ - KINETIS_CMSIS FREEDOM_E_SDK DEBUG VTOR CORTEX_M0 NO_ASM EXT_FLASH \ + KINETIS_CMSIS FREEDOM_E_SDK STM32CUBE DEBUG VTOR CORTEX_M0 NO_ASM EXT_FLASH \ SPI_FLASH ALLOW_DOWNGRADE NVM_FLASH_WRITEONCE WOLFBOOT_VERSION V \ SPMATH RAM_CODE DUALBANK_SWAP IMAGE_HEADER_SIZE \ WOLFBOOT_PARTITION_SIZE WOLFBOOT_SECTOR_SIZE \