J-Link RTT for the Masses using Semihosting on ARM
4 hours ago
- #semihosting
- #debugging
- #embedded
- J-Link RTT allows non-blocking bidirectional communication over SWD lines using ring buffers in memory.
- Semihosting enables syscalls where the debug probe acts as the kernel, useful for logging without extra hardware.
- Semihosting requires enabling in debug probes (e.g., pyocd with -S flag, openocd with specific commands).
- Semihosting involves a breakpoint instruction (bkpt 0xAB) to signal the debugger, which can throw exceptions if no debugger is connected.
- Modifying the hard fault handler is necessary to ignore exceptions when no debugger is present.
- Semihosting has performance implications as it interrupts the CPU to signal the debugger.
- Not all GUI debuggers handle semihosting gracefully; some may require disabling it via compilation flags.
- Weak attribute or linker flags can help override standard write implementations for semihosting.