| Component | Requirement |
|---|---|
| Target board | Infineon Aurix TC397 evaluation board (or TC387 Lite Kit); Cortex-M33 alternatives: STM32H7 Nucleo |
| Debug probe | Lauterbach LA-7780 (JTAG+ETM trace); or TRACE32 µTrace for single-core labs |
| TRACE32 version | R.2024.09 or later; license: TRACE32 for PowerPC/Aurix (or Cortex-M) |
| ELF file | debug_lab.elf — provided in course materials; compiled with -g -O0 for clear debug info |
| TRACE32 scripts | lab01_connect.cmm, lab01_ex1.cmm, lab01_ex2.cmm |
Lab Setup
Connect and Load Symbols
// Lab 01: Connect to target and load symbols
// Step 1: Establish JTAG connection
SYStem.RESet
SYStem.CPU TC397
SYStem.JtagClock 10MHz
SYStem.Option WATCHDOG OFF
SYStem.Up
IF INTERFACE.CABLE()!="LA-7780"
PRINT %ERROR "Wrong probe; connect LA-7780"
ELSE
PRINT "Connected: " CPUIS()
// Step 2: Load ELF with debug symbols
Data.LOAD.Elf lab_debug/debug_lab.elf /RELPATH
PRINT "Symbols loaded: " Symbol.COUNT() " symbols"
// Step 3: Reset target to defined start state
SYStem.Reset
Register.Set PC __start // set PC to reset vector
// Verify: check a known variable address
PRINT "g_testArray @ " Var.ADDRESS(g_testArray)
PRINT "Expected: within 0x70000000-0x70FFFFFF (LMU RAM)"
// Step 4: Run to main() before exercises
Go main
WAIT !STATE.RUN() 5s // wait up to 5s for halt at main
PRINT "Halted at: " Format.ADDRESS(Register(PC))Exercise 1: Find the Null Pointer Dereference
// Exercise 1: null pointer dereference — locate the fault
// Expected: program crashes inside ProcessCanFrame() with HardFault
// 1. Set catchpoint for HardFault exception (vector 3)
Break.Set VECTOR:3 /Program // halt when HardFault handler is entered
// 2. Run the program
Go
WAIT !STATE.RUN() 10s
// 3. At HardFault: read fault status registers
PRINT "HFSR: " Data.Long(SFR:SCB.HFSR) // HardFault Status Register
PRINT "CFSR: " Data.Long(SFR:SCB.CFSR) // Configurable Fault Status Register
PRINT "BFAR: " Data.Long(SFR:SCB.BFAR) // Bus Fault Address Register (faulting address)
// CFSR bit 15 (BFARVALID): 1 = BFAR contains valid fault address
// 4. Check LR to reconstruct which exception handler we're in
PRINT "LR=" Register(LR) // should be 0xFFFFFFF9 or 0xFFFFFFFD
// 5. Get PC at time of fault (in hw-pushed stack frame)
// Hardware pushes PC at SP+24
LOCAL &fault_pc
&fault_pc=Data.Long(Register(SP)+24.)
PRINT "Faulting PC: " Format.ADDRESS(&fault_pc)
// Convert to source: list source at faulting address
List &fault_pc
// Expected finding: ptr = GetCanFramePtr() returned NULL; code derefs without null check
// Fix: add null check before dereferencing GetCanFramePtr() return valueExercise 2: Stack Overflow Corruption
// Exercise 2: stack buffer overflow corrupts return address
// Symptom: function returns to wrong address -> HardFault or random behaviour
// 1. Enable stack guard watchpoint at bottom of task stack
// Stack grows down; guard zone at lowest addresses
LOCAL &stack_base
&stack_base=Var.ADDRESS(task_stack_buf)
Break.Set &stack_base /Write /Hardware // fires if stack grows below guard
// 2. Run the program; trigger the overflow condition
Go
WAIT !STATE.RUN() 10s
// 3. At watchpoint hit: inspect the situation
PRINT "Watchpoint hit at PC=" Register(PC)
PRINT "Data written to: " Register(DWT_COMP0) // address that triggered watchpoint
// 4. View the corrupted stack
Data.dump &stack_base--(&stack_base+0x100) /Long
// 5. Backtrace: where are we?
Frame.view /Caller
// 6. Find the over-writing function
// Look at Frame 0: the function writing below stack = the source of overflow
// Check Frame.LOCAL 0 for large local arrays or memcpy calls
// Expected finding: char local_buf[64]; memcpy(local_buf, src, src_len);
// src_len comes from untrusted CAN RX, not bounds-checked
// Fix: validate src_len <= sizeof(local_buf) before memcpySummary
Two exercises, two of the most common embedded bug classes: null pointer dereferences (caught via HardFault catchpoint + CFSR/BFAR register inspection) and stack overflows (caught via DWT watchpoint at the stack guard zone). The CFSR BFARVALID bit plus the BFAR register pinpoint the exact faulting address in under 30 seconds — no printf debugging, no recompilation. The stack guard watchpoint triggers at the exact instruction that first writes outside the task stack boundary, making root cause identification straightforward.
🔬 Deep Dive — Core Concepts Expanded
This section builds on the foundational concepts covered above with additional technical depth, edge cases, and configuration nuances that separate competent engineers from experts. When working on production ECU projects, the details covered here are the ones most commonly responsible for integration delays and late-phase defects.
Key principles to reinforce:
- Configuration over coding: In AUTOSAR and automotive middleware environments, correctness is largely determined by ARXML configuration, not application code. A correctly implemented algorithm can produce wrong results due to a single misconfigured parameter.
- Traceability as a first-class concern: Every configuration decision should be traceable to a requirement, safety goal, or architecture decision. Undocumented configuration choices are a common source of regression defects when ECUs are updated.
- Cross-module dependencies: In tightly integrated automotive software stacks, changing one module's configuration often requires corresponding updates in dependent modules. Always perform a dependency impact analysis before submitting configuration changes.
🏭 How This Topic Appears in Production Projects
- Project integration phase: The concepts covered in this lesson are most commonly encountered during ECU integration testing — when multiple software components from different teams are combined for the first time. Issues that were invisible in unit tests frequently surface at this stage.
- Supplier/OEM interface: This is a topic that frequently appears in technical discussions between Tier-1 ECU suppliers and OEM system integrators. Engineers who can speak fluently about these details earn credibility and are often brought into critical design review meetings.
- Automotive tool ecosystem: Vector CANoe/CANalyzer, dSPACE tools, and ETAS INCA are the standard tools used to validate and measure the correct behaviour of the systems described in this lesson. Familiarity with these tools alongside the conceptual knowledge dramatically accelerates debugging in real projects.
⚠️ Common Mistakes and How to Avoid Them
- Assuming default configuration is correct: Automotive software tools ship with default configurations that are designed to compile and link, not to meet project-specific requirements. Every configuration parameter needs to be consciously set. 'It compiled' is not the same as 'it is correctly configured'.
- Skipping documentation of configuration rationale: In a 3-year ECU project with team turnover, undocumented configuration choices become tribal knowledge that disappears when engineers leave. Document why a parameter is set to a specific value, not just what it is set to.
- Testing only the happy path: Automotive ECUs must behave correctly under fault conditions, voltage variations, and communication errors. Always test the error handling paths as rigorously as the nominal operation. Many production escapes originate in untested error branches.
- Version mismatches between teams: In a multi-team project, the BSW team, SWC team, and system integration team may use different versions of the same ARXML file. Version management of all ARXML files in a shared repository is mandatory, not optional.
📊 Industry Note
Engineers who master both the theoretical concepts and the practical toolchain skills covered in this course are among the most sought-after professionals in the automotive software industry. The combination of AUTOSAR standards knowledge, safety engineering understanding, and hands-on configuration experience commands premium salaries at OEMs and Tier-1 suppliers globally.