Skip to content

Commit 90d5de4

Browse files
committed
Fixes for unused variables. Also repaired STM32WB55 build with PKA
1 parent 4e1c9f0 commit 90d5de4

39 files changed

+106
-134
lines changed

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,12 @@ CFLAGS+= \
104104

105105
# Setup default optimizations (for GCC)
106106
ifeq ($(USE_GCC_HEADLESS),1)
107-
CFLAGS+=-Wall -Wextra -Wno-main -ffreestanding -Wno-unused -nostartfiles
107+
CFLAGS+=-Wall -Wextra -Wno-main -ffreestanding -nostartfiles
108108
CFLAGS+=-ffunction-sections -fdata-sections -fomit-frame-pointer
109+
# Allow unused parameters and functions
110+
CFLAGS+=-Wno-unused-parameter -Wno-unused-function
111+
# Error on unused variables
112+
CFLAGS+=-Wunused-variable
109113
LDFLAGS+=-Wl,-gc-sections -Wl,-Map=wolfboot.map -ffreestanding -nostartfiles
110114
# Not setting LDFLAGS directly since it is passed to the test-app
111115
LSCRIPT_FLAGS+=-T $(LSCRIPT)
@@ -465,7 +469,7 @@ utilsclean: clean
465469
$(Q)$(MAKE) -C tools/test-update-server -s clean
466470
$(Q)$(MAKE) -C tools/uart-flash-server -s clean
467471
$(Q)$(MAKE) -C tools/unit-tests -s clean
468-
$(Q)if [ "$(WOLFHSM_CLIENT)" = "1" ]; then $(MAKE) -C lib/wolfHSM/tools/whnvmtool -s clean; fi
472+
$(Q)if [ "$(WOLFHSM_CLIENT)" = "1" ]; then $(MAKE) -C $(WOLFBOOT_LIB_WOLFHSM)/tools/whnvmtool -s clean; fi
469473
$(Q)$(MAKE) -C tools/keytools/otp -s clean
470474
$(Q)$(MAKE) -C tools/squashelf -s clean
471475

arch.mk

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ ifeq ($(ARCH),AARCH64)
106106
CFLAGS+=$(ARCH_FLAGS) -DWOLFSSL_ARMASM -DWOLFSSL_ARMASM_INLINE -DWC_HASH_DATA_ALIGNMENT=8 -DWOLFSSL_AARCH64_PRIVILEGE_MODE
107107
WOLFCRYPT_OBJS += $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/cpuid.o \
108108
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/arm/armv8-sha512-asm_c.o \
109-
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/arm/armv8-sha3-asm_c.o
109+
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/arm/armv8-sha3-asm_c.o \
110+
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/arm/armv8-aes-asm_c.o \
111+
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/arm/armv8-sha256-asm_c.o
110112
endif
111113
endif
112114

@@ -190,13 +192,14 @@ ifeq ($(ARCH),ARM)
190192
ARCH_FLASH_OFFSET=0x08000000
191193
SPI_TARGET=stm32
192194
ifneq ($(PKA),0)
193-
PKA_EXTRA_OBJS+= $(STM32CUBE)/Drivers/STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_pka.o $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/st/stm32.o
194-
PKA_EXTRA_CFLAGS+=-DWOLFSSL_STM32_PKA -I$(STM32CUBE)/Drivers/STM32WBxx_HAL_Driver/Inc \
195-
-Isrc -I$(STM32CUBE)/Drivers/BSP/P-NUCLEO-WB55.Nucleo/ -I$(STM32CUBE)/Drivers/CMSIS/Device/ST/STM32WBxx/Include \
196-
-I$(STM32CUBE)/Drivers/STM32WBxx_HAL_Driver/Inc/ \
197-
-I$(STM32CUBE)/Drivers/CMSIS/Include \
198-
-Ihal \
199-
-DSTM32WB55xx
195+
PKA_EXTRA_OBJS+= $(STM32CUBE)/Drivers/STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_pka.o $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/st/stm32.o
196+
PKA_EXTRA_CFLAGS+=-DWOLFSSL_STM32WB -DWOLFSSL_STM32_PKA -DWOLFSSL_STM32_CUBEMX -DNO_STM32_HASH -DSTM32WB55xx
197+
PKA_EXTRA_CFLAGS+=-Isrc -Ihal \
198+
-I$(STM32CUBE)/Drivers/STM32WBxx_HAL_Driver/Inc \
199+
-I$(STM32CUBE)/Drivers/BSP/P-NUCLEO-WB55.Nucleo/ \
200+
-I$(STM32CUBE)/Drivers/CMSIS/Device/ST/STM32WBxx/Include \
201+
-I$(STM32CUBE)/Drivers/STM32WBxx_HAL_Driver/Inc \
202+
-I$(STM32CUBE)/Drivers/CMSIS/Include
200203
endif
201204
endif
202205

