libfx2loader icon indicating copy to clipboard operation
libfx2loader copied to clipboard

LIB:Library for loading and saving Cypress FX2LP firmware

The libfx2loader library allows you to program the Cypress FX2LP chip with new firmware. See http://bit.ly/fx2loader-api for the API docs, and http://bit.ly/fx2loader-ex for example code.

To build, first you need to install the MakeStuff Build Environment (http://bit.ly/makestuff) for your platform, then do:

chris@wotan$ cd makestuff/libs chris@wotan$ ../common/msget.sh libfx2loader # or msgit.sh if you want a local # git repo chris@wotan$ cd libfx2loader chris@wotan$ make deps

Extras in subdirectories: firmware - A minimal firmware implementing EEPROM reads/writes and a simple vendor command.

There is also a command-line utility in a separate project called "fx2loader".

The default FX2LP firmware (i.e with EEPROM isolated) enumerates as VID=0x04B4 (Cypress) and PID=0x8613 (FX2LP), and provides support for loading firmware into RAM. In order to write the EEPROM you need to load a firmware which supports EEPROM writes (e.g the provided firmware) into RAM first.

You can use any file type (.hex/.ihx, .bix or .iic) as a source or destination, and it will be converted if necessary. The EEPROM native format is .iic and the RAM native format is .bix. The conversion between different representations is potentially lossy (e.g there may be some configuration data beyond the end of the I2C records in an EEPROM or .iic file, which will be lost if you convert it to a .hex file).

If you're unsure about the suitability of a new firmware (wherever you got it from), it's a good idea to load it into RAM first to make sure it's not totally broken. Writing bad firmware to EEPROM will brick your device.

If you manage to brick your device, you will need to isolate the EEPROM. Your board may provide a jumper for this purpose. Failing that you will need to cut the SDA track between the FX2LP and the EEPROM, load a good firmware into RAM, reconnect the EEPROM (e.g replace the jumper) and load the good firmware into EEPROM.

Uploading your own SDCC-compiled firmware: Write SDCC-generated I8HEX file to FX2LP's RAM: fx2loader -v 0x04B4 -p 0x8613 firmware.hex Write SDCC-generated I8HEX file to FX2LP's EEPROM (assuming current firmware supports EEPROM writes): fx2loader -v 0x04B4 -p 0x8613 firmware.hex eeprom

Backup and restore the existing firmware: Backup FX2LP's existing 128kbit (16kbyte) EEPROM data: fx2loader -v 0x04B4 -p 0x8613 eeprom:128 backup.iic Restore FX2LP's 128kbit (16kbyte) EEPROM data from backup I2C file (assuming current firmware supports EEPROM writes): fx2loader -v 0x04B4 -p 0x8613 backup.iic eeprom

Convert between .hex files, .bix files and .iic files (file extensions are considered): fx2loader -v 0x04B4 -p 0x8613 myfile.iic myfile.bix