iarsystems / iar-vsc-debug

Visual Studio Code extension for the IAR C-SPY Debugger
https://marketplace.visualstudio.com/items?itemName=iarsystems.iar-debug
19 stars 1 forks source link

STLink v2 Debug Problems #26

Closed MrAlexandrKolesnikov closed 1 year ago

MrAlexandrKolesnikov commented 1 year ago

Hi, I try to start debugging but nothing comes out, the firmware is not written to memory

launch.json

{
    "configurations": [
    {
        "type": "cspy",
        "request": "launch",
        "name": "Debug",
        "target": "arm",
        "program": "${workspaceFolder}\\iar\\${command:iar-config.project-configuration}\\Exe\\us_gas.out",
        "stopOnSymbol": "main",
        "stopOnEntry": true,
        "workbenchPath": "${command:iar-config.toolchain}",
        "projectPath": "${command:iar-config.project-file}",
        "projectConfiguration": "${command:iar-config.project-configuration}ss",
        "trace": true,
        "driver": "ST-LINK",
        "driverOptions": [
            "--endian=little",
            "--cpu=Cortex-M4",
            "--fpu=VFPv4_SP",
            "-p",
            "${command:iar-config.toolchain}/arm/CONFIG/debugger/ST/STM32L412CB.ddf",
            "--device=STM32L412CB",
            "--semihosting",
            "--drv_interface_speed=auto",
            "--drv_interface=SWD",
            "--drv_catch_exceptions=0xff0",
            "--drv_swo_clock_setup=180000000,0,2000000",
            "--reset_style=\"9,ConnectUnderReset,1,Connect during reset",
        ],
        "download": {
            "flashLoader": "${command:iar-config.toolchain}/arm/config/flashloader/ST/FlashSTM32L41xxB.board",
            "deviceMacros": [
                "${command:iar-config.toolchain}/arm/CONFIG/debugger/ST/STM32L4xx.dmac"
            ]
        },
        "preLaunchTask": "iar: Build Project"
    }
    ]
}

Debug console autput:

