Skip to content

Commit 3aaf863

Browse files
authored
Merge pull request #24 from danielinux/stm32-pka
Support for STM32 PKHA
2 parents 1c6ea8d + dfbb027 commit 3aaf863

9 files changed

Lines changed: 85 additions & 13 deletions

File tree

arch.mk

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,15 @@ ifeq ($(TARGET),kinetis)
9696
## ECC_EXTRA_OBJS+=./lib/wolfssl/wolfcrypt/src/port/nxp/ksdk_port.o $(KINETIS_DRIVERS)/drivers/fsl_ltc.o
9797
##endif
9898
endif
99+
100+
ifeq ($(TARGET),stm32wb)
101+
ifneq ($(PKA),0)
102+
ECC_EXTRA_OBJS+= $(STM32CUBE)/Drivers/STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_pka.o ./lib/wolfssl/wolfcrypt/src/port/st/stm32.o
103+
ECC_EXTRA_CFLAGS+=-DWOLFSSL_STM32_PKA -I$(STM32CUBE)/Drivers/STM32WBxx_HAL_Driver/Inc \
104+
-Isrc -I$(STM32CUBE)/Drivers/BSP/P-NUCLEO-WB55.Nucleo/ -I$(STM32CUBE)/Drivers/CMSIS/Device/ST/STM32WBxx/Include \
105+
-I$(STM32CUBE)/Drivers/STM32WBxx_HAL_Driver/Inc/ \
106+
-I$(STM32CUBE)/Drivers/CMSIS/Include \
107+
-Ihal \
108+
-DSTM32WB55xx
109+
endif
110+
endif
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
ARCH?=ARM
2+
TARGET?=kinetis
3+
SIGN?=ECC256
4+
KINETIS?=$(HOME)/src/FRDM-K82F
5+
KINETIS_CPU?=MK82FN256VLL15
6+
KINETIS_DRIVERS?=$(KINETIS)/devices/MK82F25615
7+
KINETIS_CMSIS?=$(HOME)/src/FRDM-K64F/CMSIS
8+
FREEDOM_E_SDK?=$(HOME)/src/freedom-e-sdk
9+
DEBUG?=0
10+
VTOR?=1
11+
CORTEX_M0?=0
12+
NO_ASM?=0
13+
EXT_FLASH?=0
14+
SPI_FLASH?=0
15+
ALLOW_DOWNGRADE?=0
16+
NVM_FLASH_WRITEONCE?=1
17+
WOLFBOOT_VERSION?=0
18+
V?=0
19+
SPMATH?=1
20+
RAM_CODE?=0
21+
DUALBANK_SWAP?=0
22+
IMAGE_HEADER_SIZE?=256
23+
WOLFBOOT_PARTITION_SIZE?=0x7A000
24+
WOLFBOOT_SECTOR_SIZE?=0x1000
25+
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0xA000
26+
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x84000
27+
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0xff000

config/examples/stm32wb-small.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ TARGET=stm32wb
22
SIGN=ECC256
33
WOLFBOOT_PARTITION_BOOT_ADDRESS=0xA000
44
WOLFBOOT_PARTITION_SIZE=0x4000
5+
PKA=1

docs/Targets.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Example partitioning on Nucleo-68 board:
9494

9595
- Sector size: 4KB
9696
- Wolfboot partition size: 32 KB
97-
- Applicatiobn partition size: 128 KB
97+
- Application partition size: 128 KB
9898

9999
```C
100100
#define WOLFBOOT_SECTOR_SIZE 0x1000 /* 4 KB */
@@ -260,7 +260,7 @@ reset
260260
halt
261261
```
262262

263-
OpenOCD can be either run in background (to allow remote GDB and monitor terminal connections), or
263+
OpenOCD can be either run in background (to allow remote GDB and monitor terminal connections), or
264264
directly from command line, to execute terminal scripts.
265265

266266
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
293293
If the accepted candidate image resides on BANK B (like in this case), wolfBoot will perform one bank swap before
294294
booting.
295295

296-
The bank-swap operation is immediate and a SWAP image is not required in this case. Fallback mechanism can rely on
296+
The bank-swap operation is immediate and a SWAP image is not required in this case. Fallback mechanism can rely on
297297
a second choice (older firmware) in the other bank.
298298

299299

