Skip to content

Commit c6784cb

Browse files
committed
arch/tricore: keep board details out of startup.S
- Only ulmk_board_init() may touch board SFRs; drop early WDT hook from startup and hard-coded WDTCPU1 from secondary (park uses board API) - HIL serial expect: hot-attach ulmk_release_run so CSA is not raced by the default watchdog before board_init
1 parent c7f15d8 commit c6784cb

6 files changed

Lines changed: 10 additions & 94 deletions

File tree

arch/tricore/board_wdt_early_stub.S

Lines changed: 0 additions & 11 deletions
This file was deleted.

arch/tricore/secondary.S

Lines changed: 3 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
* DBGSR.HALT. This prologue builds a private CSA free list in DSPR1
77
* (segment 0x6), loads park SP + small-data anchors, then jumps to
88
* ulmk_arch_smp_park() which waits for release and calls the kernel entry.
9+
*
10+
* Board WDT for this core is handled by ulmk_board_cpu_wdt_disable_self()
11+
* inside ulmk_arch_smp_park() — no board SFRs in this file.
912
*/
1013

1114
.extern _ulmk_park_stack_cpu1_top
@@ -20,75 +23,12 @@
2023
.section .text._ulmk_cpu1_start, "ax"
2124
.global _ulmk_cpu1_start
2225
.type _ulmk_cpu1_start, @function
23-
.set WDTCPU1_CON0, 0xF003610C
24-
.set WDTCPU1_CON1, 0xF0036110
25-
2626
_ulmk_cpu1_start:
2727
disable
2828

2929
movh.a %a10, hi:_ulmk_park_stack_cpu1_top
3030
lea %a10, [%a10] lo:_ulmk_park_stack_cpu1_top
3131

32-
/*
33-
* Disarm WDTCPU1 before CSA construction. OpenOCD reset-end may
34-
* already have set DR, but button/PORST and flash paths without a
35-
* sticky DAP poke leave the default timeout armed — CSA init is
36-
* long enough to expire it. Own-core EndInit only (never from CPU0).
37-
*/
38-
movh.a %a2, hi:WDTCPU1_CON0
39-
lea %a2, [%a2] lo:WDTCPU1_CON0
40-
ld.w %d0, [%a2]0
41-
extr.u %d8, %d0, 2, 14 /* PW */
42-
mov %d1, 0x3F
43-
xor %d8, %d1
44-
extr.u %d9, %d0, 16, 16 /* REL */
45-
extr.u %d2, %d0, 1, 1 /* LCK? */
46-
jz %d2, .L_wdt1_cle2
47-
sh %d0, %d8, 2
48-
mov %d1, 1
49-
or %d0, %d1
50-
sh %d1, %d9, 16
51-
or %d0, %d1
52-
st.w [%a2]0, %d0
53-
.L_wdt1_cle2:
54-
sh %d0, %d8, 2
55-
mov %d1, 2 /* ENDINIT=0 LCK=1 */
56-
or %d0, %d1
57-
sh %d1, %d9, 16
58-
or %d0, %d1
59-
st.w [%a2]0, %d0
60-
.L_wdt1_wait0:
61-
ld.w %d0, [%a2]0
62-
and %d1, %d0, 1
63-
jnz %d1, .L_wdt1_wait0
64-
65-
movh.a %a3, hi:WDTCPU1_CON1
66-
lea %a3, [%a3] lo:WDTCPU1_CON1
67-
mov %d0, 8 /* DR=1 */
68-
st.w [%a3]0, %d0
69-
70-
ld.w %d0, [%a2]0
71-
extr.u %d9, %d0, 16, 16
72-
extr.u %d2, %d0, 1, 1
73-
jz %d2, .L_wdt1_set2
74-
sh %d0, %d8, 2
75-
mov %d1, 1
76-
or %d0, %d1
77-
sh %d1, %d9, 16
78-
or %d0, %d1
79-
st.w [%a2]0, %d0
80-
.L_wdt1_set2:
81-
sh %d0, %d8, 2
82-
mov %d1, 3 /* ENDINIT=1 LCK=1 */
83-
or %d0, %d1
84-
sh %d1, %d9, 16
85-
or %d0, %d1
86-
st.w [%a2]0, %d0
87-
.L_wdt1_wait1:
88-
ld.w %d0, [%a2]0
89-
and %d1, %d0, 1
90-
jz %d1, .L_wdt1_wait1
91-
9232
/*
9333
* CSA free list for DSPR1 @ 0x6xxx_xxxx:
9434
* link = 0x00060000 | extr.u(addr, 6, 16)

arch/tricore/startup.S

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
* 2. Build CSA free list (FCX/LCX) — mandatory before ANY call
1212
* 3. Set small-data address registers (A0, A1, A8, A9)
1313
* 4. Jump to ulmk_kern_start() — does not return
14+
*
15+
* Board-specific bring-up (WDT, PLL, …) belongs in ulmk_board_init(), called
16+
* from ulmk_kern_start() — never from this file.
1417
*/
1518

