OpenOCD + ARM-USB-TINY: 'number of devices' error

Hi folks,

I’ve just recently received an Olimex USB JTAG TINY adapter, and I’m working to get it running with OpenOCD and an AT91RM9200 board of my own design. I’ve based my config file on others using the Olimex USB JTAG adapter and AT91RM9200 hardware, but have been getting an error (“Error: number of discovered devices in JTAG chain (20) doesn’t match configuration (1)”). After some quick googling, it looks like this error can happen when the JTAG speed isn’t set correctly (if it’s set too fast, I think). I’ve lowered the JTAG speed quite a bit, but still receive the same error. I’ve also tried the older OpenOCD that comes on the Olimex CD, as well as the most recent version I could find – both give the same error (‘number of discovered devices in JTAG chain (20) doesn’t match configuration’), although the newer version is much more verbose:

OpenOCD output:

jtag_speed: 20
Info:   JTAG device found: 0xf828003f (Manufacturer: 0x01f, Part: 0x8280, Version: 0xf)
Info:   JTAG device found: 0x00000003 (Manufacturer: 0x001, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Error:  number of discovered devices in JTAG chain (20) doesn't match configuration (1)
Error:  check the config file and ensure proper JTAG communication (connections, speed, ...)
Error:  trying to validate configured JTAG chain anyway...
Error:  unknown EmbeddedICE version (comms ctrl: 0x00000000)
Warning:no tcl port specified, using default port 6666
Info:   JTAG device found: 0xf828003f (Manufacturer: 0x01f, Part: 0x8280, Version: 0xf)
Info:   JTAG device found: 0x00000003 (Manufacturer: 0x001, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Info:   JTAG device found: 0x0000007f (Manufacturer: 0x03f, Part: 0x0000, Version: 0x0)
Error:  number of discovered devices in JTAG chain (20) doesn't match configuration (1)
Error:  check the config file and ensure proper JTAG communication (connections, speed, ...)
Error:  trying to validate configured JTAG chain anyway...
Error:  invalid mode value encountered
Error:  cpsr contains invalid mode value - communication failure
Runtime error, file "embedded:startup.tcl", line 242:
    expected return code but got 'TARGET: target0 - Not halted'
In procedure 'ocd_process_reset' called at file "?", line 1
Runtime error, file "openocd.cfg", line 31:
    
In procedure 'script' called at file "command.c", line 445

openocd.cfg

#daemon configuration 
telnet_port 4444 
gdb_port 3333 

#interface 
interface ft2232 
ft2232_device_desc "Olimex OpenOCD JTAG TINY A" 
ft2232_layout "olimex-jtag" 
ft2232_vid_pid 0x15BA 0x0004 
jtag_speed 20

#use combined on interfaces or targets that can't set TRST/SRST separately 
#reset_config trst_and_srst srst_pulls_trst 
reset_config trst_and_srst

#jtag scan chain 
#format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE) 
jtag_device 4 0x1 0xf 0xe 
jtag_ntrst_delay 500


#target arm7tdmi <reset mode> <chainpos> <endianness> <variant> 
target arm920t little 0 arm920t 

working_area 0 0x20000000 0x200000 nobackup 

#flash bank lpc2000 <base> <size> 0 0 <target#> <variant> 
#flash bank cfi 0x00000000 0x800000 4 1 0

init
reset halt

Any thoughts?

Thanks for your help

http://cogsci.mcmaster.ca/~peter/notes1/oled_jtag1.jpg

It seems to have been a cabling / noise issue, perhaps also in tandem with some jumper settings for the AT91’s JTAG/ICE port. I drastically reduced the cable length, both on the normal 0.1" pitch JTAG cable, as well as from my 0.1" to FFC adapter board’s FFC cable to the AT91 board itself. I used an FFC connector on the AT91 board to reduce the footprint of the JTAG connector, but it looks like this may have introduced the potential for a lot of noise, such that the cable lengths now have to be really, really short.

For anyone who may have the above problem in the future, here are a few things that may be of interest, in that it seems to work:

JTAG Pin 15 (NRST) left unconnected

JTAG_SEL (on the AT91) connected to ground

NRST and JTAG_NTRST – I normally have these connected (otherwise the AT91 may not boot), but I have them unconnected now.

I’m not sure whether any of the above changes were critical, but it definitly didn’t want to work when JTAG_SEL was high, for some reason (which should select normal JTAG operation, rather than ICE).

The symptoms of the problem that I noticed, other than this error: "Error: number of discovered devices in JTAG chain (20) doesn’t match configuration (1) ", is that OpenOCD tends to detect the ID code partially correctly: "Info: JTAG device found: 0xf828003f (Manufacturer: 0x01f, Part: 0x8280, Version: 0xf) ". In my case, the Part# and Version# would sometimes move around when I changed the cable length, etc., bu the Manufacterer # was always 0x01F (the correct value). When the noise issue was resolved, it locked onto the correct value, and didn’t (incorrectly) detect any more strange devices in the chain:

log output:

jtag_speed: 10
Warning:Interface already configured, ignoring
> init
> reset halt
Info:   JTAG device found: 0x05b0203f (Manufacturer: 0x01f, Part: 0x5b02, Version: 0x0)
Warning:no tcl port specified, using default port 6666
Warning:DBGACK set while target was in unknown state. Reset or initialize target.
target state: halted
target halted in ARM state due to breakpoint, current mode: Supervisor
cpsr: 0x200000d3 pc: 0x21f0e204
MMU: disabled, D-Cache: disabled, I-Cache: enabled
Info:   accepting 'telnet' connection from 0
Info:   JTAG device found: 0x05b0203f (Manufacturer: 0x01f, Part: 0x5b02, Version: 0x0)
Warning:srst pulls trst - can not reset into halted mode. Issuing halt after reset.
target state: halted
target halted in ARM state due to breakpoint, current mode: Supervisor
cpsr: 0x200000d3 pc: 0x21f0e31c
MMU: disabled, D-Cache: disabled, I-Cache: enabled
> step
target state: halted
target halted in ARM state due to single-step, current mode: Supervisor
cpsr: 0x200000d3 pc: 0x21f0e320
MMU: disabled, D-Cache: disabled, I-Cache: enabled
>step
target state: halted
target halted in ARM state due to single-step, current mode: Supervisor
cpsr: 0x200000d3 pc: 0x21f0e348
MMU: disabled, D-Cache: disabled, I-Cache: enabled

A successful reset, halt, and several program steps! :slight_smile:

Thanks to anyone who was thinking about what this could have been, as well! I hope my issues diagnoising a noise problem with potentially incorrect JTAG pin settings helps anyone else new to AT91’s diagnose similar issues. best of luck!