majbthrd / pico-debug Goto Github PK
View Code? Open in Web Editor NEWvirtual debug pod for RP2040 "Raspberry Pi Pico" with no added hardware
virtual debug pod for RP2040 "Raspberry Pi Pico" with no added hardware
I need to debug code that uses tinyUSB for it's core functionality (basically, re-implementing the usb mass storage flash interface in normal userspace code alongside serial interfaces), is there any way to use pico-debug without using the USB interface?
Or alternatively, using it via a second pico with an interconnect to SWD and SWCLK?
So far pico-debug is the only debugger I've gotten to work, as picoprobe doesn't seem to have any documentation.
Hi,
I do not know, how else I could contact you.
I found this software, and at the page:
https://github.com/majbthrd/pico-debug/blob/master/howto/openocd.md
you mention to run openocd like:
openocd -f board/pico-debug.cfg
but:
How to I get rid of this?
As I understand, only SWD is needed, but I could not find out how to remove JTAG.
Thanks in advance,
Holger
PS: I spent hours now in trying to debug RP2040 on macOS, and I am now desperate to get anything going...
I have referred to the #5, but it didn't work for me.
After used that commands, it shows the error: hidapi is required for the CMSIS-DAP Compliant Debugger
as before.
OpenBSD has libusb, has OpenOCD build from master
without significant change (just sed -ri 's/([^_])(hid_init)/\1hidapi_\2/' src/jtag/drivers/*.c
[EDIT: that change is because of a name clash with OpenBSD own library API]), and openocd works fine with things like STM32. Great!
With pico-debug attached, I see
lsusb.openbsd.txt.
Comparing with lsusb.wsl.txt from #16 (under WSL environment):
--- lsusb.openbsd.txt Sat May 21 13:44:27 2022
+++ lsusb.wsl.txt Sat May 21 13:44:03 2022
@@ -1,29 +1,28 @@
-Bus 000 Device 006: ID 1209:2488 InterBiometrics
+Bus 001 Device 006: ID 1209:2488 Generic Peter Lawrence CMSIS-DAP Dapper Miser
Device Descriptor:
bLength 18
bDescriptorType 1
- bcdUSB 1.10
- bDeviceClass 0 (Defined at Interface level)
+ bcdUSB 2.00
+ bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
- idVendor 0x1209 InterBiometrics
- idProduct 0x2488
- bcdDevice 10.04
+ idVendor 0x1209 Generic
+ idProduct 0x2488 Peter Lawrence CMSIS-DAP Dapper Miser
+ bcdDevice 10.03
iManufacturer 2 pico-debug
iProduct 1 CMSIS-DAP
- iSerial 3 E660D4A0A72B4329
+ iSerial 3 E66038B713297738
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
- wTotalLength 41
+ wTotalLength 0x0029
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
- bmAttributes 0xa0
+ bmAttributes 0x80
(Bus Powered)
- Remote Wakeup
MaxPower 100mA
Interface Descriptor:
bLength 9
@@ -32,8 +31,8 @@
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 3 Human Interface Device
- bInterfaceSubClass 1 Boot Interface Subclass
- bInterfaceProtocol 1 Keyboard
+ bInterfaceSubClass 0
+ bInterfaceProtocol 0
iInterface 0
HID Device Descriptor:
bLength 9
@@ -42,33 +41,9 @@
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
- wDescriptorLength 34
- Report Descriptor: (length is 34)
- Item(Global): Usage Page, data= [ 0x00 0xff ] 65280
- (null)
- Item(Local ): Usage, data= [ 0x01 ] 1
- (null)
- Item(Main ): Collection, data= [ 0x01 ] 1
- Application
- Item(Local ): Usage, data= [ 0x02 ] 2
- (null)
- Item(Global): Logical Minimum, data= [ 0x00 ] 0
- Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
- Item(Global): Report Size, data= [ 0x08 ] 8
- Item(Global): Report Count, data= [ 0x40 ] 64
- Item(Main ): Input, data= [ 0x02 ] 2
- Data Variable Absolute No_Wrap Linear
- Preferred_State No_Null_Position Non_Volatile Bitfield
- Item(Local ): Usage, data= [ 0x03 ] 3
- (null)
- Item(Global): Logical Minimum, data= [ 0x00 ] 0
- Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
- Item(Global): Report Size, data= [ 0x08 ] 8
- Item(Global): Report Count, data= [ 0x40 ] 64
- Item(Main ): Output, data= [ 0x02 ] 2
- Data Variable Absolute No_Wrap Linear
- Preferred_State No_Null_Position Non_Volatile Bitfield
- Item(Main ): End Collection, data=none
+ wDescriptorLength 32
+ Report Descriptors:
+ ** UNAVAILABLE **
Endpoint Descriptor:
bLength 7
bDescriptorType 5
@@ -89,3 +64,7 @@
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1
+can't get device qualifier: Resource temporarily unavailable
+can't get debug descriptor: Resource temporarily unavailable
+Device Status: 0x0000
+ (Bus Powered)
So far so good, but I have the same error messae as #16 when running OpenOCD (Open On-Chip Debugger 0.11.0+dev-g0a36acb-dirty (2022-05-21-13:58)
, I bet that is recent enough :D).
$ doas openocd -f board/pico-debug.cfg -c 'debug_level 4'
Open On-Chip Debugger 0.11.0+dev-g0a36acb-dirty (2022-05-21-13:58)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Warn : Could not determine executable path, using configured BINDIR.
cortex_m reset_config sysresetreq
User : 6 4 options.c:63 configuration_output_handler(): debug_level: 4
User : 7 4 options.c:63 configuration_output_handler():
Info : 8 4 server.c:309 add_service(): Listening on port 6666 for tcl connections
Info : 9 4 server.c:309 add_service(): Listening on port 4444 for telnet connections
Debug: 10 4 command.c:166 script_debug(): command - init
Debug: 11 4 command.c:166 script_debug(): command - target init
Debug: 12 4 command.c:166 script_debug(): command - target names
Debug: 13 4 command.c:166 script_debug(): command - rp2040.cpu cget -event gdb-flash-erase-start
Debug: 14 4 command.c:166 script_debug(): command - rp2040.cpu configure -event gdb-flash-erase-start reset init
Debug: 15 4 command.c:166 script_debug(): command - rp2040.cpu cget -event gdb-flash-write-end
Debug: 16 4 command.c:166 script_debug(): command - rp2040.cpu configure -event gdb-flash-write-end reset halt
Debug: 17 4 command.c:166 script_debug(): command - rp2040.cpu cget -event gdb-attach
Debug: 18 4 command.c:166 script_debug(): command - rp2040.cpu configure -event gdb-attach halt 1000
Debug: 19 4 target.c:1662 handle_target_init_command(): Initializing targets...
Debug: 20 4 semihosting_common.c:130 semihosting_common_init():
Debug: 21 5 cmsis_dap_usb_bulk.c:182 cmsis_dap_usb_open(): enumerating interfaces of 0x8086:0x0000
Debug: 22 7 cmsis_dap_usb_bulk.c:182 cmsis_dap_usb_open(): enumerating interfaces of 0x4b50:0xef9c
Debug: 23 8 cmsis_dap_usb_bulk.c:182 cmsis_dap_usb_open(): enumerating interfaces of 0x8087:0x0a2b
Debug: 24 23 cmsis_dap_usb_bulk.c:182 cmsis_dap_usb_open(): enumerating interfaces of 0x04f2:0xb5ab
Debug: 25 37 cmsis_dap_usb_bulk.c:182 cmsis_dap_usb_open(): enumerating interfaces of 0x0bda:0x0316
Debug: 26 41 cmsis_dap_usb_bulk.c:162 cmsis_dap_usb_open(): found product string of 0x1209:0x2488 'CMSIS-DAP'
Debug: 27 41 cmsis_dap_usb_bulk.c:182 cmsis_dap_usb_open(): enumerating interfaces of 0x1209:0x2488
Debug: 28 41 cmsis_dap_usb_bulk.c:249 cmsis_dap_usb_open(): skipping interface 0, endpoint[0] is not bulk out
Error: 29 68 cmsis_dap_usb_hid.c:209 cmsis_dap_hid_write(): error writing data: (null)
Error: 30 68 cmsis_dap.c:461 cmsis_dap_cmd_dap_info(): CMSIS-DAP command CMD_INFO failed.
Debug: 31 68 command.c:556 run_command(): Command 'init' failed with error code -107
User : 32 68 command.c:619 command_run_line():
Debug: 33 68 target.c:2205 target_free_all_working_areas_restore(): freeing all working areas
For now, I have no question or request, just documenting this and gathering clues.
In case that is a bothering, feel free to close this and I will document it somewhere else.
$ cd ~/pico/pico-examples/build/picoboard/blinky
$ gdb-multiarch picoboard-blinky.elf
In the above gdb-multiarch command, the elf file name should contain "_", not "-".
In addition, the application must be built before the openocd is built and gdb is started.
Thanks for the good work.
Hi,
Recently, I have observed some strange behaviour and I suspect that the pico-debug interferes with some SRAM areas during debugging.
Here are some facts:
The template.uf2 is a "no-flash" image
It works well using the normal drag&drop method
When I debug it with pico-debug (both pico-debug-gimmecache.uf2 and pico-debug-maxram.uf2 have been tried), the image crash into hardfault.
around memory address 0x2000AC7C, the content is changed. And this area is supposed to be ".text". The map file can verify this.
The project is compiled and debugged in MDK. I have created a tag for you to replicate this issue.
Since the image is smaller than 16KByte, you can use the Evaluation license of MDK to test it.
Here are the steps to replicate the issue in MDK:
NOTE: Please use the latest MDK (5.35 or later) to test it.
I need your help.
I really appreciate any help you can provide.
Cheers,
Gabriel
Does built release .uf2 work for the new pico W board?
Seems like it doesn't ?
Maybe I am setting up launch.json incorrectly ? Maybe I should install something ?
1-gdb-version
Could not start GDB process, does the program exist in filesystem?
Error: spawn arm-none-eabi-gdb ENOENT
Manually running after copying .uf2 release of pico-debug gives this:
openocd -f board/pico-debug.cfg
Open On-Chip Debugger 0.12.0-rc2+dev-00028-g9501b263e (2022-12-11-17:34)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Warn : rp2040-core0.cfg configuration file is deprecated and will be
removed in the next release. Use following parameters instead:
-c 'set USE_CORE 0' -f target/rp2040.cfg
cortex_m reset_config sysresetreq
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Error: unable to open CMSIS-DAP device 0x1209:0x2488
Error: unable to find a matching CMSIS-DAP device
Firstly thanks for all the good work here
Just wanted to add some extra notes for Mac users following your openocd build notes
If you get the error:-
configure: error: hidapi is required for the CMSIS-DAP Compliant Debugger
Then take the following steps:-
git clone https://github.com/signal11/hidapi.git
cd hidapi
./bootstrap
./configure --enable-static --disable-shared
make
export HIDAPI_LIBS="-L`pwd`/mac/.libs -lhidapi"
export PKG_CONFIG_PATH="`pwd`/pc"
Then change back to the openocd directory and configure as per your instructions.
The environment variables above will ensure that hidapi is found and linked.
After I copy uf2 into Pico,it just rebooted and runing previous program, dmesg shows no device has been plugged in after mass storage device disconnected, like this:
'''
sd 6:0:0:0: [sdb] Attached SCSI removable disk
[ 596.680640] usb 1-3: USB disconnect, device number 5
[ 615.822719] usb 1-3: new full-speed USB device number 6 using xhci_hcd
[ 615.972150] usb 1-3: New USB device found, idVendor=2e8a, idProduct=0003, bcdDevice= 1.00
[ 615.972163] usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 615.972169] usb 1-3: Product: RP2 Boot
[ 615.972173] usb 1-3: Manufacturer: Raspberry Pi
[ 615.972176] usb 1-3: SerialNumber: E0C912952D54
[ 615.976957] usb-storage 1-3:1.0: USB Mass Storage device detected
[ 615.977542] scsi host6: usb-storage 1-3:1.0
[ 616.991715] scsi 6:0:0:0: Direct-Access RPI RP2 2 PQ: 0 ANSI: 2
[ 616.992297] sd 6:0:0:0: Attached scsi generic sg2 type 0
[ 616.992998] sd 6:0:0:0: [sdb] 262144 512-byte logical blocks: (134 MB/128 MiB)
[ 616.993381] sd 6:0:0:0: [sdb] Write Protect is off
[ 616.993386] sd 6:0:0:0: [sdb] Mode Sense: 03 00 00 00
[ 616.993748] sd 6:0:0:0: [sdb] No Caching mode page found
[ 616.993755] sd 6:0:0:0: [sdb] Assuming drive cache: write through
'''
And, lsusb -t seems doesn't list any new device too.When I try run openocd, it output like this:
'''
Open On-Chip Debugger 0.11.0+dev-00635-g7c6d379cf (2022-04-10-16:45)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Error: Debug adapter doesn't support any transports?
/usr/local/bin/../share/openocd/scripts/target/rp2040-core0.cfg:3: Error:
in procedure 'script'
at file "embedded:startup.tcl", line 26
at file "/usr/local/bin/../share/openocd/scripts/target/rp2040-core0.cfg", line 3
'''
I use Apple Mac M1 with Parallel Desktop + Win11 for Arm. The cmsis-dap from pico-debug cannot be recognised correctly as shown below:
meanwhile, the RP1-PR2 can be recognised:
Pico-debug used to work in Parallel Desktop + Win10 for Arm but I don't know why it doesn't work in Win11.
By the way, other CMSIS-DAP devices can be recognised, so there must be some differences in implementation.
I know this configuration is very special, but it is the only way I can connect a debugger in Apple Mac M1.
Thank you in advance.
After dropping in the pico-debug-gimmecache.uf2, it reboots as cnsis-dap, but openocd can't find it:
C:\0work\rp2040\openocd_picoprobe>openocd -f cmsis-dap.cfg -c "transport select swd" -c "adapter speed 4000" -f target/rp2040-core0.cfg
Open On-Chip Debugger 0.10.0+dev-g14c0d0d-dirty (2021-01-27-15:43)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Error: The specified debug interface was not found (cmsis-dap)
The following debug adapters are available:
I can't find cmsis-dap in the Device Manager.
Zadig find it, not sure what is the proper driver (if any).
Could you please provide a bit more detailed (step by step) instruction how to use it in Segger Studio? Your demo program compiled in Studio, but not sure how to debug it (either with pico-debug or jlink).
regards,
Jozsef
Host is reTerminal (Raspberry Pi Compute Module 4 running 32-bit OS).
❯ pwd
/home/pi/Projects/pico/pico-examples/build/picoboard/blinky
❯ ls -al
total 1060
drwxr-xr-x 3 pi pi 4096 Jun 26 15:37 .
drwxr-xr-x 5 pi pi 4096 Jun 26 15:31 ..
drwxr-xr-x 3 pi pi 4096 Jun 26 15:31 CMakeFiles
-rw-r--r-- 1 pi pi 1008 Jun 26 15:31 cmake_install.cmake
-rw-r--r-- 1 pi pi 89295 Jun 26 15:31 Makefile
-rwxr-xr-x 1 pi pi 21312 Jun 26 15:32 picoboard_blinky.bin
-rw-r--r-- 1 pi pi 335999 Jun 26 15:32 picoboard_blinky.dis
-rwxr-xr-x 1 pi pi 257680 Jun 26 15:32 picoboard_blinky.elf
-rw-r--r-- 1 pi pi 245185 Jun 26 15:32 picoboard_blinky.elf.map
-rw-r--r-- 1 pi pi 60004 Jun 26 15:32 picoboard_blinky.hex
-rw-r--r-- 1 pi pi 43008 Jun 26 15:32 picoboard_blinky.uf2
-rw-r--r-- 1 pi pi 336 Jun 26 15:37 pico-debug.cfg
❯ openocd -f ./pico-debug.cfg
Open On-Chip Debugger 0.11.0-g228ede4-dirty (2022-06-24-18:50)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
Info : Hardware thread awareness created
Info : RP2040 Flash Bank Command
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Error: unable to find a matching CMSIS-DAP device
lsusb
shows
❯ lsusb
Bus 001 Device 004: ID 1209:2488 Generic Peter Lawrence CMSIS-DAP Dapper Miser
Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
I copied pico-debug.cfg
from the openocd
source tree:
❯ cat pico-debug.cfg
# SPDX-License-Identifier: GPL-2.0-or-later
# pico-debug is a virtual CMSIS-DAP debug adapter
# it runs on the very same RP2040 target being debugged without additional hardware
# https://github.com/majbthrd/pico-debug
source [find interface/cmsis-dap.cfg]
adapter speed 4000
set CHIPNAME rp2040
source [find target/rp2040-core0.cfg]
What am I missing?
Brilliant project - unfortunately I seem to be running into an issue.
I've downloaded the precompiled pico-debug-gimmecache.uf2 and loaded it onto my raspberry pi pico.
I've also compiled the accompanying openocd. I can connect gdb to it, load software, inspect registers, etc. However, when I try to continue
in gdb, stuff breaks down, and i get a long sequence of CMSIS-DAP command XXX failed
and hid_error is not implemented yet
.
gdb output looks like this
(gdb) tar ext localhost:3333
Remote debugging using localhost:3333
0x2003bd12 in ?? ()
(gdb) load
Loading section .boot2, size 0x100 lma 0x10000000
Loading section .text, size 0x5830 lma 0x10000100
Loading section .rodata, size 0x394 lma 0x10005930
Loading section .binary_info, size 0x24 lma 0x10005cc4
Loading section .data, size 0x2e0 lma 0x10005ce8
Start address 0x100001e8, load size 24520
Transfer rate: 8 KB/sec, 4086 bytes/write.
(gdb) info registers
r0 0x2 2
r1 0x1 1
r2 0x2003c0a9 537116841
r3 0xd0000000 -805306368
r4 0xffffffff -1
r5 0xffffffff -1
r6 0xb007c0d3 -1341669165
r7 0x4005801c 1074102300
r8 0xffffffff -1
r9 0xffffffff -1
r10 0xffffffff -1
r11 0xffffffff -1
r12 0x40008000 1073774592
sp 0x20040000 0x20040000
lr 0x2003bd13 537115923
pc 0x100001e8 0x100001e8 <_entry_point>
xPSR 0x21000000 553648128
msp 0x20041f00 0x20041f00
psp 0xfffffffc 0xfffffffc
primask 0x0 0
basepri 0x0 0
faultmask 0x0 0
control 0x0 0
(gdb) monitor reset init
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ee msp: 0x20041f00
(gdb) continue
Continuing.
error writing data: hid_error is not implemented yet
Program stopped.
0x000000ee in ?? ()
openocd output looks like this (I've put in a few newlines right before doing continue
in GDB) :
Info : rp2040.core0: hardware has 4 breakpoints, 2 watchpoints
Info : starting gdb server for rp2040.core0 on 3333
Info : Listening on port 3333 for gdb connections
Info : accepting 'gdb' connection on tcp/3333
Warn : target was in unknown state when halt was requested
Info : RP2040 B0 Flash Probe: 2097152 bytes @10000000, in 512 sectors
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ee msp: 0x20041f00
Info : Writing 24520 bytes starting at 0x0
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (1781 ms). Workaround: increase "set remotetimeout" in GDB
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ee msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ee msp: 0x20041f00
Error: error writing data: hid_error is not implemented yet
Warn : target rp2040.core0 is not halted (gdb fileio)
Polling target rp2040.core0 failed, trying to reexamine
Error: error writing data: hid_error is not implemented yet
Error: CMSIS-DAP command CMD_DISCONNECT failed.
Error: error writing data: hid_error is not implemented yet
Error: CMSIS-DAP command CMD_CONNECT failed.
Error: error writing data: hid_error is not implemented yet
Error: CMSIS-DAP command CMD_DISCONNECT failed.
Error: error writing data: hid_error is not implemented yet
Error: CMSIS-DAP command CMD_CONNECT failed.
Error: error writing data: hid_error is not implemented yet
Error: CMSIS-DAP command CMD_SWD_Configure failed.
Error: error writing data: hid_error is not implemented yet
Error: error writing data: hid_error is not implemented yet
Error: CMSIS-DAP command CMD_DISCONNECT failed.
Error: error writing data: hid_error is not implemented yet
Error: CMSIS-DAP command CMD_CONNECT failed.
Error: error writing data: hid_error is not implemented yet
Error: CMSIS-DAP command CMD_SWD_Configure failed.
Error: error writing data: hid_error is not implemented yet
Error: error writing data: hid_error is not implemented yet
Error: CMSIS-DAP command CMD_DISCONNECT failed.
Error: error writing data: hid_error is not implemented yet
Error: CMSIS-DAP command CMD_CONNECT failed.
(The output is way longer than this, but nothing new.)
Any thoughts on what could be causing this, or suggestions on troubleshooting?
P.S. I'm running on MacOS, and I could compile without the fixes suggested in #5 , but I went back and applied them anyway for good measure. It made no difference to this issue.
Hello majbthrd,
I like your work very much and used it for effective debugging of my projects :)
I'm always looking for ways to simplify things, and working from within an IDE, it would be good to use only one SDK. When I compile my projects with the official SDK, I can not debug them with GDB: It loads, and when I step into a program, it terminated.
Can you explain what changes you made to the official SDK?
This may not be supported at this point however I thought it would be useful to ask. I also apologise as this may not be actually a pico-debug "issue" but related to the use of usbipd-win but I would appreciate any thoughts or pointers as this configuration could be useful to others.
I am trying to run pico-debug using an Ubuntu 20.04LTS distribution in the latest WSL2 on Windows 10. To make the physical USB ports available from the Linux WSL2 system I am using the usbipd-win package (https://github.com/dorssel/usbipd-win). I have a udev rules file to allow access to the port from a non root user.
I have downloaded, compiled and installed the openocd package as described in your instructions at https://github.com/majbthrd/pico-debug/blob/master/howto/openocd.md
Once the usbipd Windows service is running I can successfully attach the relevant USB port to the WSL2 Ubuntu instance and lsusb gives me the following response:
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 006: ID 1209:2488 Generic Peter Lawrence CMSIS-DAP Dapper Miser
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
lsusb -v
gives the following for the port in question:
Bus 001 Device 006: ID 1209:2488 Generic Peter Lawrence CMSIS-DAP Dapper Miser
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x1209 Generic
idProduct 0x2488 Peter Lawrence CMSIS-DAP Dapper Miser
bcdDevice 10.03
iManufacturer 2 pico-debug
iProduct 1 CMSIS-DAP
iSerial 3 E66038B713297738
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x0029
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.11
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 32
Report Descriptors:
** UNAVAILABLE **
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1
can't get device qualifier: Resource temporarily unavailable
can't get debug descriptor: Resource temporarily unavailable
Device Status: 0x0000
(Bus Powered)
However, when running "openocd -f board/pico-debug.cfg
" I get the following:
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Error: unable to find a matching CMSIS-DAP device
With the -d option there is additional output relating to the port :
Debug: 61 8 cmsis_dap_usb_bulk.c:161 cmsis_dap_usb_open(): found product string of 0x1209:0x2488 'CMSIS-DAP'
Debug: 62 8 cmsis_dap_usb_bulk.c:181 cmsis_dap_usb_open(): enumerating interfaces of 0x1209:0x2488
Debug: 63 8 cmsis_dap_usb_bulk.c:248 cmsis_dap_usb_open(): skipping interface 0, endpoint[0] is not bulk out
I am not sure whether pico-debug is accessed as an HID or Bulk device but if I run the command:
openocd -f board/pico-debug.cfg -c "cmsis_dap_backend hid" -d
I just get the response:
Error: 61 3 cmsis_dap.c:305 cmsis_dap_open(): unable to find a matching CMSIS-DAP device
Adding LOG_DEBUG() commands into the openocd source and re-building and re-running I can see that its attempts to enumerate an HID device fail in cmsis_dap_usb_hid.c
so it then tries to look for a bulk device in cmsis_dap_usb_bulk.c
whereupon it fails with the message about endpoint not being bulk out that I show above.
It may be that the usbipd-win implementation is not yet fully featured enough to allow what I am trying to do but as I have no background in USB it is very difficult to know so I would appreciate any thoughts or ideas where to look further.
I am unable to step through a simple blink program on my Raspberry Pi Pico using pico-debug (gimmecache).
Here are the steps I am taking;
openocd -f board/pico-debug.cfg
From there, openocd starts correctly (version 0.11.0) on port 3333arm-none-eabi-gdb blink.elf
tar ext :3333
in the gdb consoleload
, then break main
. Here I get a message with the following note : Note: automatically using hardware breakpoints for read-only addresses.
continue
As soon as I enter an s
command to step through the code, I get the following error message in the gdb console :
CMSIS-DAP command CMD_DISCONNECT failed.
error writing data: No such device
CMSIS-DAP command CMD_CONNECT failed.
error writing data: No such device
CMSIS-DAP command CMD_DISCONNECT failed.
error writing data: No such device
CMSIS-DAP command CMD_CONNECT failed.
error writing data: No such device
error writing data: No such device
I see the same messages in the openocd window,
Hi,
Given that the debugger 'owns' the USB port, how can I see the printf statements?
Hello,
Blackmagic probe for PC supports CMSIS DAP probe. I tried both uf2s download from Releases. My recognition for CMSIS Dap stumbles on the missing iManufacturer and iSerial entries. It is a good habit to provide these.
I followed the exact steps detailed under howto folder and after copying pico-debug-gimmecache.uf2, Feather RP2040 does not boot as an CMSIS adapter. It seems the uf2 need to be built with Feather RP2040 with different config.
Hi,
Thank you for this fantastic job!
I have made a Pico template for MDK, and it works well!
https://github.com/GorgonMeducer/Pico_Template
I have some questions:
Thank you in advance.
Cheers,
Gabriel
I expect that pico-debug will need certain resources on the chip to function (the readme lists PLL_USB
, for instance), but I was surprised to discover that it seems to change the clock config in ways that affects core 0's boot state.
Using an image that doesn't make any changes to clock configuration,
reset
through openocd launches into the same firmware with an apparent clock frequency of... much higher than that.I assume the debugger switches CLK_SYS_CTRL
to generate CLK_SYS
from PLL_USB
. This would be a good thing to document since it changes the startup behavior of programs.
I'm guessing that most folks aren't noticing this because they're running SDK programs that immediately switch CLK_SYS
to PLL_SYS
?
yibing@copper:~/project/rpi_pico/test_led/build$ gdb-multiarch test_led.elf
GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Copyright (C) 2018 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 "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
http://www.gnu.org/software/gdb/documentation/.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from test_led.elf...done.
(gdb) target remote localhost:3333
Remote debugging using localhost:3333
time_reached (t=...) at /home/yibing/project/rpi_pico/sdk/src/rp2_common/hardware_timer/include/hardware/timer.h:116
116 uint32_t hi_target = (uint32_t)(target >> 32u);
(gdb) load
Loading section .text, size 0x3fd4 lma 0x20000000
Loading section .rodata, size 0xeb8 lma 0x20003fd8
Loading section .binary_info, size 0x14 lma 0x20004e90
Loading section .data, size 0xb8 lma 0x20004eb0
Start address 0x20000000, load size 20312
Transfer rate: 23 KB/sec, 4062 bytes/write.
(gdb) monitor reset init
[rp2040.cpu] halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00
(gdb) b main
Breakpoint 1 at 0x200002b0: file /home/yibing/project/rpi_pico/test_led/test_led.c, line 9.
(gdb) cont
Continuing.
^C
Program received signal SIGINT, Interrupt.
0x100011c8 in ?? ()
(gdb) load
Loading section .text, size 0x3fd4 lma 0x20000000
Loading section .rodata, size 0xeb8 lma 0x20003fd8
Loading section .binary_info, size 0x14 lma 0x20004e90
Loading section .data, size 0xb8 lma 0x20004eb0
Start address 0x20000000, load size 20312
Transfer rate: 23 KB/sec, 4062 bytes/write.
(gdb) b main
Note: breakpoint 1 also set at pc 0x200002b0.
Breakpoint 2 at 0x200002b0: file /home/yibing/project/rpi_pico/test_led/test_led.c, line 9.
(gdb) cont
Continuing.
You see that the first "cont/continue" command, gdb doesn't stop at main(). It does after I loaded it the 2nd time and set the BP again.
BTW, my C code is set to run from RAM with "pico_set_binary_type(test_led no_flash)" in CMakeLists.txt.
Thanks
Mark
First off, this is really cool!
I gave it a go yesterday, but I could not quite get it to work. The UF2 file works as expected, but I could not figure out which OpenOCD branch / which initialization settings to use. I've tried the rp2040_cmsisdap
and the rp2040_singlecore
branches.
The rp2040_cmsisdap
branch was launched with the following command:
./src/openocd -s tcl -f interface/cmsis-dap.cfg -c "cmsis_dap_vid_pid 0x1209 0x2488" -c "transport select swd" -c "adapter speed 4000" -f target/rp2040.cfg
This gave me the following output:
Open On-Chip Debugger 0.10.0+dev-g7e5ea1861-dirty (2021-02-06-12:25)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
swd
adapter speed: 4000 kHz
Info : Hardware thread awareness created
Info : Hardware thread awareness created
Info : RP2040 Flash Bank Command
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : CMSIS-DAP: SWD Supported
Info : CMSIS-DAP: FW Version = 2.0.0
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 0 SWDIO/TMS = 0 TDI = 0 TDO = 0 nTRST = 0 nRESET = 0
Info : CMSIS-DAP: Interface ready
Info : clock speed 4000 kHz
Error: Sequence 4 not supported
Info : DAP init failed
Error: Sequence 3 not supported
Error: Sequence 4 not supported
For the rp2040_singlecore
branch (this was before 5e8624d):
./src/openocd -s tcl -f interface/cmsis-dap.cfg -c "cmsis_dap_vid_pid 0x1209 0x2488" -c "transport select swd" -c "adapter speed 4000" -f target/rp2040-core1.cfg
The OpenOCD server started without problem, but when I issue a load
command from GDB, the OpenOCD server hangs:
Open On-Chip Debugger 0.10.0+dev-g937c0aa1d-dirty (2021-02-06-12:45)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
swd
adapter speed: 4000 kHz
Info : Hardware thread awareness created
Info : RP2040 Flash Bank Command
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : CMSIS-DAP: SWD Supported
Info : CMSIS-DAP: FW Version = 2.0.0
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 0 SWDIO/TMS = 0 TDI = 0 TDO = 0 nTRST = 0 nRESET = 0
Info : CMSIS-DAP: Interface ready
Info : clock speed 4000 kHz
Error: Sequence 4 not supported
Info : SWD DPIDR 0x0bc12477
Info : SWD DLPIDR 0x10000001
Info : rp2040.core1: hardware has 4 breakpoints, 2 watchpoints
Info : starting gdb server for rp2040.core1 on 3333
Info : Listening on port 3333 for gdb connections
Info : accepting 'gdb' connection on tcp/3333
Warn : target was in unknown state when halt was requested
Info : RP2040 B0 Flash Probe: 2097152 bytes @10000000, in 512 sectors
Warn : target not halted
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ee msp: 0x20041f00
Info : Writing 24500 bytes starting at 0x0
Error: error writing data: hid_error is not implemented yet
Error: CMSIS-DAP command CMD_DISCONNECT failed.
Error: error writing data: hid_error is not implemented yet
Error: CMSIS-DAP command CMD_CONNECT failed.
Error: error writing data: hid_error is not implemented yet
Error: CMSIS-DAP command CMD_DISCONNECT failed.
Error: error writing data: hid_error is not implemented yet
Error: CMSIS-DAP command CMD_CONNECT failed.
Error: error writing data: hid_error is not implemented yet
^CError: error writing data: hid_error is not implemented yet
Error: CMSIS-DAP command CMD_DISCONNECT failed.
Error: error writing data: hid_error is not implemented yet
Error: CMSIS-DAP command CMD_CONNECT failed.
/bin/bash: line 1: 7445 Killed: 9 ./src/openocd -s tcl -f interface/cmsis-dap.cfg -c "cmsis_dap_vid_pid 0x1209 0x2488" -c "transport select swd" -c "adapter speed 4000" -f target/rp2040-core1.cfg
Could you add some basic usage instructions to the readme? Thanks!
Hi,I wonder if there is some way to use uart in this virtual debug pod, so we can use the "printf()" function to print log in a serial monitor.
Not having a serial number string makes it difficult to identify uniquely and support multiple connected probes.
A short manufacturer string would be nice, too.
I know they take up memory, but it's useful.
Hiya! Trying to get a basic blink working alongside pico-debug. I'm on Windows 11, and am running into this
openocd -d2 -s C:\Users\aria\.platformio\packages\tool-openocd-rp2040-earlephilhower/share/openocd/scripts -f interface/cmsis-dap.cfg -f target/rp2040.cfg -c "adapter speed 1000" -c "program {.pio\build\pico\firmware.elf} verify reset; shutdown;"
Open On-Chip Debugger 0.11.0-g610f137 (2022-02-11-13:57)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
debug_level: 2
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
Info : Hardware thread awareness created
Info : Hardware thread awareness created
Info : RP2040 Flash Bank Command
adapter speed: 1000 kHz
Info : CMSIS-DAP: SWD Supported
Info : CMSIS-DAP: FW Version = 2.0.0
Info : CMSIS-DAP: Serial# = E661640843675228
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 0 SWDIO/TMS = 0 TDI = 0 TDO = 0 nTRST = 0 nRESET = 0
Info : CMSIS-DAP: Interface ready
Info : clock speed 1000 kHz
Info : SWD DPIDR 0x0bc12477
Info : SWD DLPIDR 0x00000001
Info : DAP init failed
in procedure 'program'
** OpenOCD init failed **
shutdown command invoked
*** [upload] Error 1
For reference, here is my platformio.ini and main.cpp
#include <Arduino.h>
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
}
[env:pico]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
board = pico
framework = arduino
board_build.core = earlephilhower
debug_tool = cmsis-dap
upload_protocol = cmsis-dap
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.