@@ -1174,15 +1177,15 @@ ifeq ($(ARCH), AURIX_TC3)
11741177
# Common wolfHSM port files
11751178
CFLAGS += -I$(WOLFHSM_INFINEON_TC3XX)/port -DWOLFHSM_CFG_DMA
11761179
OBJS += $(WOLFHSM_INFINEON_TC3XX)/port/tchsm_common.o \
1177-
$(WOLFHSM_INFINEON_TC3XX)/port/tchsm_hsmhost.o
1180+
$(WOLFHSM_INFINEON_TC3XX)/port/tchsm_hsmhost.o
11781181
# General wolfHSM files
11791182
OBJS += $(WOLFBOOT_LIB_WOLFHSM)/src/wh_transport_mem.o
11801183

11811184
# NVM image generation variables
11821185
WH_NVM_BIN ?= whNvmImage.bin
11831186
WH_NVM_HEX ?= whNvmImage.hex
11841187
WH_NVM_PART_SIZE ?= 0x8000
1185-
# Default to base of HSM DFLASH1
1188+
# Default to base of HSM DFLASH1
11861189
WH_NVM_BASE_ADDRESS ?= 0xAFC00000
11871190

11881191
# Select config file based on certificate chain verification
@@ -1219,25 +1222,25 @@ ifeq ($(ARCH), AURIX_TC3)
12191222

12201223
LSCRIPT_IN=hal/$(TARGET)_hsm.ld
12211224

1222-
# wolfHSM port server-specific files
1225+
# wolfHSM port server-specific files
12231226
ifeq ($(WOLFHSM_SERVER),1)
12241227
USE_GCC_HEADLESS=0
12251228

12261229
CFLAGS += -I$(WOLFHSM_INFINEON_TC3XX)/port/server
12271230

12281231
OBJS += $(WOLFHSM_INFINEON_TC3XX)/port/server/port_halflash_df1.o \
1229-
$(WOLFHSM_INFINEON_TC3XX)/port/server/io.o \
1230-
$(WOLFHSM_INFINEON_TC3XX)/port/server/sysmem.o \
1231-
$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_hh_hsm.o \
1232-
$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_utils.o
1233-
1234-
# SW only for now, as we dont have the right protection macros
1235-
#$(WOLFHSM_INFINEON_TC3XX)/port/server/ccb_hsm.o \
1236-
#$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_hash.o \
1237-
#$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_aes.o \
1238-
#$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_cmac.o \
1239-
#$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_pk.o \
1240-
#$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_trng.o
1232+
$(WOLFHSM_INFINEON_TC3XX)/port/server/io.o \
1233+
$(WOLFHSM_INFINEON_TC3XX)/port/server/sysmem.o \
1234+
$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_hh_hsm.o \
1235+
$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_utils.o
1236+
1237+
# SW only for now, as we dont have the right protection macros
1238+
#$(WOLFHSM_INFINEON_TC3XX)/port/server/ccb_hsm.o \
1239+
#$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_hash.o \
1240+
#$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_aes.o \
1241+
#$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_cmac.o \
1242+
#$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_pk.o \
1243+
#$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_trng.o
12411244
endif
12421245

12431246
# HSM BSP specific object files

