About fx2lafw
At the end of May we released libsigrok 0.1.1. It had various fixes and improvements, but the main reason we released it was to get a release out the door before merging in the work on analog data I’d been doing in another branch.
But there was one major feature in that release which I think deserves a bit more attention. It was the first time we’ve included a driver that communicates with a device which runs firmware we ALSO wrote. This firmware is called fx2lafw, and I think it’s absolutely fantastic.
The all singing, all dancing FX2
Some of the first generation of inexpensive logic analyzers, i.e. within reach for non-megacorporation budgets, were the CWAV USBee SX and the Saleae Logic. That is to say, they’re under $200. But when you look at what’s inside, as we inevitably do, it becomes apparent that there’s really very little there. Essentially, these boards are based on a Cypress EZ-USB FX2LP chip — the FX2, for short — and a small number of components to support it. The FX2 is a generic USB interface chip, based around an 8-bit 8051 microcontroller core. It runs quite slowly, nowhere near enough to keep up with a modern high-speed USB bus. But it has some built-in peripherals which allow it do fully automated transfers from GPIO pins to the USB bus, without ever touching the 8051 core. You basically tell it which pins to sample, and which USB endpoint to send the results to, and off it goes — leaving the CPU core idle. This feature is intended for transferring data from external devices, such as hard disks, onto a USB bus.
A Cypress FX2 chip
But of course that data doesn’t have to come from a device that’s getting clocked to send data to the FX2. It takes whatever appears on the digital I/O pins, which is what a logic analyzer does. So this can be used as a simple single-chip logic analyzer. There’s a bit more to a full product than that, of course — you have to provide some sort of analog frontend, probes, a USB connector, and an enclosure. You’d also have to invest in a website/store, arrange manufacturing, and provide support. But you could sell it without all of that if you really wanted to provide something cheap that will mostly work. Enter the Chinese clones.
If you pare it down to its bare essentials, the FX2 needs an 24MHz oscillator, a small EEPROM chip, a USB connector and a few passives. Connect your own probes to broken-out GPIO pins, and you have a basic logic analyzer. So that’s what happened: various FX2 boards started showing up on Taobao, Alibaba and Ebay. There are well over a dozen different designs, some for as low as $15. Some of the clones appear to be copying other clones.
Writing logic analyzer software is not so quickly done however, as we’ve noticed here at sigrok. These people aren’t exactly going to spend the time and effort to write great software for it; so they just sell it as “Saleae/USBee compatible”, and tell you to go download software from those companies. That’s not only the PC software, but also the firmware for the FX2, which that software talks to. It’s fundamentally wrong, of course. You might make an argument that if a bare-bones FX2 board will do the job, there’s nothing wrong with making them cheap and shovelling them out the door via Ebay. But using somebody else’s firmware and software without permission is not OK.
Doing the right thing
We’ve long supported the Saleae Logic in sigrok of course; it was our very first driver. But we used the Saleae firmware. We couldn’t distribute it legally, so we published a procedure that showed people how to extract the firmware from their own, hopefully legal, driver installation.
That’s fine as it goes, but we thought we could do one better. This is where fx2lafw comes in. It’s firmware for the FX2, written from scratch, that implements the automatic sampling mode. It uses our own protocol, and communicates with our own driver, and is 100% free and open source software. It was very much a team effort: the firmware was written jointly by Uwe Hermann and Joel Holdsworth, and the sigrok driver it talks to is based on my original Saleae driver.
The fx2lafw page on the wiki currently lists some 37 FX2-based devices we know of. We've verified many to work with fx2lafw, but we know the rest will work as well. If you have one that's not listed as 100%, please do try it out and let us know!
Some of the clone makers are already linking to sigrok; we’d like all of them to do that. If and when we get a good logic analyzer GUI for sigrok, we hope they’ll stop the shenanigans altogether. But the most important thing is that you can now have a very inexpensive basic logic analyzer that uses only 100% free software. And that is a good thing indeed.
- Bert Vermeulen's blog
- 18362 reads