MCU online debugging skill using SEGGER J-Link RTT for automated log collection and AI-driven analysis. Use when users need to debug embedded MCU firmware, collect RTT logs, analyze runtime behavior, or get AI feedback on firmware execution status. Triggers on phrases like "start debugging", "check MCU logs", "online debug", "RTT logs", "analyze firmware", or "run tests on MCU".
Automated MCU debugging skill using SEGGER J-Link RTT. Enables headless log collection, analysis, and AI-driven feedback without GUI dependencies.
Verify installation:
which JLinkRTTLogger || echo "JLinkRTTLogger not found in PATH"
python scripts/rtt_control.py start \
--device STM32F103C8 \
--speed 4000 \
--channel 0 \
--output /tmp/rtt_latest.log
# Run for 30 seconds, then stop
python scripts/rtt_control.py start --device STM32F103C8 --duration 30
python scripts/analyze_log.py /tmp/rtt_latest.log
RTT log collection control. Run with --help for full options.
Key Commands:
start - Start RTT log collectionstop - Stop running RTT sessionstatus - Check if RTT is runningParameters:
| Parameter | Description | Default |
|---|---|---|
--device | MCU device name (e.g., STM32F103C8) | Required |
--interface | Debug interface (SWD/JTAG) | SWD |
--speed | SWD clock speed in kHz | 4000 |
--channel | RTT Up Channel number | 0 |
--output | Log output file path | /tmp/rtt_latest.log |
--duration | Auto-stop after N seconds | None (manual) |
--background | Run in background mode | False |
Log analysis and AI feedback generation. Run with --help for full options.
Key Options:
--last-seconds N - Analyze only last N seconds--last-lines N - Analyze only last N lines--format json|text - Output format--summary - Generate executive summary onlyWhen user says: "Start online debugging for 30 seconds, check if code runs correctly"
Execute this workflow:
Start RTT collection in background
python scripts/rtt_control.py start \
--device <MCU_DEVICE> \
--duration 30 \
--background
Wait for collection to complete (or manually stop early)
Analyze collected logs
python scripts/analyze_log.py /tmp/rtt_latest.log --summary
Report findings with structured conclusion:
For optimal AI analysis, firmware should follow the structured log format. See references/log_format.md for detailed specification.
Required Prefixes:
[BOOT] - Boot/initialization messages[STAT] - Status/statistics[TEST] - Test results[ERR] - Errors[ASSERT] - Assertion failures[FAULT] - HardFault/system faultsRecommended Key-Value Format:
[TEST] name=spi_dma result=pass
[ERR] type=i2c_nack addr=0x68
[STAT] loop_hz=998 heap_free=4096
| Scenario | Script Behavior |
|---|---|
| J-Link not connected | Exit with clear error message |
| MCU not responding | Retry 3 times, then report failure |
| RTT not initialized | Report "RTT control block not found" |
| MCU reset during logging | Attempt to re-attach automatically |
{
"status": "FAIL",
"duration_seconds": 30,
"summary": {
"boot_detected": true,
"tests_run": 5,
"tests_passed": 4,
"tests_failed": 1,
"errors_count": 2,
"faults_detected": false
},
"errors": [
{"type": "i2c_nack", "addr": "0x68", "count": 2, "first_seen": "00:15.234"}
],
"failed_tests": [
{"name": "i2c_sensor_read", "reason": "timeout"}
],
"recommendation": "I2C communication failure detected. Check I2C bus connections and pull-up resistors. Verify device at address 0x68 is powered and responding."
}
Future enhancements (not in current scope):