Flash the FTDI eeprom on a Bus Pirate under Linux
The Bus Pirate uses an FTDI USB Chip to provide the USB to serial connection. I have a Bus Pirate V2go with a FT232RL chip which still has the default settings. When I plug it in it is detected as:
ATTRS{idVendor}=="0403"
ATTRS{idProduct}=="6001"
ATTRS{manufacturer}=="FTDI"
ATTRS{product}=="FT232RL USB UART"
ATTRS{serial}=="A123abAc"
This isn’t really a problem, it will work just fine. However, I stumbled across a page about a utility for Macs that can flash the eeprom of the FTDI chip to report different details. On Macs the random looking serial number is used to create a unique /dev/tty name which means it can get confusing if you have more than one FTDI based device plugged in.
I wanted to be able to update the eeprom on my Bus Pirate (and other FTDI based devices). I can’t remember why now but I’m sure there was an important reason. I was using Ubuntu 10.04 64bit and thought it would be useful to document how to do it, especially as I managed to break it — the resolution may help others.
First we need to install the little eeprom flashing utility:
$ sudo apt-get install ftdi-eeprom
Next, create a text file called buspirate.ftdi with the following contents, edit the Bus Pirate version details as required:
vendor_id=0x0403 product_id=0x6001 max_power=0 manufacturer="Dangerous Prototypes" product="Bus Pirate v2go" serial="piratev2go" self_powered=true remote_wakeup=false use_serial=yes filename=buspirate.eeprom
If you are flashing a device other than the Bus Pirate the config values may need to be changed. Consult the man pages of ftdi_eeprom for information on config options and I would recommend getting all the details of your FTDI device before a flash and after, so that you can compare and ensure you only changed the manufacturer, product and serial strings. If you don’t specify some config options then ftdi_eeprom inserts defaults, which may change the device configuration! To probe the device before and after I suggest the following:
$ sudo lsusb -v -d 0x0403:>before.txt $ cat before.txt
Assuming before.txt looks fine, continue to flash it and afterwards:
$ sudo lsusb -v -d 0x0403:>after.txt
Compare the 2 files to make sure the device config wasn’t changed.
Flashing the Bus Pirate
Make sure your Bus Pirate is unplugged and check that there are no other FTDI devices plugged in:
$ lsusb | grep 0403:6001
Assuming you get nothing reported, plug in the Bus Pirate and check again:
$ lsusb | grep 0403:6001 Bus 006 Device 017: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
All looks good, so flash it with your new config:
$ sudo ftdi_eeprom --flash-eeprom buspirate.ftdi FTDI eeprom generator v0.3 (c) Intra2net AG <opensource@intra2net.com> Used eeprom space: 118 bytes FTDI write eeprom: 0 Writing to file: buspirate.eeprom FTDI close: 0
Now unplug and re-plug the Bus Pirate. Check it has changed:
$ udevadm info --attribute-walk -n /dev/ttyUSB0
And you should see in the output the following:
ATTRS{manufacturer}=="Dangerous Prototypes"
ATTRS{product}=="Bus Pirate v2go"
ATTRS{serial}=="piratev2go"
That’s it, you’re done!
I’ve kept the vendorid and productid the same so it will still be detected as a FT232 USB-Serial (UART) IC when you plug it in. You can change those but it may no longer work unless you configure your system to load the FTDI driver for it when it is plugged in etc. If you do change them and find it breaks, read on to find some instructions that may help.
Using ftdi_eeprom to change a non-default vid/pid to the default one
Now, when I was figuring out how to use the ftdi_eeprom program I accidently changed the vendorid and productid to an OpenMoko device whose example I was using. Naturally this meant the device no longer worked properly but no big deal, I thought, I’ll just change it back…
The problem is, the config file contains the vid and pid that you want to change to, and it is also the vid and pid the ftdi_eeprom program searches for. So, if we change the vid/pid in the config file back to the FTDI default 0403/6001 then it won’t find the Bus Pirate since it is no longer using that vid/pid. If it can’t find a device with the vid/pid specified in the config file then it will default to searching for the standard FTDI one of…0403/6001, so it still can’t find our modified Bus Pirate! I looked through the man pages and there seemed no way of changing a vid/pid from a non-default one to another one?!
So I got hold of the source of the program and found a line I could patch:
printf("Retrying with default FTDI id.\n"); i = ftdi_usb_open(&ftdi, 0x0403, 0x6001);
I changed the vid/pid to the one the Bus Pirate was now using and tried to compile it. It needed some dependencies so I got those and tried to compile them. They didn’t like my compiler…and so on. I didn’t want to head down that route and spend ages trying to compile this thing so I thought it would be quicker to patch the binary!
Make a copy of the binary and work on the copy:
$ cp /usr/bin/ftdi_eeprom ./
Open it up in a hex editor (I used GHex). Search for the default vendorid 0403 which, because of the endian, means you have to search for 0304:

It found 2 occurences and to the left of those is 0160 (i.e. the default productid 6001). Update them with the vid and pid the device is currently set to, remembering the endian:

Save it and run the new version:
$ sudo ./ftdi_eeprom --flash-eeprom buspirate.ftdi FTDI eeprom generator v0.3 (c) Intra2net AG <opensource@intra2net.com> Unable to find FTDI devices under given vendor/product id: 0x403/0x6001 Retrying with default FTDI id. Used eeprom space: 118 bytes FTDI write eeprom: 0 Writing to file: buspirate.eeprom FTDI close: 0
This time when it resorted to the search for the default ids it used our new values, found the Bus Pirate and updated it to the default ids specified in the config file. The Bus Pirate now lives to sail another day, phew!
