Skip to content

arch/tricore: add tc3xx and tc4xx boot support - #21511

Closed
zhangyu981027 wants to merge 3 commits into
apache:masterfrom
zhangyu981027:tricore_boot_1106
Closed

zhangyu981027 wants to merge 3 commits into
apache:masterfrom
zhangyu981027:tricore_boot_1106

Conversation

@zhangyu981027

@zhangyu981027 zhangyu981027 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Depends on #21509 and #21510. Please review the last commit only.

Summary

Rework the TriCore startup using the common head.S/head.asm and boot.c structure used by other architectures. CPU0 initializes .data/.bss and enters the primary boot path, while secondary CPUs enter the secondary boot path. Add TC3xx/TC4xx chip-specific boot hooks and update the board linker scripts for the new startup.

The first two commits provide the CMake HEAD-source handling and TASKING assembly preprocessing required by the final boot commit.

Impact

TriCore TC3xx and TC4xx now use the NuttX assembly entry and boot flow instead of the previous per-core coreN_main() startup. Both GNU and TASKING assembly entry paths and the corresponding linker scripts are supported. No interface changes are introduced for applications.

Testing

Host: Ubuntu Linux, x86_64, CMake.

The following board/toolchain combinations were built, flashed, and tested over the serial console. Both hello and ostest passed in all four configurations:

Board Toolchain hello ostest
A2G TC397 5V TFT (a2g-tc397-5v-tft:nsh) GNU PASS PASS
A2G TC397 5V TFT (a2g-tc397-5v-tft:nsh) TASKING VX PASS PASS
TriBoard TC4X9 COM (triboard_tc4x9_com:nsh) GNU PASS PASS
TriBoard TC4X9 COM (triboard_tc4x9_com:nsh) TASKING SmartCode PASS PASS

Each run verified the serial hello output and successful completion of ostest.

All three commits also pass tools/checkpatch.sh -c -u -m -g master..HEAD and git diff --check master..HEAD.

xuxin930 and others added 3 commits November 6, 2026 15:51
In the current cmake build, all sources of arch will be added to libarch.a,
which will cause a hidden problem: vector may be ignored by the linker.

In the makefile, HEADSRC is a header link file independent of the static library,
so there will be no such problem.

In this patch, we also assign HEAD src in cmake directly to nuttx,
so that it can directly participate in the link.

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
Support including nuttx/config.h and #if on CONFIG_* in tasking .asm
sources by preprocessing them with ctc -E before assembly.

1. ctc -E runs as a pre-pass since the astc assembler has no C
   preprocessor of its own.
2. Comments in asm must not contain lone apostrophes since ctc -E
   reads them as unterminated C character constants.

Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
Optimize the TriCore startup and organize it like other architectures
such as arm64 (head.S + boot.c):

1. Write the startup in assembly (tricore_head.S for GNU and
   tricore_head.asm for TASKING).  All cpus enter at the common
   __start.
2. CPU0 initializes .data/.bss and calls tricore_boot_primary(),
   which releases the other cores and enters nx_start().  Secondary
   cpus enter tricore_boot_secondary().
3. Move the chip-specific watchdog and clock initialization to
   tricore_boot() of each chip.
4. Remove tricore_main.c and the per-core coreN_main() entries.
5. Update the TC4xx and TC397 linker scripts for the new startup.

Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
@github-actions github-actions Bot added Area: Build system Arch: arm Issues related to ARM (32-bit) architecture Arch: arm64 Issues related to ARM64 (64-bit) architecture Arch: tricore Issues related to the TriCore architecture from Infineon Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. Board: tricore labels Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

@ssekar15 ssekar15 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is duplicate effort of what we already raise and we agree to common ground that I'm working on the split of our original PR #19041. It is completely intentional duplicate and unethical.

HEAD_CSRC += tricore_doirq.c

ifeq ($(CONFIG_ARCH_TOOLCHAIN_TASKING),y)
CMN_ASRCS += tricore_head.asm

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the TASKING toolchain and make, tricore_head.asm is never assembled: arch/tricore/src/Makefile maps only .S (AOBJS = $(ASRCS:.S=$(OBJEXT)) and the rule %$(OBJEXT): %.S), so make reports "doesn't match the target pattern" and __start is missing at link time. The Testing section lists CMake builds only.
Fix: make arch/tricore/src/Makefile use $(ASMEXT) for ASRCS and its rule (as #21496 does), and build the TASKING configs with make too.


/* TriCore core special function register (CSFR) */

#define CPU_PSW 0xFE04 /* Program Status Word */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CPU_PSW, CPU_FCX and the other new CSFR defines repeat what arch/csfr.h (included by this header) already has as TRICORE_CPU_PSW and TRICORE_CPU_FCX.
Fix: add the missing offsets (CORE_ID, BIV, BTV, ISP, LCX, VCON0) to arch/csfr.h with the TRICORE_CPU_ prefix and use them.

@ssekar15 ssekar15 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zhangyu-duck @xiaoxiang781216 avoid duplication and conflict of our initial work, here is split up for startup without iLLD #21546.

@zhangyu981027

Copy link
Copy Markdown
Contributor Author

@zhangyu-duck @xiaoxiang781216 avoid duplication and conflict of our initial work, here is split up for startup without iLLD #21546.

This startup optimization does not involve removing iLLD; rather, it aligns the approach with that of other architectures.

@ssekar15

ssekar15 commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

@zhangyu-duck @xiaoxiang781216 avoid duplication and conflict of our initial work, here is split up for startup without iLLD #21546.

This startup optimization does not involve removing iLLD; rather, it aligns the approach with that of other architectures.

As I mentioned earlier, if our initial PR had merged there is no needed of this PR. whole point is we already doing split of our PR and asked to wait untill.. these PR create unnecessary conflict and duplication, please wait until we finish.

@zhangyu981027

Copy link
Copy Markdown
Contributor Author

@zhangyu-duck @xiaoxiang781216 avoid duplication and conflict of our initial work, here is split up for startup without iLLD #21546.

This startup optimization does not involve removing iLLD; rather, it aligns the approach with that of other architectures.

As I mentioned earlier, if our initial PR had merged there is no needed of this PR. whole point is we already doing split of our PR and asked to wait untill.. these PR create unnecessary conflict and duplication, please wait until we finish.

Regarding the removal of the illd component, you base your changes on my PR for interrupts and traps. However, for the boot sequence, I still believe my own PR is more appropriate; this isn't just "removing illd," but rather aligning the boot process with that of other architectures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm Issues related to ARM (32-bit) architecture Arch: arm64 Issues related to ARM64 (64-bit) architecture Arch: tricore Issues related to the TriCore architecture from Infineon Area: Build system Board: tricore Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants