JTAG Programming Over A Network

[Matt Evans] was running up against the common programming gotcha caused by disappearing parallel ports. For years he had used a JTAG parallel cable when working with FPGAs but recently realized he no longer owned any machines with that interface available. Instead of shelling out $50 for a USB programmer he a programming interface from an old router.What he’s doing is bit-banging using Linux. In this case it’s a router running a version of Linux which makes his setup Internet friendly but this could be done in the same basic manner on any Linux device with enough available I/O to connect to the device you are programming.

18 thoughts on “JTAG Programming Over A Network

  1. @fartface: Bitbanging a USB->IEEE adapter can be *very slow* compared to a real parallel port, due to USB protocol stack overhead and timing.

    This is a nice hack. Though it’s easy enough to find an old computer cheap or free with a parallel port.

  2. I believe that even from Linux on an embedded device, bit-banging will be ludicrously slower than IN/OUT instructions from a contemporary x86. For JTAG, though, these delays might be tolerable. Still I remember a special LPT programmer for Atmel AT89C* microcontrollers offered in their appnote (it had a few latches etc because a lot of pins must be driven simultaneously). That thing worked flawlessly under plain DOS only. Try under Win95 and you’re screwed most of the time.

    A bit more about adapters. I recently needed a plain (TwinAVR-type) programmer and the only capable PC sits in the attic long ago. The idea was to choose PCMCIA, not USB: my older laptop worked flawlessly with a PCMCIA-RS232 adapter (apparently a true 16550 directly wired to the system bus), even a particular timings-demanding software was happy. Eventually I bought a ExpressCard “parallel printer” adapter. Guess what — it didn’t require any drivers and automagically popped up as “USB printing support”! Oh, the irony! The thing is in fact designed for bulk transfer and incapable to return status bit more frequently than a typical printer would provide (and it’s lots of milliseconds).

    Just checked: expresscard.org says “ExpressCard technology uses a simpler connector and eliminates the CardBus controller by using direct connections to PCI-Express and USB ports in the host”. So perhaps I was simply too gullible to miss such an important hint. On second thought, the package says “no IRQ or I/O address required” which is even more suspicious because a classical LPT is unthinkable without these.

  3. Neat hack. I might be in a similar situation soon, wanting to access physical I/O pins from within a virtual machine, so this is good for inspiration.

    saimhe: (re x86 in/out)
    Ludicrously slow? 130K/sec comes out very close to a megabit per second, assuming absolutely zero overhead. That’s not too shabby for bit-banging a serial stream from userland on a 150MHz CPU.

    (It also seems like an awfully even number, so perhaps it’s a sign that the speed is mostly limited by software or the target hardware.)

  4. First time I seen this done over the network but he’s making use of the GPIO pins on the router.

    This could be useful in other ways too if the GPIO pins could flash a jtag.
    It might be possible to make an application that would allow the router to control lights or pumps for control applications.
    Or read sensors they’re GPIO which means they probably could fake an I2C bus.

  5. Nice hack! I weaseled my way out of this problem by buying PCI and PCI express to parallel port cards for the new PCs at home :P

    @Nitory: stealing your idea for personal use :)

  6. Awesome!
    I recently acquired a Digilent Spartan-3E board and was looking at building a JTAG programming interface to save $80. This just saved me a lot of hassle.

  7. Nice!
    I was wanting to do something like this, but different.. I was looking at the source of cblsrv in hopes of bit-banging through a simple microcontroller.

    But at the end of the day, I didn’t feel like figuring out the high-level code structure of cblsrv and I gave up and bought digilent’s XUP-USB-JTAG, which I figured would probably work in Linux since it’s a clone of the official Xilinx cable… it was 60 bucks at the time but the price has gone up since.

    So, cheers for actually finding something else that works!!

  8. Nitori:
    Which reminds me of that one hack of using an old network printer server, with parallel ports, to get network-reachable GPIO. (Was that Sprite_tm? Hmm, I guess not.)

  9. Cheers guys :). @Chris, I built this precisely to get rid of the need for a ‘junk PC’ under the desk — this is a much lower-power & more portable way. (I moved house/country & got rid of the junk.)

    @magetoo, right, I think it’s a little faster than my old P4; the parallel ports are usually on a slow ISA bus (even internally) and it’s IN/OUT that are ludicrously slow. The speed is approximate, measured by hand with a stopwatch while downloading an XCV300E bitstream & rounded down to the nearest 10K/s :) In a simple for() loop test I had a GPIO changing at roughly 60MHz so I’d guess this AR7 can access IO at 1/2 core frequency. A Xilinx bitstream over JTAG experiences a lot of extra bitwiggling overhead, too.

  10. Isn’t this a little overkill? I think a router capable of running linux is more expensive than a simple usb-to-parallel chip from ftdi + microcontroller, or even a PIC with USB (like the 18F4550).
    This is a nice hack, don’t get me wrong, but I wouldn’t crack open my wrt54gl for this…
    Oh, and because we’re on HaD, may I suggest an arduino? :))

  11. @Fili: Not when it’s free ;-) I wouldn’t buy a router to do this, no, but recycled one & saved it from the trash. And you know what you can do with your Arduino >:D (I was looking at an mbed to do this with, tho as you say more expensive than buying a cable.)

Leave a Reply to ColinCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.