Pi as an OpenOCD JTAG dongle

I have been looking at problems with our WiFi at home. The Access Point is located in a fairly poor place in terms of radio propagation, so the network is extended over cable, using a second AP to increase coverage. The second AP is running a WRT variant, but it’s not working very well. I have another AP – specifically an old Sky router that I innherited. Unfortunately, it’s not had much in the way of WRT work doing for it. As any person of sound, enquiring mind would do, I decided to have a look inside. There, I discovered what appears to be a UART or JTAG port. I am in the early learning stages of hardware hacking so I thought that this might be a useful starter project.The backstory is important. I have been doing Systems Engineering, Network Engineering, Support, Management and Security (amongst various other things) for over 20 years. I am fluent in Windows, Conversant in Linux and BSD and rusty in Unix. I’m not afraid to poke around under the hood, because I generally know how to undo something. If not, there’s always a backup on hand. I’ve generally steered clear of hardware repairs as it is generally cheaper and quicker to swap out parts rather than replace them. I can solder, I can put the components in a “build kit PCB” together nice and neatly.

I was looking at USB based UART readers as a way to investigate the port on the Sky router. That was when I discovered that the Pi can be used as one of these devices, along with OpenOCD (Open Circuit Debugger), to do exactly that. This will be part one of several on my hardware hacking learning curve. Every article I have read on installing OpenOCD has a mistake (with the current version at least). You can install OpenOCD using apt, though this seems to be a fairly old version.

Getting started

  • Install Raspbian (Latest version) to your SD card
  • Update Raspbian
    • sudo apt-get update && sudo apt-get upgrade -y
  • Install OpenOCD prerequisites
    • apt-get install libtool libusb-dev libusb-1.0 autoconf automake texinfo
  • Download the latest version of OpenOCD (currently 0.10.0)
    • git clone git://git.code.sf.net/p/openocd/code openocd-code

Congratulations. You’re ready to compile.

Compiling OpenOCDxx

  • cd openocd-code
  • ./bootstrap
  • ./configure --enable-BCM2835GPIO --enable-SYSFSGPIO
    • Other articles commonly have all lower-case, and miss the leading – (there are two before each enable statement). Entering the names in lower case does not enable them (try it, and check config.log; your results may vary. It was certainly the case on a Pi3 with Raspbian Jessie and OpenOCD 0.10.0)
  • Other articles list the next step as simply “make”. This is true for the Pi 1, however we can make use of the multiple cores on all other Pi’s to speed up the process. If you have a Pi2 or newer, append “-j4” to use all 4 cores. If you have an Pi1, just run “make”.
    • make -j4
  • Then complete the process, by making the install:
    • make install

And you’ve finished! The next article will be about hooking the GPIO pins up to the target device. Hopefully without breaking anything!

Comments are closed.