0
\$\begingroup\$

First and for most I googled a lot and Its been a week of searching with no solution at all. Please bare with me!

I tried to add all necessary info! Please request more If you need.

My problem is:

I am trying to debug a STM32 bluepill board with skeleton code project using STM32-for-vscode, OpenOCD and cortex debug in Vscode but without any success. The debugging session fails!

My environment is:

1- Mac OS Big Sur version 11.1 (20C69).

2- VSCODE.

3- Cortex Debug Plugin.

4- STM32-for-Vscode plugin.

5- ARM plugin.

6- The project is a Skeleton code created using STM32CubeMax as per STM32-for-Vscode instructions.

7- Brew "Opened --HEAD" version which should work with Cortex debug plugin.

8- Using a STM32f103c8 bluepill flashed with STlink V2.1 firmware as a STlink dongle. I already edited the .cfg file to allow for non genuine STM32 CPU IDs.

9- Using stm32f103c8 bluepill as Target board to upload Code and Debug.

Please note that the exact same Hardware set works perfectly with PlatformIO and flashes and debugs correctly.

Launch.json configuration:

{ "configurations": [ { "showDevDebugOutput": true, "cwd": "${workspaceRoot}", "executable": "./build/SkeletonCode.elf", "name": "Debug STM32", "request": "launch", "type": "cortex-debug", "servertype": "openocd", "preLaunchTask": "Build STM", "device": "stlink", "configFiles": [ "interface/stlink.cfg", "target/stm32f1x.cfg" ] } ] } 

tasks.json configuration

{ "version": "2.0.0", "tasks": [ { "label": "Build STM", "type": "process", "command": "${command:stm32-for-vscode.build}", "options": { "cwd": "${workspaceRoot}" }, "group": { "kind": "build", "isDefault": true }, "problemMatcher": [ "$gcc" ] }, { "label": "Build Clean STM", "type": "process", "command": "${command:stm32-for-vscode.cleanBuild}", "options": { "cwd": "${workspaceRoot}" }, "group": { "kind": "build", "isDefault": true }, "problemMatcher": [ "$gcc" ] }, { "label": "Flash STM", "type": "process", "command": "${command:stm32-for-vscode.flash}", "options": { "cwd": "${workspaceRoot}" }, "group": { "kind": "build", "isDefault": true }, "problemMatcher": [ "$gcc" ] } ] } 

When I start debugging I get the code control in the startup file on movs r1, #0 with the debugger controls with the following:

Output:

Open On-Chip Debugger 0.11.0-rc2+dev-g427552c-dirty (2021-01-30-10:09) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'. Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD Info : Listening on port 6666 for tcl connections Info : Listening on port 4444 for telnet connections Info : clock speed 1000 kHz Info : STLINK V2J37S7 (API v2) VID:PID 0483:3748 Info : Target voltage: 5.022309 Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints Info : starting gdb server for stm32f1x.cpu on 50000 Info : Listening on port 50000 for gdb connections Info : accepting 'gdb' connection on tcp/50000 target halted due to debug-request, current mode: Handler HardFault xPSR: 0x01000003 pc: 0xfffffffe msp: 0xffffffd8 Info : device id = 0x20036410 Info : flash size = 64kbytes target halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc target halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc target halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x08000974 msp: 0x20005000 Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 100ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 700ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 1500ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 3100ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 6300ms 

Debug console output

