SonicWave
Posts: 22
Joined: Mon Mar 19, 2018 1:10 pm

Use a FT232H-Chip to debug Pi 1 B+ via JTag + OpenOCD config

Thu Mar 29, 2018 5:00 pm

Instead of ripping my SD-card apart I want to debug and upload programs comfortably via jtag without restarting my Pi by plugging power in and out.

I use this FT232H-Chip: https://www.ebay.com/itm/FT232H-High-Sp ... MCU-Module

I think I found out that AD0-AD3 are the JTag pins (Page 9: http://www.ftdichip.com/Support/Documen ... FT232H.pdf)

I installed openocd via
sudo apt-get install openocd
but now I am missing a config file. Did anyone go through this process and successfully debugged the Pi 1 via Jtag? Which config files are you using?

This is my code which should enable the alternate functions for Jtag use:

Code: Select all

    SET(GPFSEL0, 1 << GPIO4_GPFSEL_ALT5);
    SET(GPFSEL2, 
        (1 << GPIO22_GPFSEL_ALT4) |
        (1 << GPIO24_GPFSEL_ALT4) |
        (1 << GPIO25_GPFSEL_ALT4) |
        (1 << GPIO27_GPFSEL_ALT4));

dwelch67
Posts: 944
Joined: Sat May 26, 2012 5:32 pm

Re: Use a FT232H-Chip to debug Pi 1 B+ via JTag + OpenOCD config

Fri Mar 30, 2018 2:58 pm

Not the path you are asking about, I think some folks have made progress on jtag. But there is a reset pin/hole on the board which you can put a switch on. Just got my pi3b+ and I dont think the hole next to it is ground so going to super glue a switch down then use wires to hook that to reset and there is a cap nearby that one side is ground. But on the pi zero and pi3 not b+ the hole next to reset is ground you can take a through hole mini switch break two legs off to get them out of the way, twist the other to to fit them in the holes and solder them down. works great no need to unplug...

SonicWave
Posts: 22
Joined: Mon Mar 19, 2018 1:10 pm

Re: Use a FT232H-Chip to debug Pi 1 B+ via JTag + OpenOCD config

Fri Mar 30, 2018 4:43 pm

Thanks for your answer!

Even with a reset switch it is still tedious to unplug the SD-card each time I want to try out a new program. I don't think this would be a replacement for JTAG.
I think some folks have made progress on jtag
I actually thought that JTag is already working with OpenOCD + JTag Adapter on the pies?

I am using your code from github to set the GPIOs in JTag mode, I also think I wired everything correctly with my FT232H board (A0-A3), i double-triple checked everything.

I tried several things with OpenOCD.

1. I built it myself from the github sources and used this openocd.cfg config file:

Code: Select all

#
# FTDI UM232H as a JTAG interface
#
# http://www.ftdichip.com/Products/Modules/DevelopmentModules.htm#UM232H
#
# This should also work with a UM232H-B, but that has not been tested.
# Note that UM232H and UM232H-B are 3.3V only.
#

interface ftdi
#ftdi_device_desc "UM232H"
ftdi_vid_pid 0x0403 0x6014

ftdi_layout_init 0xfff8 0xfffb
ftdi_layout_signal nTRST -data 0x0100 -oe 0x0100
ftdi_layout_signal nSRST -data 0x0200 -oe 0x0200
transport select jtag
adapter_khz 15000
# UM232H        FT232H    JTAG
# Name  Pin     Name      Func
# AD0   J2-6    ADBUS0    TCK
# AD1   J2-7    ADBUS1    TDI
# AD2   J2-8    ADBUS2    TDO
# AD3   J2-9    ADBUS3    TMS
# AD4   J2-10   ADBUS4    (GPIOL0)
# AD5   J2-11   ADBUS5    (GPIOL1)
# AD6   J2-12   ADBUS6    (GPIOL2)
# AD7   J2-13   ADBUS7    (GPIOL3)
# AD0   J1-14   ACBUS0    /TRST
# AD1   J1-13   ACBUS1    /SRST
# AD2   J1-12   ACBUS2    (GPIOH2)
# AD3   J1-11   ACBUS3    (GPIOH3)
# AD4   J1-10   ACBUS4    (GPIOH4)
# AD5   J1-9    ACBUS5    (GPIOH5)
# AD6   J1-8    ACBUS6    (GPIOH6)
# AD7   J1-7    ACBUS7    (GPIOH7)
and this raspberry config file:

Code: Select all

# Broadcom 2835 on Raspberry Pi

telnet_port 4444
#gdb_port 0
#tcl_port 0

#jtag_khz 1000
adapter_khz 100

#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
with this result:
[email protected]:~/Desktop/openocd$ openocd -f openocd.cfg -f targets/rpitarget.cfg
Open On-Chip Debugger 0.10.0+dev-00364-g1756f393 (2018-03-29-21:20)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
adapter speed: 15000 kHz
adapter speed: 100 kHz
none separate
raspi.arm
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 100 kHz
Info : JTAG tap: raspi.arm tap/device found: 0x07b7617f (mfg: 0x0bf (Broadcom), part: 0x7b76, ver: 0x0)
Warn : Unexpected idcode after end of chain: 480 0x7fffffff
Warn : Unexpected idcode after end of chain: 512 0x00000000
Warn : Unexpected idcode after end of chain: 544 0x00000000
Warn : Unexpected idcode after end of chain: 576 0x00000000
Warn : Unexpected idcode after end of chain: 608 0x00000000
Warn : Unexpected idcode after end of chain: 640 0x00000000
Error: double-check your JTAG setup (interface, speed, ...)
Error: Trying to use configured scan chain anyway...
Error: raspi.arm: IR capture error; saw 0x00 not 0x01
Warn : Bypassing JTAG setup events due to errors
Error: 'arm11 target' JTAG error SCREG OUT 0x00
Error: unexpected ARM11 ID code
Info : Listening on port 3333 for gdb connections
So it is almost working (I think), but something is still wrong

Edit: Copied the wrong raspi cfg

dwelch67
Posts: 944
Joined: Sat May 26, 2012 5:32 pm

Re: Use a FT232H-Chip to debug Pi 1 B+ via JTag + OpenOCD config

Sun Apr 01, 2018 8:49 pm

I have a simple uart based bootloader, so I use the reset switch to start over, then the bootloader loads from the sd card. Download the next program/experiment through the bootloader. never have to pull the sd card out again.

Most everywhere else I use JTAG with an FTDI running JTAG, two wires to hook up the uart, five or so for the ftdi. The original pi required soldering, they moved the signal to a pin to make it easier. I keep meaning to make a board, I guess they are called hats now, with an ftdi that hooks up the uart and jtag, never did get around it.

SonicWave
Posts: 22
Joined: Mon Mar 19, 2018 1:10 pm

Re: Use a FT232H-Chip to debug Pi 1 B+ via JTag + OpenOCD config

Mon Apr 02, 2018 4:05 pm

The original pi required soldering
But what about the GPIOs 4, 22, 24, 25, 27 which can be used as JTAG by alternate functions (as described here: https://wiki.aalto.fi/download/attachme ... 322&api=v2)?

dwelch67
Posts: 944
Joined: Sat May 26, 2012 5:32 pm

Re: Use a FT232H-Chip to debug Pi 1 B+ via JTag + OpenOCD config

Wed Apr 04, 2018 3:39 am

Misread your question thought you were working the pi3 not the pi1.

At work I have to build my own openocd from sources, the apt-get one doesnt work. there is a bug in the new ftdi drivers where you can specify more in the .cfg file, you dont have to specify one of the interface boards compiled into openocd. but using that method you periodically get a data transfer failure. so you go into the openocd sources, and comment out the return on error and it tends to work. or you build for legacy, I go into turtleizer2 no reason, just because, and modify it as desired. either way you are going into the opeoncd source code and build from sources. Or at least for the stuff I use at work. I have a pin on the A port that I cant touch with openocd, and the existing legacy interface boards dont match thus going in and just modifying a line or two. really wish they had asked me before they did that we had plenty of other pins on the other ports that would have made life much easier.

My build instructions no longer work on our arm11 mpcore with the latest clone of the openocd repo. So I have gone back and stick with 0.9.0 when working with an ARM11 (cortex-m microcontrollers I can apt-get openocd or build from the newer versions and that stuff works just fine, stlink the cmsis one, jlink, etc)

Dont need to modify openocd for the pi (legacy driver) as the five jtag pins with MPSSE are defined by FTDI, the board specific stuff compiled into openocd have to do with the other pins, if you just jumper over the five you for the most part just need to match up the usb pid/vid.

Short answer, try version 0.9.0, see if that helps. Or older, from my readme it looks like I was running 0.5.0 at the time I wrote it.

I still these days l prefer to only hook up the uart rx and tx pins and not add the the other 7 required for jtag. (athough the arm11 we use at work I use jtag 99.9999999999999% of the time, sometimes I will use the uart to download something into our bootloader using xmodem, or tell others to do it that way to not have to get openocd built/running).

As for the first two boards they put out to the masses google around or go to wikipedia to see the pictures or pinouts, the P1 connector had a lot fewer pins originally, that TMS signal was only available on that S5 header. They moved it or swapped it on the next rev of the board, then later the B+ and A+ came out with more pins, but by then the arm jtag signals were all easy to get to on the P1 header. Fairly likely that I tried jtag on the B+ and A+ as more affordable FTDI boards became available and others became not available. Actually I now have some j-link knockoffs from ebay that cost about $10 each, which are not ftdi, but would work just fine too. When I started this as mentioned in the readme, the cheapest I could find without building one was 50-100 bucks where (other than the parallel port ones, macraigor, olimex, etc) you were looking at $2000+ boxes...

dwelch67
Posts: 944
Joined: Sat May 26, 2012 5:32 pm

Re: Use a FT232H-Chip to debug Pi 1 B+ via JTag + OpenOCD config

Wed Apr 04, 2018 3:40 am

wow I totally didnt read your question at all, i assumed you were talking pi3 and was trying to show a uart alternative. May have to buy some of these ft232h boards you found...

dwelch67
Posts: 944
Joined: Sat May 26, 2012 5:32 pm

Re: Use a FT232H-Chip to debug Pi 1 B+ via JTag + OpenOCD config

Wed Apr 04, 2018 3:57 am

Ordered the adafruit breakout, prefer mini/micro b to a male usb A connector...Should be here in a couple of days...

SonicWave
Posts: 22
Joined: Mon Mar 19, 2018 1:10 pm

Re: Use a FT232H-Chip to debug Pi 1 B+ via JTag + OpenOCD config

Fri Apr 06, 2018 6:56 pm

At work I have to build my own openocd from sources, the apt-get one doesnt work.
I compiled openOCD myself and it is still not working. There is a raspberry-native.cfg included (at openocd/scripts/interface/) with this content:
#
# Config for using Raspberry Pi's expansion header
#
# This is best used with a fast enough buffer but also
# is suitable for direct connection if the target voltage
# matches RPi's 3.3V and the cable is short enough.
#
# Do not forget the GND connection, pin 6 of the expansion header.
#

interface bcm2835gpio

bcm2835gpio_peripheral_base 0x20000000

# Transition delay calculation: SPEED_COEFF/khz - SPEED_OFFSET
# These depend on system clock, calibrated for stock 700MHz
# bcm2835gpio_speed SPEED_COEFF SPEED_OFFSET
bcm2835gpio_speed_coeffs 113714 28

# Each of the JTAG lines need a gpio number set: tck tms tdi tdo
# Header pin numbers: 23 22 19 21
bcm2835gpio_jtag_nums 11 25 10 9

# If you define trst or srst, use appropriate reset_config
# Header pin numbers: TRST - 26, SRST - 18

# bcm2835gpio_trst_num 7
# reset_config trst_only

# bcm2835gpio_srst_num 24
# reset_config srst_only srst_push_pull

# or if you have both connected,
# reset_config trst_and_srst srst_push_pull
and I tried the um232h.cfg (at openocd/scripts/interface/ftdi/) with this content:
#
# FTDI UM232H as a JTAG interface
#
# http://www.ftdichip.com/Products/Module ... htm#UM232H
#
# This should also work with a UM232H-B, but that has not been tested.
# Note that UM232H and UM232H-B are 3.3V only.
#

interface ftdi
#ftdi_device_desc "UM232H"
ftdi_vid_pid 0x0403 0x6014

ftdi_layout_init 0xfff8 0xfffb
ftdi_layout_signal nTRST -data 0x0100 -oe 0x0100
ftdi_layout_signal nSRST -data 0x0200 -oe 0x0200

# UM232H FT232H JTAG
# Name Pin Name Func
# AD0 J2-6 ADBUS0 TCK
# AD1 J2-7 ADBUS1 TDI
# AD2 J2-8 ADBUS2 TDO
# AD3 J2-9 ADBUS3 TMS
# AD4 J2-10 ADBUS4 (GPIOL0)
# AD5 J2-11 ADBUS5 (GPIOL1)
# AD6 J2-12 ADBUS6 (GPIOL2)
# AD7 J2-13 ADBUS7 (GPIOL3)
# AD0 J1-14 ACBUS0 /TRST
# AD1 J1-13 ACBUS1 /SRST
# AD2 J1-12 ACBUS2 (GPIOH2)
# AD3 J1-11 ACBUS3 (GPIOH3)
# AD4 J1-10 ACBUS4 (GPIOH4)
# AD5 J1-9 ACBUS5 (GPIOH5)
# AD6 J1-8 ACBUS6 (GPIOH6)
# AD7 J1-7 ACBUS7 (GPIOH7)
and I get this error message:

Code: Select all

[email protected]:~/Desktop/openocd2/0.10.0-7-20180123-1217$ openocd -f scripts/interface/raspberrypi-native.cfg -f scripts/interface/ftdi/um232h.cfg 
Open On-Chip Debugger 0.10.0+dev-00376-g3d3b45af (2018-03-30-18:38)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Error: The specified debug interface was not found (bcm2835gpio)
The following debug interfaces are available:
1: ftdi
2: usb_blaster
3: ft232r
4: jlink
5: vsllink
6: ulink
7: hla
8: osbdm
9: opendous
10: sysfsgpio
11: aice
So you go into the openocd sources, and comment out the return on error and it tends to work.
Where? Which file, which line number?
Short answer, try version 0.9.0, see if that helps.
Okay, I will try that. But which config file(s)?

To clarify: I try to upload my C-program (as kernel.elf) via a FT232H breakout board (the one I linked at my first post from ebay) to the RaspBerry 1 B+ via JTAG (by enabling the JTAG GPIO-alternate function)

Edit: I get this error after

Code: Select all

./configure
make
arm7_9_common.c: In function 'arm7_9_unset_breakpoint':
arm7_9_common.c:353:4: error: this 'if' clause does not guard... [-Werror=misleading-indentation]
if (current_instr == arm7_9->thumb_bkpt)
^~
arm7_9_common.c:356:5: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
if (retval != ERROR_OK)
^~
Edit 2: Okay, I fixed the source code problem (I don't know why they released a faulty version in the first place), but now I don't know which config files to use.

dwelch67
Posts: 944
Joined: Sat May 26, 2012 5:32 pm

Re: Use a FT232H-Chip to debug Pi 1 B+ via JTag + OpenOCD config

Sat Apr 07, 2018 3:11 am

Okay this is in part why I dont do jtag, takes me a few seconds to get the uart hooked up to use the uart based bootloader. counting the pins just cant get that right, in part, my example code for the original pi did have gpio4. but that was the original P1 header the longer pi zero and other boards you can use gpio 26 instead. So just worked (openocd 0.9.0 or 0.10.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<<18); //gpio26
ra|= 3<<18; //alt4 ARM_TDI
ra&=~(7<<21); //gpio27
ra|= 3<<21; //alt4 ARM_TMS
PUT32(GPFSEL2,ra);

//ARM_TCK D0 P1-22 OUT (25 ALT4)
//ARM_TDI D1 P1-37 IN (26 ALT4)
//ARM_TDO D2 P1-18 OUT (24 ALT4)
//ARM_TMS D3 P1-13 OUT (27 ALT4)
//ARM_TRST D4 P1-15 IN (22 ALT4)
//ARM_GND GND P1-25


#
# FTDI FT4232H Mini Module
#

interface ft2232
#ft2232_device_desc "FT4232H MiniModule"
ft2232_layout "flyswatter"
ft2232_vid_pid 0x0403 0x6014

#D0 TCK
#D1 TDI
#D2 TDO
#D3 TMS
#D4 TRST (flyswatter)

Looking at the openocd sourcecode (legacy ft2232) D4 gpio pin on the ft232h is the reset pin, not that you really need that. just the first four unless you want to do the reset command

openocd -f ft232h.cfg -f raspi.cfg
Open On-Chip Debugger 0.10.0-dev-00325-g12e4a2a (2016-07-05-23:15)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
adapter speed: 1000 kHz
none separate
raspi.arm
Warn : Using DEPRECATED interface driver 'ft2232'
Info : Consider using the 'ftdi' interface driver, with configuration files in interface/ftdi/...
Info : max TCK change to: 30000 kHz
Info : clock speed 1000 kHz
Info : JTAG tap: raspi.arm tap/device found: 0x07b7617f (mfg: 0x0bf (Broadcom), part: 0x7b76, ver: 0x0)
Info : found ARM1176
Info : raspi.arm: hardware has 6 breakpoints, 2 watchpoints


(stock unmodified openocd)
./configure --enable-legacy-ft2232_libftdi
make


Ill post the example in my raspberrypi-zero repo.

I am using the adafruit FT232H breakout board. The mpsse pins are the same D0-D3 for all the ftdi parts/boards/etc. If you have a breakout like the ones FTDI sells directly or indirectly the VDDIO needs a reference voltage, so that it knows you are hooked up to 5v or 3.3v or 1.8v or whatever. The boards that are made for jtag like the flyswatter, the amontec, and others (which you cant get anymore), you need to hook up to a voltage ref. I don thave the ebay boards you have, dont want to wait for those right now. But the adafruit, doesnt need/have that.

I am powering the pi and my uart board (using my serial port bootloader to load the arm jtag program, why mess with the sd card when you dont have to) and the ft232h board all from the same computer/hub. VREF in particular, but if the chip under test is powered separately you definitely need a ground. the amontec which you cant get anymore had a problem with this, I would have to hook up a separate ground to make it work, but was my favorite at work so we tolerated it. Got some of those other ones mentioned in my original pi repo, others solved this ground/reference problem. Power your jtag and pi from the same computer ideally hub initially to get it working.

SonicWave
Posts: 22
Joined: Mon Mar 19, 2018 1:10 pm

Re: Use a FT232H-Chip to debug Pi 1 B+ via JTag + OpenOCD config

Sat Apr 07, 2018 8:04 am

Thanks a lot for your help! Because you got it working I am hopeful that it works on my setupt as well, sometimes.

Code: Select all

[email protected]:~/Desktop/openocd2/0.10.0-7-20180123-1217$ sudo lsusb
[sudo] password for test: 
Bus 002 Device 003: ID 058f:6361 Alcor Micro Corp. Multimedia Card Reader
Bus 002 Device 004: ID 0403:6014 Future Technology Devices International, Ltd FT232H Single HS USB-UART/FIFO IC
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 001 Device 002: ID 0e0f:0003 VMware, Inc. Virtual Mouse
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

..
dmesg
[  221.769880] usb 2-1: new high-speed USB device number 5 using ehci-pci
[  222.110024] usb 2-1: New USB device found, idVendor=0403, idProduct=6014
[  222.110026] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  222.110028] usb 2-1: Product: Single RS232-HS
[  222.110029] usb 2-1: Manufacturer: FTDI
[  222.114866] ftdi_sio 2-1:1.0: FTDI USB Serial Device converter detected
[  222.115004] usb 2-1: Detected FT232H
[  222.117880] usb 2-1: FTDI USB Serial Device converter now attached to ttyUSB0
This is my output for lsusb, so the PID and VID you mentioned in your ft232h.cfg are definately correct.

Code: Select all

[email protected]:~/Desktop/openocd2/0.10.0-7-20180123-1217$ openocd -f custom_configs/ft232h.cfg -f custom_configs/raspi.cfg 
Open On-Chip Debugger 0.10.0+dev-00376-g3d3b45af (2018-03-30-18:38)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Error: The specified debug interface was not found (ft2232)
The following debug interfaces are available:
1: ftdi
2: usb_blaster
3: ft232r
4: jlink
5: vsllink
6: ulink
7: hla
8: osbdm
9: opendous
10: sysfsgpio
11: aice
What is wrong here? I don't think my ft232h breakout board is any different to yours. I am also wondering why openocd doesn't find the FTDI device even though I use correct PID/VID? Is it possible that I received a china-fake FTDI? But why does Linux recognize it as a FTDI device?

Did you install any kind of additional drivers from FTDI on your machine?

dwelch67
Posts: 944
Joined: Sat May 26, 2012 5:32 pm

Re: Use a FT232H-Chip to debug Pi 1 B+ via JTag + OpenOCD config

Mon Apr 09, 2018 1:09 pm

try configuring and building with the legacy ftdi, ft2232 is not you your list correct? it is in mine:

1: ft2232
2: ftdi
3: usb_blaster
4: usbprog
5: jlink
6: vsllink
7: rlink
8: ulink
9: arm-jtag-ew
10: hla
11: osbdm
12: opendous
13: aice
14: cmsis-dap

SonicWave
Posts: 22
Joined: Mon Mar 19, 2018 1:10 pm

Re: Use a FT232H-Chip to debug Pi 1 B+ via JTag + OpenOCD config

Mon Apr 09, 2018 1:28 pm

dwelch67 wrote:
Mon Apr 09, 2018 1:09 pm
try configuring and building with the legacy ftdi
Is "--enable ftdi" sufficient?

Code: Select all

[email protected]:~/Desktop/openocd$ ./configure --enable-ftdi
dwelch67 wrote:
Mon Apr 09, 2018 1:09 pm
ft2232 is not you your list correct?
I get this after ".configure":
OpenOCD configuration summary
--------------------------------------------------
MPSSE mode of FTDI based devices yes
ST-Link JTAG Programmer yes (auto)
TI ICDI JTAG Programmer yes (auto)
Keil ULINK JTAG Programmer yes (auto)
Altera USB-Blaster II Compatible yes (auto)
Bitbang mode of FT232R based devices yes (auto)
Versaloon-Link JTAG Programmer yes (auto)
OSBDM (JTAG only) Programmer yes (auto)
eStick/opendous JTAG Programmer yes (auto)
Andes JTAG Programmer yes (auto)
USBProg JTAG Programmer yes (auto)
Raisonance RLink JTAG Programmer yes (auto)
Olimex ARM-JTAG-EW Programmer yes (auto)
CMSIS-DAP Compliant Debugger no
Cypress KitProg Programmer no
Altera USB-Blaster Compatible yes (auto)
ASIX Presto Adapter yes (auto)
OpenJTAG Adapter yes (auto)
SEGGER J-Link Programmer yes (auto)
No...Why is it not in the list?

Code: Select all

[email protected]:~/Desktop/openocd$ openocd -f custom_config/ft232h.cfg -f custom_config/raspi.cfg Open On-Chip Debugger 0.10.0+dev-00390-g6e356cbf (2018-04-09-14:26)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Error: The specified debug interface was not found (ft2232)
The following debug interfaces are available:
1: ftdi
2: usb_blaster
3: ft232r
4: presto
5: usbprog
6: openjtag
7: jlink
8: vsllink
9: rlink
10: ulink
11: arm-jtag-ew
12: hla
13: osbdm
14: opendous
15: aice
Edit:

Because the README file (http://openocd.org/doc-release/README) at section OpenOCD Dependencies says that libftdi is needed to use ft2232 interface adapters, I installed libftdi (and also did a reboot), but even after recompiling openocd after installing libftdi, I get the exact same error as shown above :(

dwelch67
Posts: 944
Joined: Sat May 26, 2012 5:32 pm

Re: Use a FT232H-Chip to debug Pi 1 B+ via JTag + OpenOCD config

Mon Apr 09, 2018 5:54 pm

I apt-get install libftdi-dev

Then try this from my post above

(stock unmodified openocd)
./configure --enable-legacy-ft2232_libftdi
make

If you want to use the new driver (--enable ftdi) then use one of those interface configs.

flyswatter has

interface ftdi
ftdi_device_desc "Flyswatter"
ftdi_vid_pid 0x0403 0x6010

ftdi_layout_init 0x0818 0x0cfb
ftdi_layout_signal nTRST -data 0x0010
ftdi_layout_signal nSRST -oe 0x0020
ftdi_layout_signal LED -data 0x0c00

so maybe

interface ftdi
ftdi_vid_pid 0x0403 0x6010
ftdi_layout_init 0x0008 0x00fb

is sufficient. I try the new driver say once a year or two, but end up going back to the one that works. The new driver last time(s) I tried it needs this modification:

edit src/target/arm11_dbgtap.c

comment out the retval = ERROR_FAIL

if (error_count > 0) {
LOG_ERROR("%u words out of %u not transferred",
error_count, readiesNum);
//retval = ERROR_FAIL;
}

and then yes you build with --enable ftdi. but you have to use the right kind of config file for the driver you are using

interface ftdi

or

interface ft2232

(even if it is some other chip with mpsse ft4232, ft232h, etc, the legacy one you specify ft2232)

SonicWave
Posts: 22
Joined: Mon Mar 19, 2018 1:10 pm

Re: Use a FT232H-Chip to debug Pi 1 B+ via JTag + OpenOCD config

Mon Apr 09, 2018 7:41 pm

I apt-get install libftdi-dev
I also did that.
(stock unmodified openocd)
./configure --enable-legacy-ft2232_libftdi
make
Also did that.
interface ftdi
ftdi_vid_pid 0x0403 0x6010
ftdi_layout_init 0x0008 0x00fb
I used this (changed PID according to dmesg):
interface ftdi
ftdi_vid_pid 0x0403 0x6014
ftdi_layout_init 0x0008 0x00fb
and I get this:

Code: Select all

[email protected]:~/Desktop/openocd$ openocd -f custom_configs/ft232h.cfg -f custom_configs/raspi.cfg 
Open On-Chip Debugger 0.10.0+dev-00391-gf00d9bb1 (2018-04-09-20:32)
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 : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 1000 kHz
Error: JTAG scan chain interrogation failed: all zeroes
Error: Check JTAG interface, timings, target power, etc.
Error: Trying to use configured scan chain anyway...
Error: raspi.arm: IR capture error; saw 0x00 not 0x01
Warn : Bypassing JTAG setup events due to errors
Error: 'arm11 target' JTAG error SCREG OUT 0x00
Error: unexpected ARM11 ID code
Info : Listening on port 3333 for gdb connections
I am using your raspberrypi/armjag/armjtag.c with this pinout: http://raspi.tv/wp-content/uploads/2014 ... inouts.png
I also double checked the connection cables, the LED is blinking (I changed it to GPIO47 - the new LED-Pin on the 1 B+ model)

dwelch67
Posts: 944
Joined: Sat May 26, 2012 5:32 pm

Re: Use a FT232H-Chip to debug Pi 1 B+ via JTag + OpenOCD config

Mon Apr 09, 2018 9:31 pm

Check your wiring if you are using my old stuff then one pin is alt5 not alt4 and you have to get on that pin, ifyou use the pi-zero stuff I just did for you the other day, then all of them are alt4 and you use pin 37 or whatever instead of 7. You have to get all the connections right, you likely have to have a ground, you have to know from your board if you need vddio connected for a voltage reference. need to get the correct combination of openocd and drivers and config files to match the above. Ive done this many many times and it took me like an hour, all human error but that is part of it (why I dont do jtag on the pi anymore).

SonicWave
Posts: 22
Joined: Mon Mar 19, 2018 1:10 pm

Re: Use a FT232H-Chip to debug Pi 1 B+ via JTag + OpenOCD config

Tue Apr 10, 2018 4:26 pm

I am sorry that I take so much of your time but it seems, at least to me, that you are the only one on this forum who got JTAG working on the Pi.
Check your wiring if you are using my old stuff then one pin is alt5 not alt4
I checked everything! Can you confirm, that this code is correct (the LED is blinking):

Code: Select all

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 GPFSEL4     0x20200010
#define GPSET0      0x2020001C
#define GPSET1      0x20200020
#define GPCLR0      0x20200028
#define GPCLR1      0x2020002C
#define GPPUD       0x20200094
#define GPPUDCLK0   0x20200098

#define TIMEOUT 1000000


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

    //for led

    ra = 1 << 21;
    PUT32(GPFSEL4,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(GPSET1,1<<15);
        while(1)
        {
            ra=GET32(ARM_TIMER_CNT);
            if((ra-rb)>=TIMEOUT) break;
        }
        rb+=TIMEOUT;
        PUT32(GPCLR1,1<<15);
        while(1)
        {
            ra=GET32(ARM_TIMER_CNT);
            if((ra-rb)>=TIMEOUT) break;
        }
        rb+=TIMEOUT;
    }
    return(0);
}

// Copyright (c) 2012 David Welch [email protected]
ifyou use the pi-zero
I use Raspberry 1 Model B+
Ive done this many many times and it took me like an hour, all human error but that is part of it (why I dont do jtag on the pi anymore).
I try to get this working for several weeks now :(

dwelch67
Posts: 944
Joined: Sat May 26, 2012 5:32 pm

Re: Use a FT232H-Chip to debug Pi 1 B+ via JTag + OpenOCD config

Wed Apr 11, 2018 3:22 am

I used that code yes, and most recently this code:

Code: Select all

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

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 GPFSEL3     0x2020000C
#define GPFSEL4     0x20200010
#define GPSET0      0x2020001C
#define GPSET1      0x20200020
#define GPCLR0      0x20200028
#define GPCLR1      0x2020002C
#define GPPUD       0x20200094
#define GPPUDCLK0   0x20200098

#define TIMEOUT 1000000

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

    //for led

    ra=GET32(GPFSEL4);
    ra&=~(7<<21);
    ra|=1<<21;
    PUT32(GPFSEL4,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<<18);   //gpio26
    ra|=  3<<18;    //alt4 ARM_TDI
    ra&=~(7<<21);   //gpio27
    ra|=  3<<21;    //alt4 ARM_TMS
    PUT32(GPFSEL2,ra);

//ARM_TCK  D0  P1-22 OUT (25 ALT4)
//ARM_TDI  D1  P1-37  IN (26 ALT4)
//ARM_TDO  D2  P1-18 OUT (24 ALT4)
//ARM_TMS  D3  P1-13 OUT (27 ALT4)
//ARM_TRST D4  P1-15  IN (22 ALT4)
//ARM_GND  GND P1-39

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

    rb=GET32(ARM_TIMER_CNT);
    while(1)
    {
        PUT32(GPSET1,1<<(47-32));
        while(1)
        {
            ra=GET32(ARM_TIMER_CNT);
            if((ra-rb)>=TIMEOUT) break;
        }
        rb+=TIMEOUT;
        PUT32(GPCLR1,1<<(47-32));
        while(1)
        {
            ra=GET32(ARM_TIMER_CNT);
            if((ra-rb)>=TIMEOUT) break;
        }
        rb+=TIMEOUT;
    }
    return(0);
}
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------


//-------------------------------------------------------------------------
//
// Copyright (c) 2012 David Welch [email protected]
//
// 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.
//
//-------------------------------------------------------------------------
With the code you posted note that this

Code: Select all

//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)
is covered in the README.

//ARM_TMS 12/27 CAM_GPIO S5-11 OUT (27 ALT4)

is no longer S5-11, but P1-13.

And so long as you hit a ground you can use whichever one you want doesnt have to be P1-25 nor P1-39.

While beating my head against this I changed to the new pinout that came with the B+ (not the new pi3 b+ but the old lets call it pi1 b+ if this is a pi3 then you are a long way down the wrong path, your led is blinking so you say so I think you are on an old pi1):

//ARM_TDI D1 P1-37 IN (26 ALT4)

And the ground next to it which is easier to hit now, just like P1-25 was on the old old pi 1 boards.

//ARM_GND GND P1-39

either one of the TDI pins should work unless they have something stomping on P1-7...

my raspberrypi repo is in a constantly changing state of decay. I have basically abandoned it in place as is because there are folks that no doubt linked to parts of it or are used it it or whatever including myself. But have created new raspberrypi-zero and raspberrypi-three repos that are aimed at active product although they just changed the pi3...So you get what you get with the old repo. When googling the raspberry pi pinout you get the old 26 pin and the new 40 pin layouts, you dont see the hey this one is specific to the pi3 or pi2 or A+ or B+ so going with the 40 pin layout you should be able to use the code I made and tested most recently on a pi-zero, I dont see a reason why it wouldnt work.

If you change this

#define TIMEOUT 1000000

to some other number, say

#define TIMEOUT 2000000

build, load onto the sd card or into the arm however you choose to do that. Does that result in a change in the blink rate of the led? if not you are not running the code you think you are running on the pi and thats your problem.

Now as for your FT232H solution. if you unplug it completely from the raspberry pi, unplug it from your computer, short pins D0 and D1 as documented by FTDI, whatever that results in on your board. Then plug it into your coputer, if a linux machine this shows up as uarts if you dont mess with things. use minicom aim it at one of the two /dev/ttyUSBX devices that showed up when you plugged it in (dmesg), with the jumper in place do you get back what you typed? when you remove the jumper does it stop echoing back what you type? What is the voltage on D0 (or D2, or D3, or D4...) relative to a ground on that board? Is it 3.3V? If you cant get the loopback to work as a uart, then you are not going to get jtag to work, the board or how you are using is your problem. How to know which uart is ADBUS vs ACBUS? My guess is that of the two /dev/ttyUSBx ports that show up when you plug it in (unplug, dmesg -c, plug in, dmesg) the first one is ACBUS the second ADBUS. The experiment is not D bus specific put a jumper between D0 and D1 and put another between C0 and C1, or try both of the uarts that show up.


# Machine-generated file - use "minicom -s" to change parameters.
pu port /dev/ttyUSB0
pu minit
pu mhangup
pu rtscts No
pu sound No

You can take this text file and save it as /etc/minicom/minirc.usb0 copy it to usb1 and change the USB0 to USB1, ignore the this is machine generated and use minicom -s, you can use that but this is significantly easier, repeat or target the specific /dev/ttyUSBX that you see on dmesg for this ftdi part.

then

mincom usb0
or
minicom usb1
or whatever the /etc/minicom/minirc.xyz xyz part is
minicom xyz

when minicom loads if you see /dev/tty8 it is not using your rc file and you are not actually connected to the port you think you are.

even more fun start up two minicoms in two different terminal windows cross the wires so that D0 goes to C1 and C0 to D1, what you type in one window should show up on the other, and vice versa, remove one jumper wire and only one direction should work.

You simply have to divide the problem in half. Is this hardware or software. If software then continue to divide the problem in half. If hardware divide the problem in half

Further testing without jtag, take this same FT232H board you are using. Connect D0 to P1-8 and D1 to P1-10 (and a ground as needed) that should be TXD to RXD and RXD to TXD between the ftdi board and the pi. Take one of my uart examples, can you use this FT232H board to speak to the pi with D0 and D1 using the ftdi as a uart, if you cant do that then you are not going to get JTAG to work.

Divide the problem in half then divide again then divide again until you get there, sounds silly and stupid and not meant to be offensive, but that is how I solve these problems personally and professionally and mentor other folks junior or senior engineers through problems when they are so focused they cant pull back and see the whole picture. Sometimes it just takes someone else to nudge you in the right direction, sometimes you spend too much time looking at it you cant actually see it. so no offence meant here. first off is this hardware or software is it your board, is it that you are not plugged into the same usb hub (on the motherboard or an external hub, basically are the grounds not matching is there a DC voltage hanging over this), is it your FT232H board a nuance of that? The amontec board I used and loved for so long had big issues when it came to this, would have to plug into the target, then unplug from the host then replug to shed some capacitance that would cause it not to work, the grounds on that board did a whole lot of nothing, they were useless would take another usb cable from the development machine, had a usb breakout board and would take the ground from that and run that to the target just to get that stupid amontec to work. And the ftdi eval boards you have to solve vddio or they wont work. others, ones mean to be jtag boards (flyswatter, etc) you have to hook up the voltage reference (in this case to vcc on the pi, something that is 3.3v out of the pi) to get them to work, and of course you have to have your wiring right you have to count the pins right. your jumper cables need to be making good contact, sometimes they dont either because of the size of the pins or the size of the socket you might have a bad one. there is a laundry list of hardware side problems.

software side you have to be running the code you think you are running. then the wiring has to match what you have told the pi to do, do you have your alt4 and alt5's lined up right. Dont trust me, read my code, check my code, check your tools building my code, read the raspberry pi arm manual to see the table where I looked at alt4 vs alt5 vs the googled raspberry pi P1 connector pinout. changing the blink rate goes a long way toward the are you running the code you think you are running and is it building the code right such that it actually works.

Even if you think you have divide the problem in half maybe you are wrong and sometimes have to go back and start over. but once divided keep dividing

Then there is the openocd side of this and config files and versions of openocd and which driver to use. can you eliminate this as the problem? or isolate this as the problem?

Do you have an oscilloscope, a bare metal programmers best friend? Probe these signals are they wiggling, TDO, TMS, TCLK? Are they 3.3volts?

Maybe you burned up your pi or a pin on your pi, maybe you burned up your FT232H board.

Did you do any of your own soldering on these boards, did you inspect taht, maybe you have a solder bridge or a bad solder joint. Even if you didnt do it maybe the board has a bad connection, do a visual. Good thing to buy at least two of everything for these kinds of reasons, two FT232h boards two raspberry pis. Extra jumper wires.

Using a uart example and hooking up a uart, can you put jumpers between say P1-7 and P1-18. make gpio 24 a generic push pull output and gpio4 an input.. write a program that sets gpio 24 high and then reads gpio 4 and prints what you find out on the uart, have it set gpio 24 low, read gpio4 print it out. are you getting the I/O to work on these pins with your jumper wires wthout the FT232H on those pins (might use it for uart as needed). repeat for the other pins and gpio you are trying to use. can simply use a volt meter if you have one to very slowly change these pins high and low, slow enough for the volt meter to catch it, see that you can drive 3.3v at least into the meter which has a very low load.

for the openocd scripts and for other reasons are you seeing the factory default 0403:6014
Bus 001 Device 008: ID 0403:6014 Future Technology Devices International, Ltd FT232H Single HS USB-UART/FIFO IC
If your board has an eeprom on it it is possible to change the vid:pid and that can/will affect how linux reacts to this board. Some products that are generic breakouts will set their own vid:pid and you might not want to try to use those as generic uarts if they are specifically jtag boards/boxes. if generic though you should be able to use TCK as a uart TXD and TDI as a uart RXD if linux sees these ports initially as uarts.

Could be simply a linux thing. try another computer or linux install on this computer or use a ubuntu or mint installer dvd or usb stick and apt-get and make/make install what you need on the live linux those provide (dont have to install on a hard drive can use one as an operating system as is). not necessarily the latest greatest 14.04 and 16.04 based or 17.x for mint.

you shouldnt need trst, try leaving that unplugged, or tie P1-15 to VCC or tie it to GND.

try 0.9.0 from sources, built yourself with legacy ft2232., if you already have try it again. and some printfs make sure that you are really using the binary you think you are using.

You have to eliminate all of these things plus the list of other possible problems the software from me is just a wee bitty part of the equation.

David

dwelch67
Posts: 944
Joined: Sat May 26, 2012 5:32 pm

Re: Use a FT232H-Chip to debug Pi 1 B+ via JTag + OpenOCD config

Wed Apr 11, 2018 3:24 am

Not the only one to get jtag working on the pi, pretty sure of that. Others may not have posted code or talked about it, certainly.

dwelch67
Posts: 944
Joined: Sat May 26, 2012 5:32 pm

Re: Use a FT232H-Chip to debug Pi 1 B+ via JTag + OpenOCD config

Wed Apr 11, 2018 3:37 am

Hmm, I am used to FT2232 parts and FT4232 parts where all the ports are uarts by default without an eeprom. this part C0/C1 are not uarts by default...only D0/D1

dmesg -c
[16991.857343] usb 1-3.4.1: new high-speed USB device number 10 using ehci-pci
[16991.966096] usb 1-3.4.1: New USB device found, idVendor=0403, idProduct=6014
[16991.966099] usb 1-3.4.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[16991.970025] ftdi_sio 1-3.4.1:1.0: FTDI USB Serial Device converter detected
[16991.970053] usb 1-3.4.1: Detected FT232H
[16991.970319] usb 1-3.4.1: FTDI USB Serial Device converter now attached to ttyUSB1

so you cant do the C0/C1 things at the same time the minicom test you have only one ttyUSBX to deal with it either works or doesnt with an external loopback.

dwelch67
Posts: 944
Joined: Sat May 26, 2012 5:32 pm

Re: Use a FT232H-Chip to debug Pi 1 B+ via JTag + OpenOCD config

Wed Apr 11, 2018 4:24 am

Okay I am not sure where I have a pi1 B+ I know I have alt least one very likely two or more. I liked the A+ better and have more of those and easily found one. Pulled the sd card from my pi zero from the other day.

my code from my raspberrypi-zero repo which I posted notmain.c a couple of comments above.

//ARM_TCK D0 P1-22 OUT (25 ALT4)
//ARM_TDI D1 P1-37 IN (26 ALT4)
//ARM_TDO D2 P1-18 OUT (24 ALT4)
//ARM_TMS D3 P1-13 OUT (27 ALT4)
//ARM_TRST D4 P1-15 IN (22 ALT4)
//ARM_GND GND P1-39

I actually only needed

//ARM_TCK D0 P1-22 OUT (25 ALT4)
//ARM_TDI D1 P1-37 IN (26 ALT4)
//ARM_TDO D2 P1-18 OUT (24 ALT4)
//ARM_TMS D3 P1-13 OUT (27 ALT4)
//ARM_TRST P1-15 IN (22 ALT4) tied to P1-1 3.3V VCC
didnt tie a ground (well did then removed it) am using the same computer/hub for both.
did need to tie trst high for it to work.

Again to be fair am using my stock uart bootloader to load the armjtag binary, no way that is the problem. have that hooked up too. no way that is the problem...

Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 007 Device 005: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 013 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 012 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 011 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 010 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 007: ID 058f:6361 Alcor Micro Corp. Multimedia Card Reader
Bus 001 Device 013: ID 0403:6014 Future Technology Devices International, Ltd FT232H Single HS USB-UART/FIFO IC
Bus 001 Device 006: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 005: ID 262a:10aa
Bus 001 Device 003: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 003: ID 050d:0109 Belkin Components F5U109/F5U409 PDA Adapter
Bus 004 Device 002: ID 04a9:2220 Canon, Inc. CanoScan LIDE 25
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 009 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 008 Device 003: ID 046d:c249 Logitech, Inc.
Bus 008 Device 002: ID 03f9:0100 KeyTronic Corp. KT-2001 Keyboard
Bus 008 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Note I have only one 0403:6014 if you have more than one THAT COULD BE YOUR PROBLEM. maybe not but openocd grabs the first one it finds unless otherwise specified.

If you have a 0403:6014 (or any vid/pid really) that you are trying to use and it has an eeprom with a serial number and or you use the ftdi tools to write serial number so that each board is unique then add a line like this to your .cfg file

ft2232_serial T13FX4

with the unique string in this case T13FX4 in that file make one file per debug/ftdi board.

another thing you can do is unplug the other conflicting boards or replug them in a different order so that the one you are after hits first, not sure if the lsusb list is the order they hit or not can do your own experiments with the ftdi library to enumerate them. easier just to remove the conflicting devices IF you have any.

assuming you dont

I used the ft232h.cfg and raspi.cfg in that repo

#
# FTDI FT4232H Mini Module
#

interface ft2232
#ft2232_device_desc "FT4232H MiniModule"
ft2232_layout "flyswatter"
ft2232_vid_pid 0x0403 0x6014

#D0 TCK
#D1 TDI
#D2 TDO
#D3 TMS
#D4 TRST (flyswatter)

# 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


openocd -f ft232h.cfg -f raspi.cfg
Open On-Chip Debugger 0.10.0-dev-00325-g12e4a2a (2016-07-05-23:15)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
adapter speed: 1000 kHz
none separate
raspi.arm
Warn : Using DEPRECATED interface driver 'ft2232'
Info : Consider using the 'ftdi' interface driver, with configuration files in interface/ftdi/...
Info : max TCK change to: 30000 kHz
Info : clock speed 1000 kHz
Info : JTAG tap: raspi.arm tap/device found: 0x07b7617f (mfg: 0x0bf (Broadcom), part: 0x7b76, ver: 0x0)
Info : found ARM1176
Info : raspi.arm: hardware has 6 breakpoints, 2 watchpoints

then I made a new one called hello.cfg


interface ftdi
ftdi_vid_pid 0x0403 0x6014
ftdi_layout_init 0x0008 0x00fb

using the new driver:

openocd -f hello.cfg -f raspi.cfg
Open On-Chip Debugger 0.10.0-dev-00325-g12e4a2a (2016-07-05-23:15)
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
Info : JTAG tap: raspi.arm tap/device found: 0x07b7617f (mfg: 0x0bf (Broadcom), part: 0x7b76, ver: 0x0)
Info : found ARM1176
Info : raspi.arm: hardware has 6 breakpoints, 2 watchpoints

then I took the code from my raspberry pi repo armjtag directory built and ran than moved

//ARM_TDI D1 P1-37 IN (26 ALT4)

to P1-7

//ARM_TDI D1 P1-7 IN (4 ALT4)

openocd -f ft232h.cfg -f raspi.cfg
Open On-Chip Debugger 0.10.0-dev-00325-g12e4a2a (2016-07-05-23:15)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
adapter speed: 1000 kHz
none separate
raspi.arm
Warn : Using DEPRECATED interface driver 'ft2232'
Info : Consider using the 'ftdi' interface driver, with configuration files in interface/ftdi/...
Info : max TCK change to: 30000 kHz
Info : clock speed 1000 kHz
Info : JTAG tap: raspi.arm tap/device found: 0x07b7617f (mfg: 0x0bf (Broadcom), part: 0x7b76, ver: 0x0)
Info : found ARM1176
Info : raspi.arm: hardware has 6 breakpoints, 2 watchpoints

Using 0.9.0

~/openocd-0.9.0/src/openocd -f ft232h.cfg -f raspi.cfg
Open On-Chip Debugger 0.9.0 (2018-04-06-22:31)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
adapter speed: 1000 kHz
none separate
raspi.arm
Warn : Using DEPRECATED interface driver 'ft2232'
Info : Consider using the 'ftdi' interface driver, with configuration files in interface/ftdi/...
Info : max TCK change to: 30000 kHz
Info : clock speed 1000 kHz
Info : JTAG tap: raspi.arm tap/device found: 0x07b7617f (mfg: 0x0bf, part: 0x7b76, ver: 0x0)
Info : found ARM1176
Info : raspi.arm: hardware has 6 breakpoints, 2 watchpoints


~/openocd-0.9.0/src/openocd -f hello.cfg -f raspi.cfg
Open On-Chip Debugger 0.9.0 (2018-04-06-22:31)
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
Info : JTAG tap: raspi.arm tap/device found: 0x07b7617f (mfg: 0x0bf, part: 0x7b76, ver: 0x0)
Info : found ARM1176
Info : raspi.arm: hardware has 6 breakpoints, 2 watchpoints


removed the sd card copied armjtag.bin (from the old repo) over kernel.img put it back in power cycled the board


~/openocd-0.9.0/src/openocd -f hello.cfg -f raspi.cfg
Open On-Chip Debugger 0.9.0 (2018-04-06-22:31)
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
Info : JTAG tap: raspi.arm tap/device found: 0x07b7617f (mfg: 0x0bf, part: 0x7b76, ver: 0x0)
Info : found ARM1176
Info : raspi.arm: hardware has 6 breakpoints, 2 watchpoints

D4 to P1-15 instead of tying it high

//ARM_TRST D4 P1-15 IN (22 ALT4)

~/openocd-0.9.0/src/openocd -f ft232h.cfg -f raspi.cfg
Open On-Chip Debugger 0.9.0 (2018-04-06-22:31)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
adapter speed: 1000 kHz
none separate
raspi.arm
Warn : Using DEPRECATED interface driver 'ft2232'
Info : Consider using the 'ftdi' interface driver, with configuration files in interface/ftdi/...
Info : max TCK change to: 30000 kHz
Info : clock speed 1000 kHz
Info : JTAG tap: raspi.arm tap/device found: 0x07b7617f (mfg: 0x0bf, part: 0x7b76, ver: 0x0)
Info : found ARM1176
Info : raspi.arm: hardware has 6 breakpoints, 2 watchpoints

modified hello.cfg to use D4

interface ftdi
ftdi_vid_pid 0x0403 0x6014
ftdi_layout_init 0x0018 0x00fb
ftdi_layout_signal nTRST -data 0x0010

~/openocd-0.9.0/src/openocd -f hello.cfg -f raspi.cfg
Open On-Chip Debugger 0.9.0 (2018-04-06-22:31)
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
Info : JTAG tap: raspi.arm tap/device found: 0x07b7617f (mfg: 0x0bf, part: 0x7b76, ver: 0x0)
Info : found ARM1176
Info : raspi.arm: hardware has 6 breakpoints, 2 watchpoints

SonicWave
Posts: 22
Joined: Mon Mar 19, 2018 1:10 pm

Re: Use a FT232H-Chip to debug Pi 1 B+ via JTag + OpenOCD config

Wed Apr 11, 2018 6:22 pm

(not the new pi3 b+ but the old lets call it pi1 b+ if this is a pi3 then you are a long way down the wrong path, your led is blinking so you say so I think you are on an old pi1):
I mentioned it now quite a few times, but I will gladly repeat: I use a Raspberry Pi Model 1 B+
Does that result in a change in the blink rate of the led?
It indeed does!
If you cant get the loopback to work as a uart, then you are not going to get jtag to work, the board or how you are using is your problem.
Everything works fine - I get back what I type in. If I unplug the bridge, it stops echoing what I type.
So the FT232H is working (I guess)
The experiment is not D bus specific put a jumper between D0 and D1 and put another between C0 and C1, or try both of the uarts that show up.
As you noticed later, the FT232H only has one hardware unit.
if you cant do that then you are not going to get JTAG to work.
Works fine as well!
TDO, TMS, TCLK
They are doing something (captured with Saleae Logic Analyzer):

https://picload.org/view/dawcrciw/output.png.html
Maybe you burned up your pi or a pin on your pi, maybe you burned up your FT232H board.
I think we can discard that.
for the openocd scripts and for other reasons are you seeing the factory default 0403:6014
Bus 001 Device 008: ID 0403:6014 Future Technology Devices International, Ltd FT232H Single HS USB-UART/FIFO IC

Code: Select all

[ 5691.145303] usb 1-1: new high-speed USB device number 9 using ehci-pci
[ 5691.487989] usb 1-1: New USB device found, idVendor=0403, idProduct=6014
[ 5691.487995] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 5691.487999] usb 1-1: Product: Single RS232-HS
[ 5691.488002] usb 1-1: Manufacturer: FTDI
[ 5691.496121] ftdi_sio 1-1:1.0: FTDI USB Serial Device converter detected
[ 5691.496201] usb 1-1: Detected FT232H
[ 5691.500192] usb 1-1: FTDI USB Serial Device converter now attached to ttyUSB0
did need to tie trst high for it to work.
That was the problem all the time, now I get this (finally :D ):

Code: Select all

[email protected]:~/Desktop/openocd$ openocd -f custom_configs/ft232h.cfg -f custom_configs/raspi.cfg 
Open On-Chip Debugger 0.10.0+dev-00391-gf00d9bb1 (2018-04-09-20:32)
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 : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 1000 kHz
Info : JTAG tap: raspi.arm tap/device found: 0x07b7617f (mfg: 0x0bf (Broadcom), part: 0x7b76, ver: 0x0)
Info : found ARM1176
Info : raspi.arm: hardware has 6 breakpoints, 2 watchpoints
Warn : Scan chain 7 shifted out unexpected address
Warn : Scan chain 7 shifted out unexpected address
Warn : Scan chain 7 shifted out unexpected data
Warn : Scan chain 7 shifted out unexpected address
Warn : Scan chain 7 shifted out unexpected address
Warn : Scan chain 7 shifted out unexpected data
Warn : Scan chain 7 shifted out unexpected address
Warn : Scan chain 7 shifted out unexpected address
Warn : Scan chain 7 shifted out unexpected address
Warn : Scan chain 7 shifted out unexpected data
Warn : Scan chain 7 shifted out unexpected address
Warn : Scan chain 7 shifted out unexpected address
Warn : Scan chain 7 shifted out unexpected data
Warn : Scan chain 7 shifted out unexpected address
Info : Listening on port 3333 for gdb connections
What does Scan chain 7 shifted out unexpected address mean?

dwelch67
Posts: 944
Joined: Sat May 26, 2012 5:32 pm

Re: Use a FT232H-Chip to debug Pi 1 B+ via JTag + OpenOCD config

Thu Apr 12, 2018 3:11 am

You had left me no choice but to just shot gun it and toss out all kinds of things to try.

I have no clue what your new problem is. if you exit openocd and re-run it does this change? if you telnet in and halt and dump memory or registers does it work? are you connecting with gdb and maybe it is tickling something through openocd?

You know how jtag works right, a really simple serial interface that follows a simple flow chart, the error means at a high level something not expected happened, you can grep through the openocd code to see what happened. Are you still just using 0.10.0, does this happen with 0.9.0?

A number of the FTDI parts you get a uart per port, and then some of the ports, somewhere between zero and all of them depending on the part have MPSSE support. So not unrealistic on a quick glance to expect two uarts for two ports, the uarts on these parts are not related to mpsse support. I figured it out, too tired and frustrated to go back and re-edit that post, just rambled on, first draft, no re-writes...

SonicWave
Posts: 22
Joined: Mon Mar 19, 2018 1:10 pm

Re: Use a FT232H-Chip to debug Pi 1 B+ via JTag + OpenOCD config

Thu Apr 12, 2018 6:01 pm

You had left me no choice but to just shot gun it and toss out all kinds of things to try.
I am sorry, I thought I did everything you said (UART / capture stuff with Saleae Logic)?
if you exit openocd and re-run it does this change?
The amount of warning messages differs from time to time:

Code: Select all

Info : raspi.arm: hardware has 6 breakpoints, 2 watchpoints
Warn : Scan chain 7 shifted out unexpected address
Warn : Scan chain 7 shifted out unexpected address
Info : Listening on port 3333 for gdb connections
if you telnet in and halt and dump memory or registers does it work?

Code: Select all

Info : Listening on port 3333 for gdb connections
Info : accepting 'gdb' connection on tcp/3333
Error: attempted 'gdb' connection rejected
and:

Code: Select all

[email protected]:/usr/bin$ telnet localhost 3333
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+Connection closed by foreign host.
Seems as if openocd does not accept telnet connections
Are you still just using 0.10.0, does this happen with 0.9.0?
It does happen with 0.9.0 as well:

Code: Select all

[email protected]:/usr/bin$ ./openocd -f ~/Desktop/openocd/custom_configs/ft232h.cfg -f ~/Desktop/openocd/custom_configs/raspi.cfg 
Open On-Chip Debugger 0.9.0 (2018-01-21-13:43)
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
Info : JTAG tap: raspi.arm tap/device found: 0x07b7617f (mfg: 0x0bf, part: 0x7b76, ver: 0x0)
Info : found ARM1176
Info : raspi.arm: hardware has 6 breakpoints, 2 watchpoints
Warn : Scan chain 7 shifted out unexpected address
Warn : Scan chain 7 shifted out unexpected address
Warn : Scan chain 7 shifted out unexpected data
A number of the FTDI parts you get a uart per port,
I don't know but I don't think UART is the problem here anymore...

dwelch67
Posts: 944
Joined: Sat May 26, 2012 5:32 pm

Re: Use a FT232H-Chip to debug Pi 1 B+ via JTag + OpenOCD config

Thu Apr 12, 2018 6:59 pm

telnet is typically 4444, but it is in the file, just need to match what you selected and what you are trying to telnet to.

telnet_port 4444
#gdb_port 0
#tcl_port 0



$ telnet localhost 4444
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
>

server window shows

Info : accepting 'telnet' connection on tcp/4444

getting gdb to run is a whole other research project. you might just get lucky, I have zero use for debuggers like that, stopped trying to even build gdb 15+ years ago...so I cant help you there. the telnet interface is more than adequate (technically a debugger yes, but I dont single step or do breakpoints or anything like that) for anything I need to do...

Return to “Bare metal, Assembly language”

Who is online

Users browsing this forum: No registered users and 4 guests