|
Just for future reference, might someone encounter the same problem.
I've managed to get it working, It's done as follows:
I've written a HexData object which can read .hex (see description of HEX-format here: http://www.keil.com/support/docs/1584.htm ) and IIC-format (see section 3.4.3 "Serial EEPROM Present, First Byte is 0xC2" in EZ-USB_TRM.pdf). Note that the end of an IIC-file is marked by a "1" as most significant bit in the length-field. (I missed that at first)
This is stored internally as a list of std::vectors to keep the information about the gaps between the data-blocks. (along with each vector I store the address of the 1st item)
This can be "Compressed" by searching for blocks which occupy the "next" address after a block and then concatenate them. When you compress the information, you can search for strings to replace (note the indianess of the strings, which is little-endian, while the length- and address-fields in the hex- and iic-format are big-endian) because they will not be interrupted by an end-of-vector.
After "compression" and replacing the appropriate (wide)strings you'll have to regenerate a IIC-file again to upload to the EEPROM starting at address 0.
The HEX-file must be "interpreted" when writing to RAM. So writing a number of bytes starting at address X must really write at those addresses in RAM. Write to RAM is done using Vendor Request 0xA0.
- first put the 8051 to reset (write '1' to RAM address 0xE600 for the FX2LP).
- write Vend_Ax.hex to the RAM
- clear reset (write '0' to RAM address 0xE600
- write entire IIC-file with own firmware to EEPROM using Vendor Request 0xA9 (for small (<= 256 bytes) EEPROM use 0xA2) starting at address 0
- put 8051 to reset
- write hex of own firmware to RAM using 0xA0
- clear 8051 reset
- cycle port (see CyUSB.pdf "IOCTL_ADAPT_CYCLE_PORT")
Now Windows will find a new device and install a driver for it. This will be an entire new entry when a serial number is being used which is never been seen on that PC.
This can also be used for other purposes which require a temporary firmware, like updating the firmware of a connected FPGA or write to the (or another) EEPROM without write EEPROM-support in your own firmware.
|