iarsystems / iar-vsc-debug

Visual Studio Code extension for the IAR C-SPY debugger
19 stars 1 forks source link

Breakpoints does not work on STM32F4DISCOVERY and IAR EW v8.50 #21

Closed denis-shienkov closed 1 year ago

denis-shienkov commented 1 year ago

Hi, I tried to debug a simple application on the STM32F4DISCOVERY board using the IAR EW toolchain.

My setup is:

I have configured the launch.json file as following:

        {
            "type": "cspy",
            "request": "launch",
            "name": "cspy-debug",
            "target": "arm",
            "program": "${command:qbs.getProductExecutablePath}",
            "driver": "ST-LINK",
            "stopOnSymbol": "main",
            "workbenchPath": "c:/Program Files (x86)/IAR Systems/Embedded Workbench 8.4",
            "projectPath": "${workspaceFolder}",
            "projectConfiguration": "Debug",
            "trace": true,
            "driverOptions": [
                "--endian=little",
                "--cpu=Cortex-M4",
                "--fpu=VFPv4_SP",
                "-p",
                "c:/Program Files (x86)/IAR Systems/Embedded Workbench 8.4/arm/CONFIG/debugger/ST/STM32F407VG.ddf",
                "--semihosting",
                "--device=STM32F407VG",
                "--drv_interface=SWD",
                "--drv_interface_speed=1800",
                "--drv_swo_clock_setup=168000000,1,0",
                "--stlink_reset_strategy=0,2"
            ],
            "download": {
                "flashLoader": "c:/Program Files (x86)/IAR Systems/Embedded Workbench 8.4/arm/config/flashloader/ST/FlashSTM32F4xxx.board",
                "deviceMacros": [
                    "c:/Program Files (x86)/IAR Systems/Embedded Workbench 8.4/arm/config/debugger/ST/STM32F4xx.dmac"
                ]
            }
        }

When I press the debug button, then I see that the cursor goto the main function: изображение

But, when I set the break-point: изображение

and then click on continue button, then nothing happens, seems the ELF-application get stalled or something like that: изображение

By the way, the step-over (F10) break-points does work:

изображение

The C-SPY log are following:

C-SPY Server 2.0 (IAR IDE Platform 8.4.8.6680, compiled with MSVC 19.0.24215.1 on May 30 2020 04:08:07) Build tag: jenkins_8_4_x_nightly_68 Service registry running on local socket on port: 49356 Also available in serialized form in CSpyServer2-ServiceRegistry.txt Configuring CSpyServer as multicore session owner. To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Using C-SPY version: 8.4.8.6680\n"}} Using C-SPY version: 8.4.8.6680 To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Driver loaded: c:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 8.4\\arm\\bin\\armstlink2.dll\n"}} Driver loaded: c:\Program Files (x86)\IAR Systems\Embedded Workbench 8.4\arm\bin\armstlink2.dll To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Loaded macro file: c:/Program Files (x86)/IAR Systems/Embedded Workbench 8.4/arm/config/debugger/ST/STM32F4xx.dmac\n"}} Loaded macro file: c:/Program Files (x86)/IAR Systems/Embedded Workbench 8.4/arm/config/debugger/ST/STM32F4xx.dmac To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Initializing flash loader manager using c:/Program Files (x86)/IAR Systems/Embedded Workbench 8.4/arm/config/flashloader/ST/FlashSTM32F4xxx.board\n"}} Initializing flash loader manager using c:/Program Files (x86)/IAR Systems/Embedded Workbench 8.4/arm/config/flashloader/ST/FlashSTM32F4xxx.board To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Loading flash module: e:/git/ng/git/123/qbs-git/qbs-borland/examples/baremetal/stm32f4discovery/blueblink/build/iar-8_50_5-arm_debug/debug/stm32f4discovery-blueblink.c5b4f8ce/stm32f4discovery-blueblink.out\n"}} Loading flash module: e:/git/ng/git/123/qbs-git/qbs-borland/examples/baremetal/stm32f4discovery/blueblink/build/iar-8_50_5-arm_debug/debug/stm32f4discovery-blueblink.c5b4f8ce/stm32f4discovery-blueblink.out To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Loaded macro file: c:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 8.4\\arm\\config\\flashloader\\ST\\FlashSTM32F4xxx.mac\n"}} Loaded macro file: c:\Program Files (x86)\IAR Systems\Embedded Workbench 8.4\arm\config\flashloader\ST\FlashSTM32F4xxx.mac To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"ST-Link firmware too old\n"}} ST-Link firmware too old To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Connected to ST-LINK/V2 [SWD mode 1800 kHz] [Access port: 0] Firmware V2.J35 (Probe no: 53FF6D064980555721511287)\n"}} Connected to ST-LINK/V2 [SWD mode 1800 kHz] [Access port: 0] Firmware V2.J35 (Probe no: 53FF6D064980555721511287) To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Initial reset was performed\n"}} Initial reset was performed To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Timeline frontend service initialized.\n"}} Timeline frontend service initialized. To client: {"seq":0,"type":"event","event":"progressBarCreated","body":{"id":0,"title":"ST-LINK Driver","initialMessage":"Downloading application ...","canCancel":false,"minValue":0,"valueRange":100}} To client: {"seq":0,"type":"event","event":"progressBarUpdated","body":{"id":0,"message":"Downloading application ..."}} To client: {"seq":0,"type":"event","event":"progressBarUpdated","body":{"id":0,"value":0}} To client: {"seq":0,"type":"event","event":"progressBarClosed","body":{"id":0}} To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"992 bytes downloaded (20.61 Kbytes/sec)\n"}} 992 bytes downloaded (20.61 Kbytes/sec) To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Loaded debugee: c:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 8.4\\arm\\config\\flashloader\\ST\\FlashSTM32F4xxxRAM128K.out\n"}} Loaded debugee: c:\Program Files (x86)\IAR Systems\Embedded Workbench 8.4\arm\config\flashloader\ST\FlashSTM32F4xxxRAM128K.out To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Target reset\n"}} Target reset To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Unloaded macro file: c:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 8.4\\arm\\config\\flashloader\\ST\\FlashSTM32F4xxx.mac\n"}} Unloaded macro file: c:\Program Files (x86)\IAR Systems\Embedded Workbench 8.4\arm\config\flashloader\ST\FlashSTM32F4xxx.mac To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Downloaded e:/git/ng/git/123/qbs-git/qbs-borland/examples/baremetal/stm32f4discovery/blueblink/build/iar-8_50_5-arm_debug/debug/stm32f4discovery-blueblink.c5b4f8ce/stm32f4discovery-blueblink.out to flash memory.\n"}} Downloaded e:/git/ng/git/123/qbs-git/qbs-borland/examples/baremetal/stm32f4discovery/blueblink/build/iar-8_50_5-arm_debug/debug/stm32f4discovery-blueblink.c5b4f8ce/stm32f4discovery-blueblink.out to flash memory. To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"264 bytes downloaded into FLASH (0.36 Kbytes/sec)\n"}} 264 bytes downloaded into FLASH (0.36 Kbytes/sec) To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Flash loading completed successfully.\n"}} Flash loading completed successfully. To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Hardware reset with strategy 2 was performed\n"}} Hardware reset with strategy 2 was performed To client: {"seq":0,"type":"event","event":"progressBarCreated","body":{"id":1,"title":"ST-LINK Driver","initialMessage":"Reading debug information ...","canCancel":false,"minValue":0,"valueRange":100}} To client: {"seq":0,"type":"event","event":"progressBarUpdated","body":{"id":1,"message":"Reading debug information ..."}} To client: {"seq":0,"type":"event","event":"progressBarUpdated","body":{"id":1,"value":0}} To client: {"seq":0,"type":"event","event":"progressBarClosed","body":{"id":1}} To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Loaded debugee: e:/git/ng/git/123/qbs-git/qbs-borland/examples/baremetal/stm32f4discovery/blueblink/build/iar-8_50_5-arm_debug/debug/stm32f4discovery-blueblink.c5b4f8ce/stm32f4discovery-blueblink.out\n"}} Loaded debugee: e:/git/ng/git/123/qbs-git/qbs-borland/examples/baremetal/stm32f4discovery/blueblink/build/iar-8_50_5-arm_debug/debug/stm32f4discovery-blueblink.c5b4f8ce/stm32f4discovery-blueblink.out To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Loaded custom formats file: c:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 8.4\\arm/config/custom_formats.dat\n"}} Loaded custom formats file: c:\Program Files (x86)\IAR Systems\Embedded Workbench 8.4\arm/config/custom_formats.dat To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Loaded custom formats file: E:\\git\\ng\\git\\123\\qbs-git\\qbs-borland\\examples\\baremetal\\stm32f4discovery\\blueblink/custom_formats.dat\n"}} Loaded custom formats file: E:\git\ng\git\123\qbs-git\qbs-borland\examples\baremetal\stm32f4discovery\blueblink/custom_formats.dat To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Hardware reset with strategy 0 was performed\n"}} Hardware reset with strategy 0 was performed To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Target reset\n"}} Target reset To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Using 'auto' breakpoint type.\n"}} Using 'auto' breakpoint type. To client: {"seq":0,"type":"event","event":"initialized"} From client: setBreakpoints({"source":{"name":"gpio.c","path":"e:\\git\\ng\\git\\123\\qbs-git\\qbs-borland\\examples\\baremetal\\stm32f4discovery\\blueblink\\gpio.c"},"lines":[78],"breakpoints":[{"line":78}],"sourceModified":false}) Setting breakpoint: _ 1 "EMUL_CODE" "{e:\git\ng\git\123\qbs-git\qbs-borland\examples\baremetal\stm32f4discovery\blueblink\gpio.c}.78.1" 0 0 1 "" 0 "" 0 From client: setBreakpoints({"source":{"name":"main.c","path":"e:\\git\\ng\\git\\123\\qbs-git\\qbs-borland\\examples\\baremetal\\stm32f4discovery\\blueblink\\main.c"},"lines":[63],"breakpoints":[{"line":63}],"sourceModified":false}) Setting breakpoint: _ 1 "EMUL_CODE" "{e:\git\ng\git\123\qbs-git\qbs-borland\examples\baremetal\stm32f4discovery\blueblink\main.c}.63.1" 0 0 1 "" 0 "" 0 From client: setDataBreakpoints({"breakpoints":[]}) To client: {"seq":0,"type":"response","request_seq":5,"command":"setDataBreakpoints","success":true,"body":{"breakpoints":[]}} From client: setInstructionBreakpoints({"breakpoints":[]}) To client: {"seq":0,"type":"response","request_seq":6,"command":"setInstructionBreakpoints","success":true,"body":{"breakpoints":[]}} To client: {"seq":0,"type":"response","request_seq":3,"command":"setBreakpoints","success":true,"body":{"breakpoints":[{"verified":true,"line":78,"column":5,"message":"Code @ gpio.c:78.5, type: default (auto) \n 0x0800005A [Fetch ] Thumb","source":{"name":"gpio.c","path":"e:\\git\\ng\\git\\123\\qbs-git\\qbs-borland\\examples\\baremetal\\stm32f4discovery\\blueblink\\gpio.c"}}]}} To client: {"seq":0,"type":"response","request_seq":4,"command":"setBreakpoints","success":true,"body":{"breakpoints":[{"verified":true,"line":63,"column":5,"message":"Code @ main.c:63.5, type: default (auto) \n 0x08000084 [Fetch ] Thumb","source":{"name":"main.c","path":"e:\\git\\ng\\git\\123\\qbs-git\\qbs-borland\\examples\\baremetal\\stm32f4discovery\\blueblink\\main.c"}}]}} From client: configurationDone(undefined) To client: {"seq":0,"type":"response","request_seq":7,"command":"configurationDone","success":true} To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Session started\n"}} Session started To client: {"seq":0,"type":"response","request_seq":2,"command":"launch","success":true} From client: threads(undefined) To client: {"seq":0,"type":"response","request_seq":8,"command":"threads","success":true,"body":{"threads":[{"id":0,"name":"0: Cortex-M4"}]}} From client: threads(undefined) From client: getBreakpointTypes(undefined) To client: {"seq":0,"type":"response","request_seq":10,"command":"getBreakpointTypes","success":true,"body":["auto","hardware","software"]} From client: registers(undefined) To client: {"seq":0,"type":"response","request_seq":11,"command":"registers","success":true,"body":{"svdContent":"\n\n Auto-Generated\n 8\n 32\n 0\n \n \n ADC1\n \n 0x40012000\n \n \n ADC1_SR\n SR\n ADC1_SR / SR\nReadWrite @ 0x40012000\nstatus register\n 0\n 32\n read-write\n \n \n OVR\n ADC1_SR.OVR / OVR\nReadWrite @ 0x40012000\nbit [5]\nOverrun\n 5\n 5\n \n \n STRT\n ADC1_SR.STRT / STRT\nReadWrite @ 0x40012000\nbit [4]\nRegular channel start flag\n 4\n 4\n \n \n JSTRT\n ADC1_SR.JSTRT / JSTRT\nReadWrite @ 0x40012000\nbit [3]\nInjected channel start\n flag\n 3\n 3\n \n [...] To client: {"seq":0,"type":"response","request_seq":9,"command":"threads","success":true,"body":{"threads":[{"id":0,"name":"0: Cortex-M4"}]}} To client: {"seq":0,"type":"event","event":"stopped","body":{"reason":"entry","threadId":0,"allThreadsStopped":true}} From client: threads(undefined) To client: {"seq":0,"type":"response","request_seq":12,"command":"threads","success":true,"body":{"threads":[{"id":0,"name":"0: Cortex-M4"}]}} From client: threads(undefined) To client: {"seq":0,"type":"response","request_seq":13,"command":"threads","success":true,"body":{"threads":[{"id":0,"name":"0: Cortex-M4"}]}} From client: stackTrace({"threadId":0,"levels":1}) From client: stackTrace({"threadId":0,"startFrame":0,"levels":20}) To client: {"seq":0,"type":"response","request_seq":14,"command":"stackTrace","success":true,"body":{"stackFrames":[{"id":1000,"source":{"name":"main.c","path":"E:\\git\\ng\\git\\123\\qbs-git\\qbs-borland\\examples\\baremetal\\stm32f4discovery\\blueblink\\main.c","sourceReference":0},"line":61,"column":1,"name":"main","instructionPointerReference":"0x0000000008000082"},{"id":1001,"line":0,"column":0,"name":"[_call_main + 0xd]","instructionPointerReference":"0x00000000080000d6"}]}} To client: {"seq":0,"type":"response","request_seq":15,"command":"stackTrace","success":true,"body":{"stackFrames":[{"id":1002,"source":{"name":"main.c","path":"E:\\git\\ng\\git\\123\\qbs-git\\qbs-borland\\examples\\baremetal\\stm32f4discovery\\blueblink\\main.c","sourceReference":0},"line":61,"column":1,"name":"main","instructionPointerReference":"0x0000000008000082"},{"id":1003,"line":0,"column":0,"name":"[_call_main + 0xd]","instructionPointerReference":"0x00000000080000d6"}]}} From client: evaluate({"expression":"_tx_thread_created_ptr","frameId":1000}) CSpyException: Error (col 1): Unknown or ambiguous symbol. _tx_thread_created_ptr To client: {"seq":0,"type":"response","request_seq":16,"command":"evaluate","success":false,"message":"CSpyException: Error (col 1): Unknown or ambiguous symbol. _tx_thread_created_ptr"} From client: evaluate({"expression":"pxReadyTasksLists","frameId":1000}) CSpyException: Error (col 1): Unknown or ambiguous symbol. pxReadyTasksLists To client: {"seq":0,"type":"response","request_seq":17,"command":"evaluate","success":false,"message":"CSpyException: Error (col 1): Unknown or ambiguous symbol. pxReadyTasksLists"} From client: evaluate({"expression":"_kernel_thread_info_offsets","frameId":1000}) CSpyException: Error (col 1): Unknown or ambiguous symbol. _kernel_thread_info_offsets To client: {"seq":0,"type":"response","request_seq":18,"command":"evaluate","success":false,"message":"CSpyException: Error (col 1): Unknown or ambiguous symbol. _kernel_thread_info_offsets"} From client: evaluate({"expression":"_track_list_k_mutex","frameId":1000}) CSpyException: Error (col 1): Unknown or ambiguous symbol. _track_list_k_mutex To client: {"seq":0,"type":"response","request_seq":19,"command":"evaluate","success":false,"message":"CSpyException: Error (col 1): Unknown or ambiguous symbol. _track_list_k_mutex"} From client: continue({"threadId":0}) To client: {"seq":0,"type":"response","request_seq":20,"command":"continue","success":true}
jlonnberg commented 1 year ago

HI @denis-shienkov, It seems like the backend fails to properly install the breakpoint into the target. Have you tried the same project in the workbench just to see that it works there? At first glance, it seems like you're missing some options for the debugger, e.g., --stlink_probe=stlinkv2, which might be triggering the issue. The VS-code plugins can also consume the command line for the debugger from the xcl-files that the workbench generate once you open the project in EWARM to give you something to comapre with.

denis-shienkov commented 1 year ago

@jlonnberg ,

Have you tried the same project in the workbench just to see that it works there?

Yes, it does work within IAR EW.

I also tried to take the output ELF file generated from the IAR EW, and pass it to the VSCode, no results.

At first glance, it seems like you're missing some options for the debugger, e.g., --stlink_probe=stlinkv2

It did not help.

the xcl-files that the workbench generate once you open the project in EWARM to give you something to comapre with

I see two *.xcl files blueblink.Debug.driver.xcl and blueblink.Debug.general.xcl : settings.zip

where the general contains this:

"C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.4\arm\bin\armproc.dll" "C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.4\arm\bin\armstlink2.dll" "E:\git\ng\git\123\qbs-git\qbs-borland\examples\baremetal\stm32f4discovery\blueblink\Debug\Exe\blueblink.out" --plugin="C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.4\arm\bin\armbat.dll" --device_macro="C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.4\arm\config\debugger\ST\STM32F4xx.dmac" --flash_loader="C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.4\arm\config\flashloader\ST\FlashSTM32F4xxx.board"

and the driver contains this:

"--endian=little" "--cpu=Cortex-M4" "--fpu=VFPv4_SP" "-p" "C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.4\arm\CONFIG\debugger\ST\STM32F407VG.ddf" "--semihosting" "--device=STM32F407VG" "--drv_interface=SWD" "--stlink_reset_strategy=0,0" "--drv_swo_clock_setup=168000000,1,2000000" "--drv_catch_exceptions=0x000" "--drv_debug_ap=0"

so, I have added the similar options to the VSCode:

        {
            "type": "cspy",
            "request": "launch",
            "name": "cspy-debug",
            "target": "arm",
            "program": "E:/git/ng/git/123/qbs-git/qbs-borland/examples/baremetal/stm32f4discovery/blueblink/Debug/Exe/blueblink.out",
            "driver": "ST-LINK",
            "stopOnSymbol": "main",
            "workbenchPath": "c:/Program Files (x86)/IAR Systems/Embedded Workbench 8.4",
            "projectPath": "${workspaceFolder}",
            "projectConfiguration": "Debug",
            "trace": true,
            "driverOptions": [
                "--endian=little",
                "--cpu=Cortex-M4",
                "--fpu=VFPv4_SP",
                "-p",
                "c:/Program Files (x86)/IAR Systems/Embedded Workbench 8.4/arm/CONFIG/debugger/ST/STM32F407VG.ddf",
                "--semihosting",
                "--device=STM32F407VG",
                "--drv_interface=SWD",
                "--drv_swo_clock_setup=168000000,1,2000000",
                "--stlink_reset_strategy=0,0",
                "--drv_catch_exceptions=0x000",
                "--drv_debug_ap=0"
            ],
            "download": {
                "flashLoader": "c:/Program Files (x86)/IAR Systems/Embedded Workbench 8.4/arm/config/flashloader/ST/FlashSTM32F4xxx.board",
                "deviceMacros": [
                    "c:/Program Files (x86)/IAR Systems/Embedded Workbench 8.4/arm/config/debugger/ST/STM32F4xx.dmac"
                ]
            }
        }

but it did not help too.

jlonnberg commented 1 year ago

I'll have a look at it and see if I can reproduce it. Please ensure that the correct type of breakpoint is used as well, see https://github.com/IARSystems/iar-vsc-debug/blob/master/docs/README.md#BreakpointTypes for reference

jlonnberg commented 1 year ago

@denis-shienkov The version of EWARM that you're using is incompatible with the latest set of vs-code extension. You need to install debug plugins version 1.10.5 instead and it should work as expected.

denis-shienkov commented 1 year ago

@jlonnberg ,

You need to install debug plugins version 1.10.5 instead and it should work as expected.

So, do I need to downgrade the IAR C-SPY Debug extension from current 1.20.2 to 1.10.5 ?

The version of EWARM that you're using is incompatible with the latest set of vs-code extension.

What is EWARM version is compatible then with the latest 1.20.0 extension? Is it EWARM v9.30 or later ?

jlonnberg commented 1 year ago

Yes, downgrading the debug extension will fix the problem.

I've tested the stlink and it should work with EWARM 9.20 and later.