Reading symbols from '/Users/engmoh/Embedded/VSCODE_Projects/2-STM32_Skeleton/build/SkeletonCode.elf' Finished reading symbols Please check OUTPUT tab (Adapter Output) for output from /usr/local/bin/openocd Launching server: "/usr/local/bin/openocd" "-c" "gdb_port 50000" "-s" "/Users/engmoh/Embedded/VSCODE_Projects/2-STM32_Skeleton" "-f" "interface/stlink.cfg" "-f" "target/stm32f1x.cfg" Launching GDB: "arm-none-eabi-gdb" "-q" "--interpreter=mi2" 1-gdb-set target-async on 2-interpreter-exec console "source /Users/engmoh/.vscode/extensions/marus25.cortex-debug-0.3.10/support/gdbsupport.init" 3-target-select extended-remote localhost:50000 4-interpreter-exec console "monitor reset halt" 5-target-download 6-interpreter-exec console "monitor reset halt" 7-enable-pretty-printing GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-group-added","output":[["id","i1"]]}]} GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"Reading symbols from /Users/engmoh/Embedded/VSCODE_Projects/2-STM32_Skeleton/build/SkeletonCode.elf...\n"}]} Reading symbols from /Users/engmoh/Embedded/VSCODE_Projects/2-STM32_Skeleton/build/SkeletonCode.elf... GDB -> App: {"token":1,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}} GDB -> App: {"token":2,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}} GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-group-started","output":[["id","i1"],["pid","42000"]]}]} GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-created","output":[["id","1"],["group-id","i1"]]}]} GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"0xfffffffe in ?? ()\n"}]} 0xfffffffe in ?? () GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"stopped","output":[["frame",[["addr","0xfffffffe"],["func","??"],["args",[]],["arch","armv7"]]],["thread-id","1"],["stopped-threads","all"]]}]} Not implemented stop reason (assuming exception): undefined GDB -> App: {"token":3,"outOfBandRecord":[],"resultRecords":{"resultClass":"connected","results":[]}} 8-thread-list-ids GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"target","content":"target halted due to debug-request, current mode: Thread \n"}]} target halted due to debug-request, current mode: Thread GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"target","content":"xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc\n"}]} xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc GDB -> App: {"token":4,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}} 9-thread-list-ids GDB -> App: {"token":5,"outOfBandRecord":[{"isStream":false,"type":"status","asyncClass":"download","output":[]}]} GDB -> App: {"token":5,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["address","0x08000974"],["load-size","4116"],["transfer-rate","159072"],["write-rate","686"]]}} GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"target","content":"\n"}]} GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"target","content":"jtag status contains invalid mode value - communication failure\n"}]} jtag status contains invalid mode value - communication failure GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"target","content":"Polling target stm32f1x.cpu failed, trying to reexamine\n"}]} Polling target stm32f1x.cpu failed, trying to reexamine GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"target","content":"Examination failed, GDB will be halted. Polling again in 100ms\n"}]} Examination failed, GDB will be halted. Polling again in 100ms GDB -> App: {"token":6,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}} GDB -> App: {"token":7,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}} 10-break-insert "/Users/engmoh/Embedded/VSCODE_Projects/2-STM32_Skeleton/Core/Src/main.c:63" GDB -> App: {"token":8,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["thread-ids",[["thread-id","1"]]],["current-thread-id","1"],["number-of-threads","1"]]}} 11-thread-info 1 GDB -> App: {"token":9,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["thread-ids",[["thread-id","1"]]],["current-thread-id","1"],["number-of-threads","1"]]}} 12-thread-info 1 GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"Note: automatically using hardware breakpoints for read-only addresses.\n"}]} Note: automatically using hardware breakpoints for read-only addresses. GDB -> App: {"token":10,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["bkpt",[["number","1"],["type","breakpoint"],["disp","keep"],["enabled","y"],["addr","0x080001a4"],["func","main"],["file","Core/Src/main.c"],["fullname","/Users/engmoh/Embedded/VSCODE_Projects/2-STM32_Skeleton/Core/Src/main.c"],["line","72"],["thread-groups",["i1"]],["times","0"],["original-location","/Users/engmoh/Embedded/VSCODE_Projects/2-STM32_Skeleton/Core/Src/main.c:63"]]]]}} GDB -> App: {"token":11,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","Remote target"],["frame",[["level","0"],["addr","0x08000974"],["func","Reset_Handler"],["args",[]],["file","startup_stm32f103xb.s"],["fullname","/Users/engmoh/Embedded/VSCODE_Projects/2-STM32_Skeleton/startup_stm32f103xb.s"],["line","65"],["arch","armv7"]]],["state","stopped"]]]]]}} GDB -> App: {"token":12,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","Remote target"],["frame",[["level","0"],["addr","0x08000974"],["func","Reset_Handler"],["args",[]],["file","startup_stm32f103xb.s"],["fullname","/Users/engmoh/Embedded/VSCODE_Projects/2-STM32_Skeleton/startup_stm32f103xb.s"],["line","65"],["arch","armv7"]]],["state","stopped"]]]]]}} 13-stack-info-depth --thread 1 10000 GDB -> App: {"token":13,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["depth","1"]]}} 14-stack-list-frames --thread 1 0 0 GDB -> App: {"token":14,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["stack",[["frame",[["level","0"],["addr","0x08000974"],["func","Reset_Handler"],["file","startup_stm32f103xb.s"],["fullname","/Users/engmoh/Embedded/VSCODE_Projects/2-STM32_Skeleton/startup_stm32f103xb.s"],["line","65"],["arch","armv7"]]]]]]}} 15-thread-list-ids GDB -> App: {"token":15,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["thread-ids",[["thread-id","1"]]],["current-thread-id","1"],["number-of-threads","1"]]}} 16-thread-info 1 17-data-list-register-names GDB -> App: {"token":16,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","Remote target"],["frame",[["level","0"],["addr","0x08000974"],["func","Reset_Handler"],["args",[]],["file","startup_stm32f103xb.s"],["fullname","/Users/engmoh/Embedded/VSCODE_Projects/2-STM32_Skeleton/startup_stm32f103xb.s"],["line","65"],["arch","armv7"]]],["state","stopped"]]]]]}} GDB -> App: {"token":17,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["register-names",["r0","r1","r2","r3","r4","r5","r6","r7","r8","r9","r10","r11","r12","sp","lr","pc","","","","","","","","","","xPSR","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","msp","psp","primask","basepri","faultmask","control"]]]}} 18-stack-info-depth --thread 1 10000 GDB -> App: {"token":18,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["depth","1"]]}} 19-stack-list-frames --thread 1 0 0 GDB -> App: {"token":19,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["stack",[["frame",[["level","0"],["addr","0x08000974"],["func","Reset_Handler"],["file","startup_stm32f103xb.s"],["fullname","/Users/engmoh/Embedded/VSCODE_Projects/2-STM32_Skeleton/startup_stm32f103xb.s"],["line","65"],["arch","armv7"]]]]]]}} 20-stack-info-depth --thread 1 10000 GDB -> App: {"token":20,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["depth","1"]]}} 21-stack-list-frames --thread 1 0 0 GDB -> App: {"token":21,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["stack",[["frame",[["level","0"],["addr","0x08000974"],["func","Reset_Handler"],["file","startup_stm32f103xb.s"],["fullname","/Users/engmoh/Embedded/VSCODE_Projects/2-STM32_Skeleton/startup_stm32f103xb.s"],["line","65"],["arch","armv7"]]]]]]}} 22-thread-list-ids GDB -> App: {"token":22,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["thread-ids",[["thread-id","1"]]],["current-thread-id","1"],["number-of-threads","1"]]}} 23-thread-info 1 GDB -> App: {"token":23,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","Remote target"],["frame",[["level","0"],["addr","0x08000974"],["func","Reset_Handler"],["args",[]],["file","startup_stm32f103xb.s"],["fullname","/Users/engmoh/Embedded/VSCODE_Projects/2-STM32_Skeleton/startup_stm32f103xb.s"],["line","65"],["arch","armv7"]]],["state","stopped"]]]]]}} 24-data-list-register-values N GDB -> App: {"token":24,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["register-values",[[["number","0"],["value","0"]],[["number","1"],["value","0"]],[["number","2"],["value","0"]],[["number","3"],["value","0"]],[["number","4"],["value","0"]],[["number","5"],["value","0"]],[["number","6"],["value","0"]],[["number","7"],["value","0"]],[["number","8"],["value","0"]],[["number","9"],["value","0"]],[["number","10"],["value","0"]],[["number","11"],["value","0"]],[["number","12"],["value","0"]],[["number","13"],["value","0xffffffd8"]],[["number","14"],["value","-7"]],[["number","15"],["value","0x8000974 <Reset_Handler>"]],[["number","25"],["value","16777219"]],[["number","91"],["value","0x20005000"]],[["number","92"],["value","0x0"]],[["number","93"],["value","0"]],[["number","94"],["value","0"]],[["number","95"],["value","0"]],[["number","96"],["value","0"]]]]]}} 25-stack-list-variables --thread 1 --frame 0 --simple-values GDB -> App: {"token":25,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["variables",[]]]}} 26-data-evaluate-expression --thread 1 --frame 0 LoopCopyDataInit GDB -> App: {"token":26,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["value","{<text variable, no debug info>} 0x8000980 <Reset_Handler+12>"]]}} 27-data-evaluate-expression --thread 1 --frame 0 Reset_Handler GDB -> App: {"token":27,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["value","{<text variable, no debug info>} 0x8000974 <Reset_Handler>"]]}} 28-data-evaluate-expression --thread 1 --frame 0 .weak GDB -> App: {"token":28,"outOfBandRecord":[],"resultRecords":{"resultClass":"error","results":[["msg","A syntax error in expression, near `.weak'."]]}} hover: A syntax error in expression, near `.weak'. (from data-evaluate-expression --thread 1 --frame 0 .weak) 

as soon as I click on step into from the debugger control I get the following console output:

DB -> App: {"token":29,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["frame",[["level","0"],["addr","0x08000974"],["func","Reset_Handler"],["file","startup_stm32f103xb.s"],["fullname","/Users/engmoh/Embedded/VSCODE_Projects/2-STM32_Skeleton/startup_stm32f103xb.s"],["line","65"],["arch","armv7"]]]]}} 30-exec-step --thread 1 GDB -> App: {"token":30,"outOfBandRecord":[],"resultRecords":{"resultClass":"running","results":[]}} GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"running","output":[["thread-id","all"]]}]} GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"log","content":"Warning:\n"}]} Warning: GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"log","content":"Cannot insert hardware breakpoint 1.\n"}]} Cannot insert hardware breakpoint 1. GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"log","content":"Could not insert hardware breakpoints:\n"}]} 

