+ /* Four bytes of eeprom at 0x20 are purchase year & month in BCD format, with 16bit
+ * complemented checksum; e.g. 2004DFFB = 2020-April.
+ * This helps to identify the age of devices if unknown magic numbers occur.
+ */
+ if ((ret = ctrl_in(sdi, CMD_EEPROM, 0x20, 0, purchase_date_bcd, sizeof(purchase_date_bcd))) != SR_OK) {
+ sr_err("failed to read eeprom purchase_date_bcd");
+ }
+ else {
+ sr_dbg("purchase date: 20%02hx-%02hx", (purchase_date_bcd[0]) & 0x00ff, (purchase_date_bcd[0] >> 8) & 0x00ff);
+ if (purchase_date_bcd[0] != (0x0ffff & ~purchase_date_bcd[1])) {
+ sr_err("purchase date: checksum failure");
+ }
+ }
+
+ /*
+ * There are four known kingst logic analyser devices which use this same usb vid and pid:
+ * LA2016, LA1016 and the older revision of each of these. They all use the same hardware
+ * and the same FX2 mcu firmware but each requires a different fpga bitstream. They are
+ * differentiated by a 'magic' byte within the 8 bytes of EEPROM from address 0x08.
+ * For example;
+ *
+ * magic=0x08
+ * | ~magic=0xf7
+ * | |
+ * 08F7000008F710EF
+ * | |
+ * | ~magic-backup
+ * magic-backup
+ *
+ * It seems that only these magic bytes are used, other bytes shown above are 'don't care'.
+ * Changing the magic byte on newer device to older magic causes OEM software to load
+ * the older fpga bitstream. The device then functions but has channels out of order.
+ * It's likely the bitstreams were changed to move input channel pins due to PCB changes.
+ *
+ * magic 9 == LA1016a using "kingst-la1016a1-fpga.bitstream" (latest v1.3.0 PCB, perhaps others)
+ * magic 8 == LA2016a using "kingst-la2016a1-fpga.bitstream" (latest v1.3.0 PCB, perhaps others)
+ * magic 3 == LA1016 using "kingst-la1016-fpga.bitstream"
+ * magic 2 == LA2016 using "kingst-la2016-fpga.bitstream"
+ *
+ * This was all determined by altering the eeprom contents of an LA2016 and LA1016 and observing
+ * the vendor software actions, either raising errors or loading specific bitstreams.
+ *
+ * Note:
+ * An LA1016 cannot be converted to an LA2016 by changing the magic number - the bitstream
+ * will not authenticate with ic U10, which has different security coding for each device type.
+ */
+
+ if ((ret = ctrl_in(sdi, CMD_EEPROM, 0x08, 0, &buf, sizeof(buf))) != SR_OK) {
+ sr_err("failed to read eeprom device identifier bytes");