C-SPY Server 2.0 (IAR IDE Platform 8.3.4.6127, compiled with MSVC 19.0.24215.1 on Sep 19 2019 01:52:44)
Build tag: jenkins_8_3_x_nightly_37
Service registry running on local socket on port: 62598
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.3.4.6127\n"}}
Using C-SPY version: 8.3.4.6127
To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Driver loaded: C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 8.3\\arm\\bin\\armstlink2.dll\n"}}
Driver loaded: C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.3\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.3/arm/CONFIG/debugger/ST/STM32L4xx.dmac\n"}}
Loaded macro file: C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 8.3/arm/CONFIG/debugger/ST/STM32L4xx.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.3/arm/config/flashloader/ST/FlashSTM32L41xxB.board\n"}}
Initializing flash loader manager using C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 8.3/arm/config/flashloader/ST/FlashSTM32L41xxB.board
To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Loading flash module: C:\\Users\\a.kolesnikov\\Work\\gasflow\\iar\\Debug\\Exe\\us_gas.out\n"}}
Loading flash module: C:\Users\a.kolesnikov\Work\gasflow\iar\Debug\Exe\us_gas.out
To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"None of the application was placed in flash memory.\n"}}
None of the application was placed in flash memory.
To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Downloaded C:\\Users\\a.kolesnikov\\Work\\gasflow\\iar\\Debug\\Exe\\us_gas.out to flash memory.\n"}}
Downloaded C:\Users\a.kolesnikov\Work\gasflow\iar\Debug\Exe\us_gas.out to flash memory.
To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"0 bytes downloaded into FLASH (0.00 Kbytes/sec)\n"}}
0 bytes downloaded into FLASH (0.00 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":"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.J29.S7 (Probe no: 34560967)\n"}}
Connected to ST-Link/V2 [SWD mode 1800 kHz] [Access port: 0] Firmware V2.J29.S7 (Probe no: 34560967)
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":"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":"progressBarUpdated","body":{"id":0,"value":390}}
To client: {"seq":0,"type":"event","event":"progressBarUpdated","body":{"id":0,"value":840}}
To client: {"seq":0,"type":"event","event":"progressBarClosed","body":{"id":0}}
To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"72935 bytes downloaded (56.30 Kbytes/sec)\n"}}
72935 bytes downloaded (56.30 Kbytes/sec)
To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Loaded debugee: C:\\Users\\a.kolesnikov\\Work\\gasflow\\iar\\Debug\\Exe\\us_gas.out\n"}}
Loaded debugee: C:\Users\a.kolesnikov\Work\gasflow\iar\Debug\Exe\us_gas.out
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":"Warning: Stack pointer is setup to incorrect alignment. Stack addr = 0xFFFFFFFF\n"}}
Warning: Stack pointer is setup to incorrect alignment. Stack addr = 0xFFFFFFFF
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":"Loaded custom formats file: C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 8.3\\arm/config/custom_formats.dat\n"}}
Loaded custom formats file: C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.3\arm/config/custom_formats.dat
To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Loaded custom formats file: c:\\Users\\a.kolesnikov\\Work\\gasflow\\iar/custom_formats.dat\n"}}
Loaded custom formats file: c:\Users\a.kolesnikov\Work\gasflow\iar/custom_formats.dat
Failed to initialize variables provider: Error: Trying to connect to service with unsupported transport.
Failed to initialize variables provider: Error: Trying to connect to service with unsupported transport.
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":"main.c","path":"c:\\Users\\a.kolesnikov\\Work\\gasflow\\src\\main.c"},"lines":[284],"breakpoints":[{"line":284}],"sourceModified":false})
Setting breakpoint: _ 1 "EMUL_CODE" "{c:\Users\a.kolesnikov\Work\gasflow\src\main.c}.284.1" 0 0 1 "" 0 "" 0
From client: setDataBreakpoints({"breakpoints":[]})
To client: {"seq":0,"type":"response","request_seq":4,"command":"setDataBreakpoints","success":true,"body":{"breakpoints":[]}}
From client: setInstructionBreakpoints({"breakpoints":[]})
To client: {"seq":0,"type":"response","request_seq":5,"command":"setInstructionBreakpoints","success":true,"body":{"breakpoints":[]}}
To client: {"seq":0,"type":"response","request_seq":3,"command":"setBreakpoints","success":true,"body":{"breakpoints":[{"verified":true,"line":284,"column":8,"message":"Code @ main.c:284.8, type: default (auto) \n    0x000093F4           [Fetch           ]  Thumb","source":{"name":"main.c","path":"c:\\Users\\a.kolesnikov\\Work\\gasflow\\src\\main.c"}}]}}
From client: configurationDone(undefined)
To client: {"seq":0,"type":"response","request_seq":6,"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":7,"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":9,"command":"getBreakpointTypes","success":true,"body":["auto","hardware","software"]}
From client: registers(undefined)
To client: {"seq":0,"type":"response","request_seq":10,"command":"registers","success":true,"body":{"svdContent":"<?xml version=\"1.0\"?>\n<device>\n  <name>Auto-Generated</name>\n  <addressUnitBits>8</addressUnitBits>\n  <width>32</width>\n  <resetValue>0</resetValue>\n  <peripherals>\n    <peripheral>\n      <name>ADC</name>\n      <description/>\n      <baseAddress>0x50040000</baseAddress>\n      <registers>\n        <register>\n          <name>ADC_ISR</name>\n          <displayName>ISR</displayName>\n          <description>ADC_ISR / ISR\nReadWrite @ 0x50040000\ninterrupt and status register</description>\n          <addressOffset>0</addressOffset>\n          <size>32</size>\n          <access>read-write</access>\n          <fields>\n            <field>\n              <name>JQOVF</name>\n              <description>ADC_ISR.JQOVF / JQOVF\nReadWrite @ 0x50040000\nbit [10]\nJQOVF</description>\n              <msb>10</msb>\n              <lsb>10</lsb>\n            </field>\n            <field>\n              <name>AWD3</name>\n              <description>ADC_ISR.AWD3 / AWD3\nReadWrite @ 0x50040000\nbit [9]\nAWD3</description>\n              <msb>9</msb>\n              <lsb>9</lsb>\n            </field>\n            <field>\n              <name>AWD2</name>\n              <description>ADC_ISR.AWD2 / AWD2\nReadWrite @ 0x50040000\nbit [8]\nAWD2</description>\n              <msb>8</msb>\n              <lsb>8</lsb>\n            </field>\n            <field>\n              <name>AWD1</[...]
To client: {"seq":0,"type":"response","request_seq":8,"command":"threads","success":true,"body":{"threads":[{"id":0,"name":"0: Cortex-M4"}]}}
To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"HardFault exception.\nThe processor has escalated a configurable-priority exception to HardFault.\n   An MPU or Execute Never (XN) default memory map access violation has occurred on an instruction fetch (CFSR.IACCVIOL, MMFAR).\n   A derived bus fault has occurred on exception entry (CFSR.STKERR, BFAR).\n\nException occured at PC = 0xffffffff, LR = 0x0\n\nSee the call stack for more information.\n"}}
HardFault exception.
The processor has escalated a configurable-priority exception to HardFault.
   An MPU or Execute Never (XN) default memory map access violation has occurred on an instruction fetch (CFSR.IACCVIOL, MMFAR).
   A derived bus fault has occurred on exception entry (CFSR.STKERR, BFAR).

