USB hub used for In System Programming

Did you order that 4-port USB hub because it was almost free but now it’s just sitting in your junk box? Why not turn it into an In System Programmer for AVR chips? [Paul] came up with HUB ISP as an answer to the chicken-or-egg problem we’ve seen with other diy programmers. It uses the data wires from four different USB cables to program AVR chips, enlisting the help of a 74HC00 NAND gate along the way. You do not need to have a programmed microcontroller as all the magic happens on the software end of things. The one caveat is that [Paul’s] method currently only works on Linux machines.

Linux, ftw. Dual-boot every machine you own, people. Unless you want to unplug from windows altogether. It’s up to you. Also, keep in mind that you can boot Linux from a USB thumb drive; I have several distros in my pocket right now: DSL-not, Fedora 10, Ubuntu 10.04 Gnome, Ubuntu 10.04 Netbook remix, Slax. Damn small is pretty sweet, as it can run from as little as 50MB fixed. Hmmm, I believe I already have a quad NAND chip. He’s harvesting +Vcc from two of the ports and GND from the other two; neat idea, as you get up to 200mA with that.

Quoting @PocketBrain “OMFGBBQSAUCE-I HAVE A BONER FOR LINUX, YOU SHOULD TOO!”

Considering you can make a pony prog with 4 resistors and the proper connectors (db25, and idc6 or idc10…), this seems like a waste of perfectly good usb cables, and a NAND gate — not to mention the usb hub. GOOD hubs are hard to come by.

@Ryan Leach: If you write a USB filter driver for Windows it’ll enable you to send anything you wish to your USB controller to process. All the Linux magic (well, almost) is possible with Windows too… it’s just that those who need that magic are using Linux already. ;P

This is one of those projects that are made just for “Look how cool I am and what I can do on Linux, ofcourse”.
For the next one I have an idea: use the leds on the keyboard for output (coupled with some photorezistors and tranzistors) and the click from the mouse for input. That would be awesome! And useless…
Go get 4 rezistors, a serial/parallel connector and you have a working programmer. And you aren’t stuck on linux.

I just don’t see it as much of a challenge to windows, its the same hardware, you can run ring 0, filter drivers etc. libusb is ported and functional, used it a bunch of times before. Not sure why people think its so hard to do this stuff on windows?

I only ported it because of what PocketBrain said, i looked at Pauls site, i see the don’t bother me with windows stuff do it yourself, so everything you need is posted above.

“If you are just getting started with AVR microcontrollers, ISP programming is not a good place to begin, even if you buy a ready made programmer, and certainly not by trying to build your own!”

What the hell kind of crap statement is that? ISP programming is just programming the chip while it’s in the ‘system’ instead of programming the chip then inserting it into the system. Building an ISP programmer isn’t that hard either, it’s very straight forward and there have been plenty of guides for the beginners. It felt like the guy was saying “ISP programming is too complicated for you to understand, so go get an arduino or teensy.”

As hackers we constantly strive to learn how things work, and to share that information freely with each other. The best way to learn is to do: Pick up a soldering iron, build a simple programmer and learn how to work with a microcontroller. Hell, not all of our projects work the first time around, it’s all a learning experience.

The main problem on Windows or Mac is libusb’s lack of usb_detach_kernel_driver_np(). Everything else you did sounds reasonable, but #ifdef’ing out that bit probably kills any hope it would work.

On Linux, that asks the kernel to unload its driver, and then you can claim the interface and send control transfers to it. Windows just doesn’t support this from userland, as far as I’m aware.

There certainly is some way to do this on Windows… I just don’t know how. But the USB-IF compliance test program does something like this, where it takes over a hub and uses it to subject your USB device to all sorts of scenarios to check if it’s USB compliant. Older versions required you to have a PS2 keyboard and mouse, because it apparently switches the entire USB protocol stack for its own. I’ve run it several times, but never seen the source, but you can get the binary for free at http://www.usb.org.

The main problem, even if you’re able to send control transfer to the hub, is if Windows is still using it, the host controller driver will see new device arrivals and try to do lots of stuff. You have to keep the ports disabled to do this kind of I/O.

I really never intended this to be Linux vs Windows thing… I simply use Linux and even when I had this crazy idea, I figured Linux wouldn’t let me detach its driver for the hub and let me have exclusive access, at least not so easily from user space, but it did!

Also, it looks like everyone’s missed the ideas (near end of the page) about improving the timing and somehow using the root hub. If anyone could figure that stuff out, it might be possible to do AVR ISP programming using only 3 USB cables and 3 resistors… no hub and no NAND gates!

@Fili
How is this one of those projects? It states right there in the article what this is good for, if you didn’t read it: its good for getting an AVR programmed to make a proper USB ISP programmer… like the USBasp that was covered the other day.

I agree with the others though, 4 USB cables will probably set you back more than the hub did to start with. Solder direct to the board!

why the hell are people shitting on someone doing something with an object that was never intended?

I could have sworn that doing that was considered a hack. and I am also sure that people are getting out of touch when they say “go order a proper one instead of wasting time making one” Why waste a learning experience by circumventing the opportunity purchasing something already made?

this is a great hack that I would have never thought of myself, I am glad to see people coming up with new ideas, but people that belittle someones ideas have really gotten out of touch with what hacking is all about.

this is good for a couple reasons, ponyprog does not support every chip out there, serial and parallel ports are disappearing from computers.

dumb crap 4 port usb hubs are nothing, usb cables are nothing (plus you can still use the other end or the wire) if your totally flat broke and some office worker drops a box of corporate usb dongles on you as you loiter in the lobby, yes you sir can burn an avr

Osgeld, thanks for making the point I was about to. I’m sick of trying to use an ‘old’ Atom 1.6ghz board with a serial port on it for this sort of stuff, and usb->serial adapters don’t always work properly, especially under 64bit Windows. This would certainly come in handy, as I already have a busted-open 4 port hub here, casing just shattered after falling from my table. I triple-boot all three major OSes, so I could care less if it’s Win32, Carbon/Cocoa/ObjC, or native Linux C code, and I’ll probably play with charliex’s modification to see if/how it works.

For everyone who’s reacted so negatively, generally that HUB ISP is not as good as regular “chicken or egg” programmers, and maybe not even as cheap depending on how you obtain a hub and 4 cables, I added these words to the “Not For Beginners, or Anyone Who Values Their Time” section: (which was originally meant to explain HUB ISP’s limitations, but apparently not as successfully as I’d imagined)

HUB ISP is certainly not a viable replacement for regular “chicken or egg” AVR ISP programmers, which are much faster and more reliable, and maybe even cheaper… eg, Teensy running the ArduinoISP code (yup, another shameless plug).

I am really glad so many of you appreciate this little idea I spent the weekend turning into working code and a nice web page… it’s a hack and I believe the first time anyone’s ever used reset pulses and pullup detection on disabled USB ports to do simple I/O.

omg.. always these stupid people on hackaday. he just made a good hack and people try to make it look bad because it requires linux?! take a look at the source and make it work for windows. and also people complain about the use of “expensive” cables.. solder some wires to an old hub. again its a hack. if you dont want to use it just shut up and respect his work. i think he has done a good job.

very cool… lets see avr dragon 49.00+shiping=$$$
4port hub in junk box free (and taking up space)+4usb cables in junk box(more like 2dozen or so from cheap digi-cams and dead mp3 players)free=priceless… as it was stated this is not go-out-and-buy-something-made-for-that-purpose-a-day.com(by the way that site name is available…for all the wankers) it’s hack-a-day and this is most certainly a hack.