libftdi Archives

Subject: Re: EEPROM: calculate user_data_addr

From: Yegor Yefremov <yegorslists@xxxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx, Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
Date: Thu, 3 Aug 2023 11:18:12 +0200
On Tue, Aug 1, 2023 at 11:44 AM Yegor Yefremov
<yegorslists@xxxxxxxxxxxxxx> wrote:
>
> On Mon, Jul 31, 2023 at 1:53 PM Yegor Yefremov
> <yegorslists@xxxxxxxxxxxxxx> wrote:
> >
> > I want to write ca. 25 bytes as user data (my FTDI chips are FT2232,
> > FT4232 and FTX). What is my strategy to calculate the user_data_addr?
> >
> > If I set EEPROM defaults via ftdi_eeprom_initdefaults() providing only
> > the product string. Then I perform ftdi_eeprom_build() and use its
> > return value to calculate the user_data_addr like: eeprom->size -
> > user_area_size
> >
> > But this doesn't work as with 128 byte EEPROM (FT2232/4232), the
> > free_end is 26 and thus I get:
> >
> > "Warning, user data overlaps the strings area!"
> >
> > How should EEWriteUserArea() look like in libftdi1?
> >
> > And what about returning an error instead of printing a warning when
> > the user data overlaps with the strings or generated data?
>
> After adding debug output, I can see that free_start for the
> TYPE_2232C chip is at 0x15 and free_end at 0x16. And this doesn't make
> much sense as it is much smaller than user_area_size value.
>
> According to the Application Note AN_121 [1], the user area starts
> after the SerialNumber string (at least for the 128 bytes EEPROMs,
> 256 and 512 bytes EEPROM have another approach). Unfortunately, I
> still cannot find the user area description for the FT-X series.
>
> FT_000071 for the D2XX.dll describes the following routines handling
> the user area:
>
> FT_EE_UASize()
> FT_EE_UARead()
> FT_EE_UAWrite()
>
> This would be useful to have them in libftdi.
>
> [1] 
> https://www.ftdichip.com/Documents/AppNotes/AN_121_FTDI_Device_EEPROM_User_Area_Usage.pdf
> [2] 
> https://ftdichip.com/wp-content/uploads/2020/08/D2XX_Programmers_GuideFT_000071.pdf

I have sent two patches [1], [2] that fix the issue for me. The
question is, whether we should spare the byte after "output[i &
eeprom_size_mask] = eeprom->is_not_pnp" for better alignment. Variable
naming and return value of eeprom_build() should be also reworked to
correspond to the FTDI's application note.

What do you think about it?

[1] http://developer.intra2net.com/mailarchive/html/libftdi/2023/msg00018.html
[2] http://developer.intra2net.com/mailarchive/html/libftdi/2023/msg00019.html

Yegor

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx

Current Thread