Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVD not updating registers #210

Closed
mes1234 opened this issue Sep 29, 2019 · 15 comments
Closed

SVD not updating registers #210

mes1234 opened this issue Sep 29, 2019 · 15 comments

Comments

@mes1234
Copy link

mes1234 commented Sep 29, 2019

Hello,

I've started using cortex debug addin.
It works ok, until I want to use svd file.
It looks like it not updating registers, after refresh it shows:
GDB -> App: {"token":267,"outOfBandRecord":[],"resultRecords":{"resultClass":"error","results":[["msg","Unable to read memory."]]}}

Here is my code repo:

https://github.com/mes1234/nucleo_bare_metal

@haneefdm
Copy link
Collaborator

haneefdm commented Sep 29, 2019

Could you post a little bit more from the Debug Console window? Also from the Adapter Output window to see messages if any from pyocd.

@mes1234
Copy link
Author

mes1234 commented Sep 29, 2019

Sure, I'll do it when I get to laptop

@mes1234
Copy link
Author

mes1234 commented Sep 29, 2019

Some details:
I am working on ST nucleo board with STM32F103RBT6 unit.
At this stage I am working on bare metal approach to blink LED on GPIOA pin 5. Code is running ok and LED is blinking.
I've tried to add svd file for my unit. It starts and shows all registers correctly mapped to memory, according to spec GPIOA is 0x4001 0800 and it shows this way in svd preview in VS code.
Also I am able to run full debugger in VS code using preview of registers which updated according to program.
The issue is with svd preview. It does not update value after any operation. eg.

GPIOA->ODR =0x000ffff;

Works correctly in code but register is still:
Screenshot from 2019-09-29 19-52-41

Also after any operation of refreshing svd preview in debug console I receive:
Screenshot from 2019-09-29 19-55-10

This is my repository:
https://github.com/mes1234/nucleo_bare_metal
and this is my .vscode/launch.json:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "cortex-debug",
            "request": "launch",
            "servertype": "pyocd",
            "cwd": "${workspaceRoot}",
            "executable": "exec/main.elf",
            "name": "Debug (pyOCD)",
            "device": "STM32F103RB",
            "targetId": "",
            "boardId": "",
            "showDevDebugOutput": true,
            "svdFile": "svd/STM32F103.svd",
            "preLaunchTask": "build",
        }
    ]
}

Is there any other setup I need to complete to allow svd preview to update?
I am running Ubutu 18.04 and pyocd as server.

Thank in advace for any help!

Witek

@haneefdm
Copy link
Collaborator

Since I don't have your HW, I can't debug with your project but I can see what tools you are using.

What I need is the full output of the Debug Console... before the following. I want to know what requests were made to gdb, which ones succeeded and which failed. What I see below is just the response to one failed request.

GDB -> App: {"token":267,"outOfBandRecord":[],"resultRecords":{"resultClass":"error","results":[["msg","Unable to read memory."]]}}

And, the output from pyocd.

You can also use the memory window to see what is at 0x40010800. If memory reads are not working in that region of the address space then, SVD can't work. I see a couple of registers there that night be the issue. I still need to see what requests were made to GDB

@mes1234
Copy link
Author

mes1234 commented Sep 29, 2019

Hi
Here is whole output.

I cannot see memmory window. This is how my VS code looks like where I can find it?
Screenshot from 2019-09-29 21-50-34

