cortex-debug icon indicating copy to clipboard operation
cortex-debug copied to clipboard

No RTT connect retry with OpenOCD

Open kossnikita opened this issue 1 year ago • 1 comments

Describe the bug

cortex-debug try to start RTT before RTT initialization, so OpenOCD unable to find RTT block. But there's no connect retry after that. Even with rtt_start_retry > 0

But I able to start RTT with telnet rtt start after SEGGER_RTT_ConfigUpBuffer() during debug session and this works.

Also I have similar project with same setup (board + stlink) and this works perfectly on same host with same launch.json. Can't say what difference between projects.

Expected behavior

cortex-debug should retry connect to RTT if rtt_start_retry > 0

Environment:

  • Cortex-Debug 1.12.1 git(652d042)
  • OS: Windows_NT x64 10.0.22621
  • GDB Version: Open On-Chip Debugger 0.11.0-00006-gbec841d3f-dirty
  • Compiler Toolchain Version: Arm GNU Toolchain 13.2.rel1 (Build arm-13.7)) 13.2.90.20231008-git

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "cortex-debug",
            "name": "Cortex Debug",
            "cwd": "${workspaceFolder}",
            "serverpath": "D:/ARM/tool-openocd-at32-0.1100.220911/bin/openocd.exe",
            "executable": "${workspaceFolder}/build/firmware",
            "request": "launch",
            "servertype": "openocd",
            "svdFile": "${workspaceFolder}/peripherals.svd",
            "showDevDebugOutput": "raw",
            "runToEntryPoint": "main",
            "configFiles": [
                "interface/stlink.cfg",
                "target/at32f421xx.cfg"
            ],
            "rttConfig": {
                "enabled": true,
                "address": "auto",
                "clearSearch": false,
                "rtt_start_retry": 1000,
                "decoders": [
                    {
                        "port": 0,
                        "type": "console",
                    },
                ]
            },
        }
    ]
}

Attach text from Debug Console

Cortex-Debug: VSCode debugger extension version 1.12.1 git(652d042). Usage info: https://github.com/Marus/cortex-debug#usage
"configuration": {
    "type": "cortex-debug",
    "name": "Cortex Debug",
    "cwd": "D:\\ARM\\oled-test",
    "serverpath": "D:/ARM/tool-openocd-at32-0.1100.220911/bin/openocd.exe",
    "executable": "D:/ARM/oled-test/build/firmware",
    "request": "launch",
    "servertype": "openocd",
    "svdFile": "D:\\ARM\\oled-test/peripherals.svd",
    "showDevDebugOutput": "raw",
    "runToEntryPoint": "main",
    "configFiles": [
        "interface/stlink.cfg",
        "target/at32f421xx.cfg"
    ],
    "rttConfig": {
        "enabled": true,
        "address": "auto",
        "clearSearch": false,
        "rtt_start_retry": 1000,
        "decoders": [
            {
                "port": 0,
                "type": "console"
            }
        ]
    },
    "__configurationTarget": 6,
    "gdbServerConsolePort": 55878,
    "pvtAvoidPorts": [],
    "chainedConfigurations": {
        "enabled": false
    },
    "debuggerArgs": [],
    "swoConfig": {
        "enabled": false,
        "decoders": [],
        "cpuFrequency": 0,
        "swoFrequency": 0,
        "source": "probe"
    },
    "graphConfig": [],
    "preLaunchCommands": [],
    "postLaunchCommands": [],
    "preAttachCommands": [],
    "postAttachCommands": [],
    "preRestartCommands": [],
    "postRestartCommands": [],
    "preResetCommands": [],
    "postResetCommands": [],
    "searchDir": [],
    "toolchainPrefix": "arm-none-eabi",
    "extensionPath": "c:/Portable/VSCode/data/extensions/marus25.cortex-debug-1.12.1",
    "registerUseNaturalFormat": true,
    "variableUseNaturalFormat": false,
    "pvtVersion": "1.12.1",
    "__sessionId": "ca2c8565-6ffd-4d1b-9e14-75d3a222edc3",
    "pvtShowDevDebugOutput": "raw"
}
Reading symbols from arm-none-eabi-objdump.exe --syms -C -h -w D:/ARM/oled-test/build/firmware
Reading symbols from arm-none-eabi-nm.exe --defined-only -S -l -C -p D:/ARM/oled-test/build/firmware
Launching GDB: arm-none-eabi-gdb.exe -q --interpreter=mi2
1-gdb-version
Launching gdb-server: "D:/ARM/tool-openocd-at32-0.1100.220911/bin/openocd.exe" -c "gdb_port 50000" -c "tcl_port 50001" -c "telnet_port 50002" -s "D:\\ARM\\oled-test" -f "c:/Portable/VSCode/data/extensions/marus25.cortex-debug-1.12.1/support/openocd-helpers.tcl" -f interface/stlink.cfg -f target/at32f421xx.cfg
    Please check TERMINAL tab (gdb-server) for output from D:/ARM/tool-openocd-at32-0.1100.220911/bin/openocd.exe