config/examples/stm32l4-cube.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ SPMATH?=1
1515
RAM_CODE?=0
1616
DUALBANK_SWAP?=0
1717
IMAGE_HEADER_SIZE?=0x200
18-
STM32CUBE?=$(HOME)/STM32Cube/Repository/STM32Cube_FW_L4_V1.17.0
18+
STM32CUBE?=$(HOME)/STM32Cube/Repository/STM32Cube_FW_L4_V1.18.1
1919
WOLFBOOT_SECTOR_SIZE=0x1000
2020
WOLFBOOT_PARTITION_SIZE=0x7A000
2121
WOLFBOOT_PARTITION_BOOT_ADDRESS=0x0800A000

config/examples/stm32wb-pka-1mb.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ WOLFBOOT_PARTITION_UPDATE_ADDRESS=0x08083800
88
WOLFBOOT_PARTITION_SWAP_ADDRESS=0x080FF000
99
NVM_FLASH_WRITEONCE=1
1010
PKA=1
11+
STM32CUBE?=$(HOME)/STM32Cube/Repository/STM32Cube_FW_WB_V1.23.0
12+
NO_ARM_ASM=1

docs/wolfHSM.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ make test-sim-internal-flash-with-update
144144

145145
#### wolfHSM Server Mode Build
146146

147-
To build the simulator configured to use embedded wolfHSM server mode, use the `WOLFHSM_SERVER=1` makefile option. In this mode, wolfBoot includes the complete wolfHSM server and no external HSM server is required. Currently the wolfHSM server only supporst the certificate chain verification mode of authentication.
147+
To build the simulator configured to use embedded wolfHSM server mode, use the `WOLFHSM_SERVER=1` makefile option. In this mode, wolfBoot includes the complete wolfHSM server and no external HSM server is required. Currently the wolfHSM server only supports the certificate chain verification mode of authentication.
148148