Exception occured at PC = 0xffffffff, LR = 0x0

See the call stack for more information.
To client: {"seq":0,"type":"event","event":"stopped","body":{"reason":"entry","threadId":0,"allThreadsStopped":true}}
From client: threads(undefined)
From client: threads(undefined)
To client: {"seq":0,"type":"response","request_seq":11,"command":"threads","success":true,"body":{"threads":[{"id":0,"name":"0: Cortex-M4"}]}}
To client: {"seq":0,"type":"response","request_seq":12,"command":"threads","success":true,"body":{"threads":[{"id":0,"name":"0: Cortex-M4"}]}}
From client: stackTrace({"threadId":0,"startFrame":0,"levels":20})
To client: {"seq":0,"type":"response","request_seq":13,"command":"stackTrace","success":true,"body":{"stackFrames":[{"id":1000,"line":0,"column":0,"name":"","instructionPointerReference":"0x00000000fffffffe"}]}}
From client: stackTrace({"threadId":0,"levels":1})
To client: {"seq":0,"type":"response","request_seq":14,"command":"stackTrace","success":true,"body":{"stackFrames":[{"id":1001,"line":0,"column":0,"name":"","instructionPointerReference":"0x00000000fffffffe"}]}}
From client: evaluate({"expression":"_tx_thread_created_ptr","frameId":1001})
CSpyException: Error (col 1): Unknown or ambiguous symbol. _tx_thread_created_ptr
To client: {"seq":0,"type":"response","request_seq":15,"command":"evaluate","success":false,"message":"CSpyException: Error (col 1): Unknown or ambiguous symbol. _tx_thread_created_ptr"}
From client: evaluate({"expression":"pxReadyTasksLists","frameId":1001})
CSpyException: Error (col 1): Unknown or ambiguous symbol. pxReadyTasksLists
To client: {"seq":0,"type":"response","request_seq":16,"command":"evaluate","success":false,"message":"CSpyException: Error (col 1): Unknown or ambiguous symbol. pxReadyTasksLists"}
From client: evaluate({"expression":"_kernel_thread_info_offsets","frameId":1001})
CSpyException: Error (col 1): Unknown or ambiguous symbol. _kernel_thread_info_offsets
To client: {"seq":0,"type":"response","request_seq":17,"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":1001})
CSpyException: Error (col 1): Unknown or ambiguous symbol. _track_list_k_mutex
To client: {"seq":0,"type":"response","request_seq":18,"command":"evaluate","success":false,"message":"CSpyException: Error (col 1): Unknown or ambiguous symbol. _track_list_k_mutex"}
From client: scopes({"frameId":1000})
To client: {"seq":0,"type":"response","request_seq":19,"command":"scopes","success":true,"body":{"scopes":[{"name":"Local","variablesReference":1000,"expensive":false},{"name":"Static","variablesReference":1001,"expensive":false},{"name":"CPU Registers","variablesReference":1002,"expensive":false}]}}
From client: variables({"variablesReference":1000})
Error: Not supported in EWARM v8.40
To client: {"seq":0,"type":"response","request_seq":20,"command":"variables","success":false,"message":"Error: Not supported in EWARM v8.40"}
From client: setBreakpoints({"source":{"name":"main.c","path":"c:\\Users\\a.kolesnikov\\Work\\gasflow\\src\\main.c"},"lines":[158,284],"breakpoints":[{"line":158},{"line":284}],"sourceModified":false})
Setting breakpoint: _ 1 "EMUL_CODE" "{c:\Users\a.kolesnikov\Work\gasflow\src\main.c}.158.1" 0 0 1 "" 0 "" 0
To client: {"seq":0,"type":"response","request_seq":21,"command":"setBreakpoints","success":true,"body":{"breakpoints":[{"verified":true,"line":158,"column":2,"message":"Code @ main.c:158.2, type: default (auto) \n    0x000091D0           [Fetch           ]  Thumb","source":{"name":"main.c","path":"c:\\Users\\a.kolesnikov\\Work\\gasflow\\src\\main.c"}},{"verified":true,"line":284,"column":8,"message":"Code @ main.c:284.8, type: default (auto) \n    0x000093F4           [Fetch           ]  Thumb","source":{"name":"main.c","path":"c:\\Users\\a.kolesnikov\\Work\\gasflow\\src\\main.c"}}]}}
From client: continue({"threadId":0})
To client: {"seq":0,"type":"response","request_seq":22,"command":"continue","success":true}
From client: pause({"threadId":0})
CSpyException: Failed to suspend debugger
To client: {"seq":0,"type":"response","request_seq":23,"command":"pause","success":false,"message":"CSpyException: Failed to suspend debugger"}
From client: pause({"threadId":0})
CSpyException: Failed to suspend debugger
To client: {"seq":0,"type":"response","request_seq":24,"command":"pause","success":false,"message":"CSpyException: Failed to suspend debugger"}
From client: terminate({"restart":false})
To client: {"seq":0,"type":"response","request_seq":25,"command":"terminate","success":true}
To client: {"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Shutting down C-SPY...\n"}}
Shutting down C-SPY...
Shutting down debug server...
Exiting.
CSpyServer exited with code 0
To client: {"seq":0,"type":"event","event":"terminated"}
From client: disconnect({"restart":false})
To client: {"seq":0,"type":"response","request_seq":26,"command":"disconnect","success":true}
jlonnberg commented 1 year ago

@MrAlexandrKolesnikov Hello! Can you please try to execute the same configuration in the EWARM workbench and see if it works there?

MrAlexandrKolesnikov commented 1 year ago

@jlonnberg Hello! In IAR workbench everything build and debug work too

jlonnberg commented 1 year ago

@MrAlexandrKolesnikov I see. Which version of EWARM are you using?

MrAlexandrKolesnikov commented 1 year ago

@jlonnberg 8.40.2

jlonnberg commented 1 year ago

@MrAlexandrKolesnikov I've now tested this with an ST-Link v2 and a STM32F103ZE card which also uses a flashloader. For me, this works in both EWARM and VS-Code so I'm currently unable to reproduce the problem.

The log seems to indicate that none of the application is actually flashed which might indicate that something is wrong with the configuration. Is the launch requests driver options exaclty the same as the ones found in the settings catalog for the EWARM project? If they are, is it possible for you to try with another probe to see if it's the probe that triggers the issue?