microsoft / vscode-arduino

Visual Studio Code extension for Arduino
Other
1.14k stars 194 forks source link

Unable to debug Adafruit Feather M0 #443

Open jdeane opened 6 years ago

jdeane commented 6 years ago

Hello,

I have a problem debugging an Adafruit Feather M0 using VSCode-Arduino. I have installed libusb to get Openocd to recognise the jlink.

I'm using:

Here is the verbose output when I try to debug the application:

1: (140) LaunchOptions<LocalLaunchOptions xmlns='http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014'
1: (149) LaunchOptions  ExePath='c:\Users\jdean\Desktop\Test\.build\adafruit_feather_m0\app.ino.elf'
1: (149) LaunchOptions  WorkingDirectory='c:\Users\jdean\Desktop\Test'
1: (149) LaunchOptions  TargetArchitecture='arm'
1: (149) LaunchOptions  ExeArguments=''
1: (149) LaunchOptions MIMode='gdb'
1: (149) LaunchOptions  MIDebuggerPath='C:\Users\jdean\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\bin\arm-none-eabi-gdb.exe'
1: (149) LaunchOptions  WaitDynamicLibLoad='false'
1: (149) LaunchOptions  DebugServer='C:\Users\jdean\AppData\Local\Arduino15\packages\arduino\tools\openocd\0.9.0-arduino\bin\openocd.exe'
1: (150) LaunchOptions  DebugServerArgs='-s C:\Users\jdean\AppData\Local\Arduino15\packages\arduino\tools\openocd\0.9.0-arduino\share\openocd\scripts\ -f interface/jlink.cfg -c "transport select swd" -f target/at91samdXX.cfg -c "telnet_port disabled" -c "tcl_port disabled"'
1: (150) LaunchOptions  ServerStarted='Info\ :\ [\w\d\.]*:\ hardware'
1: (150) LaunchOptions  FilterStderr='true'
1: (150) LaunchOptions>
1: (150) LaunchOptions    <CustomLaunchSetupCommands>
1: (150) LaunchOptions        <Command IgnoreFailures='false' Description=''>target remote localhost:3333</Command>
1: (150) LaunchOptions        <Command IgnoreFailures='false' Description=''>file c:/Users/jdean/Desktop/Test/.build/adafruit_feather_m0/app.ino.elf</Command>
1: (150) LaunchOptions        <Command IgnoreFailures='false' Description=''>load</Command>
1: (150) LaunchOptions        <Command IgnoreFailures='false' Description=''>monitor reset halt</Command>
1: (150) LaunchOptions        <Command IgnoreFailures='false' Description=''>monitor reset init</Command>
1: (150) LaunchOptions    </CustomLaunchSetupCommands>
1: (150) LaunchOptions    <LaunchCompleteCommand>exec-continue</LaunchCompleteCommand>
1: (150) LaunchOptions</LocalLaunchOptions>
1: (185) Starting: "C:\Users\jdean\AppData\Local\Arduino15\packages\arduino\tools\openocd\0.9.0-arduino\bin\openocd.exe" -s C:\Users\jdean\AppData\Local\Arduino15\packages\arduino\tools\openocd\0.9.0-arduino\share\openocd\scripts\ -f interface/jlink.cfg -c "transport select swd" -f target/at91samdXX.cfg -c "telnet_port disabled" -c "tcl_port disabled"
1: (282) Starting: "C:\Users\jdean\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\bin\arm-none-eabi-gdb.exe" --interpreter=mi
1: (291) DebuggerPid=21152
1: (322) ->=thread-group-added,id="i1"
1: (323) ->~"GNU gdb (GNU Tools for ARM Embedded Processors) 7.6.0.20140228-cvs\n"
1: (323) ->~"Copyright (C) 2013 Free Software Foundation, Inc.\n"
1: (323) ->~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\nand \"show warranty\" for details.\n"
1: (323) ->~"This GDB was configured as \"--host=i686-w64-mingw32 --target=arm-none-eabi\".\nFor bug reporting instructions, please see:\n"
1: (323) ->~"<http://www.gnu.org/software/gdb/bugs/>.\n"
1: (323) ->(gdb)
1: (328) <-1001-gdb-set target-async on
1: (332) ->1001^done
1: (332) ->(gdb)
1: (332) ->&"\n"
1: (332) ->^done
1: (332) ->(gdb)
1: (333) 1001: elapsed time 5
1: (337) <-1002-interpreter-exec console "set pagination off"
1: (343) ->=cmd-param-changed,param="pagination",value="off"
1: (343) ->1002^done
1: (343) ->(gdb)
1: (343) 1002: elapsed time 6
1: (343) ->&"\n"
1: (343) ->^done
1: (343) ->(gdb)
1: (343) <-1003-gdb-set solib-search-path c:\\Users\\jdean\\Desktop\\Test\\.build\\adafruit_feather_m0;
1: (353) ->1003^done
1: (353) ->(gdb)
1: (353) 1003: elapsed time 10
1: (353) ->&"\n"
1: (353) ->^done
1: (353) ->(gdb)
1: (355) <-1004-interpreter-exec console "target remote localhost:3333"
1: (379) ->~"Remote debugging using localhost:3333\n"
1: (382) ->=thread-group-started,id="i1",pid="42000"
1: (382) ->=thread-created,id="1",group-id="i1"
1: (394) ->~"0xfffffffe in ?? ()\n"
1: (394) ->*stopped,frame={addr="0xfffffffe",func="??",args=[]},thread-id="1",stopped-threads="all"
1: (394) ->1004^done
1: (394) ->(gdb)
1: (395) ->&"\n"
1: (395) ->^done
1: (395) ->(gdb)
1: (400) 1004: elapsed time 45
1: (400) <-1005-thread-info 1
1: (405) ->1005^done,threads=[{id="1",target-id="Remote target",frame={level="0",addr="0xfffffffe",func="??",args=[]},state="stopped"}]
1: (405) ->(gdb)
1: (405) ->&"\n"
1: (405) ->^done
1: (405) ->(gdb)
1: (406) 1005: elapsed time 5
1: (406) <-1006-interpreter-exec console "file c:/Users/jdean/Desktop/Test/.build/adafruit_feather_m0/app.ino.elf"
1: (416) ->~"A program is being debugged already.\nAre you sure you want to change the file? "
1: (416) ->~"(y or n) [answered Y; input not from terminal]\n"
1: (416) ->~"Reading symbols from c:\\Users\\jdean\\Desktop\\Test\\.build\\adafruit_feather_m0\\app.ino.elf..."
1: (421) ->~"done.\n"
1: (422) ->1006^done
1: (422) ->(gdb)
1: (422) 1006: elapsed time 16
1: (422) <-1007-interpreter-exec console "load"
1: (422) ->&"\n"
1: (422) ->^done
1: (423) ->(gdb)
1: (1158) ->~"Loading section .text, size 0x259c lma 0x2000\n"
1: (1159) ->1007+download,{section=".text",section-size="9628",total-size="279707"}
1: (1159) ->~"Loading section .data, size 0x100 lma 0x459c\n"
1: (1159) ->1007+download,{section=".data",section-size="256",total-size="279707"}
1: (2147) ->~"Start address 0x2208, load size 9884\n"
1: (2148) ->~"Transfer rate: 5 KB/sec, 4942 bytes/write.\n"
1: (2148) ->1007^done
1: (2148) ->(gdb)
1: (2148) 1007: elapsed time 1726
1: (2148) <-1008-interpreter-exec console "monitor reset halt"
1: (2148) ->&"\n"
1: (2148) ->^done
1: (2148) ->(gdb)
1: (2187) ->@"target state: halted\n"
1: (2187) ->@"target halted due to debug-request, current mode: Thread \n"
1: (2187) ->@"xPSR: 0x21000000 pc: 0xfffffffe msp: 0xfffffffc\n"
1: (2188) ->1008^done
1: (2188) ->(gdb)
1: (2188) 1008: elapsed time 40
1: (2188) ->&"\n"
1: (2188) ->^done
1: (2188) ->(gdb)
1: (2188) <-1009-interpreter-exec console "monitor reset init"
1: (2237) ->@"target state: halted\n"
1: (2237) ->@"target halted due to debug-request, current mode: Thread \n"
1: (2237) ->@"xPSR: 0x21000000 pc: 0xfffffffe msp: 0xfffffffc\n"
1: (2239) ->1009^done
1: (2239) ->(gdb)
1: (2239) 1009: elapsed time 51
1: (2239) ->&"\n"
1: (2239) ->^done
1: (2239) ->(gdb)
1: (2304) <-1010-break-insert -f app.ino:8
1: (2315) ->1010^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000212a",func="loop()",file="c:\\Users\\jdean\\Desktop\\Test/app.ino",fullname="c:\\Users\\jdean\\Desktop\\Test\\app.ino",line="8",thread-groups=["i1"],times="0",original-location="app.ino:8"}
1: (2315) ->(gdb)
1: (2315) 1010: elapsed time 10
1: (2315) ->&"\n"
1: (2315) ->^done
1: (2315) ->(gdb)
1: (2324) <-1011-symbol-list-lines c:\\Users\\jdean\\Desktop\\Test\\app.ino
1: (2326) ->1011^done,lines=[{pc="0x00002114",line="2"},{pc="0x00002116",line="3"},{pc="0x00002120",line="4"},{pc="0x00002128",line="0"},{pc="0x00002128",line="7"},{pc="0x0000212a",line="8"},{pc="0x00002132",line="9"},{pc="0x0000213c",line="0"}]
1: (2326) ->(gdb)
1: (2326) 1011: elapsed time 2
1: (2326) ->&"\n"
1: (2326) ->^done
1: (2326) ->(gdb)
openocd: Open On-Chip Debugger 0.9.0-gd4b7679 (2015-06-10-22:24)
openocd: Licensed under GNU GPL v2
openocd: For bug reports, read
openocd:    http://openocd.org/doc/doxygen/bugs.html
openocd: cygwin warning:
openocd:   MS-DOS style path detected: C:\Users\jdean\AppData\Local\Arduino15\packages\arduino\tools\openocd\0.9.0-arduino\share\openocd\scripts\/interface/jlink.cfg
openocd:   Preferred POSIX equivalent is: /share/openocd/scripts/interface/jlink.cfg
openocd:   CYGWIN environment variable option "nodosfilewarning" turns off this warning.
openocd:   Consult the user's guide for more details about POSIX paths:
openocd:     http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
openocd: Info : JLink SWD mode enabled
openocd: swd
openocd: adapter speed: 500 kHz
openocd: adapter_nsrst_delay: 100
openocd: cortex_m reset_config sysresetreq
openocd: Info : tcl server disabled
openocd: Info : telnet server disabled
openocd: Info : J-Link V9 compiled Oct  6 2017 16:38:28
openocd: Info : J-Link caps 0xb9ff7bbf
openocd: Info : J-Link hw version 93000
openocd: Info : J-Link hw type J-Link
openocd: Info : J-Link max mem block 69824
openocd: Info : J-Link configuration
openocd: Info : USB-Address: 0x0
openocd: Info : Kickstart power on JTAG-pin 19: 0xffffffff
openocd: Info : Vref = 3.261 TCK = 0 TDI = 0 TDO = 0 TMS = 1 SRST = 1 TRST = 0
openocd: Info : J-Link JTAG Interface ready
openocd: Info : clock speed 500 kHz
openocd: Info : SWD IDCODE 0x0bc11477
openocd: Info : at91samd.cpu: hardware has 4 breakpoints, 2 watchpoints
=thread-group-added,id="i1"
GNU gdb (GNU Tools for ARM Embedded Processors) 7.6.0.20140228-cvs
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-w64-mingw32 --target=arm-none-eabi".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
=cmd-param-changed,param="pagination",value="off"
openocd: Info : accepting 'gdb' connection on tcp/3333
openocd: Info : SAMD MCU: SAMD21G18A (256KB Flash, 32KB RAM)
openocd: undefined debug reason 7 - target needs reset
openocd: Error: address + size wrapped(0xfffffffe, 0x00000004)
openocd: target state: halted
openocd: target halted due to debug-request, current mode: Thread 
openocd: xPSR: 0x21000000 pc: 0xfffffffe msp: 0xfffffffc
openocd: target state: halted
openocd: target halted due to debug-request, current mode: Thread 
openocd: xPSR: 0x21000000 pc: 0xfffffffe msp: 0xfffffffc
openocd: target state: halted
openocd: target halted due to debug-request, current mode: Thread 
openocd: xPSR: 0x21000000 pc: 0xfffffffe msp: 0xfffffffc
openocd: target state: halted
openocd: target halted due to debug-request, current mode: Thread 
openocd: xPSR: 0x21000000 pc: 0xfffffffe msp: 0xfffffffc
1: (2354) <-1012-interpreter-exec console "info sharedlibrary"
1: (2358) ->~"No shared libraries loaded at this time.\n"
1: (2358) ->1012^done
1: (2358) ->(gdb)
1: (2358) 1012: elapsed time 4
1: (2358) ->&"\n"
1: (2358) ->^done
1: (2358) ->(gdb)
Loaded 'shared libraries loaded at this time.'. Cannot find or open the symbol file.
1: (2368) <-1013-thread-info
1: (2369) ->1013^done,threads=[{id="1",target-id="Remote target",frame={level="0",addr="0x00002208",func="Reset_Handler",args=[],file="C:\\Users\\jdean\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.0.20\\cores\\arduino\\cortex_handlers.c",fullname="C:\\Users\\jdean\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.0.20\\cores\\arduino\\cortex_handlers.c",line="141"},state="stopped"}],current-thread-id="1"
1: (2369) ->(gdb)
1: (2369) 1013: elapsed time 1
1: (2369) ->&"\n"
1: (2369) ->^done
1: (2369) ->(gdb)
1: (2376) <-1014-stack-list-frames 0 1000
1: (2379) ->1014^done,stack=[frame={level="0",addr="0x00002208",func="Reset_Handler",file="C:\\Users\\jdean\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.0.20\\cores\\arduino\\cortex_handlers.c",fullname="C:\\Users\\jdean\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.0.20\\cores\\arduino\\cortex_handlers.c",line="141"}]
1: (2379) ->(gdb)
1: (2379) ->&"\n"
1: (2379) ->^done
1: (2379) ->(gdb)
1: (2379) 1014: elapsed time 3
1: (2383) <--exec-continue
1: (2390) ->~"Note: automatically using hardware breakpoints for read-only addresses.\n"
Note: automatically using hardware breakpoints for read-only addresses.
1: (2391) ->^running
1: (2391) ->*running,thread-id="all"
1: (2391) ->(gdb)
1: (2391) ->&"\n"
1: (2391) ->^done
1: (2391) ->(gdb)
openocd: Error: at91samd.cpu -- clearing lockup after double fault
1: (2493) ->@"at91samd.cpu -- clearing lockup after double fault\n"
@"at91samd.cpu -- clearing lockup after double fault\n"
openocd: Polling target at91samd.cpu failed, trying to reexamine
openocd: Info : at91samd.cpu: hardware has 4 breakpoints, 2 watchpoints
openocd: Error: address + size wrapped(0xfffffffe, 0x00000004)
1: (2526) ->*stopped,reason="signal-received",signal-name="SIGINT",signal-meaning="Interrupt",frame={addr="0xfffffffe",func="??",args=[]},thread-id="1",stopped-threads="all"
1: (2526) <-1015-stack-list-frames 0 1000
openocd: Info : SWD IDCODE 0x0bc11477
openocd: Error: Failed to read memory at 0xfffffff4
openocd: Info : SWD IDCODE 0x0bc11477
openocd: Error: Failed to read memory at 0xffffffc0
1: (2547) ->1015^done,stack=[frame={level="0",addr="0xfffffffe",func="??"},frame={level="1",addr="0xfffffff9",func="<signal handler called>"},frame={level="2",addr="0x00000000",func="??"},frame={level="3",addr="0x00000000",func="??"}]
1: (2547) ->(gdb)
1: (2547) 1015: elapsed time 21
1: (2547) ->&"\n"
1: (2547) ->^done
1: (2547) ->(gdb)
Execute debugger commands using "-exec <command>", for example "-exec info registers" will list registers in use (when GDB is the debugger)
1: (2613) <-1016-stack-list-arguments 2 0 2
1: (2618) ->1016^done,stack-args=[frame={level="0",args=[]},frame={level="1",args=[]},frame={level="2",args=[]}]
1: (2618) ->(gdb)
1: (2618) 1016: elapsed time 5
1: (2618) ->&"\n"
1: (2618) ->^done
1: (2618) ->(gdb)

Any ideas?

andxu commented 6 years ago

Seems your firmware has problems, see http://forum.segger.com/index.php?page=Thread&threadID=3392, to fix it, try to reset your firmware back to default, to make sure options at 00804000 are valid as the following descriptions:

"Good" board option bytes:

00804000 = FF C7 E0 D8 5D FC FF FF FF FF FF FF FF FF FF FF

"Bad" boards option bytes:

00804000 = FA C7 E0 D8 5D FC FF FF FF FF FF FF FF FF FF FF

liydu commented 6 years ago

@jdeane , have you got this issue solved?

jdeane commented 6 years ago

Hi,

I didn't try the solution above. I was able to get it working reasonably well by using the GDB from Atmel 7 and the Segger GDB server.

I'll try the solution above over the next few days and post back.

Thanks.

czgtest commented 6 years ago

@jdeane do you try the solution and fix work ?

jdeane commented 6 years ago

Hi,

I tried the above fix, and unfortunately, I'm getting the same errors.

I have updated the J-Link software to 6.30f

I set the values starting at address 0x00804000 to FF C7 E0 D8 5D FC FF FF FF FF FF FF FF FF FF FF I reloaded the bootloader using Atmel Studio 7, leaving erase option unchecked. I'm seeing these errors when debugging from VSCode:

