I recently had an issue with a bad eeprom in an FT232H module and needed to hand craft an eeprom image from a mix of a generated image and the one which shipped with the board. I don't have a windows system to use the FTDI utility.

I modified ftdi_eeprom to be able to generate the checksum when using the flash_raw option - attached is the patch (against head) if you are interested.

The full details of the issue can be found here: https://forums.adafruit.com/viewtopic.php?f=19&t=64489


Andy


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [email protected]   
--- ftdi_eeprom/main.c	2015-11-20 22:54:56.000000000 +0000
+++ ftdi_eeprom/main.c.new	2016-01-10 23:30:16.430071870 +0000
@@ -216,6 +216,7 @@
         CFG_INT("eeprom_type", 0x00, 0),
         CFG_STR("filename", "", 0),
         CFG_BOOL("flash_raw", cfg_false, 0),
+        CFG_BOOL("flash_setchecksum", cfg_false, 0),
         CFG_BOOL("high_current", cfg_false, 0),
         CFG_INT_CB("cbus0", -1, 0, parse_cbus),
         CFG_INT_CB("cbus1", -1, 0, parse_cbus),
@@ -611,6 +612,20 @@
                     exit (-1);
                 }
 
+		if (cfg_getbool(cfg,"flash_setchecksum"))
+		{
+			uint32_t i;
+			uint16_t crc = 0xaaaa;
+			unsigned char *d8 = eeprom_buf;
+
+			for (i = 0; i < my_eeprom_size - 2; i += 2) {
+				crc ^= d8[i] | (d8[i+1] << 8);
+				crc  = (crc << 1) | (crc >> 15);
+			}
+			eeprom_buf[my_eeprom_size-2]=(crc & 0xff);
+			eeprom_buf[my_eeprom_size-1]=(crc >> 8);
+			printf ("Set checksum to %04x\n",crc);
+		}
                 ftdi_set_eeprom_buf(ftdi, eeprom_buf, my_eeprom_size);
             }
         }


Reply via email to