Although, I have not set any breakpoints at all!

and in **Output ** I get:

Info : dropped 'gdb' connection shutdown command invoked 

Then the debugger controls buttons are grayed out! and my MCU is bricked and I would need to Erase it using a UART connection to get it back to work!

What to do? How to be able to program and debug this board using my environment!

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Target voltage: 5.022309: This doesn't sound right. How exactly have you connected the ST-Link to your target board? Furthermore I recommend you first verify the ST-Link setup by reading the chip info and flashing firmware using st-util and similar tools and then move on to debugging. \$\endgroup\$ Commented Jan 31, 2021 at 18:02
  • \$\begingroup\$ @Codo It is connected correctly using the SWDIO SWCLK 3.3V and GND connection. I already tried the same hardware with PlatformIO an It's working flawlessly! \$\endgroup\$ Commented Feb 1, 2021 at 18:25

2 Answers 2

1
\$\begingroup\$

Here its how i configured it (im able to debug step to step and place breakpoints with the SWD port & a stlink v2 usb on a STM32F103VE) on Windows 10

The important thing was to set the openocd folder as launch folder (cwd):

{ "version": "0.3.0", "configurations": [ { "showDevDebugOutput": true, "cwd": "${env:USERPROFILE}\\.platformio\\packages\\tool-openocd\\bin", "executable": "${workspaceFolder}\\.pio\\build\\STM32F103VE_longer\\firmware.elf", "name": "Debug STM32", "request": "launch", "type": "cortex-debug", "armToolchainPath": "${env:USERPROFILE}\\.platformio\\packages\\[email protected]\\bin", "servertype": "openocd", "device": "stlink", "configFiles": [ "..\\scripts\\interface\\stlink.cfg", "..\\scripts\\target\\stm32f1x.cfg" ] } ] } 

