OpenOCD has built-in ftdi support, which is deprecating proprietary ftd2xx library that causing a lot of linkage problems on newer linux distributions.
./openocd-0.7.0/configure --prefix=/home/${USER}/work/toolchain/install --enable-ftdi make all install
There are three major section in configuration file we need to describe.
JTAG adapter interface
Incoming client ports
Target SoC
Let's take the following file as a starting point for JTAG interface configuration
./openocd-0.7.0/tcl/interface/ftdi/flossjtag-noeeprom.cfg
This file may be included AS-IS, besides nSRST configuration, which we are not using.
For the client connection ports, let's define default openocd telnet and gdb ports
telnet_port 4444
gdb_port 8000
For the SoC configuration we need to define CHIPNAME and CPU_TAPID. I have not found IDCODE value in BCM2835 datasheet, so let's run the OpenOCD with invalid TAPID...
Info : JTAG tap: rspi.arm tap/device found: 0x07b7617f (mfg: 0x0bf, part: 0x7b76, ver: 0x0)
Bingo, we found our TAPID (or IDCODE if you like)! Besides that, we need to tell that we have ARM11 core, and the length of ARM11 instruction register, which is 5 bits.
OpenOCD is a server, which may handle a number of connections. We will be utilizing a telnet connection for controlling the target itself and a gdb remote for debugging uploaded programs.
The server itself should be started as root so it can have access to JTAG hardware. Server will be searching local files for uploading in the folder it was started.
sudo /home/${USER}/work/toolchain/install/bin/openocd -f raspberry.cfg
Once the server running, we can try opening a telnet session.
Once started, OpenOCD is listening for incoming telnet connection on the port 4444. Telnet session gives you ability to control OpenOCD directly regardless of GDB connected. Please note that OpenOCD will be searching files in its folder, and it does not matter which folder you are starting telnet from.
telnet localhost 4444
[todo]