Note: automatically using hardware breakpoints for read-only addresses.
1: (10826) ->^running
1: (10826) ->*running,thread-id="all"
1: (10826) ->(gdb)
1: (10826) ->&"\n"
1: (10826) ->^done
1: (10826) ->(gdb)
openocd: Error: at91samd.cpu -- clearing lockup after double fault
1: (10927) ->@"at91samd.cpu -- clearing lockup after double fault\n"
@"at91samd.cpu -- clearing lockup after double fault\n"
openocd: Polling target at91samd.cpu failed, trying to reexamine
openocd: Info : at91samd.cpu: hardware has 4 breakpoints, 2 watchpoints
openocd: Error: address + size wrapped(0xfffffffe, 0x00000004)
1: (10973) ->*stopped,reason="signal-received",signal-name="SIGINT",signal-meaning="Interrupt",frame={addr="0xfffffffe",func="??",args=[]},thread-id="1",stopped-threads="all"
1: (10973) <-1015-stack-list-frames 0 1000
openocd: Info : SWD IDCODE 0x0bc11477
openocd: Error: Failed to read memory at 0xfffffff4
openocd: Info : SWD IDCODE 0x0bc11477
openocd: Error: Failed to read memory at 0xffffffc0
1: (10995) ->1015^done,stack=[frame={level="0",addr="0xfffffffe",func="??"},frame={level="1",addr="0xfffffff9",func="<signal handler called>"},frame={level="2",addr="0x00000000",func="??"},frame={level="3",addr="0x00000000",func="??"}]
1: (10995) ->(gdb)
1: (10995) 1015: elapsed time 22
1: (10996) ->&"\n"
1: (10996) ->^done
1: (10996) ->(gdb)
Execute debugger commands using "-exec <command>", for example "-exec info registers" will list registers in use (when GDB is the debugger)
1: (11060) <-1016-stack-list-arguments 0 0 2
1: (11068) ->1016^done,stack-args=[frame={level="0",args=[]},frame={level="1",args=[]},frame={level="2",args=[]}]
1: (11068) ->(gdb)
1: (11068) 1016: elapsed time 8
1: (11068) ->&"\n"
1: (11068) ->^done
1: (11068) ->(gdb)
jdeane commented 6 years ago

``

jdeane commented 6 years ago

Apologies I closed the issue in error.

czgtest commented 6 years ago

@Sneezry Can you help out?