Please check OUTPUT tab (Adapter Output) for log of pyocd-gdbserver
Launching server: "pyocd-gdbserver" "--persist" "--port" "50000" "--reset-break"
1-gdb-set target-async on
2-interpreter-exec console "source /home/witek/.vscode/extensions/marus25.cortex-debug-0.3.1/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 /home/witek/CODE/arm/test_gnu/exec/main.elf...\n"}]}
Reading symbols from /home/witek/CODE/arm/test_gnu/exec/main.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":"0x08000162 in main () at src/main.c:22\n"}]}
0x08000162 in main () at src/main.c:22
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"22\t    if (val>32000)\n"}]}
22	    if (val>32000)
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"stopped","output":[["frame",[["addr","0x08000162"],["func","main"],["args",[]]]],["file","src/main.c"],["fullname","/home/witek/CODE/arm/test_gnu/src/main.c"],["line","22"],["arch","armv7"]]}]}
Not implemented stop reason (assuming exception): undefined
GDB -> App: {"token":3,"outOfBandRecord":[],"resultRecords":{"resultClass":"connected","results":[]}}
8-thread-list-ids
GDB -> App: {"token":4,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
GDB -> App: {"token":5,"outOfBandRecord":[{"isStream":false,"type":"status","asyncClass":"download","output":[]}]}
GDB -> App: {"token":5,"outOfBandRecord":[{"isStream":false,"type":"status","asyncClass":"download","output":[]}]}
GDB -> App: {"token":5,"outOfBandRecord":[{"isStream":false,"type":"status","asyncClass":"download","output":[]}]}
9-thread-list-ids
GDB -> App: {"token":5,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["address","0x8000186"],["load-size","460"],["transfer-rate","32280"],["write-rate","230"]]}}
GDB -> App: {"token":6,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
GDB -> App: {"token":7,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
10-break-insert "/home/witek/CODE/arm/test_gnu/src/main.c:17"
11-break-insert "/home/witek/CODE/arm/test_gnu/src/main.c:25"
GDB -> App: {"token":8,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["thread-ids",[["thread-id","1"]]],["current-thread-id","1"],["number-of-threads","1"]]}}
12-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"]]}}
13-thread-info 1
GDB -> App: {"token":10,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["bkpt",[["number","1"],["type","breakpoint"],["disp","keep"],["enabled","y"],["addr","0x0800014a"],["func","main"],["file","src/main.c"],["fullname","/home/witek/CODE/arm/test_gnu/src/main.c"],["line","17"],["thread-groups",["i1"]],["times","0"],["original-location","/home/witek/CODE/arm/test_gnu/src/main.c:17"]]]]}}
GDB -> App: {"token":11,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["bkpt",[["number","2"],["type","breakpoint"],["disp","keep"],["enabled","y"],["addr","0x0800016e"],["func","main"],["file","src/main.c"],["fullname","/home/witek/CODE/arm/test_gnu/src/main.c"],["line","25"],["thread-groups",["i1"]],["times","0"],["original-location","/home/witek/CODE/arm/test_gnu/src/main.c:25"]]]]}}
GDB -> App: {"token":12,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","Thread 1"],["frame",[["level","0"],["addr","0x08000186"],["func","reset_handler"],["args",[]]]],["arch","armv7"]]]]]}}
GDB -> App: {"token":13,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","Thread 1"],["frame",[["level","0"],["addr","0x08000186"],["func","reset_handler"],["args",[]]]],["arch","armv7"]]]]]}}
14-thread-list-ids
GDB -> App: {"token":14,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["thread-ids",[["thread-id","1"]]],["current-thread-id","1"],["number-of-threads","1"]]}}
15-thread-info 1
GDB -> App: {"token":15,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","Thread 1"],["frame",[["level","0"],["addr","0x08000186"],["func","reset_handler"],["args",[]]]],["arch","armv7"]]]]]}}
16-data-list-register-names
GDB -> App: {"token":16,"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","control","basepri","faultmask"]]]}}
17-stack-list-frames --thread 1 0 20
18-thread-list-ids
GDB -> App: {"token":17,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["stack",[["frame",[["level","0"],["addr","0x08000186"],["func","reset_handler"],["arch","armv7"]]]]]]}}
19-data-disassemble -s 0x08000186 -e 0x080001b4 -- 2
GDB -> App: {"token":18,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["thread-ids",[["thread-id","1"]]],["current-thread-id","1"],["number-of-threads","1"]]}}
20-thread-info 1
GDB -> App: {"token":19,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["asm_insns",[[["address","0x08000186"],["func-name","reset_handler"],["offset","0"],["opcodes","0b 48"],["inst","ldr\tr0, [pc, #44]\t; (0x80001b4 <reset_bss_loop+8>)"]],[["address","0x08000188"],["func-name","reset_handler"],["offset","2"],["opcodes","85 46"],["inst","mov\tsp, r0"]],[["address","0x0800018a"],["func-name","reset_handler"],["offset","4"],["opcodes","00 20"],["inst","movs\tr0, #0"]],[["address","0x0800018c"],["func-name","reset_handler"],["offset","6"],["opcodes","0a 49"],["inst","ldr\tr1, [pc, #40]\t; (0x80001b8 <reset_bss_loop+12>)"]],[["address","0x0800018e"],["func-name","reset_handler"],["offset","8"],["opcodes","0b 4a"],["inst","ldr\tr2, [pc, #44]\t; (0x80001bc <reset_bss_loop+16>)"]],[["address","0x08000190"],["func-name","reset_handler"],["offset","10"],["opcodes","0b 4b"],["inst","ldr\tr3, [pc, #44]\t; (0x80001c0 <reset_bss_loop+20>)"]],[["address","0x08000192"],["func-name","reset_handler"],["offset","12"],["opcodes","02 e0"],["inst","b.n\t0x800019a <reset_handler+20>"]],[["address","0x08000194"],["func-name","reset_handler"],["offset","14"],["opcodes","1c 58"],["inst","ldr\tr4, [r3, r0]"]],[["address","0x08000196"],["func-name","reset_handler"],["offset","16"],["opcodes","0c 50"],["inst","str\tr4, [r1, r0]"]],[["address","0x08000198"],["func-name","reset_handler"],["offset","18"],["opcodes","04 30"],["inst","adds\tr0, #4"]],[["address","0x0800019a"],["func-name","reset_handler"],["offset","20"],["opcodes","44 18"],["inst","adds\tr4, r0, r1"]],[["address","0x0800019c"],["func-name","reset_handler"],["offset","22"],["opcodes","94 42"],["inst","cmp\tr4, r2"]],[["address","0x0800019e"],["func-name","reset_handler"],["offset","24"],["opcodes","f9 d3"],["inst","bcc.n\t0x8000194 <reset_handler+14>"]],[["address","0x080001a0"],["func-name","reset_handler"],["offset","26"],["opcodes","00 20"],["inst","movs\tr0, #0"]],[["address","0x080001a2"],["func-name","reset_handler"],["offset","28"],["opcodes","08 49"],["inst","ldr\tr1, [pc, #32]\t; (0x80001c4 <reset_bss_loop+24>)"]],[["address","0x080001a4"],["func-name","reset_handler"],["offset","30"],["opcodes","08 4a"],["inst","ldr\tr2, [pc, #32]\t; (0x80001c8 <reset_bss_loop+28>)"]],[["address","0x080001a6"],["func-name","reset_handler"],["offset","32"],["opcodes","01 e0"],["inst","b.n\t0x80001ac <reset_handler+38>"]],[["address","0x080001a8"],["func-name","reset_handler"],["offset","34"],["opcodes","08 60"],["inst","str\tr0, [r1, #0]"]],[["address","0x080001aa"],["func-name","reset_handler"],["offset","36"],["opcodes","04 31"],["inst","adds\tr1, #4"]],[["address","0x080001ac"],["func-name","reset_handler"],["offset","38"],["opcodes","91 42"],["inst","cmp\tr1, r2"]],[["address","0x080001ae"],["func-name","reset_handler"],["offset","40"],["opcodes","fb d3"],["inst","bcc.n\t0x80001a8 <reset_handler+34>"]],[["address","0x080001b0"],["func-name","reset_handler"],["offset","42"],["opcodes","ff f7 be bf"],["inst","b.w\t0x8000130 <main>"]]]]]}}
GDB -> App: {"token":20,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","Thread 1"],["frame",[["level","0"],["addr","0x08000186"],["func","reset_handler"],["args",[]]]],["arch","armv7"]]]]]}}
21-data-list-register-values N
GDB -> App: {"token":21,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["register-values",[[["number","0"],["value","0"]],[["number","1"],["value","1"]],[["number","2"],["value","1073881088"]],[["number","3"],["value","134217728"]],[["number","4"],["value","536870912"]],[["number","5"],["value","-142868689"]],[["number","6"],["value","-2136563178"]],[["number","7"],["value","536891376"]],[["number","8"],["value","-578818050"]],[["number","9"],["value","536871752"]],[["number","10"],["value","-1858035778"]],[["number","11"],["value","1146656204"]],[["number","12"],["value","-25830145"]],[["number","13"],["value","0x20005000"]],[["number","14"],["value","-1"]],[["number","15"],["value","0x8000186 <reset_handler>"]],[["number","25"],["value","16777216"]],[["number","91"],["value","0x20005000"]],[["number","92"],["value","0xa8fd1c4"]],[["number","93"],["value","0"]],[["number","94"],["value","0"]],[["number","95"],["value","0"]],[["number","96"],["value","0"]]]]]}}
22-exec-continue --thread 1
GDB -> App: {"token":22,"outOfBandRecord":[],"resultRecords":{"resultClass":"running","results":[]}}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"running","output":[["thread-id","all"]]}]}
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: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"breakpoint-modified","output":[["bkpt",[["number","1"],["type","breakpoint"],["disp","keep"],["enabled","y"],["addr","0x0800014a"],["func","main"],["file","src/main.c"],["fullname","/home/witek/CODE/arm/test_gnu/src/main.c"],["line","17"],["thread-groups",["i1"]],["times","1"],["original-location","/home/witek/CODE/arm/test_gnu/src/main.c:17"]]]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"\n"}]}

GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"Breakpoint 1, main () at src/main.c:17\n"}]}
Breakpoint 1, main () at src/main.c:17
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"17\t    GPIOA->ODR =0x000ffff;\n"}]}
17	    GPIOA->ODR =0x000ffff;
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"stopped","output":[["reason","breakpoint-hit"],["disp","keep"],["bkptno","1"],["frame",[["addr","0x0800014a"],["func","main"],["args",[]]]],["file","src/main.c"],["fullname","/home/witek/CODE/arm/test_gnu/src/main.c"],["line","17"],["arch","armv7"]]}]}
23-thread-list-ids
24-data-read-memory-bytes 0x40010800 28
25-data-read-memory-bytes 0x40002c00 12
26-data-list-register-values N
GDB -> App: {"token":23,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["thread-ids",[["thread-id","1"]]],["current-thread-id","1"],["number-of-threads","1"]]}}
GDB -> App: {"token":24,"outOfBandRecord":[],"resultRecords":{"resultClass":"error","results":[["msg","Unable to read memory."]]}}
GDB -> App: {"token":25,"outOfBandRecord":[],"resultRecords":{"resultClass":"error","results":[["msg","Unable to read memory."]]}}
27-thread-info 1
GDB -> App: {"token":26,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["register-values",[[["number","0"],["value","0"]],[["number","1"],["value","536870912"]],[["number","2"],["value","858993459"]],[["number","3"],["value","1073809408"]],[["number","4"],["value","536870912"]],[["number","5"],["value","-142868689"]],[["number","6"],["value","-2136563178"]],[["number","7"],["value","536891376"]],[["number","8"],["value","-578818050"]],[["number","9"],["value","536871752"]],[["number","10"],["value","-1858035778"]],[["number","11"],["value","1146656204"]],[["number","12"],["value","-25830145"]],[["number","13"],["value","0x20004ff0"]],[["number","14"],["value","-1"]],[["number","15"],["value","0x800014a <main+26>"]],[["number","25"],["value","1627389952"]],[["number","91"],["value","0x20004ff0"]],[["number","92"],["value","0xa8fd1c4"]],[["number","93"],["value","0"]],[["number","94"],["value","0"]],[["number","95"],["value","0"]],[["number","96"],["value","0"]]]]]}}
GDB -> App: {"token":27,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","Thread 1"],["frame",[["level","0"],["addr","0x0800014a"],["func","main"],["args",[]]]],["file","src/main.c"],["fullname","/home/witek/CODE/arm/test_gnu/src/main.c"],["line","17"],["arch","armv7"]]]]]}}
28-stack-list-frames --thread 1 0 20
GDB -> App: {"token":28,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["stack",[["frame",[["level","0"],["addr","0x0800014a"],["func","main"],["file","src/main.c"],["fullname","/home/witek/CODE/arm/test_gnu/src/main.c"],["line","17"],["arch","armv7"]]]]]]}}
29-stack-info-frame --thread 1 --frame 0
GDB -> App: {"token":29,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["frame",[["level","0"],["addr","0x0800014a"],["func","main"],["file","src/main.c"],["fullname","/home/witek/CODE/arm/test_gnu/src/main.c"],["line","17"],["arch","armv7"]]]]}}
30-exec-next --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":false,"type":"exec","asyncClass":"stopped","output":[["reason","end-stepping-range"],["frame",[["addr","0x08000152"],["func","main"],["args",[]]]],["file","src/main.c"],["fullname","/home/witek/CODE/arm/test_gnu/src/main.c"],["line","18"],["arch","armv7"]]}]}
31-thread-list-ids
32-data-read-memory-bytes 0x40010800 28
33-data-read-memory-bytes 0x40002c00 12
34-data-list-register-values N
GDB -> App: {"token":31,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["thread-ids",[["thread-id","1"]]],["current-thread-id","1"],["number-of-threads","1"]]}}
35-thread-info 1
GDB -> App: {"token":32,"outOfBandRecord":[],"resultRecords":{"resultClass":"error","results":[["msg","Unable to read memory."]]}}
GDB -> App: {"token":33,"outOfBandRecord":[],"resultRecords":{"resultClass":"error","results":[["msg","Unable to read memory."]]}}
GDB -> App: {"token":34,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["register-values",[[["number","0"],["value","0"]],[["number","1"],["value","536870912"]],[["number","2"],["value","65535"]],[["number","3"],["value","1073809408"]],[["number","4"],["value","536870912"]],[["number","5"],["value","-142868689"]],[["number","6"],["value","-2136563178"]],[["number","7"],["value","536891376"]],[["number","8"],["value","-578818050"]],[["number","9"],["value","536871752"]],[["number","10"],["value","-1858035778"]],[["number","11"],["value","1146656204"]],[["number","12"],["value","-25830145"]],[["number","13"],["value","0x20004ff0"]],[["number","14"],["value","-1"]],[["number","15"],["value","0x8000152 <main+34>"]],[["number","25"],["value","1627389952"]],[["number","91"],["value","0x20004ff0"]],[["number","92"],["value","0xa8fd1c4"]],[["number","93"],["value","0"]],[["number","94"],["value","0"]],[["number","95"],["value","0"]],[["number","96"],["value","0"]]]]]}}
GDB -> App: {"token":35,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","Thread 1"],["frame",[["level","0"],["addr","0x08000152"],["func","main"],["args",[]]]],["file","src/main.c"],["fullname","/home/witek/CODE/arm/test_gnu/src/main.c"],["line","18"],["arch","armv7"]]]]]}}
36-stack-list-frames --thread 1 0 20
GDB -> App: {"token":36,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["stack",[["frame",[["level","0"],["addr","0x08000152"],["func","main"],["file","src/main.c"],["fullname","/home/witek/CODE/arm/test_gnu/src/main.c"],["line","18"],["arch","armv7"]]]]]]}}
37-data-read-memory-bytes 0x40010800 28
GDB -> App: {"token":37,"outOfBandRecord":[],"resultRecords":{"resultClass":"error","results":[["msg","Unable to read memory."]]}}
0000230:WARNING:gdb_server:pyocd-gdbserver is deprecated; please use the new combined pyocd tool.
0000451:INFO:board:Target type is stm32f103rb
0000526:INFO:dap:DP IDR = 0x1ba01477 (v1 rev1)
0000586:INFO:ap:AP#0 IDR = 0x14770011 (AHB-AP var1 rev1)
0000591:INFO:rom_table:AP#0 ROM table #0 @ 0xe00ff000 (designer=020 part=410)
0000594:INFO:rom_table:[0]<e000e000:SCS-M3 class=14 designer=43b part=000>
0000596:INFO:rom_table:[1]<e0001000:DWT class=14 designer=43b part=002>
0000598:INFO:rom_table:[2]<e0002000:FPB class=14 designer=43b part=003>
0000600:INFO:rom_table:[3]<e0000000:ITM class=14 designer=43b part=001>
0000602:INFO:rom_table:[4]<e0040000:TPIU-M3 class=9 designer=43b part=923 devtype=11 archid=0000 devid=0:0:ca0>
0000603:INFO:cortex_m:CPU core #0 is Cortex-M3 r1p1
0000607:INFO:dwt:4 hardware watchpoints
0000611:INFO:fpb:6 hardware breakpoints, 4 literal comparators
0000622:INFO:server:Semihost server started on port 4444
0000623:INFO:gdbserver:GDB server started on port 50000
0000646:INFO:gdbserver:One client connected!
0000765:INFO:gdbserver:Attempting to load Argon
0000766:INFO:gdbserver:Attempting to load FreeRTOS
0000766:INFO:gdbserver:Attempting to load Zephyr
0000766:INFO:gdbserver:Attempting to load RTX5
[---|---|---|---|---|---|---|---|---|----]
[========================================]
0000892:INFO:loader:Erased 0 bytes (0 sectors), programmed 0 bytes (0 pages), skipped 1024 bytes (1 page) at 9.20 kB/s

