微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

vscode Cortex-Debug 与 stm32l0 发生异常

如何解决vscode Cortex-Debug 与 stm32l0 发生异常

我想使用 VSCode Cortex-Debug 来调试 stm32l071 项目。 首先我用STM32cubeMX构建了一个简单的项目。 我发现在调试的第一行(重置处理程序)发生了异常。 而且如果偏移起始地址,程序似乎会崩溃。

我通过修改ld文件的FLASH的ORIGIN和system_stm32l0xx.c中的VECT_TAB_OFFSET来偏移程序的起始地址,看来程序计数器在第一行之后就变得奇怪了,无法运行到main。但是如果我尝试使用 OpenOCD 和 gdb 命令行,程序可以运行到 main 并正常工作。另外如果我不偏移地址,在异常之后程序仍然可以正常工作。

我的launch.json如下

{
    "showDevDebugOutput": true,"cwd": "D:\\Tools\\openocd","executable": "${workspaceRoot}/Debug/2460P_testST.elf","name": "Debug STM32","request": "launch","type": "cortex-debug","servertype": "openocd","device": "STM32L071CB","configFiles": [
        "interface/stlink.cfg","target/stm32l0.cfg"
    ]
}

以下是我的开发环境
电脑:Windows 10
OpenOCD:0.11
VSCode:1.55.2
皮质调试:0.3.12
ST-Link v2

也许调试控制台能帮上忙,贴如下