Finished reading symbols from objdump: Time: 57 ms
Finished reading symbols from nm: Time: 61 ms
-> =thread-group-added,id="i1"
-> ~"GNU gdb (Arm GNU Toolchain 13.2.rel1 (Build arm-13.7)) 13.2.90.20231008-git\n"
-> ~"Copyright (C) 2023 Free Software Foundation, Inc.\n"
-> ~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law."
-> ~"\nType \"show copying\" and \"show warranty\" for details.\n"
-> ~"This GDB was configured as \"--host=i686-w64-mingw32 --target=arm-none-eabi\".\n"
-> ~"Type \"show configuration\" for configuration details.\n"
-> ~"For bug reporting instructions, please see:\n"
-> ~"<https://bugs.linaro.org/>.\n"
-> ~"Find the GDB manual and other documentation resources online at:\n    <"
-> ~"http://www.gnu.org/software/gdb/documentation/>.\n\n"
-> ~"For help, type \"help\".\n"
-> ~"Type \"apropos word\" to search for commands related to \"word\".\n"
-> 1^done
2-gdb-set mi-async on
-> 2^done
3-interpreter-exec console "set print demangle on"
-> 3^done
4-interpreter-exec console "set print asm-demangle on"
-> =cmd-param-changed,param="print asm-demangle",value="on"
-> 4^done
5-enable-pretty-printing
-> 5^done
6-interpreter-exec console "source c:/Portable/VSCode/data/extensions/marus25.cortex-debug-1.12.1/support/gdbsupport.init"
-> 6^done
7-interpreter-exec console "source c:/Portable/VSCode/data/extensions/marus25.cortex-debug-1.12.1/support/gdb-swo.init"
-> =cmd-param-changed,param="language",value="c"
-> =cmd-param-changed,param="language",value="auto"
-> 7^done
8-interpreter-exec console "set output-radix 0x10"
-> ~"Output radix now set to decimal 16, hex 10, octal 20.\n"
Output radix now set to decimal 16, hex 10, octal 20.
-> =cmd-param-changed,param="output-radix",value="16"
-> 8^done
9-interpreter-exec console "set input-radix 0xa"
-> ~"Input radix now set to decimal 10, hex a, octal 12.\n"
Input radix now set to decimal 10, hex a, octal 12.
-> 9^done
10-file-exec-and-symbols "D:/ARM/oled-test/build/firmware"
-> 10^done
11-target-select extended-remote localhost:50000
-> =thread-group-started,id="i1",pid="42000"
-> =thread-created,id="1",group-id="i1"
-> ~"0x08000410 in main () at D:/ARM/oled-test/src/main.c:63\n"
0x08000410 in main () at D:/ARM/oled-test/src/main.c:63
-> ~"63\t  while (1) {\n"
63	  while (1) {
-> *stopped,frame={addr="0x08000410",func="main",args=[],file="D:/ARM/oled-test/src/main.c",fullname="D:\\ARM\\oled-test\\src\\main.c",line="63",arch="armv7e-m"},thread-id="1",stopped-threads="all"
mi2.status = stopped
Program stopped, probably due to a reset and/or halt issued by debugger
-> 11^connected
12-interpreter-exec console "monitor reset halt"
-> @"target halted due to debug-request, current mode: Thread \n"
target halted due to debug-request, current mode: Thread
-> @"xPSR: 0x01000000 pc: 0x080004d4 msp: 0x20004000\n"
xPSR: 0x01000000 pc: 0x080004d4 msp: 0x20004000
-> 12^done
13-target-download
-> 13+download,{section=".isr_vector",section-size="204",total-size="69225"}
-> 13+download,{section=".isr_vector",section-sent="204",section-size="204",total-sent="204",total-size="69225"}
-> 13+download,{section=".text",section-size="6352",total-size="69225"}
-> 13+download,{section=".rodata",section-size="144",total-size="69225"}
-> 13+download,{section=".ARM",section-size="8",total-size="69225"}
-> 13+download,{section=".init_array",section-size="8",total-size="69225"}
-> 13+download,{section=".fini_array",section-size="4",total-size="69225"}
-> 13+download,{section=".data",section-size="8",total-size="69225"}
-> 13^done,address="0x080004d4",load-size="6728",transfer-rate="157840",write-rate="961"
14-interpreter-exec console "monitor reset halt"
-> @"target halted due to debug-request, current mode: Thread \n"
target halted due to debug-request, current mode: Thread
-> @"xPSR: 0x01000000 pc: 0x080004d4 msp: 0x20004000\n"
xPSR: 0x01000000 pc: 0x080004d4 msp: 0x20004000
-> 14^done
Created RTT terminal for channel 0 on tcp port 60501
Returning dummy thread-id to workaround VSCode issue with pause button not working
Returning dummy thread-id to workaround VSCode issue with pause button not working
Returning dummy stack frame to workaround VSCode issue with pause button not working: {"threadId":1,"startFrame":0,"levels":20}
15-stack-list-frames --thread 1 0 0
-> 15^done,stack=[frame={level="0",addr="0x080004d4",func="Reset_Handler",arch="armv7e-m"}]
16-var-create --thread 1 --frame 0 hover_7a75c957b76689d3b6a0a85c8c658938ef2dc0b775bca777cfb982c515a1b9e3 @ "_tx_thread_created_ptr"
-> &"warning: could not convert '_tx_thread_created_ptr' from the host encoding (CP1252) to UTF-32.\nThis normally should not happen, please file a bug report."
warning: could not convert '_tx_thread_created_ptr' from the host encoding (CP1252) to UTF-32.
This normally should not happen, please file a bug report.
-> &"\n"

-> 16^error,msg="-var-create: unable to create variable object"
hover -var-create: unable to create variable object (from var-create --thread 1 --frame 0 hover_7a75c957b76689d3b6a0a85c8c658938ef2dc0b775bca777cfb982c515a1b9e3 @ "_tx_thread_created_ptr")17-var-create --thread 1 --frame 0 hover_a0caade21aee976e19237a7c24094af6def1d2acf887dea47c867fd543f48cc2 @ "pxReadyTasksLists"
-> 17^error,msg="-var-create: unable to create variable object"
hover -var-create: unable to create variable object (from var-create --thread 1 --frame 0 hover_a0caade21aee976e19237a7c24094af6def1d2acf887dea47c867fd543f48cc2 @ "pxReadyTasksLists")18-var-create --thread 1 --frame 0 hover_3a036eb0c8fd1a02d65dd10c96ee568e6997b1105097f5efe0bf86d1c1fd3176 @ "_kernel_thread_info_offsets"
-> 18^error,msg="-var-create: unable to create variable object"
hover -var-create: unable to create variable object (from var-create --thread 1 --frame 0 hover_3a036eb0c8fd1a02d65dd10c96ee568e6997b1105097f5efe0bf86d1c1fd3176 @ "_kernel_thread_info_offsets")19-var-create --thread 1 --frame 0 hover_88a8e759d0b575f6f113f5badafcf28ed3aeb200cbe075b3bf4af9a8ae216f56 @ "_track_list_k_mutex"
-> 19^error,msg="-var-create: unable to create variable object"
hover -var-create: unable to create variable object (from var-create --thread 1 --frame 0 hover_88a8e759d0b575f6f113f5badafcf28ed3aeb200cbe075b3bf4af9a8ae216f56 @ "_track_list_k_mutex")20-interpreter-exec console "monitor rtt setup 0x20000008 10 {SEGGER RTT}"
-> 20^done
21-interpreter-exec console "monitor rtt server start 60501 0"
-> @"Listening on port 60501 for rtt connections\n"
Listening on port 60501 for rtt connections
-> 21^done
22-interpreter-exec console "monitor rtt start"
-> @"rtt: Searching for control block 'SEGGER RTT'\n"
rtt: Searching for control block 'SEGGER RTT'
-> @"rtt: No control block found\n"
rtt: No control block found
-> 22^done
23-break-insert -t --function main
-> ~"Note: automatically using hardware breakpoints for read-only addresses.\n"
Note: automatically using hardware breakpoints for read-only addresses.
-> 23^done,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x080003ea",func="main",file="D:/ARM/oled-test/src/main.c",fullname="D:\\ARM\\oled-test\\src\\main.c",line="59",thread-groups=["i1"],times="0",original-location="-function main"}
24-exec-continue --all
-> 24^running
-> *running,thread-id="all"
mi2.status = running
-> @"accepting 'rtt' connection on tcp/60501\n"
accepting 'rtt' connection on tcp/60501
-> =breakpoint-modified,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x080003ea",func="main",file="D:/ARM/oled-test/src/main.c",fullname="D:\\ARM\\oled-test\\src\\main.c",line="59",thread-groups=["i1"],times="1",original-location="-function main"}
-> ~"\n"

-> ~"Temporary breakpoint 1, main () at D:/ARM/oled-test/src/main.c:59\n"
Temporary breakpoint 1, main () at D:/ARM/oled-test/src/main.c:59
-> ~"59\t  SEGGER_RTT_ConfigUpBuffer(0, NULL, NULL, 0, SEGGER_RTT_MODE_NO_BLOCK_SKIP);\n"
59	  SEGGER_RTT_ConfigUpBuffer(0, NULL, NULL, 0, SEGGER_RTT_MODE_NO_BLOCK_SKIP);
-> *stopped,reason="breakpoint-hit",disp="del",bkptno="1",frame={addr="0x080003ea",func="main",args=[],file="D:/ARM/oled-test/src/main.c",fullname="D:\\ARM\\oled-test\\src\\main.c",line="59",arch="armv7e-m"},thread-id="1",stopped-threads="all"
mi2.status = stopped
-> =breakpoint-deleted,id="1"
25-thread-list-ids
-> 25^done,thread-ids={thread-id="1"},current-thread-id="1",number-of-threads="1"
26-thread-list-ids
-> 26^done,thread-ids={thread-id="1"},current-thread-id="1",number-of-threads="1"
27-thread-info 1
-> 27^done,threads=[{id="1",target-id="Remote target",frame={level="0",addr="0x080003ea",func="main",args=[],file="D:/ARM/oled-test/src/main.c",fullname="D:\\ARM\\oled-test\\src\\main.c",line="59",arch="armv7e-m"},state="stopped"}]
28-thread-info 1
-> 28^done,threads=[{id="1",target-id="Remote target",frame={level="0",addr="0x080003ea",func="main",args=[],file="D:/ARM/oled-test/src/main.c",fullname="D:\\ARM\\oled-test\\src\\main.c",line="59",arch="armv7e-m"},state="stopped"}]
29-stack-list-frames --thread 1 0 0
-> 29^done,stack=[frame={level="0",addr="0x080003ea",func="main",file="D:/ARM/oled-test/src/main.c",fullname="D:\\ARM\\oled-test\\src\\main.c",line="59",arch="armv7e-m"}]
30-stack-list-frames --thread 1 0 19
-> 30^done,stack=[frame={level="0",addr="0x080003ea",func="main",file="D:/ARM/oled-test/src/main.c",fullname="D:\\ARM\\oled-test\\src\\main.c",line="59",arch="armv7e-m"}]
31-var-create --thread 1 --frame 0 hover_7a75c957b76689d3b6a0a85c8c658938ef2dc0b775bca777cfb982c515a1b9e3 @ "_tx_thread_created_ptr"
-> 31^error,msg="-var-create: unable to create variable object"
hover -var-create: unable to create variable object (from var-create --thread 1 --frame 0 hover_7a75c957b76689d3b6a0a85c8c658938ef2dc0b775bca777cfb982c515a1b9e3 @ "_tx_thread_created_ptr")32-var-create --thread 1 --frame 0 hover_a0caade21aee976e19237a7c24094af6def1d2acf887dea47c867fd543f48cc2 @ "pxReadyTasksLists"
-> 32^error,msg="-var-create: unable to create variable object"
hover -var-create: unable to create variable object (from var-create --thread 1 --frame 0 hover_a0caade21aee976e19237a7c24094af6def1d2acf887dea47c867fd543f48cc2 @ "pxReadyTasksLists")33-var-create --thread 1 --frame 0 hover_3a036eb0c8fd1a02d65dd10c96ee568e6997b1105097f5efe0bf86d1c1fd3176 @ "_kernel_thread_info_offsets"
-> 33^error,msg="-var-create: unable to create variable object"
hover -var-create: unable to create variable object (from var-create --thread 1 --frame 0 hover_3a036eb0c8fd1a02d65dd10c96ee568e6997b1105097f5efe0bf86d1c1fd3176 @ "_kernel_thread_info_offsets")34-var-create --thread 1 --frame 0 hover_88a8e759d0b575f6f113f5badafcf28ed3aeb200cbe075b3bf4af9a8ae216f56 @ "_track_list_k_mutex"
-> 34^error,msg="-var-create: unable to create variable object"
hover -var-create: unable to create variable object (from var-create --thread 1 --frame 0 hover_88a8e759d0b575f6f113f5badafcf28ed3aeb200cbe075b3bf4af9a8ae216f56 @ "_track_list_k_mutex")35-stack-info-frame --thread 1 --frame 0
-> 35^done,frame={level="0",addr="0x080003ea",func="main",file="D:/ARM/oled-test/src/main.c",fullname="D:\\ARM\\oled-test\\src\\main.c",line="59",arch="armv7e-m"}
36-stack-list-variables --thread 1 --frame 0 --simple-values
-> 36^done,variables=[]
37-var-create --thread 1 --frame 0 hover_a5f8705d7a764a11607220227e75219e4cb3ab6fb7b609e174cebd291527cb25 @ "none"
-> 37^error,msg="-var-create: unable to create variable object"
hover -var-create: unable to create variable object (from var-create --thread 1 --frame 0 hover_a5f8705d7a764a11607220227e75219e4cb3ab6fb7b609e174cebd291527cb25 @ "none")

kossnikita avatar Mar 22 '24 11:03 kossnikita

I am having the same issue -- also with an ST-Link and OpenOCD. It can't find RTT at first and then never retries for some reason. A hacky workaround I added is to use

"postResetCommands": [
    "monitor rtt start"
]

And then manually reset the device after flashing. This gives it enough time to initialize RTT but isn't a great solution.

calebchalmers avatar May 20 '24 23:05 calebchalmers