RTT and VSCode
romancardenas opened this issue · 2 comments
I'm trying to setup a VS Code project for debugging embedded rust applications for the micro:bit v2.20 board.
I use the following tools:
- MacOS 12.3.1
- OpenOCD 0.11.0
- The
cortex-debug
plugin for VSCode.
The Rust project is available in this repository.
It should be easy to reproduce my problem, but I can provide you more details if needed.
The repository contains all the required files for using either cargo-embed
or VSCode.
With cargo-embed
, the RTT channel is successfully created and I can see the rprintln!
messages. However, cargo-embed
does not support RTT and GDB debugging simultaneously.
With cortex-debug
, I use the following launch.json
file:
{
"version": "0.2.0",
"showDevDebugOutput": true,
"configurations": [
{
"name": "Debug (Blinky)",
"type": "cortex-debug",
"preLaunchTask": "build",
"request": "launch",
"servertype": "openocd",
"interface": "swd",
"cwd": "${workspaceRoot}",
"executable": "${workspaceRoot}/target/thumbv7em-none-eabihf/debug/blink-led",
"device": "nrf52833_01AA",
"svdFile": "${workspaceRoot}/nrf52833.svd",
"configFiles": [
"interface/cmsis-dap.cfg",
"target/nrf52.cfg"
],
"rttConfig": {
"enabled": true,
"address": "auto",
"decoders": [
{
"port": 0,
"type": "console"
}
]
},
"runToEntryPoint": "main",
},
]
}
The debugging works great. However, it seems that the RTT channel is not successfully created:
Info : Listening on port 60002 for rtt connections
Info : rtt: Searching for control block 'SEGGER RTT'
Info : rtt: No control block found
Info : accepting 'rtt' connection on tcp/60002
I'm not sure what I am missing. Do you know how to configure the cortex-debug
plugin for debugging AND RTT channel?
I've been reading the cortex-debug
documentation for RTT channels. It seems that "Setup of RTT is automatic by default. For this to work, your executable needs to have symbols so we can locate the address of the global symbol _SEGGER_RTT
". Does this crate create this symbol at compilation time or at run time? Maybe that is the issue.
I asked to the folks of cortex-debug
here and they found the issue: OpenOCD only looks for the RTT control block once at the beginning. As this block is not still ready, it returns an error and forgets about it. I'll try to install a JLink-compliant driver to my board and see if JLink solves this by automatically polling the RTT block.