149149
```sh
150150
# Grab the HSM server simulator configuration (with certificate chain verification)
@@ -228,7 +228,7 @@ When using wolfHSM server mode, no external server is required. wolfBoot include
228228
# Create a simulated NVM image for the POSIX flash file simulator containing the dummy root CA for cert chain verification.
229229
# You must build whnvmtool first if you haven't already, and ensure the file name matches the simulated NVM image file
230230
# name in hal/sim.c
231-
./lib/wolfHSM/tools/whnvmtool/whnvmtool --image=wolfBoot_wolfHSM_NVM.bin --size 16348 --invert-erased-byte tools/scripts/wolfBoot-wolfHSM-sim-dummy-certchain.nvminit
231+
./lib/wolfHSM/tools/whnvmtool/whnvmtool --image=wolfBoot_wolfHSM_NVM.bin --size 16348 --invert-erased-byte tools/scripts/wolfBoot-wolfHSM-sim-dummy-certchain.nvminit
232232

233233
# Run the wolfBoot simulator with embedded wolfHSM server to stage an update
234234
./wolfboot.elf update_trigger get_version

hal/lpc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include "fsl_flashiap.h"
2727
#include "fsl_power.h"
2828

29-
static int flash_init = 0;
3029
uint32_t SystemCoreClock;
3130

3231
#ifdef NVM_FLASH_WRITEONCE

hal/mcxa.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#define BOARD_BOOTCLOCKFRO96M_CORE_CLOCK 96000000UL
3737

3838
static flash_config_t pflash;
39-
static int flash_init = 0;
4039

4140
uint32_t SystemCoreClock;
4241

hal/nrf5340.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,6 @@ static uint32_t hal_shm_status_wait(ShmInfo_t* info, uint32_t status,
479479
uint32_t timeout_ms)
480480
{
481481
uint32_t status_ret = SHARED_STATUS_UNKNOWN;
482-
int ret = 0;
483482

484483
do {
485484
/* see if status shared already */
@@ -558,7 +557,7 @@ static void hal_net_check_version(void)
558557
{
559558
int ret;
560559
struct wolfBoot_image img;
561-
uint32_t timeout, status = 0;
560+
uint32_t status = 0;
562561

563562
#ifdef TARGET_nrf5340_app
564563
/* check the network core version */
@@ -674,7 +673,7 @@ static void hal_net_check_version(void)
674673
}
675674
/* proceed to update_flash routines */
676675
#endif /* TARGET_nrf5340_* */
677-
exit:
676+
(void)status;
678677
wolfBoot_printf("Status: App %s (ver %d), Net %s (ver %d)\n",
679678
hal_shm_status_string(shm->core.app.status), shm->core.app.version,
680679
hal_shm_status_string(shm->core.net.status), shm->core.net.version);

hal/nxp_ls1028a.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,6 @@ void xspi_flash_write(uintptr_t address, const uint8_t *data, uint32_t len)
537537
{
538538
uint32_t size = 0;
539539
uint32_t tx_data = 0;
540-
uint32_t size_wm = 0;
541540
uint32_t loop_cnt = 0;
542541
uint32_t remaining, rem_size = 0;
543542
uint32_t i = 0, j = 0;
@@ -839,8 +838,6 @@ void hal_init(void)
839838
{
840839
volatile uint32_t counter=0xFFFFul; /* used for delay */
841840
#ifdef DEBUG_UART
842-
uint32_t fw;
843-
844841
uart_init();
845842
wolfBoot_printf("wolfBoot Init\n");
846843
#endif

hal/nxp_p1021.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,10 +1164,7 @@ static void config_io_pin(uint8_t port, uint8_t pin, int dir, int open_drain,
11641164

11651165
static void read_io_pin(uint8_t port, uint8_t pin, int *data)
11661166
{
1167-
uint32_t pin_1bit_mask, tmp_val;
1168-
1169-
/* Calculate pin location for 1bit mask */
1170-
pin_1bit_mask = (uint32_t)(1 << (NUM_OF_PINS - (pin + 1)));
1167+
uint32_t tmp_val;
11711168

11721169
/* Read the data */
11731170
tmp_val = get32(GUTS_CPDAT(port));
@@ -1299,7 +1296,9 @@ static void qe_upload_microcode(const struct qe_firmware *firmware,
12991296
static int qe_upload_firmware(const struct qe_firmware *firmware)
13001297
{
13011298
unsigned int i, j;
1299+
#ifdef ENABLE_QE_CRC32
13021300
uint32_t crc;
1301+
#endif
13031302
size_t calc_size = sizeof(struct qe_firmware);
13041303
size_t length;
13051304
const struct qe_header *hdr;
@@ -1567,6 +1566,7 @@ static void hal_irq_init(void)
15671566

15681567
set32(PIC_GCR, PIC_GCR_M); /* eanble mixed-mode */
15691568
reg = get32(PIC_GCR); /* read back */
1569+
(void)reg;
15701570
}
15711571
#endif
15721572

@@ -1685,6 +1685,7 @@ int ext_flash_write(uintptr_t address, const uint8_t *data, int len)
16851685
ELBC_FIR_OP(4, ELBC_FIR_OP_WB) |
16861686
ELBC_FIR_OP(5, ELBC_FIR_OP_CW1));
16871687
#endif
1688+
(void)block_size; /* not used - shown for reference */
16881689

16891690
/* page write loop */
16901691
while (pos < len) {
@@ -1717,6 +1718,7 @@ int ext_flash_write(uintptr_t address, const uint8_t *data, int len)
17171718
wolfBoot_printf("write page %d, col %d, status %x\n",
17181719
page, col, status);
17191720
#endif
1721+
(void)status;
17201722
address += page_size - col;
17211723
pos += page_size - col;
17221724
data += page_size - col;
@@ -1857,6 +1859,7 @@ int ext_flash_erase(uintptr_t address, int len)
18571859
#ifdef DEBUG_EXT_FLASH
18581860
wolfBoot_printf("erase page %d, status %x\n", page, status);
18591861
#endif
1862+
(void)status;
18601863
len -= block_size;
18611864
}
18621865

0 commit comments

Comments
 (0)