From b0dcdb858362bba26d02f7503e8f492a6a3f873b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Frauenschl=C3=A4ger?= Date: Fri, 20 Nov 2026 21:57:07 +0100 Subject: [PATCH 1/6] aurix_tc4xx: replace iLLD with wolfLLD The TC4 HAL, its startup and the test app no longer use the Infineon iLLD. The wolfHSM TC4 port now supplies the wolfLLD startup and driver objects through tchsm_wolfboot.mk, so arch.mk drops the iLLD include list and sources, and the test app drops the second Ifx_Ssw_Tc0 build that compiled out the hypervisor exit (the port's linker script now marks it in the crt config table). - UART: tc4_uart, with the divider computed from the live fASCLINF so the CSRM, which prints before the host starts the PLLs, keeps 115200 baud. hal_prepare_boot() drains with tc4_uart_BlockOnTC() instead of a fixed delay. - Watchdogs, software reset and the backup clock switch before boot use tc4_wtu_Disable(), tc4_TriggerSwReset() and tc4_clock_SwitchToBackup(). - The wolfHSM client's SRC access grant uses the port's tchsm_Notify_OpenSrcs(), shared with the demo client. - The test app's empty _init() stub for the iLLD startup goes. --- Makefile | 5 +- arch.mk | 118 +------------------------------- hal/aurix_tc4xx.c | 135 ++++++++++++------------------------- test-app/Makefile | 18 +---- test-app/app_aurix_tc4xx.c | 3 - 5 files changed, 51 insertions(+), 228 deletions(-) diff --git a/Makefile b/Makefile index b9f3023420..f014486ab4 100644 --- a/Makefile +++ b/Makefile @@ -306,9 +306,8 @@ CFLAGS+=$(WOLFPSA_CFLAGS) ifeq ($(USE_GCC_HEADLESS),1) CFLAGS+=-Wall -Wextra -Wno-main -ffreestanding ifneq (,$(filter aurix_tc4xx aurix_tc4xx_csrm,$(TARGET))) - # No -fdata-sections: tricore-elf-gcc 13 emits bare-named data sections - # (.varname, not .bss.varname) that escape the iLLD linker script's - # clear/copy tables, leaving statics uninitialized at boot. + # No -fdata-sections: gcc 13's bare-named data sections (.varname) escape + # the linker script's clear/copy tables and stay uninitialized at boot. CFLAGS+=-ffunction-sections -fomit-frame-pointer else ifeq ($(TARGET)-$(GCC),aurix_tc3xx-1) # Same as above for the TC3xx host built with tricore-elf-gcc (GCC=1) diff --git a/arch.mk b/arch.mk index 74c41ca426..f81b2d754f 100644 --- a/arch.mk +++ b/arch.mk @@ -3393,7 +3393,6 @@ ifeq ($(ARCH), AURIX) # wolfHSM TC4xx port root. Expected that wolfBoot is inside as a submodule. WOLFHSM_INFINEON_TC4XX?=$(abspath ..) - TC4_LLD_DIR?=$(WOLFHSM_INFINEON_TC4XX)/drivers TC4_WB_DIR?=$(WOLFHSM_INFINEON_TC4XX)/port/wolfboot # TC4 derivative device selection from the port device.mk. @@ -3409,16 +3408,6 @@ ifeq ($(ARCH), AURIX) -ffunction-sections -fno-builtin -std=gnu99 \ -DPART_BOOT_EXT -DPART_UPDATE_EXT -DPART_SWAP_EXT \ -DWOLFBOOT_LOADER_MAIN - # Vendor iLLD sources trip some -Wextra diagnostics - CFLAGS += -Wno-missing-field-initializers -Wno-unused-parameter \ - -Wno-unused-variable -Wno-sign-compare -Wno-type-limits - - # iLLD include paths. SSW configuration differs per core. - ifeq ($(TARGET), aurix_tc4xx_csrm) - CFLAGS += -I$(TC4_WB_DIR)/csrm -I$(TC4_WB_DIR)/csrm/Cfg_Ssw - else - CFLAGS += -I$(TC4_WB_DIR) -I$(TC4_WB_DIR)/Cfg_Ssw - endif # Linker scripts ship with the port, not in hal/. ifeq ($(TARGET), aurix_tc4xx_csrm) @@ -3426,73 +3415,6 @@ ifeq ($(ARCH), AURIX) else $(call LSCRIPT_IN_DEFAULT,$(TC4_WB_DIR)/aurix_tc4xx.ld) endif - CFLAGS += \ - -I$(TC4_LLD_DIR) \ - -I$(TC4_LLD_DIR)/Infra/Ssw/TC4xx/Csrm \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/Csrm \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/Csrm/Cpu/Trap \ - -I$(TC4_LLD_DIR)/Infra \ - -I$(TC4_LLD_DIR)/Infra/Platform \ - -I$(TC4_LLD_DIR)/Infra/Platform/Compilers \ - -I$(TC4_LLD_DIR)/Infra/Sfr \ - -I$(TC4_LLD_DIR)/Infra/Sfr/$(DEV_DERIV) \ - -I$(TC4_LLD_DIR)/Infra/Ssw \ - -I$(TC4_LLD_DIR)/Infra/Ssw/TC4xx \ - -I$(TC4_LLD_DIR)/Infra/Ssw/TC4xx/Tricore \ - -I$(TC4_LLD_DIR)/Service \ - -I$(TC4_LLD_DIR)/Service/CpuGeneric \ - -I$(TC4_LLD_DIR)/Service/CpuGeneric/If \ - -I$(TC4_LLD_DIR)/Service/CpuGeneric/If/Ccu6If \ - -I$(TC4_LLD_DIR)/Service/CpuGeneric/StdIf \ - -I$(TC4_LLD_DIR)/Service/CpuGeneric/SysSe \ - -I$(TC4_LLD_DIR)/Service/CpuGeneric/SysSe/Bsp \ - -I$(TC4_LLD_DIR)/Service/CpuGeneric/SysSe/General \ - -I$(TC4_LLD_DIR)/Service/CpuGeneric/SysSe/Time \ - -I$(TC4_LLD_DIR)/Service/CpuGeneric/_Utilities \ - -I$(TC4_LLD_DIR)/Service/Tricore \ - -I$(TC4_LLD_DIR)/Service/Tricore/Comm \ - -I$(TC4_LLD_DIR)/Service/Tricore/Math \ - -I$(TC4_LLD_DIR)/iLLD \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/Ap \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/Ap/Std \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/Asclin \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/Asclin/Asc \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/Asclin/Std \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/Clock \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/Clock/Std \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/Egtm \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/Egtm/Std \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/Geth \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/Geth/Std \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/Port \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/Port/Std \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/Src \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/Src/Std \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/_Impl \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/_Impl/$(DEV_DERIV) \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/_Lib \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/_Lib/DataHandling \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/_Lib/Timer \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/_PinMap \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/_PinMap/$(DEV_DERIV) \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/Tricore \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/Tricore/Cpu \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/Tricore/Cpu/Irq \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/Tricore/Cpu/Std \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/Tricore/Cpu/Trap \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/Tricore/Flash/Std \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/Tricore/Smu \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/Tricore/Smu/Std \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/Tricore/Stm \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/Tricore/Stm/Std \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/Tricore/Vmt \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/Tricore/Vmt/Std \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/Tricore/Wtu \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/Tricore/Wtu/Std \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/Tricore/_Impl \ - -I$(TC4_LLD_DIR)/iLLD/TC4xx/Tricore/_Impl/$(DEV_DERIV) # No TriCore asm in wolfCrypt MATH_OBJS+=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/sp_c32.o @@ -3545,45 +3467,11 @@ ifeq ($(ARCH), AURIX) # such that the binary image can be contiguous OBJCOPY_FLAGS+=-R '.bmhd*' -R '.usercfg*' -R '.csusercfg*' -R '.sdata4' -R '.sdata' -R '.zdata' - # iLLD startup software and drivers used by the HAL. - TC4_LLD_SRCS := \ - $(wildcard $(TC4_LLD_DIR)/Infra/Platform/Compilers/*.c) \ - $(TC4_LLD_DIR)/Infra/Ssw/TC4xx/Tricore/Ifx_Ssw_Infra.c \ - $(wildcard $(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/Ap/Std/*.c) \ - $(wildcard $(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/Asclin/Std/*.c) \ - $(wildcard $(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/Clock/Std/*.c) \ - $(wildcard $(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/Port/Std/*.c) \ - $(wildcard $(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/Src/Std/*.c) \ - $(wildcard $(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/_Impl/*.c) \ - $(wildcard $(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/_Impl/$(DEV_DERIV)/*.c) \ - $(wildcard $(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/_PinMap/IfxAsclin_PinMap*.c) \ - $(wildcard $(TC4_LLD_DIR)/iLLD/TC4xx/CpuGeneric/_PinMap/$(DEV_DERIV)/IfxAsclin_PinMap*.c) \ - $(wildcard $(TC4_LLD_DIR)/iLLD/TC4xx/Tricore/Cpu/Std/*.c) \ - $(wildcard $(TC4_LLD_DIR)/iLLD/TC4xx/Tricore/Stm/Std/*.c) \ - $(wildcard $(TC4_LLD_DIR)/iLLD/TC4xx/Tricore/Wtu/Std/*.c) \ - $(wildcard $(TC4_LLD_DIR)/iLLD/TC4xx/Tricore/_Impl/*.c) - + # wolfLLD startup and drivers, entry glue and boot mode headers ifeq ($(TARGET), aurix_tc4xx_csrm) - # CSRM (CPU6) startup software + trap table - TC4_LLD_SRCS += \ - $(TC4_LLD_DIR)/Infra/Ssw/TC4xx/Csrm/Ifx_Ssw_Tc6.c \ - $(TC4_LLD_DIR)/iLLD/TC4xx/Csrm/Cpu/Trap/IfxCpu_Trap_Cs.c - OBJS += $(TC4_LLD_SRCS:.c=.o) - OBJS += $(TC4_WB_DIR)/csrm/Cfg_Ssw/Ifx_Cfg_Ssw.o \ - $(TC4_WB_DIR)/csrm/Cfg_Ssw/Ifx_Cfg_SswBmhdCs.o \ - $(TC4_WB_DIR)/csrm/tc4_wolfboot_csrm_main.o + OBJS += $(TCHSM_WB_CSRM_LLD_OBJS) $(TCHSM_WB_CSRM_OBJS) else - # Host CPU0 startup software and trap table. - TC4_LLD_SRCS += \ - $(TC4_LLD_DIR)/Infra/Ssw/TC4xx/Tricore/Ifx_Ssw_Tc0.c \ - $(wildcard $(TC4_LLD_DIR)/iLLD/TC4xx/Tricore/Cpu/Irq/*.c) \ - $(wildcard $(TC4_LLD_DIR)/iLLD/TC4xx/Tricore/Cpu/Trap/*.c) \ - $(wildcard $(TC4_LLD_DIR)/iLLD/TC4xx/Tricore/Smu/Std/*.c) \ - $(wildcard $(TC4_LLD_DIR)/iLLD/TC4xx/Tricore/Vmt/Std/*.c) - OBJS += $(TC4_LLD_SRCS:.c=.o) - OBJS += $(TC4_WB_DIR)/Cfg_Ssw/Ifx_Cfg_Ssw.o \ - $(TC4_WB_DIR)/Cfg_Ssw/Ifx_Cfg_SswBmhd.o \ - $(TC4_WB_DIR)/tc4_wolfboot_main.o + OBJS += $(TCHSM_WB_HOST_LLD_OBJS) $(TCHSM_WB_HOST_OBJS) endif endif # TC4xx endif diff --git a/hal/aurix_tc4xx.c b/hal/aurix_tc4xx.c index 287392843d..33f2e2055c 100644 --- a/hal/aurix_tc4xx.c +++ b/hal/aurix_tc4xx.c @@ -30,28 +30,21 @@ #include "loader.h" /* for wolfBoot_panic */ #include "printf.h" -/* iLLD headers */ -#include "Ifx_Types.h" -#include "IfxAsclin.h" -#include "IfxAsclin_PinMap.h" -#include "IfxCpu.h" -#include "IfxWtu.h" -#ifndef TARGET_aurix_tc4xx_csrm -#include "IfxClock.h" -#endif +/* wolfLLD headers */ +#include "tc4/tc4.h" +#include "tc4/tc4_clock.h" +#include "tc4/tc4_uart.h" +#include "tc4/tc4_wtu.h" #if defined(WOLFBOOT_ENABLE_WOLFHSM_CLIENT) -#include "IfxApApu.h" -#include "IfxApProt.h" -#include "IfxSrc.h" - /* wolfHSM headers */ #include "wolfhsm/wh_client.h" #include "wolfhsm/wh_error.h" /* wolfHSM AURIX TC4xx port headers */ #include "tchsm_topology.h" #include "tchsm_client.h" +#include "tchsm_notify.h" #include "tchsm_spr_apu.h" /* wolfHSM client ID for the HSM server. @@ -392,55 +385,41 @@ static int RAMFUNCTION programBytesToErasedFlash(uint32_t address, #if defined(DEBUG_UART) || defined(UART_FLASH) -#define TC4_UART (&MODULE_ASCLIN0) #define TC4_UART_BAUD (115200u) -#define TC4_UART_FIFO_SIZE (16u) + +/* ASCLIN0 on P14.0 (TX) and P14.1 (RX). The CSRM may run before the host + * has set up the clock tree, so the divider follows the live fASCLINF. */ +static tc4_uartpin_t tc4Uart = { + .asclin = 0u, + .txport = 14u, + .txpin = 0u, + .txalt = 2u, + .rxport = 14u, + .rxpin = 1u, + .rxsel = 0u, +}; int uart_tx(const uint8_t c); int uart_rx(uint8_t* c); void uart_init(void); void uart_write(const char* buf, unsigned int sz); +static int tc4UartReady = 0; + void uart_init(void) { - Ifx_ASCLIN* u = TC4_UART; - - IfxAsclin_enableModule(u); - IfxAsclin_setClockSource(u, IfxAsclin_ClockSource_noClock); - IfxAsclin_setFrameMode(u, IfxAsclin_FrameMode_initialise); - IfxAsclin_setPrescaler(u, 1); - IfxAsclin_setClockSource(u, IfxAsclin_ClockSource_ascFastClock); - (void)IfxAsclin_setBitTiming( - u, (float32)TC4_UART_BAUD, IfxAsclin_OversamplingFactor_16, - IfxAsclin_SamplePointPosition_8, IfxAsclin_SamplesPerBit_three); - IfxAsclin_setClockSource(u, IfxAsclin_ClockSource_noClock); - - IfxAsclin_enableParity(u, FALSE); - IfxAsclin_setStopBit(u, IfxAsclin_StopBit_1); - IfxAsclin_setShiftDirection(u, IfxAsclin_ShiftDirection_lsbFirst); - IfxAsclin_setDataLength(u, IfxAsclin_DataLength_8); - IfxAsclin_setTxFifoInletWidth(u, IfxAsclin_TxFifoInletWidth_1); - IfxAsclin_setRxFifoOutletWidth(u, IfxAsclin_RxFifoOutletWidth_1); - IfxAsclin_setFrameMode(u, IfxAsclin_FrameMode_asc); - - IfxAsclin_initTxPin(&IfxAsclin0_TX_F_P14_0_OUT, IfxPort_OutputMode_pushPull, - IfxPort_PadDriver_cmosAutomotiveSpeed1); - IfxAsclin_initRxPin(&IfxAsclin0_RXA_F_P14_1_IN, IfxPort_InputMode_pullUp, - IfxPort_PadDriver_cmosAutomotiveSpeed1); - - IfxAsclin_setClockSource(u, IfxAsclin_ClockSource_ascFastClock); - IfxAsclin_disableAllFlags(u); - IfxAsclin_clearAllFlags(u); - IfxAsclin_flushTxFifo(u); - IfxAsclin_enableTxFifoOutlet(u, TRUE); + tc4UartReady = + (tc4_uart_SetBaud(&tc4Uart, tc4_clock_GetAsclinFastFrequency(), + TC4_UART_BAUD) == 0) && + (tc4_uart_Init(&tc4Uart) == 0); } int uart_tx(const uint8_t c) { - Ifx_ASCLIN* u = TC4_UART; - while (IfxAsclin_getTxFifoFillLevel(u) >= TC4_UART_FIFO_SIZE) { + if (!tc4UartReady) { + return 0; } - IfxAsclin_writeTxData(u, c); + tc4_uart_Write8(&tc4Uart, c); return 1; } @@ -461,20 +440,6 @@ void uart_write(const char* buf, unsigned int sz) } } -/* Block until the TX FIFO has fully drained onto the wire */ -static void uart_flush(void) -{ - Ifx_ASCLIN* u = TC4_UART; - volatile uint32_t i; - - while (IfxAsclin_getTxFifoFillLevel(u) != 0u) { - } - /* Delay in case TC flag is still set from an earlier idle - * period while the last frame sits in the shift reg. */ - for (i = 0; i < 200000u; i++) { - } -} - #endif /* DEBUG_UART || UART_FLASH */ /* @@ -484,7 +449,7 @@ static void uart_flush(void) void hal_init(void) { #ifdef TARGET_aurix_tc4xx_csrm - IfxWtu_disableSecurityWatchdog(IfxWtu_getSecurityWatchdogPassword()); + tc4_wtu_Disable(TC4_WTU_WDTSEC); /* The CSRM PFLASH bank must be allocated to the CSRM or the CSCI * command writes will fail silently */ @@ -492,8 +457,8 @@ void hal_init(void) wolfBoot_panic(); } #else - IfxWtu_disableCpuWatchdog(IfxWtu_getCpuWatchdogPassword()); - IfxWtu_disableSystemWatchdog(IfxWtu_getSystemWatchdogPassword()); + tc4_wtu_Disable(TC4_WTU_WDTCPU(0u)); + tc4_wtu_Disable(TC4_WTU_WDTSYS); /* Refuse to run if a host PFLASH bank has been reallocated to CSRM. */ if ((*TC4_GP_BKALLOC & 0xFu) != 0u) { @@ -527,15 +492,16 @@ void hal_prepare_boot(void) /* Final print, then drain so the clock switch below cannot corrupt * in-flight characters */ wolfBoot_printf("hal_prepare_boot\n"); - uart_flush(); - IfxAsclin_setClockSource(TC4_UART, IfxAsclin_ClockSource_noClock); - IfxAsclin_disableModule(TC4_UART); + if (tc4UartReady) { + tc4_uart_BlockOnTC(&tc4Uart); + } #endif #ifndef TARGET_aurix_tc4xx_csrm - /* Host cores must return the clock tree to the backup clock and power the - * PLLs down, as the iLLD SSW can't handle already initialized PLLs. */ - (void)IfxClock_switchToBackupClock(&IfxClock_defaultClockConfig); + /* The application starts on the backup clock; the PLLs stay powered */ + if (tc4_clock_SwitchToBackup() != 0) { + wolfBoot_panic(); + } #endif } @@ -552,9 +518,7 @@ void RAMFUNCTION arch_reboot(void) while (1) { } #else - IfxCpu_triggerSwReset(); - while (1) { - } + tc4_TriggerSwReset(); #endif } @@ -787,23 +751,12 @@ volatile int g_tc4_hsmc_hw_rc; /* CPU0 hardware setup for HsmHost transport. */ static int tc4_hsmc_hw_init(void) { - { - IfxApApu_ApuConfig apConfig; - IfxApApu_initConfig(&apConfig); - const unsigned long srcTagMask = - (1UL << IfxApProt_TagId_cpu0d) | (1UL << IfxApProt_TagId_cpu0ds) | - (1UL << IfxApProt_TagId_cpu1d) | (1UL << IfxApProt_TagId_cpu1ds) | - (1UL << IfxApProt_TagId_cpucsd) | (1UL << IfxApProt_TagId_cpucsds); - apConfig.wraTagId = srcTagMask; - apConfig.rdaTagId = srcTagMask; - apConfig.wrbTagId = 0U; - apConfig.rdbTagId = 0U; - IfxSrc_configureAccessToSrcs(&apConfig); - } - - /* Probe SR0 to confirm SRC ACCEN writes are enabled. */ - SRC_GPSR4_SR0.U = 0x00006014u; - if (((SRC_GPSR4_SR0.U >> 12) & 0xFu) != 6u) { + const uint32_t srcTagMask = + TCHSM_APPROT_TAGS_FOR_CORE(0u) | TCHSM_APPROT_TAGS_FOR_CORE(1u) | + TCHSM_APPROT_TAGS_FOR_CORE(TC4_CORE_ID_CPUCS); + + if (tchsm_Notify_OpenSrcs(TCHSM_HSMHOST_CLIENT_APP0, srcTagMask) != + WH_ERROR_OK) { return -1; } diff --git a/test-app/Makefile b/test-app/Makefile index 7235faefec..8a00dcc0fb 100644 --- a/test-app/Makefile +++ b/test-app/Makefile @@ -1673,17 +1673,11 @@ ifneq (,$(filter aurix_tc4xx aurix_tc4xx_csrm,$(TARGET))) hal_$(TARGET).o: CFLAGS+=-DRAM_CODE -D__WOLFBOOT ../test-app/libwolfboot.o: CFLAGS+=-DRAM_CODE -D__WOLFBOOT ifeq ($(TARGET),aurix_tc4xx_csrm) - # CSRM app uses the shared startup and driver objects. - APP_OBJS += $(TC4_LLD_SRCS:.c=.o) - APP_OBJS += $(TC4_WB_DIR)/csrm/Cfg_Ssw/Ifx_Cfg_Ssw.o + APP_OBJS += $(TCHSM_WB_CSRM_LLD_OBJS) # CSRM app linker script ships with the port. LSCRIPT_TEMPLATE = $(TC4_WB_DIR)/csrm/tc4cs_app.ld else - # Host test-app uses patched iLLD startup and drivers from the TC4 port. - # Drop Ifx_Ssw_Tc0.o and replace with patched aurix_tc4xx_ssw_tc0.o below - APP_OBJS += $(filter-out %/Ifx_Ssw_Tc0.o,$(TC4_LLD_SRCS:.c=.o)) - APP_OBJS += $(TC4_WB_DIR)/Cfg_Ssw/Ifx_Cfg_Ssw.o - APP_OBJS += aurix_tc4xx_ssw_tc0.o + APP_OBJS += $(TCHSM_WB_HOST_LLD_OBJS) # Host app linker script ships with the port. LSCRIPT_TEMPLATE = $(TC4_WB_DIR)/tc4tc_app.ld endif @@ -1694,14 +1688,6 @@ ifneq (,$(filter aurix_tc4xx aurix_tc4xx_csrm,$(TARGET))) $(WOLFBOOT_LIB_WOLFHSM)/src/wh_transport_mem.o endif -# Build Ifx_Ssw_Tc0.c a second time as aurix_tc4xx_ssw_tc0.o with the -# hypervisor exit compiled out, since wolfBoot already ran it before -# jumping to the app. The new name keeps it from conflicting with the -# bootloader's Ifx_Ssw_Tc0.o, which is built from the same file -aurix_tc4xx_ssw_tc0.o: $(TC4_LLD_DIR)/Infra/Ssw/TC4xx/Tricore/Ifx_Ssw_Tc0.c - @echo "\t[CC-APP] $@" - $(Q)$(CC) $(CFLAGS) -DIFX_CFG_SSW_SKIP_DISABLE_VIRTUALIZATION -c -o $@ $< - # Default goal for argument-less sub-makes. .DEFAULT_GOAL := image.bin endif diff --git a/test-app/app_aurix_tc4xx.c b/test-app/app_aurix_tc4xx.c index e80ed5edd9..0a3bff3d34 100644 --- a/test-app/app_aurix_tc4xx.c +++ b/test-app/app_aurix_tc4xx.c @@ -40,9 +40,6 @@ extern whClientContext hsmClientCtx; #define BASE_FW_VERSION 1 -/* Empty _init for the SSW C init hook. */ -void _init(void) {} - /* Hang on flash HAL faults. */ void wolfBoot_panic(void) { From a165a735fd946da2c432d4329435bad41804ae66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Frauenschl=C3=A4ger?= Date: Sat, 21 Nov 2026 11:15:12 +0100 Subject: [PATCH 2/6] tc4xx: lock the cross-verify key in the NVM provisioning image The wolfBoot public key in the TC4 NVM image was provisioned with the verify usage flag only, so any core of client 1 could replace or erase the root of the cross-verification. Add WH_NVM_FLAGS_NONMODIFIABLE and WH_NVM_FLAGS_NONDESTROYABLE (flags 0x901). --- tools/scripts/tc4xx/wolfBoot-wolfHSM-keys.nvminit | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/scripts/tc4xx/wolfBoot-wolfHSM-keys.nvminit b/tools/scripts/tc4xx/wolfBoot-wolfHSM-keys.nvminit index 834c01192f..77b36c7c52 100644 --- a/tools/scripts/tc4xx/wolfBoot-wolfHSM-keys.nvminit +++ b/tools/scripts/tc4xx/wolfBoot-wolfHSM-keys.nvminit @@ -2,8 +2,9 @@ # # Key format # key