1

I want to use an FT2232H Mini Board as Raspberry Pi JTAG (based on https://github.com/dwelch67/raspberrypi/tree/master/armjtag). I use a raspberry pi B version 1 (this one with the 26-pin connector and the 8-pin connector in front of it). So the whole JTAG should be connected with the 26-pin connector. I´ve installed openocd on my Ubunu host with version 0.9 (via apt):

daniel@DevVM:~/Schreibtisch/raspberrypi/armjtag$ openocd -v
Open On-Chip Debugger 0.9.0 (2018-01-24-01:05)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html

My wiring is the same as in the description (without the UART):

JTAG: (FT board left, Raspi right)
  TCK:   CN2-7   P1-22
  TDI:   CN2-10  P1-7
  TDO:   CN2-9   P1-18
  TMS:   CN2-12  P1-13
UART:
  TXRX:  CN3-26  P1-10
  RXTX:  CN3-25  P1-8
Ground:
  GND:   CN2-2   P1-6
Raspi to Raspi:
  TRST:  P1-1    P1-15
FTDI board to FTDI board:
  VCCIO: CN2-1   CN2-11
  VCC:   CN3-1   CN3-3

I have also copied the compiled file armjtag.bin as kernel7.img to the SD card, including bootcode.bin and start.elf. The green LED of my raspberry pi is blinking if I power up the device. lsusb list the FT2232H

daniel@DevVM:~/Schreibtisch/raspberrypi/armjtag$ lsusb
Bus 001 Device 006: ID 05e3:0745 Genesys Logic, Inc. Logilink CR0012
Bus 001 Device 016: ID 0403:6010 Future Technology Devices International, Ltd FT2232C Dual USB-UART/FIFO IC
Bus 001 Device 002: ID 0403:6010 Future Technology Devices International, Ltd FT2232C Dual USB-UART/FIFO IC
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 80ee:0021 VirtualBox USB Tablet
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

and dmesg also list it

[11216.585697] usb 1-3: new high-speed USB device number 17 using ehci-pci
[11216.880594] usb 1-3: New USB device found, idVendor=0403, idProduct=6010
[11216.880599] usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[11216.880603] usb 1-3: Product: Debugger
[11216.880606] usb 1-3: Manufacturer: FTDI
[11216.880610] usb 1-3: SerialNumber: FT3IYNGQ
[11216.890524] ftdi_sio 1-3:1.0: FTDI USB Serial Device converter detected
[11216.890553] usb 1-3: Detected FT2232H
[11216.898263] usb 1-3: FTDI USB Serial Device converter now attached to ttyUSB2
[11216.905603] ftdi_sio 1-3:1.1: FTDI USB Serial Device converter detected
[11216.906055] usb 1-3: Detected FT2232H
[11216.914128] usb 1-3: FTDI USB Serial Device converter now attached to ttyUSB3

But I got this error if I run openocd:

daniel@DevVM:~/Schreibtisch/raspberrypi/armjtag$ openocd -f ft2232h.cfg -f raspi.cfg
Open On-Chip Debugger 0.9.0 (2018-01-24-01:05)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
adapter speed: 1000 kHz
none separate
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
raspi.arm
Info : clock speed 1000 kHz
Error: JTAG scan chain interrogation failed: all ones
Error: Check JTAG interface, timings, target power, etc.
Error: Trying to use configured scan chain anyway...
Error: raspi.arm: IR capture error; saw 0x1f not 0x01
Warn : Bypassing JTAG setup events due to errors
Error: 'arm11 target' JTAG error SCREG OUT 0x1f
Error: unexpected ARM11 ID code

My ft2232.cfg looks like this:

# FTDI FT2232H Mini Module
#

interface ftdi
ftdi_device_desc "Debugger"
ftdi_vid_pid 0x0403 0x6010

And my raspi.cfg like this

# Broadcom 2835 on Raspberry Pi

telnet_port 4444
#gdb_port 0
#tcl_port 0

#jtag_khz 1000
adapter_khz 1000

#jtag_nsrst_delay 400
#jtag_ntrst_delay 400

if { [info exists CHIPNAME] } {
   set  _CHIPNAME $CHIPNAME
} else {
   set  _CHIPNAME raspi
}

reset_config none

if { [info exists CPU_TAPID ] } {
   set _CPU_TAPID $CPU_TAPID
} else {
   set _CPU_TAPID 0x07b7617F
}
jtag newtap $_CHIPNAME arm -irlen 5 -expected-id $_CPU_TAPID

set _TARGETNAME $_CHIPNAME.arm
target create $_TARGETNAME arm11 -chain-position $_TARGETNAME

And my armjtag.c to enable the JTAG functions for the I/O:

//-------------------------------------------------------------------------
//-------------------------------------------------------------------------

extern void PUT32 ( unsigned int, unsigned int );
extern unsigned int GET32 ( unsigned int );
extern void dummy ( unsigned int );

#define ARM_TIMER_LOD 0x2000B400
#define ARM_TIMER_VAL 0x2000B404
#define ARM_TIMER_CTL 0x2000B408
#define ARM_TIMER_DIV 0x2000B41C
#define ARM_TIMER_CNT 0x2000B420

#define SYSTIMERCLO 0x20003004
#define GPFSEL0     0x20200000
#define GPFSEL1     0x20200004
#define GPFSEL2     0x20200008
#define GPSET0      0x2020001C
#define GPCLR0      0x20200028
#define GPPUD       0x20200094
#define GPPUDCLK0   0x20200098

#define TIMEOUT 1000000


//-------------------------------------------------------------------------
int notmain ( void )
{
    unsigned int ra;
    unsigned int rb;

    //for led

    ra=GET32(GPFSEL1);
    ra&=~(7<<18); //gpio16  OK LED
    ra|=1<<18; //gpio16 output
    PUT32(GPFSEL1,ra);

    //for jtag

    //alt4 = 0b011 3
    //alt5 = 0b010 2


    PUT32(GPPUD,0);
    for(ra=0;ra<150;ra++) dummy(ra);
    PUT32(GPPUDCLK0,(1<<4)|(1<<22)|(1<<24)|(1<<25)|(1<<27));
    for(ra=0;ra<150;ra++) dummy(ra);
    PUT32(GPPUDCLK0,0);

    ra=GET32(GPFSEL0);
    ra&=~(7<<12); //gpio4
    ra|=2<<12; //gpio4 alt5 ARM_TDI
    PUT32(GPFSEL0,ra);

    ra=GET32(GPFSEL2);
    ra&=~(7<<6); //gpio22
    ra|=3<<6; //alt4 ARM_TRST
    ra&=~(7<<12); //gpio24
    ra|=3<<12; //alt4 ARM_TDO
    ra&=~(7<<15); //gpio25
    ra|=3<<15; //alt4 ARM_TCK
    ra&=~(7<<21); //gpio27
    ra|=3<<21; //alt4 ARM_TMS
    PUT32(GPFSEL2,ra);

//ARM_TRST      22 GPIO_GEN3 P1-15 IN  (22 ALT4)
//ARM_TDO     5/24 GPIO_GEN5 P1-18 OUT (24 ALT4)
//ARM_TCK    13/25 GPIO_GEN6 P1-22 OUT (25 ALT4)
//ARM_TDI     4/26 GPIO_GCLK P1-7   IN ( 4 ALT5)
//ARM_TMS    12/27 CAM_GPIO  S5-11 OUT (27 ALT4)

    PUT32(ARM_TIMER_CTL,0x00F90000);
    PUT32(ARM_TIMER_CTL,0x00F90200);

    rb=GET32(ARM_TIMER_CNT);
    while(1)
    {
        PUT32(GPSET0,1<<16);
        while(1)
        {
            ra=GET32(ARM_TIMER_CNT);
            if((ra-rb)>=TIMEOUT) break;
        }
        rb+=TIMEOUT;
        PUT32(GPCLR0,1<<16);
        while(1)
        {
            ra=GET32(ARM_TIMER_CNT);
            if((ra-rb)>=TIMEOUT) break;
        }
        rb+=TIMEOUT;
    }
    return(0);
}
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------


//-------------------------------------------------------------------------
//
// Copyright (c) 2012 David Welch dwelch@dwelch.com
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-------------------------------------------------------------------------

I´ve also checked the connections three-four times. Everything is okay.

So what is the problem. Does anybody has an idea?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.