1619
.extern _ulmk_kernel_stack_top
@@ -21,7 +24,6 @@
2124
.extern _small_data3_
2225
.extern _small_data4_
2326
.extern ulmk_kern_start
24-
.extern ulmk_board_wdt_disable_early
2527

2628
.section .text._start, "ax"
2729
.global _start
@@ -30,21 +32,6 @@ _start:
3032
/* 0. Interrupts off until the kernel unlocks them. */
3133
disable
3234

33-
/*
34-
* Board hook: disable CPU0 + Safety WDT before CSA construction.
35-
* Default timeout can expire during the CSA loop on standalone reset
36-
* (OpenOCD reset-end pokes WDT only under OCDS). Weak stub is ji %a11.
37-
* No CALL (CSA not ready). ji needs a register operand; local .L labels
38-
* have no hi/lo reloc — use a global continue label.
39-
*/
40-
movh.a %a11, hi:_start_after_wdt
41-
lea %a11, [%a11] lo:_start_after_wdt
42-
movh.a %a2, hi:ulmk_board_wdt_disable_early
43-
lea %a2, [%a2] lo:ulmk_board_wdt_disable_early
44-
ji %a2
45-
.global _start_after_wdt
46-
_start_after_wdt:
47-
4835
/* 1. Supervisor stack + clear PSW.IS
4936
*
5037
* SSW / cold reset may leave PSW.IS=1. board_init runs before arch_init
@@ -122,7 +109,7 @@ _start_after_wdt:
122109
movh.a %a9, hi:_small_data4_
123110
lea %a9, [%a9] lo:_small_data4_
124111

125-
/* 4. Common C runtime bring-up (relocates .data/.bss, calls kernel). */
112+
/* 4. Common C runtime bring-up (relocates .data/.bss, calls board_init). */
126113
j ulmk_kern_start
127114

128115
.L_hang:

cmake/arch_sources.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ if(ULMK_ARCH STREQUAL "tricore")
77
${ULMK_ARCH_DIR}/ctx_switch.S)
88
set(ULMK_ARCH_EXE_SOURCES
99
${ULMK_ARCH_DIR}/startup.S
10-
${ULMK_ARCH_DIR}/board_wdt_early_stub.S
1110
${ULMK_ARCH_DIR}/secondary.S
1211
${ULMK_ARCH_DIR}/vectors.S)
1312
elseif(ULMK_ARCH STREQUAL "riscv")

tests/arch/tricore.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ ARCH_LDFLAGS := -mcpu=tc39xx
1717

1818
ARCH_KERNEL_SRCS := \
1919
$(ROOT)/arch/tricore/startup.S \
20-
$(ROOT)/arch/tricore/board_wdt_early_stub.S \
2120
$(ROOT)/arch/tricore/arch.c \
2221
$(ROOT)/arch/tricore/smp.c \
2322
$(ROOT)/arch/tricore/ctx_switch.S \

tools/hil/hil_serial_expect.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ sleep 0.2
5555

5656
if [[ -n "${ULMK_HIL_OCD:-}" && -n "${ULMK_HIL_OCD_CFG:-}" ]]; then
5757
pkill -9 -x openocd 2>/dev/null || true
58+
# Prefer hot-attach release (WDT disarm + HARR clear). "reset halt" races
59+
# the OCDS sequencer on TAS and can leave the core stuck at STAD.
5860
"${ULMK_HIL_OCD}" -s "${ULMK_HIL_OCD_SCRIPTS}" -s "${ULMK_HIL_OCD_BOARD_DIR}" \
5961
-f "${ULMK_HIL_OCD_CFG}" \
60-
-c "gdb port disabled; init; reset halt; resume; shutdown" \
62+
-c "gdb port disabled; reset_config none separate; init; targets tc27x.cpu0; ulmk_release_run; resume; after 200; shutdown" \
6163
>/dev/null 2>&1 || true
6264
fi
6365

0 commit comments

Comments
 (0)