Then in vscode pio tab, i just Upload the built firmware and run Debug/Start Debugging...

I get such thing in output tab :

xPack OpenOCD, x86_64 Open On-Chip Debugger 0.11.0-00155-ge392e485e (2021-03-15-16:44) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'. Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD Info : Listening on port 50001 for tcl connections Info : Listening on port 50002 for telnet connections Info : clock speed 1000 kHz Info : STLINK V2J29S7 (API v2) VID:PID 0483:3748 Info : Target voltage: 3.242133 Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints Info : starting gdb server for stm32f1x.cpu on 50000 Info : Listening on port 50000 for gdb connections Info : accepting 'gdb' connection on tcp/50000 target halted due to debug-request, current mode: Thread xPSR: 0x61000000 pc: 0x08008da6 msp: 0x2000ffa8 Info : device id = 0x10036414 Info : flash size = 512kbytes target halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x08002470 msp: 0x2000ffd8 target halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x08002470 msp: 0x2000ffd8 Info : Padding image section 0 at 0x080001e4 with 4 bytes Info : Padding image section 1 at 0x08036d2c with 4 bytes target halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x08002470 msp: 0x2000ffd8 target halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x08002470 msp: 0x2000ffd8 Info : halted: PC: 0x08008112 
\$\endgroup\$
0
\$\begingroup\$

As it is set in the config file you are only building but not flashing the software when you run the debug configuration.

You need to run the flashing task first, then you will be running the fresh code. You can do it with: ctrl+shift+P (will open the command palette) -> Build and flash to stm32 platform

Otherwise, you can change "Build STM" to "Flash STM" in the config file. This will flash every time you run the configuration. Notice: it won't work if you restart the debug configuration. You need to stop it and start it again.

\$\endgroup\$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.