libftdi Archives

Subject: [EEPROM branch] Dynamic string offset calculation

From: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Fri, 24 Sep 2010 10:43:36 +0200
Hello Uwe,

consider this code:

int ftdi_eeprom_build(struct ftdi_context *ftdi)
    // Dynamic content
    // Strings start at 0x94 (TYPE_AM, TYPE_BM)
    // 0x96 (TYPE_2232C), 0x98 (TYPE_R) and 0x9a (TYPE_x232H)
    i = 0;
    case TYPE_2232H:
    case TYPE_4232H:
        i += 2;
    case TYPE_R:
        i += 2;
    case TYPE_2232C:
        i += 2;
    case TYPE_AM:
    case TYPE_BM:
        i += 0x94;
    /* Wrap around 0x80 for 128 byte EEPROMS (Internale and 93x46) */
    k = eeprom->size -1;

    // Addr 0E: Offset of the manufacturer string + 0x80, calculated later
    // Addr 0F: Length of manufacturer string
    // Output manufacturer
    output[0x0E] = i;  // calculate offset
    output[i++ & k] = manufacturer_size*2 + 2;

For a FT245BM type chip, the eeprom->size will be 0x80.
This results in 

i = 0x94;
k = 127;

"i++ & k" will result in 0x14. The length of the manufacturer string
is stored in 0x0f, so this is wrong for the BM type chips. Luckily
it will be overwritten later on.

Can you enlighten me why the offset for the "length of the manufacturer 
string descriptor" is calculated dynamically? Atleast for the FT245BM and 
the FT2232C, it's always at 0x0F. Cut'n'paste typo?


libftdi - see for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread