FTDI2232 JTAG

From HW wiki
Jump to navigation Jump to search

PiKRON's JTAG adapter

Author: Petr Porazil

File:Jt usb5.pdf

Adapter is compatible with standard 20 pin ARM JTAG connector as well as provides reduced 10 pin connector used on PiKRON's LPC17xx, LPC21xx, i.MX and other boards.

Permit access to usb as non-root user

in /etc/udev/rules.d add file 45-ftdi-libftdi.rules with following content:

ACTION!="add", SUBSYSTEM!="usb_device", GOTO="kcontrol_rules_end"
ATTR(idProduct)=="bcd9", ATTR(idVendor)=="0403", MODE:="666"
LABEL="kcontrol_rules_end"

Values are checked on Stellaris board and Ubuntu 10.10. Then reload rules

:/# initctl reload-configuration udev

and reconnect your hardware.

Older setup for LCP2148

#daemon configuration
telnet_port 4444
gdb_port 3333

# tell gdb our flash memory map
# and enable flash programming
#gdb_memory_map enable
#gdb_flash_program enable

#interface
interface ft2232
#ft2232_device_desc "JTAG"
ft2232_layout usbjtag
ft2232_vid_pid 0x0403 0x6010
#jtag_speed 3

# reset layout for ul_usb1 and jt_usb5 with ft2232
#               7     TRST      NTRST        IOL0
#               6     nHRST     RST          IOL2
#               4     RTCK      SRST         IOL1

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

source [find target/lpc2148.cfg]

init
reset halt

Setup for STM3210C-EVAL

telnet_port 4444
gdb_port 3333
#set CHIPNAME STM32F107VCT6
#set WORKAREASIZE 0x10000
interface ftdi
#ftdi_device_desc "Dual RS232"
ftdi_vid_pid 0x0403 0x6010

ftdi_layout_init 0x05f8 0x0cfb
ftdi_layout_signal nTRST -data 0x0010 -noe 0x0800
ftdi_layout_signal nSRST -ndata 0x0040 -noe 0x0400

#source [find interface/ftdi/xds100v2.cfg]
source [find board/stm3210c_eval.cfg]
reset_config trst_and_srst

init; 
#ftdi_set_signal PWR_RST 1; jtag arp_init

#stm32f1x.cpu arp_halt
#wait_halt
#stm32f1x.cpu curstate
openocd -c "source [find load-jt_usb5.cfg]" -c "program STM3210C-EVAL_FW_V1.1.0.hex"

Setup for TMS570LS3137

The OpenOCD setup for TMS570LS3137 board. Setup files for this target are part of rtems-tms570-utils repository.

telnet_port 4444
gdb_port 3333

adapter_khz 1500

source [find interface/ftdi/xds100v2.cfg]
source [find target/ti_tms570.cfg]

reset_config trst_only
init; ftdi_set_signal PWR_RST 1; jtag arp_init

reset halt
wait_halt
resume
sleep 1000
tms570.cpu arp_halt
wait_halt

# reset and prepare target by running setup code from Flash when GDB is connected
tms570.cpu configure -event gdb-attach {
        cortex_r4 dbginit
        reset halt
        wait_halt
        resume
        sleep 1000
        tms570.cpu arp_halt
        wait_halt
}

OpenOCD and GDB Quirks

GDB level initialization commands ("gdb-openocd.init" scripst)

#set debug remote 1
#set debug infrun 1
#set remotelogfile my_remote.log

set endian big
target remote localhost:3333

#set remote software-breakpoint-packet 0
#monitor gdb_breakpoint_override hard
load

#source gdb_initial_commands

Wrapper to start and connect together GDB and OpenOCD and run DDD gui. The script starts OpenOCD if needed. GDB is started then and "gdb-openocd.init" commands sequence ensures connection to OpenOCD, loading of application image to the target (file name is the first script parameter).

#!/bin/sh

SCRIP_DIR="$(dirname "$(readlink -f "$0")")"

nc -w 3 -z localhost 4444
if [ $? -ne 0 ]
then
  echo "Starting OpenOCD"
  # use next options for detailed operation log
  #   -d3 -l path_to_log/open_ocd.log
  openocd -f "$SCRIP_DIR/openocd.cfg" &
  OPENOCD_PID=$!
  nc -w 10 -z localhost 4444
  if [ $? -ne 0 ]
  then
    echo "OpenOCD start failed"
  fi
fi

ddd --debugger arm-rtems4.11-gdb -x "$SCRIP_DIR/gdb-openocd.init" "$1"

kill $OPENOCD_PID

JT_USB5 pin assignment

Data Bit Signal FT2232 JT_USB5 Type Description
Bit0 TCK/SK ADBUS0 TCK Out Clock Signal Output
Bit1 TDI/DO ADBUS1 TDI Out Serial Data Out
Bit2 TDO/DI ADBUS2 TDO In Serial Data In
Bit3 TMS/CS ADBUS3 TMS Out Select Signal Out
Bit4 GPIOL0 ADBUS4 nTRST In/Out General Purpose I/O
Bit5 GPIOL1 ADBUS5 RTCK In/Out General Purpose I/O
Bit6 GPIOL2 ADBUS6 RST In/Out General Purpose I/O
Bit7 GPIOL3 ADBUS7 DBGRQ In/Out General Purpose I/O
Bit8 GPIOH0 ACBUS0 DBACK In/Out General Purpose I/O
Bit9 GPIOH1 ACBUS1 AC1 In/Out General Purpose I/O
Bit10 GPIOH2 ACBUS2 RXLED In/Out General Purpose I/O
Bit11 GPIOH3 ACBUS3 TXLED In/Out General Purpose I/O