@@ -2394,7 +2394,25 @@ endif
23942394ifeq ($(ARCH ) , AURIX)
23952395 # TC3xx HSM and host cores
23962396 ifneq (,$(filter aurix_tc3xx aurix_tc3xx_hsm,$(TARGET)))
2397- USE_GCC? =1
2397+ # Toolchain selection (mutually exclusive, HT_GCC is the default),
2398+ # matching the wolfHSM tc3xx tchsm-server/tchsm-client Makefiles:
2399+ # HT_GCC=1 HighTec GCC (Tricore host; ARM arm-elf-gcc for the HSM)
2400+ # HT_LLVM=1 HighTec LLVM/clang (Tricore or ARM)
2401+ # GCC=1 Open-source GCC (tricore-elf; arm-none-eabi for the HSM)
2402+ ifneq ($(filter-out 0 1,$(words $(filter 1,$(GCC) $(HT_GCC) $(HT_LLVM)))),)
2403+ $(error GCC, HT_GCC, and HT_LLVM are mutually exclusive; set only one)
2404+ endif
2405+ ifneq ($(filter 1,$(USE_CLANG) $(USE_ARMCLANG)),)
2406+ $(error Use HT_LLVM=1 for AURIX clang builds, not USE_CLANG/USE_ARMCLANG)
2407+ endif
2408+ ifeq ($(GCC),1)
2409+ USE_GCC: =1
2410+ else ifeq ($(HT_LLVM),1)
2411+ USE_GCC: =0
2412+ else
2413+ HT_GCC: =1
2414+ USE_GCC: =1
2415+ endif
23982416
23992417 CFLAGS += -I$(TC3_DIR ) -Ihal
24002418
@@ -2407,6 +2425,14 @@ ifeq ($(ARCH), AURIX)
24072425 -std=gnu99 -DPART_BOOT_EXT -DPART_UPDATE_EXT -DPART_SWAP_EXT \
24082426 -DHAVE_TC3XX -DWOLFBOOT_LOADER_MAIN
24092427
2428+ ifeq ($(HT_GCC),1)
2429+ # Older HT GCC 4.6 flags designated/partial initializers
2430+ CFLAGS += -Wno-missing-field-initializers
2431+ # Older HT GCC 4.6 also flags WOLFBOOT_HDR_GET_U32() on byte arrays as
2432+ # type-punning
2433+ CFLAGS += -Wno-strict-aliasing
2434+ endif
2435+
24102436 # Set TC3_CFG_DFLASH_SINGLE_ENDED=1 for devices with DFLASH provisioned in single
24112437 # ended mode (default expects complement sensing)
24122438 ifeq ($(TC3_CFG_DFLASH_SINGLE_ENDED),1)
@@ -2452,11 +2478,37 @@ ifeq ($(ARCH), AURIX)
24522478 ifeq ($(TARGET), aurix_tc3xx_hsm)
24532479 # HSM core (ARM Cortex-M3)
24542480 ARCH_FLASH_OFFSET? =0x80028000
2455- # HSM compiler flags, build options, source code, etc
2456- ifeq ($(USE_GCC),1)
2457- # Just arm-none-eabi-gcc for now
2481+
2482+ # wolfHSM server ECC configs use hardware-only ECC via the PKC crypto
2483+ # callback. Cert manager uses INVALID_DEVID for signature checks so register
2484+ # a find callback to ensure these use HW acceleration as well.
2485+ ifeq ($(WOLFHSM_SERVER),1)
2486+ ifneq (,$(filter ECC%,$(SIGN)))
2487+ # if SIGN==ECC
2488+ CFLAGS+ =-DWOLF_CRYPTO_CB_ONLY_ECC -DWOLF_CRYPTO_CB_FIND
2489+ endif
2490+ endif
2491+
2492+ ifeq ($(GCC),1)
2493+ # Open-source ARM GCC
24582494 CROSS_COMPILE? =arm-none-eabi-
2495+ else ifeq ($(HT_LLVM),1)
2496+ # HighTec ARM LLVM (clang + lld + picolibc)
2497+ HT_ARM_PATH? =$(HOME ) /HighTec/toolchains/arm/v10.0.0
2498+ CC =$(HT_ARM_PATH ) /bin/clang
2499+ LD =$(CC )
2500+ AS =$(CC )
2501+ AR =$(HT_ARM_PATH ) /bin/llvm-ar
2502+ OBJCOPY =$(HT_ARM_PATH ) /bin/llvm-objcopy
2503+ SIZE =$(HT_ARM_PATH ) /bin/llvm-size
2504+ # clang applies warning flags positionally, so skip the main
2505+ # Makefile's late USE_GCC_HEADLESS -Wall/-Wextra block (it would
2506+ # re-enable warnings suppressed above)
2507+ USE_GCC_HEADLESS: =0
24592508 else
2509+ # HighTec ARM GCC (the default)
2510+ HT_ARM_GCC_PATH? =/opt/hightec/gnuarm_v4.6.5.1-3b75921-lin64
2511+ CROSS_COMPILE? =$(HT_ARM_GCC_PATH ) /bin/arm-elf-
24602512 endif
24612513
24622514 # Compiler flags
@@ -2478,13 +2530,52 @@ ifeq ($(ARCH), AURIX)
24782530 # Temporary fix masking wolfCrypt unused function warning with RSA_LOW_MEM
24792531 CFLAGS += -Wno-unused-function
24802532
2533+ ifeq ($(HT_LLVM),1)
2534+ # gnu11 overrides the earlier gnu99: clang rejects wolfSSL's typedef
2535+ # redefinitions under C99. clang also lacks GCC's per-function
2536+ # optimize attribute used by WC_OMIT_FRAME_POINTER, so define it
2537+ # empty and omit frame pointers globally (required for SP inline ASM)
2538+ CFLAGS += -std=gnu11 -fomit-frame-pointer -DWC_OMIT_FRAME_POINTER=
2539+ # picolibc stdio calls the POSIX fd functions (write etc.) and the
2540+ # port's syscalls.c provides them on top of __io_putchar
2541+ OBJS += $(WOLFHSM_INFINEON_TC3XX ) /port/server/syscalls.o
2542+ endif
2543+
24812544 LDFLAGS += -march=armv7-m -mcpu=cortex-m3 -mthumb -mlittle-endian -g \
2482- --specs=nano.specs - Wl,--gc-sections -static -Wl,--cref -Wl,-n \
2545+ -Wl,--gc-sections -static -Wl,--cref -Wl,-n \
24832546 -ffunction-sections -fdata-sections \
24842547 -nostartfiles \
24852548 -Wl,-Map="wolfboot.map" \
24862549 -Wl,-L$(TC3_DIR ) /tc3
24872550
2551+ ifeq ($(HT_GCC),1)
2552+ # HighTec libgcc references ARM unwind symbols, but .ARM.exidx is
2553+ # discarded. Define empty bounds and stub the personality routines to
2554+ # avoid pulling in ~3.4KB of unneccessary unwinder code.
2555+ LDFLAGS += -Wl,--defsym,__exidx_start=0 -Wl,--defsym,__exidx_end=0 \
2556+ -Wl,--defsym,__aeabi_unwind_cpp_pr0=0 \
2557+ -Wl,--defsym,__aeabi_unwind_cpp_pr1=0 \
2558+ -Wl,--defsym,__aeabi_unwind_cpp_pr2=0
2559+ # HighTec's ancient ARM ld cannot parse the BSP linker-script fragments.
2560+ # Flatten them at parse time with the wolfHSM port's ld-flatten.sh.
2561+ # Paths are relative to this arch.mk, which is included from both the
2562+ # wolfBoot root and test-app directories.
2563+ ARCHMK_DIR: =$(dir $(lastword $(MAKEFILE_LIST ) ) )
2564+ LSCRIPT_IN =$(ARCHMK_DIR ) config/$(TARGET ) _flat.ld
2565+ ifeq ($(filter clean keysclean,$(MAKECMDGOALS)),)
2566+ LD_FLATTEN_OUT: =$(shell $(WOLFHSM_INFINEON_TC3XX ) /tchsm-server/ld-flatten.sh \
2567+ $(ARCHMK_DIR ) hal/$(TARGET ) .ld $(LSCRIPT_IN ) $(TC3_DIR ) /tc3 && echo OK)
2568+ ifneq ($(LD_FLATTEN_OUT),OK)
2569+ $(error ld-flatten.sh failed for hal/$(TARGET).ld)
2570+ endif
2571+ endif
2572+ else ifeq ($(HT_LLVM),1)
2573+ # picolibc: no specs files, lld parses the BSP scripts directly
2574+ else
2575+ # newlib-nano (arm-none-eabi)
2576+ LDFLAGS += --specs=nano.specs
2577+ endif
2578+
24882579 # wolfHSM port server-specific files
24892580 ifeq ($(WOLFHSM_SERVER),1)
24902581 USE_GCC_HEADLESS =0
@@ -2516,18 +2607,27 @@ ifeq ($(ARCH), AURIX)
25162607 else
25172608 # TriCore host core
25182609 ARCH_FLASH_OFFSET? =0x800A0000
2519- ifeq ($(USE_GCC),1)
2610+ ifeq ($(GCC),1)
2611+ TRICORE_GCC_PATH? =$(HOME ) /workspace/toolchains/tricore-gcc-13.4.1-linux
2612+ CROSS_COMPILE? =$(TRICORE_GCC_PATH ) /bin/tricore-elf-
2613+ # Open GCC has a bug in data section naming, eliminate this for now
2614+ CFLAGS: =$(filter-out -fdata-sections,$(CFLAGS ) )
2615+ # Required for open GCC compatibility with wolfLLD-tc3xx bus error
2616+ # skipping logic. By default, open GCC memcpy uses a post-increment load
2617+ # so without this, bus error skip logic will result in an infinite loop
2618+ # when wolfBoot reads from erased flash.
2619+ CFLAGS+ =-fno-auto-inc-dec
2620+ else ifeq ($(HT_LLVM),1)
2621+ HT_TRICORE_LLVM_PATH? =$(HOME ) /HighTec/toolchains/tricore/v11.0.0
2622+ CC =$(HT_TRICORE_LLVM_PATH ) /bin/clang
2623+ LD =$(CC )
2624+ AS =$(CC )
2625+ AR =$(HT_TRICORE_LLVM_PATH ) /bin/llvm-ar
2626+ OBJCOPY =$(HT_TRICORE_LLVM_PATH ) /bin/llvm-objcopy
2627+ SIZE =$(HT_TRICORE_LLVM_PATH ) /bin/llvm-size
2628+ else
25202629 HT_ROOT? =/opt/hightec/gnutri_v4.9.4.1-11fcedf-lin64
25212630 CROSS_COMPILE? =$(HT_ROOT ) /bin/tricore-
2522- else
2523- HT_ROOT? =~/HighTec/toolchains/tricore/v9.1.2
2524- CROSS_COMPILE? =$(HT_ROOT ) /bin
2525- CC =$(CROSS_COMPILE ) /clang
2526- LD =$(CROSS_COMPILE ) /clang
2527- AS =$(CROSS_COMPILE ) /clang
2528- AR =$(CROSS_COMPILE ) /llvm-ar
2529- OBJCOPY =tricore-objcopy
2530- SIZE =$(CROSS_COMPILE ) /llvm-size
25312631 endif
25322632
25332633 # No asm for you!
@@ -2538,7 +2638,16 @@ ifeq ($(ARCH), AURIX)
25382638 CFLAGS+ = -fshort-double -mtc162 -fstrict-volatile-bitfields -fno-builtin \
25392639 -fno-strict-aliasing
25402640 else
2541- CFLAGS+ = --target=tricore -march=tc162
2641+ # Use hardware FP with 32-bit doubles, matching GCC's # -fshort-double.
2642+ # Limit clang inlining by callee stack size.
2643+ # Use gnu11 because clang rejects wolfSSL's typedef redefinitions under gnu99.
2644+ CFLAGS+ = -march=tc162 -mfloat-abi=hh32 -finline-max-stacksize=4096 \
2645+ -std=gnu11 -ffreestanding -Wno-unused-function
2646+
2647+ # clang applies warning flags positionally, so skip the main
2648+ # Makefile's late USE_GCC_HEADLESS -Wall/-Wextra block (it would
2649+ # re-enable warnings suppressed above)
2650+ USE_GCC_HEADLESS: =0
25422651 endif
25432652
25442653 DEBUG_AFLAGS = -Wa,--gdwarf-2
@@ -2547,7 +2656,7 @@ ifeq ($(ARCH), AURIX)
25472656 ifeq ($(USE_GCC),1)
25482657 LDFLAGS+ = -fshort-double -mtc162 -nostartfiles -Wl,--extmap="a"
25492658 else
2550- LDFLAGS+ = --target=tricore -march=tc162 -Wl,--entry=tc3tc_start
2659+ LDFLAGS+ = -march=tc162 -mfloat-abi=hh32 -Wl,--entry=tc3tc_start
25512660 endif
25522661
25532662 LDFLAGS+ = -Wl,--gc-sections -Wl,--cref -Wl,-n \
@@ -2568,7 +2677,8 @@ ifeq ($(ARCH), AURIX)
25682677 $(TC3_DIR ) /../tc3tc_bootloader/tc3tc_bootloader.o
25692678
25702679 ifeq ($(WOLFHSM_CLIENT),1)
2571- CFLAGS += -I$(WOLFHSM_INFINEON_TC3XX ) /port/client
2680+ # GNU enables io.c's write() stub, which picolibc (HT_LLVM) needs
2681+ CFLAGS += -I$(WOLFHSM_INFINEON_TC3XX ) /port/client -DGNU
25722682 OBJS += $(WOLFHSM_INFINEON_TC3XX ) /port/client/hsm_ipc.o \
25732683 $(WOLFHSM_INFINEON_TC3XX ) /port/client/io.o \
25742684 $(WOLFHSM_INFINEON_TC3XX ) /port/client/tchsm_hh_host.o
0 commit comments