@mes1234
Copy link
Author

mes1234 commented Sep 29, 2019

Ok I found memory check: this is output:
Screenshot from 2019-09-29 21-57-05

And this is log window:

[2019-09-29 21:46:37.204] [renderer1] [error] ioctl(2) failed, EBADF: Error: ioctl(2) failed, EBADF
    at UnixTerminal.resize (/snap/code/15/usr/share/code/resources/app/node_modules.asar/node-pty/lib/unixTerminal.js:227:13)
    at S.resize (file:///snap/code/15/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:2857:920)
    at E.setDimensions (file:///snap/code/15/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:4047:766)
    at _processManager.ptyProcessReady.then (file:///snap/code/15/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:4074:897)
[2019-09-29 21:46:54.691] [renderer1] [error] Failed  to read peripheral GPIOA:read-failed Error: Unable to read memory: Unable to read memory. (from data-read-memory-bytes 0x40010800 28)
[2019-09-29 21:54:51.649] [renderer1] [error] Failed  to read peripheral GPIOA:read-failed Error: Unable to read memory: Unable to read memory. (from data-read-memory-bytes 0x40010800 28)

@haneefdm
Copy link
Collaborator

Okay, I see the problem. The memory read is trying to read 28 bytes but 8 of those bytes are write-only.

You enter the following in the "Debug Console"

-data-read-memory-bytes 0x40010800 16

The above should succeed. If the above fail, then we have a different problem. Change 16 to 20 or 24 and it will probably fail.

Please confirm. It is a bug in Cortex-Debug and I can fix it after your confirmation.

@mes1234
Copy link
Author

mes1234 commented Sep 30, 2019

Hi
I've checked both 16 and 20 and it give the same result. But I am having problem to understand the output.
Could you take a look?

-data-read-memory-bytes 0x40010800 16

Screenshot from 2019-09-30 20-43-13

-data-read-memory-bytes 0x40010800 20

Screenshot from 2019-09-30 20-45-10

@haneefdm
Copy link
Collaborator

Oh darn/puzzled. Can we even read 4 or 8 bytes? If not, nothing will work. At this point, I am suspecting problem may be pyocd? Is it possible for you to try with OpenOCD -- just as an experiment.

My theory was that up to 16 bytes from that address, everything should be fine. Are other peripheral addresses working or is it across the board failure?

Normally even if you have a write-only mem-mapped-regs, trying to read from the debug port should still work with undefined results but it depends on how the chip designer decided to implement.

@mes1234
Copy link
Author

mes1234 commented Sep 30, 2019

Switching to openOCD works like charm :)
Thank you very much for help!

@mes1234 mes1234 closed this as completed Sep 30, 2019
@haneefdm
Copy link
Collaborator

Whew!!. You may want to file an issue with either pyocd or STM simply mentioning why memory reads fail and/or how they can expect SVD to even work. Use gdb as an example instead of this extension. I know it is a bit of work It will help a whole lot of people.

Chances are you will have the exact same issues with Eclipse-based IDEs

@mes1234
Copy link
Author

mes1234 commented Sep 30, 2019

OK I will post issue on pyocd while I can easily link this issue.
For future reference its here:
pyocd/pyOCD#732

@kab4rt
Copy link

kab4rt commented Jul 26, 2020

Although the issue is now closed I would like to add some feedback as I recently run into the same problem with STM32L5 and I think that the potential solution description may save some other people time.

Firstly I would like to confirm that Cortex-Debug plugin is working properly. Secondly the problem with SVD or more generally with peripherals memory sector access is caused by the way pyOCD is handling CMSIS packs, or to be more precise - by the information provided in pack descriptor.
During GDB connection establishment some information are exchanged between client and server. One of it is memory map request (qXfer:memory-map:read) with response packet format as an XML document. Apparently this data is later on used by a GDB client to validate memory I/O operation before sending a request to a server. The received memory map can be dumped to client console by info mem command.
During my tests I was able to confirm that when peripheral address space is not present in the memory map a data read request packet is never transmitted to the GDB server. Peripheral register view works with openOCD because the memory map provided to the client provides r/w permissions to almost full MCU address area.
The last part that remains is to explain why memory map provided by pyOCD is incomplete. Basically, the number of targets supported by the tool after the installation is limited but can be easily expanded with CMSIS packs. Those packs are parsed during server initialization to determine flash sectors and programming algorithms and generally to build device memory map. Now let's take a look at some device defined in STM32L5 pack descriptor file (.pdsc):

<!-- *************************  Device 'STM32L552CCTx'  ***************************** -->
<device Dname="STM32L552CCTx">
    <debug svd="CMSIS/SVD/STM32L552.svd"/>
    <compile header="Drivers/CMSIS/Device/ST/STM32L5xx/Include/stm32l5xx.h" define="STM32L552xx"/>

    <book name="Documentation/DB3609_STM32L552.pdf"          title="STM32L552xx Data Sheet"/>

    <memory name="Flash-non-secure" access="rx"  id="IROM1" start="0x08000000" size="0x00040000" default="1" startup="1" />
    <memory name="Flash-secure"     access="rx"  id="IROM2" start="0x0C000000" size="0x00040000" default="0" startup="1" />
    <memory name="SRAM-non-secure"  access="rwx" id="IRAM1" start="0x20000000" size="0x00040000" default="1" init="0" />
    <memory name="SRAM-secure"      access="rwx" id="IRAM2" start="0x30000000" size="0x00040000" default="0" init="0" />

    <feature type="QFP" n="48"/>
</device>

Flash and RAM sectors are properly defined but that's it. All remaining address space is not part of memory map and therefore illegal to access by a GDB client. After I had modified the pack descriptor and added additional memory section for peripheral address space the SVD/peripheral register view functionality was fully restored.

<memory name="Peripheral"      access="rw" id="PERPH" start="0x40000000" size="0x10000000" default="0" init="0" />

The same issue type ("unable to read memory") will happen in case of other address sectors like FSMC external memory or some vendor registers unless they are not defined in the memory map.

For the record my environment:

  • GDB client: GNU Arm Embedded Toolchain 8.3.1
  • GDB server: pyOCD 0.27.1
  • STM32L5 pack: Keil.STM32L5xx_DFP.1.2.0.pack
  • Cortex-Debug extension: 0.3.7

@haneefdm
Copy link
Collaborator

Thank you for the investigation, resolution, and explanation.

@AlexanderStein
Copy link

Another workaround when using pyOCD is to use a user script
So you can add those regions manually without changing SVDs and packs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants