October 05, 2024, 08:50:33 PM

Faulty ARM-JTAG-SWD?

Started by Artem, March 23, 2024, 07:39:12 PM

Previous topic - Next topic

Artem

Hi all,
embedded development is relatively new topic for me and I learn everything myself, so I apologize for possibly stupid questions here.

So, I've bought a kit of ARM-USB-TINY-H, ARM-JTAG-SWD and ARM-JTAG-20-10 to work first of all with Atmel chips like SAMC21, SAMD21 etc. I tried to test the whole setup with Sammy-C21 development board (ATSAMC21G18) which I have at hand, and I failed to get openocd connected to it. Of course, I might have wrong Openocd config, but one thing makes me a bit confused. At my work we have Atmel-Ice debugger, and I used it many times with Sammy-C21. With Atmel-Ice, one can hook up the debugger to the target board, while both devices are powered up, and unless you run openocd, the Sammy-C21 works normally - the firmware is running, the LED is blinking. But when I connect the Olimex devices (ARM-USB-TINY-H -> (no cable in between, as mentioned in docs!!) ARM-JTAG-SWD adapter -> ARM-JTAG-20-10 adapter), the Sammy-C21 does not seem to work (LED does not blink, though 3.3V voltage is ok, doesn't seem to be shorted or something). I tested the pinout in 20-10 adapter, that is OK. I tried to connect only JTAG-SWD adapter plus 20-10 pin adapter to the SAmmy-C21, with the main TINY-H disconnected, and that already does not allow Sammy to run. So, my hypothesis is that JTAG-SWD adapter might be faulty. Or is that expected behavior, that it affects the target board even without openocd running? Is there any way to test the adapter before trying to get it replaced by reseller? Thanks.
Brinter Oy, Finland

LubOlimex

#1
The LED behavior can't be used as indication whether it works or not. It is probably just held in reset. Different devices have different reset strategies and states that has to be accounted for in the openocd cfg.

When using ARM-JTAG-SWD you need extra parameter, the sample connection should be like:

openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f interface/ftdi/olimex-arm-jtag-swd.cfg -f target/at91samdXX.cfg

Are you using any GUI software on top of OpenOCD or just OpenOCD? Some environments might work exclusively with some hardware.
Technical support and documentation manager at Olimex

LubOlimex

By the way do you power the target board off the debugger?
Technical support and documentation manager at Olimex

Artem

Thank you for the replies. I use the following config:

source [find interface/ftdi/olimex-arm-usb-tiny-h.cfg]
source [find interface/ftdi/olimex-arm-jtag-swd.cfg]

# chip name
set CHIPNAME at91samc21g18

source [find target/at91samdXX.cfg]

which is then called as:

openocd -f samc21_olimex.cfg.

I've tried to run openocd without any GUI. The ARM-USB-TINY-H is seen in the list of devices (lsusb), but the openocd's output is just:

Info : FTDI SWD mode enabled
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 400 kHz
Error: Error connecting DP: cannot read IDR

The Sammy-C21 board is powered externally.

Regarding your reply for LED activity, just in case once again: the Sammy board IS normally working when Atmel-ICE (both powered and unpowered) is hooked up to it, but IS NOT working when Olimex is hooked up. In both cases, I do not run openocd, the debuggers are in a passive state, as far as I understand. With Olimex the problem is present also in the case when I connect only the JTAG-SWD adapter to the SAmmy board, i.e. the adapter is completely un-powered and passive in this moment, but somehow halts the CPU on Sammy board. So the question is: is that normal for Olimex adapter to halt the CPU in such circumstances (probably, due to the design), or can that indicate some hardware fault in the adapter?
Brinter Oy, Finland

LubOlimex

Yes, it is possible due to different design of reset circuit. Measure the state of the reset pin.
Technical support and documentation manager at Olimex

LubOlimex

Can you upload a picture with the hardware connections and cables that show the JTAG connection? Also maybe a diagram with the signals at your target board so we can track if maybe some hardware discrepancy is going on.

Also make sure to test with the basic line in your openocd:

openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f interface/ftdi/olimex-arm-jtag-swd.cfg -f target/at91samdXX.cfg
Technical support and documentation manager at Olimex

Artem

thanks, I'll try to that tomorrow by the evening
Brinter Oy, Finland

Artem

Hi!

Quote from: LubOlimex on March 25, 2024, 12:48:52 PMCan you upload a picture with the hardware connections and cables that show the JTAG connection? Also maybe a diagram with the signals at your target board so we can track if maybe some hardware discrepancy is going on.

Also make sure to test with the basic line in your openocd:

openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f interface/ftdi/olimex-arm-jtag-swd.cfg -f target/at91samdXX.cfg

1. Photo of the setup A

Pins state (measured on JTAG-20-10 adapter on 20-pin connectors, debugger and JTAG-SWD adapter connected)

(1) VTref: 0.83V (after attempt to connect to openocd: 0.42V)
(3) nTRST: 0
(5) TDI: 0
(7) TMS: 0
(9) TCK: 2.56V (after attempt to connect to openocd: 0V)
(11) RTCK: 0
(13) TDO: 0
(15) RESET: 3.28V
(17) DBGRQ: 0
(19) 5V-supply: 4.98V

(*) Another exposed Vcc on target board: 3.28V (doesn't change at any moment)

2. Photo os the setup B

Pins state (measured on JTAG-20-10 adapter on 20-pin connectors, JTAG-SWD adapter disconnected)

(1) VTref: 3.28V
(3) nTRST: 0
(5) TDI: 0
(7) TMS: 0
(9) TCK: 0
(11) RTCK: 0
(13) TDO: 0
(15) RESET: 3.28V
(17) DBGRQ: 0
(19) 5V-supply: 0V

(*) Another exposed Vcc on target board: 3.28V (doesn't change at any moment)

3. Running one-liner code for Olimex doesn't change anything:
openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f interface/ftdi/olimex-arm-jtag-swd.cfg -f target/at91samdXX.cfg Info : FTDI SWD mode enabled
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 400 kHz
Error: Error connecting DP: cannot read IDR

4. Connection via Atmel-Ice, for comparison:

openocd -f interface/cmsis-dap.cfg -f target/at91samdXX.cfgInfo : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : CMSIS-DAP: SWD supported
Info : CMSIS-DAP: JTAG supported
Info : CMSIS-DAP: FW Version = 1.0
Info : CMSIS-DAP: Serial# = J41800043599
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 400 kHz
Info : SWD DPIDR 0x0bc11477
Info : [at91samd.cpu] Cortex-M0+ r0p1 processor detected
Info : [at91samd.cpu] target has 4 breakpoints, 2 watchpoints
Info : starting gdb server for at91samd.cpu on 3333
Info : Listening on port 3333 for gdb connections
Info : [at91samd.cpu] external reset detected
Brinter Oy, Finland

LubOlimex

I feel like the small 10-pin connector is placed in reverse. Looking at the red marking of the cable it seems you got pin #1 to position #10. But I can't find pinout of JTAG connector of Sammy board.... It is not written in the info sheet...
Technical support and documentation manager at Olimex

Artem

thank you for reply. You were right! Here's output from simple ping:

Info : FTDI SWD mode enabled
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 400 kHz
Info : SWD DPIDR 0x0bc11477
Info : [at91samc21g18.cpu] Cortex-M0+ r0p1 processor detected
Info : [at91samc21g18.cpu] target has 4 breakpoints, 2 watchpoints
Info : starting gdb server for at91samc21g18.cpu on 3333
Info : Listening on port 3333 for gdb connections
Info : [at91samc21g18.cpu] external reset detected

I also managed to program our bootloader to the Sammy, so everything is fine  8)

However, I'm still curious regarding the pinout mismatch. Does Olimex suppose mirrored connector soldering compared to Atmel, or do I misunderstand something?

I soldered all our Sammy boards which we have at work according to the cable which we have for Atmel-Ice. Olimex cable from JTAG-SWD adapter also works fine for the Atmel-Ice and Sammy. We also use Tag-Connect cables for our custom boards with SAMD21, which works fine with Atmel-Ice but failed with Olimex (haven't tried to modify the cable yet, but I'm sure now that the problem is again the pinout).

Moreover, the schematic on page 7 in Sammy data sheet is:

1 VTG   2 SWDIO
3 GND   4 SWDCLK
5 GND   6 (SWO)
7 (Key) 8 NC
9 GND   10 nSRST

This matches (by pin numbering) the Atmel's and Olimex' pinout, if I understand correctly.
Brinter Oy, Finland

LubOlimex

Glad about the news.

I think Microchip's/Atmel's is reversed  :) : https://www.bigmessowires.com/2018/06/13/atmel-ice-wiring-horror/

There is schematic on page 7 but this is not the PCB. We know how it looks in the schematic but it can be the opposite on the PCB, depending on the footprint of the connector. What I mean with simple words is that on the same pinout you can place the notched plastic differently also it is possible to connect the cables in reverse.
Technical support and documentation manager at Olimex

Artem

Yes, that's true but I didn't know that ::)  Actually, I've found that the tag-connect cables which we have at work are also non-standard with respect to default SWD pinout, but are specific to Atmel-Ice. I cut off the key on the debugger-side connector and tested our custom boards with Olimex Tiny - everything works fine for SAMD21 as well. Thank you for your products and for support!
Brinter Oy, Finland