Open ruswerner opened 7 months ago
Using the jtag wire harness does work with some targets - it's worth a try as it might 'just work'. It was removed because it's not ideal and doesn't work with all targets.
The ideal method to connect to swd targets is to use an adapter from the cortex header to whatever pin configuration your target uses.
There are off-the-shelf breakout boards available, or you could slice up a cortex-to-cortex cable, or - if you have a bitmagic, the 14-pin harness should fit, centered on the 10-pin header, to break out the lines you need
Thanks. I'll give it a try and create a PR if it's reliable on the Pico targets, since those are quite popular.
@securelyfitz I got it reliably flashing my binary using the openocd v0.12 from homebrew (macOS M1) and the JTAG header with the mode set to SWD. However, after openocd does it's thing, the Tigard UART serial devices disappear from the OS until I do a hard power cycle on the Tigard. I was using the Tigard UART interface to watch the serial output of the pico on UART0, but this gets shutdown at the USB device level when SWD is used. Is this expected? I couldn't find anything in the docs about it.
I was hoping to keep the UART interface running continuously, and then use SWD to flash binaries as I develop.
Thanks!
No, this isn't expected behavior. on linux, both uart devices show up, then openocd unloads the second one to put it in jtag mode, but it doesn't affect the first uart port at all. That leads me to guess is it's a driver issue. I am out of town and away, but can try to reproduce next week.
Thanks. I'm available to test things here if that's helpful. In the meantime (while your away), I'll gather all the info I can and post it here.
Mode Switch: SWD Voltage Switch: 1.8V Tigard UART <-> Pi Pico W UART0 Tigard JTAG <-> Pi Pico W SWD
Version: macOS 12.6 Chip: Apple M1 Max
Loaded KEXT's:
229 2 0xfffffe00074065c0 0x4000 0x4000 com.apple.driver.usb.cdc (5.0.0) 10AE7D44-AA1F-3587-86E2-694A05C05225 <210 128 56 5 4 3 1>
258 1 0xfffffe000740f500 0x4000 0x4000 com.apple.driver.usb.serial (6.0.0) 2B94B45C-E335-3FB1-AF3E-E37D4F16A2B4 <56 44 5 4 3 1>
259 0 0xfffffe0007402840 0x4000 0x4000 com.apple.driver.usb.cdc.acm (5.0.0) F039A005-E805-35EF-AED3-AF45E5C38006 <258 229 210 128 56 44 5 4 3 1>
260 0 0xfffffe000740a050 0x4000 0x4000 com.apple.driver.usb.cdc.ecm (5.0.0) 05B1D3AC-5AE5-3911-B076-1957951BD771 <229 210 56 55 45 5 4 3 1>
Tigard V1.1 Product ID: 0x6010 Vendor ID: 0x0403 Version: 7.00 Serial Number: TG110a52
/dev/tty.usbserial-TG110a520 /dev/tty.usbserial-TG110a521
OpenOCD: 0.12.0 (installed via brew install openocd
)
Interface config:
tigard-swd.cfg
adapter driver ftdi
transport select swd
ftdi vid_pid 0x0403 0x6010
ftdi channel 1
adapter speed 2000
ftdi layout_init 0x0028 0x002b
ftdi layout_signal SWD_EN -data 0
ftdi layout_signal nSRST -data 0x0020
Target config: https://github.com/raspberrypi/openocd/blob/rp2040-v0.12.0/tcl/target/rp2040.cfg
$ openocd -f tigard-swd.cfg -f ~/Development/openocd/tcl/target/rp2040.cfg -c "program build/src/main.elf verify reset"
Open On-Chip Debugger 0.12.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : FTDI SWD mode enabled
Warn : Transport "swd" was already selected
Info : Hardware thread awareness created
Info : Hardware thread awareness created
Info : clock speed 2000 kHz
Info : SWD DPIDR 0x0bc12477, DLPIDR 0x00000001
Info : SWD DPIDR 0x0bc12477, DLPIDR 0x10000001
Info : [rp2040.core0] Cortex-M0+ r0p1 processor detected
Info : [rp2040.core0] target has 4 breakpoints, 2 watchpoints
Info : [rp2040.core1] Cortex-M0+ r0p1 processor detected
Info : [rp2040.core1] target has 4 breakpoints, 2 watchpoints
Info : starting gdb server for rp2040.core0 on 3333
Info : Listening on port 3333 for gdb connections
[rp2040.core0] halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00
[rp2040.core1] halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00
** Programming Started **
Info : Found flash device 'win w25q16jv' (ID 0x001540ef)
Info : RP2040 B0 Flash Probe: 2097152 bytes @0x10000000, in 32 sectors
Info : Padding image section 1 at 0x1004f014 with 236 bytes (bank write end alignment)
Warn : Adding extra erase range, 0x1004f100 .. 0x1004ffff
** Programming Finished **
** Verify Started **
** Verified OK **
** Resetting Target **
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
^ at this point the tty devices disappear
Im recalling a recent openocd bug where it didn't properly handle primary/secondary channels of the ft2232h, but I can't find reference to it right now. One thing to try - start openocd with only the tigard cfg file and not the pi one. It should find a device, which means jtag is working, but do nothing else. If uart still works, then we're narrowing it down to more likely openocd than driver issues...
$ sudo openocd -f tigard-swd.cfg
Open On-Chip Debugger 0.12.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : FTDI SWD mode enabled
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 2000 kHz
Warn : gdb services need one or more targets defined
^ tty devices disappear at this point
@ruswerner - I recently opened #67. Did you find a solution to your issue? I am not able to get SWD work on Tigard with stm32f4x targets.
I am trying to use SWD on a Pi Pico W, which uses a standard 3-pin header. How can I connect Tigard to this SWD port? The docs used to say that SWD can be used on the JTAG header... is this not the case any more? I also want to debug Pico's that have the JST-PH 3-pin plug, which also isn't compatible with the CORTEX plug.
Any suggestions would be welcome. Thanks!
Commit reference: https://github.com/tigard-tools/tigard/commit/1275221d661072746b5fc847e02f1a3c2570293c