Reading symbols from 'C:\Users\Daniel2.chen\STM32CubeIDE\workspace_1.6.1\2460P_testST/Debug/2460P_testST.elf'
Finished reading symbols
Please check OUTPUT tab (Adapter Output) for output from openocd.exe
Launching server: "openocd.exe" "-c" "gdb_port 50000" "-s" "D:\Tools\openocd" "-f" "interface/stlink.cfg" "-f" "target/stm32l0.cfg"
Launching GDB: "arm-none-eabi-gdb.exe" "-q" "--interpreter=mi2"
1-gdb-set target-async on
2-interpreter-exec console "source c:/Users/Daniel2.chen/.vscode/extensions/marus25.cortex-debug-0.3.12/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 C:\\Users\\Daniel2.chen\\STM32CubeIDE\\workspace_1.6.1\\2460P_testST/Debug/2460P_testST.elf...\n"}]}
Reading symbols from C:\Users\Daniel2.chen\STM32CubeIDE\workspace_1.6.1\2460P_testST/Debug/2460P_testST.elf...
GDB -> App: {"token":1,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
GDB -> App: {"token":2,"results":[]}}
GDB -> App: {"outOfBandRecord":[{"isstream":false,"asyncclass":"thread-group-started","i1"],["pid","42000"]]}]}
GDB -> App: {"outOfBandRecord":[{"isstream":false,"asyncclass":"thread-created","1"],["group-id","content":"Reset_Handler () at ../Core/Startup/startup_stm32l071cbtx.s:52\n"}]}
Reset_Handler () at ../Core/Startup/startup_stm32l071cbtx.s:52
GDB -> App: {"outOfBandRecord":[{"isstream":true,"content":"52\t   ldr   r0,=_estack\n"}]}
52     ldr   r0,=_estack
GDB -> App: {"outOfBandRecord":[{"isstream":false,"type":"exec","asyncclass":"stopped","output":[["frame",[["addr","0x08000fc4"],["func","Reset_Handler"],["args",[]],["file","../Core/Startup/startup_stm32l071cbtx.s"],["fullname","C:\\Users\\Daniel2.chen\\STM32CubeIDE\\workspace_1.6.1\\2460P_testST\\Core\\Startup\\startup_stm32l071cbtx.s"],["line","52"],["arch","armv6s-m"]]],["thread-id",["stopped-threads","all"]]}]}
Not implemented stop reason (assuming exception): undefined
GDB -> App: {"token":3,"resultRecords":{"resultClass":"connected","results":[]}}
8-thread-list-ids
GDB -> App: {"outOfBandRecord":[{"isstream":true,"type":"target","content":"Unable to match requested speed 300 kHz,using 240 kHz\n"}]}
Unable to match requested speed 300 kHz,using 240 kHz
GDB -> App: {"outOfBandRecord":[{"isstream":true,"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,"content":"xPSR: 0xf1000000 pc: 0x08000fc4 msp: 0x20005000\n"}]}
xPSR: 0xf1000000 pc: 0x08000fc4 msp: 0x20005000
GDB -> App: {"token":4,"results":[]}}
9-thread-list-ids
GDB -> App: {"token":5,"outOfBandRecord":[{"isstream":false,"type":"status","asyncclass":"download","output":[]}]}
GDB -> App: {"token":5,"results":[["address",["load-size","26596"],["transfer-rate","34384"],["write-rate","3324"]]}}
GDB -> App: {"outOfBandRecord":[{"isstream":true,"content":"xPSR: 0xf1000000 pc: 0x08000fc4 msp: 0x20005000\n"}]}
xPSR: 0xf1000000 pc: 0x08000fc4 msp: 0x20005000
GDB -> App: {"token":6,"results":[]}}
GDB -> App: {"token":7,"results":[]}}
10-break-insert "c:\\Users\\Daniel2.chen\\STM32CubeIDE\\workspace_1.6.1\\2460P_testST\\Core\\Src\\main.c:97"
GDB -> App: {"token":8,"results":[["thread-ids",[["thread-id","1"]]],["current-thread-id",["number-of-threads","1"]]}}
GDB -> App: {"token":9,"1"]]}}
11-thread-info 1
12-thread-info 1
GDB -> App: {"outOfBandRecord":[{"isstream":true,"content":"Note: automatically using hardware breakpoints for read-only addresses.\n"}]}
Note: automatically using hardware breakpoints for read-only addresses.
GDB -> App: {"token":10,"results":[["bkpt",[["number",["type","breakpoint"],["disp","keep"],["enabled","y"],["addr","0x08000502"],"main"],"../Core/Src/main.c"],"C:\\Users\\Daniel2.chen\\STM32CubeIDE\\workspace_1.6.1\\2460P_testST\\Core\\Src\\main.c"],"97"],["thread-groups",["i1"]],["times","0"],["original-location","c:\\Users\\Daniel2.chen\\STM32CubeIDE\\workspace_1.6.1\\2460P_testST\\Core\\Src\\main.c:97"]]]]}}
GDB -> App: {"token":11,"results":[["threads",[[["id",["target-id","Remote target"],["frame",[["level",["state","stopped"]]]]]}}
GDB -> App: {"token":12,"stopped"]]]]]}}
13-stack-info-depth --thread 1 10000
GDB -> App: {"token":13,"results":[["depth","1"]]}}
14-stack-list-frames --thread 1 0 0
GDB -> App: {"token":14,"results":[["stack",[["frame","armv6s-m"]]]]]]}}
15-stack-info-depth --thread 1 10000
16-thread-list-ids
17-data-list-register-names
GDB -> App: {"token":15,"1"]]}}
18-stack-list-frames --thread 1 0 0
GDB -> App: {"token":16,"1"]]}}
19-thread-info 1
GDB -> App: {"token":17,"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"]]]}}
GDB -> App: {"token":18,"armv6s-m"]]]]]]}}
GDB -> App: {"token":19,"stopped"]]]]]}}
20-data-list-register-values N
GDB -> App: {"token":20,"results":[["register-values",[[["number",["value","-1"]],"2"],"3"],"4"],"5"],"6"],"7"],"8"],"9"],"10"],"11"],"12"],"13"],"0x20005000"]],"14"],"15"],"0x8000fc4 <Reset_Handler>"]],"25"],"-251658240"]],"91"],"92"],"0xfffffffc"]],"93"],"0"]],"94"],"95"],"96"],"0"]]]]]}}
21-stack-info-depth --thread 1 10000
GDB -> App: {"token":21,"1"]]}}
22-stack-list-frames --thread 1 0 0
23-thread-list-ids
GDB -> App: {"token":22,"armv6s-m"]]]]]]}}
GDB -> App: {"token":23,"1"]]}}
24-thread-info 1
GDB -> App: {"token":24,"stopped"]]]]]}}
25-stack-info-depth --thread 1 10000
GDB -> App: {"token":25,"1"]]}}
26-stack-list-frames --thread 1 0 0
GDB -> App: {"token":26,"armv6s-m"]]]]]]}}
27-stack-list-variables --thread 1 --frame 0 --simple-values
GDB -> App: {"token":27,"results":[["variables",[]]]}}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。