Programming the Onboard I2C EEPROM
Downloading the firmware to the internal RAM of the EZ-USB device is
a nice thing during development. It gives you increased flexibility and
shorter turnaround cycles when building or debugging the code.
a board is not destined to a single purpose but can serve different
by exchanging the firmware online. This can even be automated when the
systems sees the need for a certain functionality.
All this works fine with a properly configured host in the background
and if the user has the ability to guide its mechanisms. Still there
are scenarios where all this is just bothering. Either because a device
selected to run the same firmware all the time or because there are no
to transfer the firmware into internal RAM. Expecially when a device
be connected to different hosts running different operationg systems or
there is no chance to download directly after the host's system start.
Here, the need arises to place the firmware permanently into a
non-volatile memory getting benefit from the feature that the EZ-USB is
able to load
its RAM from an onboard EEPROM.
The compiled firmware has to be reordered to fit the format which is
expected by the boot-loader. No matter how you program the EEPROM, a
has to take place that results in a structure as specified in the by
Cypress (for details refer to "The
Integrated Circuit Technical Reference Manual" v1.9, section 5.8).
This task is performed by the script create_ezhid_e2.pl. It
takes the compiled firmware in IHEX-format and outputs a reformatted
Run it as
create_ezhid_e2.pl < firmware.ihx > e2_data.ihx
After the preparation step all input data for the programming process
is available. In case you own an E(E)PROM programmer, put in the EEPROM
and load the reformatted ihex-file. This can be annoying and is in fact
not necessary. Just use the EZ-USB to program its onboard EEPROM itself.
The firmware i2c_firm in the tools directory turns the EZ-USB
into an I2C-programmer which receives data via USB and
into the EEPROM. It can read out the EEPROM for test purposes as well
returns the content back to the host computer. Just build the firmware
transfer it to the EZ-USB in the usual way. On the host side there is a
script called eeprom.pl that reads in an ihex-file and sends
data to the board.
eeprom.pl -d /proc/bus/usb/001/011 -w -i e2_data.ihx
will send the content of e2_data.ihx to the specified USB
Single bytes can be written as well:
eeprom.pl -d /proc/bus/usb/001/011 -w -a 0x0200 -l 2 -D
This will place the two bytes 0xaf and 0xfe at address 0x0200 and
in the EEPROM.
To verify that the bytes have been actually written, execute the
eeprom.pl -d /proc/bus/usb/001/011 -r -a 0x0200 -l 2
For all options run eeprom.pl -h or have a look at the script
You will need libusb and
module to access USB devices from userland.
There might be times during debugging when you are confronted with the
that your buggy little firmware hangs the EZ-USB so bad that it is no
possible to download anything to internal RAM. Unplugging the board
help If the firmware resides in the EEPROM. Your only chance to
the troublesome memory content is to disable the EEPROM before the
is powered on to prevent the USB core from boot-loading the firmware.
the EEPROM again, download i2_firm and finally clean at least
first byte. Here you must tweak eeprom.pl and disable I2C
autodetection. Specify the correct bus address and address size. This
because the USB core will store the information that there is no EEPROM
at power-up and autodetection in i2_firm will guess the wrong
Fell free to contact me if you have problems with this.