@@ -309,5 +309,3 @@ From another console, connect using gdb, e.g.:
309309
arm-none-eabi-gdb
310310
(gdb) target remote:3333
311311
```
312-
313-

hal/stm32wb.c

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@
2020
*/
2121

2222
#include <stdint.h>
23-
#include <image.h>
23+
#include "image.h"
24+
#ifdef WOLFSSL_STM32_PKA
25+
#include "stm32wbxx_hal.h"
26+
PKA_HandleTypeDef hpka = { };
27+
#endif
28+
2429
/* STM32 WB register configuration */
2530

2631
/* Assembly helpers */
@@ -286,6 +291,11 @@ static void clock_pll_on(void)
286291
void hal_init(void)
287292
{
288293
clock_pll_on();
294+
#ifdef WOLFSSL_STM32_PKA
295+
__HAL_RCC_PKA_CLK_ENABLE();
296+
hpka.Instance = PKA;
297+
HAL_PKA_Init(&hpka);
298+
#endif
289299
}
290300

291301
void hal_prepare_boot(void)
@@ -297,3 +307,26 @@ void hal_prepare_boot(void)
297307
clock_pll_off();
298308
}
299309

310+
#ifdef WOLFSSL_STM32_PKA
311+
312+
313+
void HAL_PKA_MspInit(PKA_HandleTypeDef* hpka)
314+
{
315+
if(hpka->Instance==PKA)
316+
{
317+
/* Peripheral clock enable */
318+
__HAL_RCC_PKA_CLK_ENABLE();
319+
}
320+
}
321+
322+
/* This value is unused, the function is never called
323+
* as long as the timeout is 0xFFFFFFFF.
324+
* It is defined here only to avoid a compiler error
325+
* for a missing symbol in hal_pka_driver.
326+
*/
327+
uint32_t HAL_GetTick(void)
328+
{
329+
return 0;
330+
}
331+
332+
#endif

lib/wolfssl

Submodule wolfssl updated 368 files

test-app/app_stm32f7.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030

3131
/* UART module */
3232
#define UART1_PIN_AF 7
33-
#define UART1_RX_PIN 10
34-
#define UART1_TX_PIN 9
33+
#define UART1_RX_PIN 10
34+
#define UART1_TX_PIN 9
3535
#define UART1 (0x40011000)
3636
#define UART1_CR1 (*(volatile uint32_t *)(UART1 + 0x00))
3737
#define UART1_CR2 (*(volatile uint32_t *)(UART1 + 0x04))
@@ -278,7 +278,7 @@ void uart_update_mgr(void)
278278

279279
#define LED_BOOT_PIN (4)
280280
#define LED_USR_PIN (12)
281-
void boot_led_on(void)
281+
static void boot_led_on(void)
282282
{
283283
uint32_t reg;
284284
uint32_t pin = LED_BOOT_PIN;
@@ -290,7 +290,7 @@ void boot_led_on(void)
290290
GPIOD_BSRR |= (1 << pin);
291291
}
292292

293-
void boot_led_off(void)
293+
static void boot_led_off(void)
294294
{
295295
GPIOD_BSRR |= (1 << (LED_BOOT_PIN + 16));
296296
}

test-app/app_stm32wb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929

3030
#ifdef PLATFORM_stm32wb
3131

32+
volatile uint32_t time_elapsed = 0;
3233
void main(void) {
3334
boot_led_on();
3435
/* Wait for reboot */
3536
while(1)
3637
;
3738
}
3839
#endif /** PLATFROM_stm32wb **/
39-

tools/config.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ ifeq ($(ARCH),)
88
KINETIS_DRIVERS?=$(KINETIS)/devices/MK64F12
99
KINETIS_CMSIS?=$(KINETIS)/CMSIS
1010
FREEDOM_E_SDK?=$(HOME)/src/freedom-e-sdk
11+
STM32CUBE?=$(HOME)/src/STM32CubeWB/STM32Cube_FW_WB_V1.2.0
1112
DEBUG?=0
1213
VTOR?=1
1314
CORTEX_M0?=0
@@ -31,7 +32,7 @@ endif
3132

3233

3334
CONFIG_VARS:= ARCH TARGET SIGN KINETIS KINETIS_CPU KINETIS_DRIVERS \
34-
KINETIS_CMSIS FREEDOM_E_SDK DEBUG VTOR CORTEX_M0 NO_ASM EXT_FLASH \
35+
KINETIS_CMSIS FREEDOM_E_SDK STM32CUBE DEBUG VTOR CORTEX_M0 NO_ASM EXT_FLASH \
3536
SPI_FLASH ALLOW_DOWNGRADE NVM_FLASH_WRITEONCE WOLFBOOT_VERSION V \
3637
SPMATH RAM_CODE DUALBANK_SWAP IMAGE_HEADER_SIZE \
3738
WOLFBOOT_PARTITION_SIZE WOLFBOOT_SECTOR_SIZE \

0 commit comments

Comments
 (0)