From 678781db39a3b5196c532393de70f1323e3d767f Mon Sep 17 00:00:00 2001 From: Brett Nicholas <7547222+bigbrett@users.noreply.github.com> Date: Thu, 10 Sep 2026 10:19:08 -0600 Subject: [PATCH] AURIX tc3 ARCH/TARGET refactor anticipating TC4xx --- Makefile | 2 +- arch.mk | 42 +++++++++++++------ config/examples/aurix-tc375-ecc.config | 2 +- config/examples/aurix-tc375-elf-ecc.config | 2 +- .../aurix-tc375-elf-wolfHSM-certs-ecc.config | 2 +- ...rix-tc375-elf-wolfHSM-certs-rsa4096.config | 2 +- .../aurix-tc375-elf-wolfHSM-ecc.config | 2 +- config/examples/aurix-tc375-hsm-ecc.config | 5 +-- ...lithic-update-wolfHSM-certs-rsa4096.config | 5 +-- ...m-self-update-wolfHSM-certs-rsa4096.config | 5 +-- .../aurix-tc375-hsm-wolfHSM-certs-ecc.config | 5 +-- ...rix-tc375-hsm-wolfHSM-certs-rsa4096.config | 5 +-- docs/Targets.md | 2 + hal/aurix_tc3xx.c | 13 +++--- hal/aurix_tc3xx_hsm.c | 23 ++++++++++ hal/tc3_cfg.h | 2 +- options.mk | 4 +- test-app/Makefile | 10 ++--- test-app/app_aurix_tc3xx_hsm.c | 22 ++++++++++ test-app/tc3_cfg.h | 2 +- 20 files changed, 109 insertions(+), 48 deletions(-) create mode 100644 hal/aurix_tc3xx_hsm.c create mode 100644 test-app/app_aurix_tc3xx_hsm.c diff --git a/Makefile b/Makefile index c8845884..1c402b03 100644 --- a/Makefile +++ b/Makefile @@ -274,7 +274,7 @@ ifeq ($(ARCH),C2000) # cl2000 enters link mode via -z (in LDFLAGS); the .cmd is a positional arg. LSCRIPT_FLAGS+=$(LSCRIPT) endif -ifeq ($(ARCH),AURIX_TC3) +ifeq ($(ARCH),AURIX) ifneq ($(USE_GCC_HEADLESS),1) LSCRIPT_FLAGS+=-T $(LSCRIPT) endif diff --git a/arch.mk b/arch.mk index 1e873241..04806b93 100644 --- a/arch.mk +++ b/arch.mk @@ -2171,10 +2171,30 @@ ifeq ($(ARCH),C2000) $(Q)$(CC) $(CFLAGS) -c $(OUTPUT_FLAG) $@ $^ endif -# Infineon AURIX Tricore -ifeq ($(ARCH), AURIX_TC3) - # TC3xx specific - ifeq ($(TARGET), aurix_tc3xx) +# Infineon AURIX platforms +# +# TC3xx SoCs are a heterogeneous architecture with ARM and Tricore CPUs, but are +# grouped together in wolfBoot under ARCH=AURIX, since platform support is +# different enough from existing ARCH variants to not share things like compiler +# flags or startup code. +# +# TARGET=aurix_tc3xx: AURIX TC3xx TriCore host +# TARGET=aurix_tc3xx_hsm: AURIX TC3xx Cortex-M3 HSM core +# TARGET=aurix_tc4xx: AURIX TC4xx Tricore host (coming soon) + +# Backwards compatibility migration error for legacy ARCH=AURIX_TC3 +ifeq ($(filter clean keysclean,$(MAKECMDGOALS)),) + ifeq ($(ARCH),AURIX_TC3) + $(error ARCH=AURIX_TC3 was renamed to ARCH=AURIX) + endif + ifeq ($(AURIX_TC3_HSM),1) + $(error AURIX_TC3_HSM=1 was replaced by TARGET=aurix_tc3xx_hsm) + endif +endif + +ifeq ($(ARCH), AURIX) + # TC3xx HSM and host cores + ifneq (,$(filter aurix_tc3xx aurix_tc3xx_hsm,$(TARGET))) USE_GCC?=1 CFLAGS += -I$(TC3_DIR) -Ihal @@ -2230,7 +2250,8 @@ ifeq ($(ARCH), AURIX_TC3) BOOT_IMG=test-app/image.elf endif - ifeq ($(AURIX_TC3_HSM),1) + ifeq ($(TARGET), aurix_tc3xx_hsm) + # HSM core (ARM Cortex-M3) ARCH_FLASH_OFFSET?=0x80028000 # HSM compiler flags, build options, source code, etc ifeq ($(USE_GCC),1) @@ -2253,7 +2274,7 @@ ifeq ($(ARCH), AURIX_TC3) endif CFLAGS += -march=armv7-m -mcpu=cortex-m3 -mthumb -mlittle-endian \ - -fno-builtin -DWOLFBOOT_AURIX_TC3XX_HSM + -fno-builtin # Temporary fix masking wolfCrypt unused function warning with RSA_LOW_MEM CFLAGS += -Wno-unused-function @@ -2265,8 +2286,6 @@ ifeq ($(ARCH), AURIX_TC3) -Wl,-Map="wolfboot.map" \ -Wl,-L$(TC3_DIR)/tc3 - LSCRIPT_IN=hal/$(TARGET)_hsm.ld - # wolfHSM port server-specific files ifeq ($(WOLFHSM_SERVER),1) USE_GCC_HEADLESS=0 @@ -2274,7 +2293,6 @@ ifeq ($(ARCH), AURIX_TC3) CFLAGS += -I$(WOLFHSM_INFINEON_TC3XX)/port/server OBJS += $(WOLFHSM_INFINEON_TC3XX)/port/server/port_halflash_df1.o \ - $(WOLFHSM_INFINEON_TC3XX)/port/server/io.o \ $(WOLFHSM_INFINEON_TC3XX)/port/server/sysmem.o \ $(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_hh_hsm.o \ $(WOLFHSM_INFINEON_TC3XX)/port/server/tchsm_utils.o\ @@ -2297,7 +2315,7 @@ ifeq ($(ARCH), AURIX_TC3) $(TC3_DIR)/../tc3arm_bootloader/tc3arm_bootloader.o else - # Tricore compiler settings + # TriCore host core ARCH_FLASH_OFFSET?=0x800A0000 ifeq ($(USE_GCC),1) HT_ROOT?=/opt/hightec/gnutri_v4.9.4.1-11fcedf-lin64 @@ -2357,8 +2375,8 @@ ifeq ($(ARCH), AURIX_TC3) $(WOLFHSM_INFINEON_TC3XX)/port/client/tchsm_hh_host.o endif - endif # !AURIX_TC3_HSM - endif + endif # aurix_tc3xx_hsm + endif # TC3xx # TC4xx specific ifeq ($(TARGET), aurix_tc4xx) diff --git a/config/examples/aurix-tc375-ecc.config b/config/examples/aurix-tc375-ecc.config index 0f7ac970..fe0d35e0 100644 --- a/config/examples/aurix-tc375-ecc.config +++ b/config/examples/aurix-tc375-ecc.config @@ -1,4 +1,4 @@ -ARCH?=AURIX_TC3 +ARCH?=AURIX TARGET?=aurix_tc3xx SIGN?=ECC256 HASH?=SHA256 diff --git a/config/examples/aurix-tc375-elf-ecc.config b/config/examples/aurix-tc375-elf-ecc.config index 5dc89c7a..58bb2fa0 100644 --- a/config/examples/aurix-tc375-elf-ecc.config +++ b/config/examples/aurix-tc375-elf-ecc.config @@ -1,4 +1,4 @@ -ARCH?=AURIX_TC3 +ARCH?=AURIX TARGET?=aurix_tc3xx SIGN?=ECC256 HASH?=SHA256 diff --git a/config/examples/aurix-tc375-elf-wolfHSM-certs-ecc.config b/config/examples/aurix-tc375-elf-wolfHSM-certs-ecc.config index 07a35b77..f84c9929 100644 --- a/config/examples/aurix-tc375-elf-wolfHSM-certs-ecc.config +++ b/config/examples/aurix-tc375-elf-wolfHSM-certs-ecc.config @@ -1,4 +1,4 @@ -ARCH?=AURIX_TC3 +ARCH?=AURIX TARGET?=aurix_tc3xx SIGN?=ECC256 HASH?=SHA256 diff --git a/config/examples/aurix-tc375-elf-wolfHSM-certs-rsa4096.config b/config/examples/aurix-tc375-elf-wolfHSM-certs-rsa4096.config index 303753dd..214fedb7 100644 --- a/config/examples/aurix-tc375-elf-wolfHSM-certs-rsa4096.config +++ b/config/examples/aurix-tc375-elf-wolfHSM-certs-rsa4096.config @@ -1,4 +1,4 @@ -ARCH?=AURIX_TC3 +ARCH?=AURIX TARGET?=aurix_tc3xx SIGN?=RSA4096 HASH?=SHA256 diff --git a/config/examples/aurix-tc375-elf-wolfHSM-ecc.config b/config/examples/aurix-tc375-elf-wolfHSM-ecc.config index fed0044d..7116a133 100644 --- a/config/examples/aurix-tc375-elf-wolfHSM-ecc.config +++ b/config/examples/aurix-tc375-elf-wolfHSM-ecc.config @@ -1,4 +1,4 @@ -ARCH?=AURIX_TC3 +ARCH?=AURIX TARGET?=aurix_tc3xx SIGN?=ECC256 HASH?=SHA256 diff --git a/config/examples/aurix-tc375-hsm-ecc.config b/config/examples/aurix-tc375-hsm-ecc.config index 38db3e0b..983329e9 100644 --- a/config/examples/aurix-tc375-hsm-ecc.config +++ b/config/examples/aurix-tc375-hsm-ecc.config @@ -1,6 +1,5 @@ -ARCH?=AURIX_TC3 -TARGET?=aurix_tc3xx -AURIX_TC3_HSM=1 +ARCH?=AURIX +TARGET?=aurix_tc3xx_hsm SIGN?=ECC256 HASH?=SHA256 DEBUG?=0 diff --git a/config/examples/aurix-tc375-hsm-monolithic-update-wolfHSM-certs-rsa4096.config b/config/examples/aurix-tc375-hsm-monolithic-update-wolfHSM-certs-rsa4096.config index 0e697d64..a6026737 100644 --- a/config/examples/aurix-tc375-hsm-monolithic-update-wolfHSM-certs-rsa4096.config +++ b/config/examples/aurix-tc375-hsm-monolithic-update-wolfHSM-certs-rsa4096.config @@ -1,6 +1,5 @@ -ARCH?=AURIX_TC3 -TARGET?=aurix_tc3xx -AURIX_TC3_HSM=1 +ARCH?=AURIX +TARGET?=aurix_tc3xx_hsm SIGN?=RSA4096 HASH?=SHA256 DEBUG?=0 diff --git a/config/examples/aurix-tc375-hsm-self-update-wolfHSM-certs-rsa4096.config b/config/examples/aurix-tc375-hsm-self-update-wolfHSM-certs-rsa4096.config index 8fb9e847..79dc3c64 100644 --- a/config/examples/aurix-tc375-hsm-self-update-wolfHSM-certs-rsa4096.config +++ b/config/examples/aurix-tc375-hsm-self-update-wolfHSM-certs-rsa4096.config @@ -1,6 +1,5 @@ -ARCH?=AURIX_TC3 -TARGET?=aurix_tc3xx -AURIX_TC3_HSM=1 +ARCH?=AURIX +TARGET?=aurix_tc3xx_hsm SIGN?=RSA4096 HASH?=SHA256 DEBUG?=0 diff --git a/config/examples/aurix-tc375-hsm-wolfHSM-certs-ecc.config b/config/examples/aurix-tc375-hsm-wolfHSM-certs-ecc.config index 9a9bdf7c..bbd84542 100644 --- a/config/examples/aurix-tc375-hsm-wolfHSM-certs-ecc.config +++ b/config/examples/aurix-tc375-hsm-wolfHSM-certs-ecc.config @@ -1,6 +1,5 @@ -ARCH?=AURIX_TC3 -TARGET?=aurix_tc3xx -AURIX_TC3_HSM=1 +ARCH?=AURIX +TARGET?=aurix_tc3xx_hsm SIGN?=ECC256 HASH?=SHA256 DEBUG?=0 diff --git a/config/examples/aurix-tc375-hsm-wolfHSM-certs-rsa4096.config b/config/examples/aurix-tc375-hsm-wolfHSM-certs-rsa4096.config index f4caaa5e..76b012c3 100644 --- a/config/examples/aurix-tc375-hsm-wolfHSM-certs-rsa4096.config +++ b/config/examples/aurix-tc375-hsm-wolfHSM-certs-rsa4096.config @@ -1,6 +1,5 @@ -ARCH?=AURIX_TC3 -TARGET?=aurix_tc3xx -AURIX_TC3_HSM=1 +ARCH?=AURIX +TARGET?=aurix_tc3xx_hsm SIGN?=RSA4096 HASH?=SHA256 DEBUG?=0 diff --git a/docs/Targets.md b/docs/Targets.md index 8f28417f..afb61286 100644 --- a/docs/Targets.md +++ b/docs/Targets.md @@ -8603,6 +8603,8 @@ At this point, the kernel image in partition "A" is verified and staged and you wolfBoot supports the Infineon AURIX TC3xx family and includes a demo application for the TC375 AURIX LiteKit-V2. It can be configured to run on either the TriCore application cores or the HSM core. +Both cores build with `ARCH=AURIX`. `TARGET` selects the core: `aurix_tc3xx` for the TriCore application cores and `aurix_tc3xx_hsm` for the HSM core. Example configurations are in `config/examples/aurix-tc375-*.config`. + On AURIX TC3xx devices, wolfBoot can also integrate with [wolfHSM](https://www.wolfssl.com/products/wolfhsm/) to offload cryptographic operations and key management to the HSM core. Currently, wolfBoot for TC3xx is distributed as part of the wolfHSM TC3xx platform release bundle, not as a standalone package. This bundle is under NDA and is not publicly available. diff --git a/hal/aurix_tc3xx.c b/hal/aurix_tc3xx.c index f179144b..46bb1bb1 100644 --- a/hal/aurix_tc3xx.c +++ b/hal/aurix_tc3xx.c @@ -37,7 +37,8 @@ #ifdef TC3_CFG_HAVE_BOARD #include "tc3/tc3_board.h" #endif -#ifdef WOLFBOOT_AURIX_TC3XX_HSM +/* TARGET_aurix_tc3xx_hsm: HSM core build, see hal/aurix_tc3xx_hsm.c */ +#ifdef TARGET_aurix_tc3xx_hsm #include "tc3/tc3arm.h" #else #include "tc3/tc3tc.h" @@ -297,7 +298,7 @@ void uart_write(const char* buf, unsigned int sz) * the firmware images*/ void hal_init(void) { -#ifndef WOLFBOOT_AURIX_TC3XX_HSM +#ifndef TARGET_aurix_tc3xx_hsm /* Update BTV to use RAM Trap Table */ tc3tc_traps_InitBTV(); @@ -322,7 +323,7 @@ void hal_init(void) #ifdef DEBUG_UART uart_init(); -#ifndef WOLFBOOT_AURIX_TC3XX_HSM +#ifndef TARGET_aurix_tc3xx_hsm wolfBoot_printf("Hello from TC3xx wolfBoot on Tricore: V%d\n", WOLFBOOT_VERSION); #else @@ -356,7 +357,7 @@ void hal_prepare_boot(void) tc3_clock_SetBoot(); -#ifndef WOLFBOOT_AURIX_TC3XX_HSM +#ifndef TARGET_aurix_tc3xx_hsm tc3tc_isr_Cleanup(); tc3tc_traps_DeinitBTV(); @@ -368,7 +369,7 @@ void hal_prepare_boot(void) TC3_ENFORCE_BUS_ERRORS(); } -#ifndef WOLFBOOT_AURIX_TC3XX_HSM +#ifndef TARGET_aurix_tc3xx_hsm void do_boot(const uint32_t* app_offset) { LED_OFF(LED_WOLFBOOT); @@ -378,7 +379,7 @@ void do_boot(const uint32_t* app_offset) RAMFUNCTION void arch_reboot(void) { -#ifdef WOLFBOOT_AURIX_TC3XX_HSM +#ifdef TARGET_aurix_tc3xx_hsm tc3arm_HsmBridgeSysReset(); #else tc3_Scu_TriggerSwReset(1, WOLFBOOT_AURIX_RESET_REASON); diff --git a/hal/aurix_tc3xx_hsm.c b/hal/aurix_tc3xx_hsm.c new file mode 100644 index 00000000..9367e6d1 --- /dev/null +++ b/hal/aurix_tc3xx_hsm.c @@ -0,0 +1,23 @@ +/* aurix_tc3xx_hsm.c + * + * Copyright (C) 2014-2026 wolfSSL Inc. + * + * This file is part of wolfBoot. + * + * wolfBoot is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * wolfBoot is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with wolfBoot. If not, see . + */ + +/* TC3xx HSM core (ARM Cortex-M3). The build defines TARGET_aurix_tc3xx_hsm, + * which selects the HSM paths inside the shared TC3xx HAL. */ +#include "aurix_tc3xx.c" diff --git a/hal/tc3_cfg.h b/hal/tc3_cfg.h index bb592d67..b16775fe 100644 --- a/hal/tc3_cfg.h +++ b/hal/tc3_cfg.h @@ -20,7 +20,7 @@ #ifndef TC3_CFG_H #define TC3_CFG_H -#if defined(WOLFBOOT_AURIX_TC3XX_HSM) +#if defined(TARGET_aurix_tc3xx_hsm) #define TC3_CFG_HAVE_ARM #else #define TC3_CFG_HAVE_TRICORE diff --git a/options.mk b/options.mk index c3dba9d9..ac6b3fb3 100644 --- a/options.mk +++ b/options.mk @@ -970,7 +970,7 @@ ifeq ($(DEBUG_SYMBOLS),1) CFLAGS+=-g -DDEBUG_SYMBOLS ifeq ($(USE_GCC),1) CFLAGS+=-ggdb3 - else ifneq ($(ARCH),AURIX_TC3) + else ifneq ($(ARCH),AURIX) ifneq ($(USE_CLANG),1) # -gstabs was removed in GCC 12; -gdwarf-4 works on old and new GCC CFLAGS+=-gdwarf-4 @@ -1480,7 +1480,7 @@ ifeq ($(USE_GCC_HEADLESS),1) ifeq ($(USE_GCC),1) ifneq ($(USE_CLANG),1) ifneq ($(ARCH),RENESAS_RX) - ifneq ($(ARCH),AURIX_TC3) + ifneq ($(ARCH),AURIX) CFLAGS+="-Wstack-usage=$(STACK_USAGE)" endif endif diff --git a/test-app/Makefile b/test-app/Makefile index b39a1996..d48df80e 100644 --- a/test-app/Makefile +++ b/test-app/Makefile @@ -88,7 +88,7 @@ ifeq ($(TARGET),ti_hercules) else CFLAGS+=-Wall -ffreestanding -Wno-unused -ffunction-sections -fdata-sections # Stack usage computation not supported on TriCore - ifneq ($(ARCH),AURIX_TC3) + ifneq ($(ARCH),AURIX) ifneq ($(USE_CLANG),1) CFLAGS+=-Wstack-usage=$(STACK_USAGE_LIMIT) endif @@ -97,7 +97,7 @@ else CFLAGS+=-g ifeq ($(USE_GCC),1) CFLAGS+=-ggdb3 - else ifneq ($(ARCH),AURIX_TC3) + else ifneq ($(ARCH),AURIX) ifneq ($(USE_CLANG),1) # -gstabs was removed in GCC 12; -gdwarf-4 works on old and new GCC CFLAGS+=-gdwarf-4 @@ -175,7 +175,7 @@ ifeq ($(DEBUG_UART),1) APP_NEEDS_STRING:=1 endif -ifeq ($(ARCH),AURIX_TC3) +ifeq ($(ARCH),AURIX) # AURIX RAM_CODE HAL flash drivers need wolfBoot memcpy APP_NEEDS_STRING:=1 endif @@ -1251,7 +1251,7 @@ endif CFLAGS+=-I"$(WOLFBOOT_LIB_WOLFSSL)" -ifeq ($(TARGET),aurix_tc3xx) +ifneq (,$(filter aurix_tc3xx aurix_tc3xx_hsm,$(TARGET))) # Add BSP objects (same as in arch.mk for wolfBoot) APP_OBJS += $(TC3_DIR)/src/tc3_clock.o \ $(TC3_DIR)/src/tc3_flash.o \ @@ -1259,7 +1259,7 @@ ifeq ($(TARGET),aurix_tc3xx) $(TC3_DIR)/src/tc3_uart.o \ $(TC3_DIR)/src/tc3.o - ifeq ($(AURIX_TC3_HSM),1) + ifeq ($(TARGET),aurix_tc3xx_hsm) APP_OBJS += $(TC3_DIR)/src/tc3arm_crt.o \ $(TC3_DIR)/src/tc3arm.o # Use TC3 Arm app linker script diff --git a/test-app/app_aurix_tc3xx_hsm.c b/test-app/app_aurix_tc3xx_hsm.c new file mode 100644 index 00000000..e3a0e4be --- /dev/null +++ b/test-app/app_aurix_tc3xx_hsm.c @@ -0,0 +1,22 @@ +/* app_aurix_tc3xx_hsm.c + * + * Copyright (C) 2014-2026 wolfSSL Inc. + * + * This file is part of wolfBoot. + * + * wolfBoot is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * wolfBoot is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with wolfBoot. If not, see . + */ + +/* TC3xx HSM core build of the test application; see app_aurix_tc3xx.c. */ +#include "app_aurix_tc3xx.c" diff --git a/test-app/tc3_cfg.h b/test-app/tc3_cfg.h index 0446bc98..f8fa8fd6 100644 --- a/test-app/tc3_cfg.h +++ b/test-app/tc3_cfg.h @@ -21,7 +21,7 @@ #ifndef TC3_CFG_H #define TC3_CFG_H -#if defined(WOLFBOOT_AURIX_TC3XX_HSM) +#if defined(TARGET_aurix_tc3xx_hsm) #define TC3_CFG_HAVE_ARM #else #define TC3_CFG_HAVE_TRICORE