libftdi Archives

Subject: Re: [EEPROM branch] Dynamic string offset calculation

From: Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Fri, 24 Sep 2010 11:24:53 +0200
>>>>> "Thomas" == Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx> writes:

    Thomas> Hello Uwe, consider this code:

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

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

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

    Thomas> i = 0x94; k = 127;

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

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

For AM/BM chip with 46 type EEPROM:
0xe = 0x94,
0xf = length,
0x14 = First Byte of the string

This should be the result of the code above and if it is, I think it is
What is wrong is the comment:
   // Addr 0E: Offset of the manufacturer string + 0x80, calculated later
It should be 
// Addr 0E: Offset of the manufacturer string 

But start of the string area is different for different chips (see again

Hope I did get your question...

Uwe Bonnes                bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------

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

Current Thread