Skip to content

Commit 2546ebc

Browse files
dgarskedanielinux
authored andcommitted
Fixes for unused variables. Also repaired STM32WB55 build with PKA
1 parent e6383d7 commit 2546ebc

39 files changed

+106
-132
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)
@@ -469,7 +473,7 @@ utilsclean: clean
469473
$(Q)$(MAKE) -C tools/test-update-server -s clean
470474
$(Q)$(MAKE) -C tools/uart-flash-server -s clean
471475
$(Q)$(MAKE) -C tools/unit-tests -s clean
472-
$(Q)if [ "$(WOLFHSM_CLIENT)" = "1" ]; then $(MAKE) -C lib/wolfHSM/tools/whnvmtool -s clean; fi
476+
$(Q)if [ "$(WOLFHSM_CLIENT)" = "1" ]; then $(MAKE) -C $(WOLFBOOT_LIB_WOLFHSM)/tools/whnvmtool -s clean; fi
473477
$(Q)$(MAKE) -C tools/keytools/otp -s clean
474478
$(Q)$(MAKE) -C tools/squashelf -s clean
475479

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

@@ -1180,15 +1183,15 @@ ifeq ($(ARCH), AURIX_TC3)
11801183
# Common wolfHSM port files
11811184
CFLAGS += -I$(WOLFHSM_INFINEON_TC3XX)/port -DWOLFHSM_CFG_DMA
11821185
OBJS += $(WOLFHSM_INFINEON_TC3XX)/port/tchsm_common.o \
1183-
$(WOLFHSM_INFINEON_TC3XX)/port/tchsm_hsmhost.o
1186+
$(WOLFHSM_INFINEON_TC3XX)/port/tchsm_hsmhost.o
11841187
# General wolfHSM files
11851188
OBJS += $(WOLFBOOT_LIB_WOLFHSM)/src/wh_transport_mem.o
11861189

11871190
# NVM image generation variables
11881191
WH_NVM_BIN ?= whNvmImage.bin
11891192
WH_NVM_HEX ?= whNvmImage.hex
11901193
WH_NVM_PART_SIZE ?= 0x8000
1191-
# Default to base of HSM DFLASH1
1194+
# Default to base of HSM DFLASH1
11921195
WH_NVM_BASE_ADDRESS ?= 0xAFC00000
11931196

11941197
# Select config file based on certificate chain verification
@@ -1225,25 +1228,25 @@ ifeq ($(ARCH), AURIX_TC3)
12251228

12261229
LSCRIPT_IN=hal/$(TARGET)_hsm.ld
12271230

1228-
# wolfHSM port server-specific files
1231+
# wolfHSM port server-specific files
12291232
ifeq ($(WOLFHSM_SERVER),1)
12301233
USE_GCC_HEADLESS=0
12311234

12321235
CFLAGS += -I$(WOLFHSM_INFINEON_TC3XX)/port/server
12331236

12341237
OBJS += $(WOLFHSM_INFINEON_TC3XX)/port/server/port_halflash_df1.o \
1235-
$(WOLFHSM_INFINEON_TC3XX)/port/server/io.o \
1236-
$(WOLFHSM_INFINEON_TC3XX)/port/server/sysmem.o \
1237-
$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_hh_hsm.o \
1238-
$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_utils.o
1239-
1240-
# SW only for now, as we dont have the right protection macros
1241-
#$(WOLFHSM_INFINEON_TC3XX)/port/server/ccb_hsm.o \
1242-
#$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_hash.o \
1243-
#$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_aes.o \
1244-
#$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_cmac.o \
1245-
#$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_pk.o \
1246-
#$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_trng.o
1238+
$(WOLFHSM_INFINEON_TC3XX)/port/server/io.o \
1239+
$(WOLFHSM_INFINEON_TC3XX)/port/server/sysmem.o \
1240+
$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_hh_hsm.o \
1241+
$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_utils.o
1242+
1243+
# SW only for now, as we dont have the right protection macros
1244+
#$(WOLFHSM_INFINEON_TC3XX)/port/server/ccb_hsm.o \
1245+
#$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_hash.o \
1246+
#$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_aes.o \
1247+
#$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_cmac.o \
1248+
#$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_pk.o \
1249+
#$(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_trng.o
12471250
endif
12481251

12491252
# 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
@@ -487,7 +487,6 @@ static uint32_t hal_shm_status_wait(ShmInfo_t* info, uint32_t status,
487487
uint32_t timeout_ms)
488488
{
489489
uint32_t status_ret = SHARED_STATUS_UNKNOWN;
490-
int ret = 0;
491490

492491
do {
493492
/* see if status shared already */
@@ -566,7 +565,7 @@ static void hal_net_check_version(void)
566565
{
567566
int ret;
568567
struct wolfBoot_image img;
569-
uint32_t timeout, status = 0;
568+
uint32_t status = 0;
570569

571570
#ifdef TARGET_nrf5340_app
572571
/* check the network core version */
@@ -682,7 +681,7 @@ static void hal_net_check_version(void)
682681
}
683682
/* proceed to update_flash routines */
684683
#endif /* TARGET_nrf5340_* */
685-
exit:
684+
(void)status;
686685
wolfBoot_printf("Status: App %s (ver %d), Net %s (ver %d)\n",
687686
hal_shm_status_string(shm->core.app.status), shm->core.app.version,
688687
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)