Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow 1020 bytes of EEPROM + add standard Arduino EEPROM API #64

Merged
merged 36 commits into from
Mar 8, 2021

Conversation

SuperUserNameMan
Copy link
Contributor

@SuperUserNameMan SuperUserNameMan commented Nov 4, 2020

It was only possible to use 512 bytes of EEPROM despite space for 1024 1020 bytes was reserved.
( Note that the EEPROM controler of the LGT8Fx32p will keep using 2048 bytes from the flash to store these 1024 bytes. )

PS : for more details, see explanations in discussion below IN THE DEDICATED WIKI PAGE

UPDATE 20210208 : PLEASE HELP - MORE TESTING REQUIRED

  • I can only test with LGT8F32p !
  • this new library has not been made compatible nor tested with other LGT MCU variants

TODO ( for me ) :

  • create a wiki page
  • explain consequence of emulated eeprom
  • introduce the C/C++ API
  • introduce the LGT EEPROM object API
  • (re)introduce the Arduino EEPROM object API
  • insert the wiki page into the wiki-home-page
  • retest
  • improved default compatibility for lgt8fx8a/e/d variants

UPDATE 20201106 :

Agreeing with @seisfeld, I took this opportunity to add full support of the standard Arduino EEPROM API.
I've done some test, but you may want to test it more extensively and report eventual bugs.

Note about the old LGT EEPROM API :

By default, EEPROM will use the Arduino EEPROM API.

The old LGT EEPROM API remains available this way :

#define USE_LGT_EEPROM_API
#include <EEPROM.h>

I've updated LGT EEPROM examples.

Note about the standard Arduino EEPROM API :

EEPROM.length() will return the actual available size of the EEPROM, but you can also use the E2END macro to get the last address of the EEPROM[].

E2END was normally defined into <AVR/io.h> as an integer, but is now redefined as (lgt_eeprom_size()-1) so it always match the current size of the emulated EEPROM.

On LGT8F328p, the actual available size of the emulated EEPROM is 1020. (not 1024)
On LGT8F88a, it is 508 (not 512).
On LGT8Fx8e and LGT8Fx8d : TODO

The size of the emulated EEPROM can be changed at your own risks using : void lgt_eeprom_init( uint8_t number_of_1KB_pages );. (increasing the size of the emulated EEPROM will overwrite the bootloader if you use one, or a part of your program depending of its size).

You can also use EEPROM.change_size( uint8_t number_of_1KB_pages ) in the Arduino EEPROM API.

Note : On LGT8Fx8a/e/d it will have no effect.

number_of_1KB_pages theoretical size of the EEPROM actual available bytes occupied space into main Flash memory beginning address into Flash memory
0 0 0 0 n/a
1 1024 1020 2048 0x7800
2 2048 2040 4096 0x7000
4 4096 4080 8192 0x6000
8 8192 8160 16384 0x4000
default 1024 1020 2048 0x7800

Because of the way EEPROM is emulated, if we increase the size of the emulated EEPROM to 2KB, 4KB or 8KB, every lasts 4 bytes of each 1KB blocks will be read only. Because of that, there will be "holes" into the continuous address space.

That's why I added an extra bool real_address_mode = false parameter to the 8bits read/write functions and methods of the C API and of the LGT EEPROM API.

When this parameter is set to false (default), the address will be automatically recalculated to skip each one of these read-only 4 bytes.

So, by default, you don't have to care about these 4bytes holes into your EEPROM address space.

However, you have to keep in mind that because of these holes, the actual size of the available EEPROM is slightly smaller than what one would expect (1020 instead of 1024, 2040 instead of 2048, etc).

To know the available space of the EEPROM, you can use the EEPROM.length() method of the Arduino EEPROM API, or the EEPROM.size() method of the LGT EEPROM API, or the lgt_eeprom_size() of the C/C++ API.

Also, the E2END macro, which was normally defined into <AVR/io.h>, is redefiend to make use of the lgt_eeprom_size() so it will always matches the current size of the emulated EEPROM if you change it using lgt_eeprom_init().

WARNING when changing the size of the emulated EEPROM :

The size of the emulated EEPROM can be changed anytime at run-time using lgt_eepom_init( uint8_t number_of_1KB_pages = 1 ).

However, you have to keep in mind that the EEPROM emulation will take twice the size of the EEPROM from the end of the main Flash memory. This mean that increasing the size of the EEPROM might overwrite the bootloader and a part of your program.

The default bootloader is stored from 0x7400 to 0x77ff.

So, increasing the size of the EEPROM above 1KB will overwrite this bootloader.

The only way to restore the bootloader is using an ISP.

But if you have an ISP, you don't need the bootloader anymore.

It was only possible to use 512 bytes of EEPROM despite space for 1024 bytes were reserved.
( Note that the EEPROM controler of the LGT8Fx32p will reserve 2048 bytes from the flash. )
I removed the EEARH masks so we will be able to change the size of EEPROM at compile time.
The E2PCTL inside the LGT8Fx38p will do the rest.
@dwillmore
Copy link
Collaborator

Do we have a writeup of how the EEPROM works on these chips? It would be nice to keep documenting some of these 'features' that we're running into.

@seisfeld
Copy link
Contributor

seisfeld commented Nov 4, 2020

It was only possible to use 512 bytes of EEPROM despite space for 1024 bytes was reserved.

Is this backed by example code? I'm sorry I don't understand what the EEARH mask is for anyways. 😅

@SuperUserNameMan
Copy link
Contributor Author

SuperUserNameMan commented Nov 4, 2020

Do we have a writeup of how the EEPROM works on these chips?

@dwillmore : I've found information into the databook v1.0.5-english.

They say the EEPROM is stored into the main Flash, and that it will uses twice the size of the EEPROM.
So, if the EEPROM is defined 1024, it will use 2048 from the Flash. (which mean, less space for the sketch).

They say that to write into the fake EEPROM, they first have to erase the full flash page which are 1KB long.
They explain the E2PCTL (the EEPROM controller) uses a technique of "page swapping" to ensure the data will not be lost in case of power failure. So it swaps between two 1Kb flash pages each time we write to the EEPROM.

However, they also explain that this technique require the controller to uses the 2 lasts bytes of each page, which mean that over the 1024 bytes of EEPROM, only 1022 are actually available.

Though, because the flash memory works in 32bits patterns, that's the 4 last bytes that might be unusable, and only 1020 bytes are actually available. <==== edit : I'll have to double check this though.

In the original code, EEARH = ( address >> 8 ) & 0x1; was limiting the addressable space of the EEPROM to 512.
In a first step, I changed EEARH = ( address >> 8 ) & 0x3; so the addressable space was 1024.
However, I noticed that in the EEPROMClass::write32() function, the author did not mask the EEARH, then I remembered that the size of the EEPROM could be set at compile time at runtime (I did not remember how, but I remembered it is possible.), so I removed the bit mask of all the other EEARH = ( address >> 8 ); so we could add a menu into the Arduino IDE to choose the size of the EEPROM later. (edit : I added lgt_eeprom_init(uint8_t number_of_1KB_page); to set it at run-time at our own risk since the bootloader expect the EEPROM to be 1KB.)

If you apply my patch, the actual size of the EEPROM can be confirmed using this example code :

// EDIT : YOU MUST APPLY THE PATCH TO EEPROM.c

#include <EEPROM.h>

void setup()
{
	Serial.begin(9600);
	Serial.println(F("Hello!"));
	
	delay(1000);
	
	//#define DATA(a) (( a )&0xff) // <==== change this to change the data pattern written to the EEPROM
	#define DATA(a) (( (a)>>5 )&0xff) // <==== change this to change the data pattern written to the EEPROM

	
	Serial.println(F("Writing to EEPROM : "));
	for(uint16_t a=0; a<1024; a++)
	{
		byte b = DATA(a);
		Serial.print( a );
		Serial.print(F(":"));
		Serial.print( b );
		EEPROM.write( a, b );
		Serial.println(F("."));
	}
	
	Serial.println(F("Reading from EEPROM : "));
	for(uint16_t a=0; a<1024; a++)
	{
		byte b = DATA(a);
		Serial.print( a );
		Serial.print(F(":"));
		Serial.print( b );
		byte r = EEPROM.read( a );
		if ( b != r )
		{
			Serial.print(F("<=== ERR : "));
			Serial.print( r );
		}
		Serial.println(F("."));
	}
}

void loop()
{
}

EDIT : extra notes regarding the way EEPROM works on LGT8F328p :

how to disable EEPROM so we have the full 32KB of flash for the sketch ?

the fake EEPROM can be disabled by setting bit 6 of the ECCR register to 0.

how to choose the size of the EEPROM ?

the size of the EEPROM can be set using bits 0 and 1 of the ECCR register :

bit 1 bit 0 EEPROM size Programming flash space
0 0 1024 - 2 30KB
0 1 2048 - 4 28KB
1 0 4096 - 8 24KB
1 1 8192 - 16 16KB

Note : the EEPROM size actually available to user is EEPROM size minus 2 bytes per 1KB page.

TODO : verify that when the size of the emulated EEPROM is increased at run-time, the space of the EEPROM does not overlap with the space of the bootloader (I got the bootloader corrupted when I was playing with the size of the EEPROM).

warning : dont confuse ECCR with EECR

@SuperUserNameMan
Copy link
Contributor Author

SuperUserNameMan commented Nov 4, 2020

@seisfeld :

Is this backed by example code? I'm sorry I don't understand what the EEARH mask is for anyways. sweat_smile

Yes, the example above (but you must apply the modification to your libraries/E2PROM/EEPROM.c file indeed.

Also, you can use my version of LarduinoISP with AVRdude in terminal mode to dump flash 0x7800 2048 and see by yourself the two 1k pages of the EEPROM are stored at 0x7800 and 0x7c00.

PS : regarding EEARH, it is the register of the EEPROM controller that stores the high part of the address to which we want to read or write. If we apply a 0x1 mask, the maximum addressable space is limited to 512. If we apply a 0x3 mask, the limit is 1024.

@seisfeld
Copy link
Contributor

seisfeld commented Nov 4, 2020

Thanks for the explanation.

However, they also explain that this technique require the controller to uses the 2 lasts bytes of each page, which mean that over the 1024 bytes of EEPROM, only 1022 are actually available.

So, can we access 1024 bytes (like in your example) or not?

@SuperUserNameMan
Copy link
Contributor Author

SuperUserNameMan commented Nov 4, 2020

So, can we access 1024 bytes (like in your example) or not?

You can read 1024 bytes, but you can write only 1020 bytes. (PS : if you apply my patch indeed ... else 512 rw)

@SuperUserNameMan SuperUserNameMan changed the title allow 1024 bytes of EEPROM allow 1020 bytes of EEPROM Nov 4, 2020
@seisfeld
Copy link
Contributor

seisfeld commented Nov 4, 2020

I tried your example from above. It writes from 0 to 1023 and reads from 0 to 1023. I'm not receiving any ERR. I did not apply the patch. I guess this is not the expected result without the patch right? I should get ERR after 512?

@SuperUserNameMan
Copy link
Contributor Author

SuperUserNameMan commented Nov 4, 2020

I tried your example from above. It writes from 0 to 1023 and reads from 0 to 1023. I'm not receiving any ERR. I did not apply the patch. I guess this is not the expected result without the patch right? I should get ERR after 512?

Yes, if you don't apply the patch, writing from 512 to 1023 will overwrite 0 to 511. (that's because of the 0x1 bitmask in EEPROM.c which keeps the address rolling between 0 and 511).

If you change #define DATA(a) ( ( (a)>>5 ) & 0xff ) in the example above, without the patch, I think you should see errors showing that the first 512 bytes of the EEPROM were overwritten by the last 512 bytes.
With the patch, you should see errors at the 4 last bytes (addr 1019 to 1023).

That's also why some sketches directly ported from ATmega328p will not work if they expect 1024 bytes of EEPROM.

@seisfeld
Copy link
Contributor

seisfeld commented Nov 4, 2020

Confirmed, after the #definechange it writes 0 to 1023 (well it says it does). But on read I get errors from 0 to 511 and it says it read back fine from 512 to 1023 (why is this, when it never wrote there?).

@SuperUserNameMan
Copy link
Contributor Author

SuperUserNameMan commented Nov 4, 2020

Confirmed, after the #definechange it writes 0 to 1023 (well it says it does). But on read I get errors from 0 to 511 and it says it read back fine from 512 to 1023 (why is this, when it never wrote there?).

first, you must understand that i wrote this example for when the patch is applied to show it is possible to actually write from 512 to 1020 or 1022, and that the two last bytes are used by the eeprom controller like it is explained into the datasheet.

If you run this example without the patch, addresses from 512 to 1023 are bitmasked with 0x1FF by the inner code of EEPROM.write() and EEPROM.read(). So when the example does a EEPROM.write( 512, 123 );, this function will actually does EEPROM.write( 512 & 0x1FF, 123 ); and because the result of 512 & 0x1ff is 0, it will become like EEPROM.write( 0, 123 );. Which mean that writing to the EEPROM at addresses from 512 to 1023 will overwrite addresses 0 to 511.
And when you EEPROM.read(512) you actually read from 0 because of the bitmask mentioned. Which means that reading from 512 to 1023 you will actually be reading from 0 to 511.

I can't do better explanation. If you don't understand I'm sorry.

@seisfeld
Copy link
Contributor

seisfeld commented Nov 4, 2020

Makes perfect sense now since the read is also affected the same way as the write. Thanks for the explanation. ✌🏻

@SuperUserNameMan
Copy link
Contributor Author

SuperUserNameMan commented Nov 5, 2020

Well, this afternoon I implemented a EEPROM::size() and EEPROM::set_size() as well as an algorithm to make the address of EEPROM::read()/write() continuous (so we don't have to skip every 2 last bytes of each 1KB page manually).

It was working, except that my bootloader got somehow corrupted.
EDIT : I think it was caused by the LarduinoISP algorithm to unlock the flash : this algo has to erase the first 1KB of the flash to unlock a device after it was powered-down.

@seisfeld
Copy link
Contributor

seisfeld commented Nov 5, 2020

I'd think it would be sufficient when EEPROM size can be set at compile time.

On a different note: Are you also planning adding EEPROM::put() and EEPROM::get()? Currently I'm using something like the following as a band aid:

template <class T> int EEPROM_put(int ee, const T& value)
{
  const byte* p = (const byte*)(const void*)&value;
  unsigned int i;

  for (i = 0; i < sizeof(value); i++) EEPROM.write(ee++, *p++);
  return i;
}

template <class T> int EEPROM_get(int ee, T& value)
{
  byte* p = (byte*)(void*)&value;
  unsigned int i;

  for (i = 0; i < sizeof(value); i++) *p++ = EEPROM.read(ee++);
  return i;
}

Last not least, what about EEPROM::update()? For that I use this (which is, I think, suboptimal):

template <class T> void EEPROM_update(int ee, const T& value)
{
  EEPROM.read(ee) != value ? EEPROM.write(ee, value) : delay(0);
}

@SuperUserNameMan
Copy link
Contributor Author

SuperUserNameMan commented Nov 5, 2020

I'd think it would be sufficient when EEPROM size can be set at compile time.

Agreed.

Though I have absolutely no clue about how to make it possible, mainly because I've seen that the size of the EEPROM is defined into the bootloaders : https://github.com/dbuezas/lgt8fx/search?q=ECCR

That's why I was thinking of making EEPROM::size() and EEPROM::set_size() so that the user could choose the size of the EEPROM according to the size of the compiled sketch.
But seems that it collides with the bootloader anyway ... ( edit : it does : bootloader is stored from 0x7400 to 0x77ff, while a 2KB eeprom will use from 0x7000 to 0x7FFF )

Also, AVRdude expect 1024 of EEPROM since the LGT8F328p pretends to be an ATmega328p.
So many more questions ...

On a different note: Are you also planning adding EEPROM::put() and EEPROM::get()? Currently I'm using something like the following as a band aid:

Yes, the API of the LGT EEPROMClass differs from the standard Arduino EEPROM API.
Maybe we could take this opportunity to add these missing functions.

Access as array EEPROM[] is also missing.

I'll try to add them tomorrow.

@SuperUserNameMan
Copy link
Contributor Author

@seisfeld :

I rewrote the whole EEPROM.h file to incorporate the full standard Arduino EEPROM API.

The LGT EEPROM API will remain available using a #define USE_LGT_EEPROM_API before #incldue <EEPROM.h>.

I'm going to try to update this pull request with these changes ....

@seisfeld
Copy link
Contributor

seisfeld commented Nov 6, 2020

@SuperUserNameMan That sounds awesome!

- add support for standard Arduino EEPROM API
- add C-like lgt_eeprom_xxxx() API
- put everything into a single EEPROM.h header file
- old projects can keep using the original LGT EEPROM API by defining USE_LGT_EEPROM_API
- add comments documenting how EEPROM emulation works with LGT8F328p

TODO : add better support for LGT8F8, LGT8F16, LGT8F328d and LGT8F328e ?
not useful anymore. Everything is into EEPROM.h
@SuperUserNameMan
Copy link
Contributor Author

@SuperUserNameMan That sounds awesome!

I've made some tests, but I think more testing are welcome.

Also, since I'm updating Github using copy/paste, I hope everything is up to date .......


Here is a test of EEPROM[] :

#include <EEPROM.h>

void setup()
{
	Serial.begin(9600);

	while(!Serial);

	Serial.print(F("EEPROM size : ")); Serial.println( EEPROM.size() );

	Serial.println(F("Writing using EEPROM[] = xx : "));

	for( int a=0; a< EEPROM.size(); a++ )
	{
		EEPROM[a] = ((a>>4)&0xFF);

		Serial.print(F("."));

		if ( ( a % 64 ) == 63 ) Serial.println();
	}

	Serial.println("done");


	Serial.println(F("Writing using EEPROM[]++ : "));

	for( int a=0; a< EEPROM.size(); a++ )
	{
		EEPROM[a]++;

		Serial.print(F("."));

		if ( ( a % 64 ) == 63 ) Serial.println();
	}

	Serial.println("done");

	Serial.println(F("Reading using --EEPROM[] : "));
	int err = 0;

	for( int a=0; a< EEPROM.size(); a++ )
	{
		if ( (--EEPROM[a]) == ((a>>4)&0xFF) )
		{
			Serial.print(F("."));
		}
		else
		{
			Serial.print(F("!"));
			err++;
		}

		if ( ( a % 64 ) == 63 ) Serial.println();
	}

	if ( err )
	{
		Serial.print("Errors : ");
		Serial.println( err );
	}
	else
	{
		Serial.println("OK");
	}

}

void loop()
{
}

@SuperUserNameMan SuperUserNameMan changed the title allow 1020 bytes of EEPROM allow 1020 bytes of EEPROM + add standard Arduino EEPROM API Nov 6, 2020
@LaZsolt
Copy link
Collaborator

LaZsolt commented Feb 22, 2021

Fail.

I tried to upload a simple blink skech before the EEPROM test, but brick the broard. Not working any more. And this is the second what I ruined. No effect on RESET or RESET with power on. LED lighting with half brightness. Amen.

@SuperUserNameMan
Copy link
Contributor Author

Fail.

I tried to upload a simple blink skech before the EEPROM test, but brick the broard. Not working any more. And this is the second what I ruined. No effect on RESET or RESET with power on. LED lighting with half brightness. Amen.

The Blink sketch brick your board ? or the EEPROM sketch ?

@dbuezas
Copy link
Owner

dbuezas commented Feb 23, 2021

but brick the board.
RIP. Good that these are so cheap. Can ISP fix it?

BTW, there is a donations function in github, we could activate it specifically for the contributors to get 10 boards to brick while developing.

@5chufti
Copy link

5chufti commented Feb 23, 2021

so there are at least two possibilities: either a) something killed the bootloader and the half brightness LED is just due to the code going hay-wire or b) some important initialisation parameters (fuses?) might be located in "eeprom" ...

@LaZsolt
Copy link
Collaborator

LaZsolt commented Feb 23, 2021

@SuperUserNameMan

The Blink sketch brick my board. After this happened, I tried to find more information about this red Wemos XI 1.0.0 board, but I found almost nothing. Strange thing is, when I view on Aliexpress a few sellers, all of these boards has no feedback at all. Only at one seller, in the Question section find this:
Can not upload to charge a single program
Does not work
If there is no loader in the board, then it is necessary to connect with the pins near the reset button and with the help of a purmator (arduino) load. Purmator maybe mean a programmer.
I have a few boards come without bootloader

So my idea is most of the the boards is a scam or without bootloader.
But if the chip are without bootloader, why it did blinking like a bootloader do?

@LaZsolt
Copy link
Collaborator

LaZsolt commented Feb 23, 2021

@dbuezas

Can ISP fix it?

I think ISP can not fix it. I tried to powerig up, while RESET was hold down, but the LED was lighting half bright while the RESET still pressed down. So it is dead.

I already ordered a Massduino nano.

@dbuezas
Copy link
Owner

dbuezas commented Feb 23, 2021

Oh wow... maybe it internally shorted the pins that are connected to 2 ports.

@SuperUserNameMan
Copy link
Contributor Author

@LaZsolt : I see the XI board has a place to solder external oscillator. Could it be an issue with thedefault clock source or the clock speed ?

if you have a spare Wemos XI, maybe you could try the official SDK to see if it works better ...

@SuperUserNameMan
Copy link
Contributor Author

@5chufti :

b) some important initialisation parameters (fuses?) might be located in "eeprom" ...

F88-A uses the last 8 bytes of its 512 eeprom as fuses.

But Fx8-D datasheet make no mention of fuses (熔丝).

@SuperUserNameMan SuperUserNameMan marked this pull request as ready for review March 3, 2021 12:47
@SuperUserNameMan
Copy link
Contributor Author

@dbuezas : I think it's ready for review.

I documented everything in the wiki.

I trried to update the readme.md like you mentioned, with a "in next release : Arduino EEPROM API", but I failed : Github wanted me to make a separate pull requesst, so I let you do that if you want.

Regarding compatibility with LGT8Fx8-D and 88-D : I've done my theoretical best, but still not TESTED.

@dbuezas
Copy link
Owner

dbuezas commented Mar 8, 2021

Wow @SuperUserNameMan. Just Wow.

@dbuezas dbuezas merged commit dbf35c5 into dbuezas:master Mar 8, 2021
dbuezas added a commit that referenced this pull request Mar 8, 2021
added mention to standard Arduino EEPROM API by SuperUserNameMan in #64
@youxiaojie
Copy link

@LaZsolt : that's very nice of you ! thanks !

Could you compile without errors to F328D?

YES.

And could you compile without errors to --> F88-D <-- ?

NO. because of #108

I could test this EEPROM library on a Wemos XI red board with F328D, if you give me a link to your test program.

I added a "test" sketch into examples : https://github.com/SuperUserNameMan/lgt8fx/tree/master/lgt8f/libraries/E2PROM/examples

Look at the readme to see what to expect.

And please, update the EEPROM library, because i've just debugged it !

On 328-P, the test should take 1 minute to complete.

On 328-D, it should be a little longer because the SWM mode is emulated using simple lgt_eeprom_write_block() (there is no SWM mode on 328-D).

Thanks ! I can't wait to see the result.
If you have question, just ask.

is eeprom ok for 328d?I can help you to test{only in 1020 bytes, no isp}.now I found it has 512 limit in 1.06 version with eeprom demo.the addr is reset to zero after 511. if I use your new code I must pay attention 1020 address limits if I dont wannt to destroy bootloader?

@SuperUserNameMan
Copy link
Contributor Author

@youxiaojie :

is eeprom ok for 328d?

The new EEPROM library still needs tests for 328d.

But there might be an other unrelated bug with 328d : @LaZsolt and @jg1uaa mentioned issues when uploading the "Blink test" example to 328d.

I can help you to test{only in 1020 bytes, no isp}.now I found it has 512 limit in 1.06 version with eeprom demo.the addr is reset to zero after 511. if I use your new code I must pay attention 1020 address limits if I dont wannt to destroy bootloader?

With the new code, by default, you will be limited to 1020 bytes.
If you write after 1019, it will be ignored. (nothing will happen).
If you read after 1019, it will return 0.

The bootloader will be damaged ONLY if you increase the size of the EEPROM using lgt_eeprom_init() (see documentation here ), and you will need an ISP to restore the bootloader.

But if you stick to default, there is nothing to worry about. (except maybe a bug into the new code).

@youxiaojie
Copy link

youxiaojie commented Apr 1, 2021

a bland new, first time do not why success

328D (rare) detected

lgt_eeprom_size( true  ) = 1024

lgt_eepro328D (rare) detected
lgt_eeprom_size( true  ) = 1024
lgt_eeprom_size( false ) = 1020
EEPROM.length()          = 1020
EEPROM E2END             = 1019
--------
Writing using EEPROM[] = xx : 
FC.B2.4A.9C.96.A6.49.B6.CF.CF.28.05.E8.A1.A6.BA.63.21.72.B4.67.98.98.37.67.11.86.F8.3F.C7.8A.F6.7E.54.26.DF.98.89.DB.43.70.5B.F5.2E.ED.3A.2B.43.2A.2B.91.11.E5.EB.F3.C1.76.D5.9D.0F.18.F8.44.7A.
33.F6.54.99.AD.74.8B.62.E5.08.BC.45.06.60.9D.C7.D0.A1.84.AB.3D.2C.3E.E7.BA.7E.A3.0C.8A.06.74.75.75.3F.E6.C0.6F.84.D7.21.5D.41.82.FC.4C.DE.D2.20.63.FF.A5.C6.D0.93.69.E9.AA.AF.96.9C.26.6A.77.8F.
CE.96.DE.FE.46.AF.1E.4F.19.B6.0A.90.BA.B5.50.3A.02.16.8D.A6.5D.34.53.73.39.6D.FC.97.06.53.74.BE.58.FA.AC.19.92.1C.BB.A6.2C.01.F2.8D.53.15.82.95.37.FF.0B.24.6B.9E.91.DE.92.4E.4C.6A.03.FB.74.95.
D0.47.5B.97.57.83.AC.72.8E.79.4E.D2.6D.E4.01.1A.56.9C.F9.F1.BA.27.CA.DC.13.68.BC.89.72.57.00.05.17.68.B7.7E.BF.CA.D4.11.7D.45.3B.17.AB.E9.F1.70.25.86.D2.F9.AF.A9.CD.3D.95.29.39.C6.E8.B1.14.8D.
AC.F7.71.A7.A3.0F.77.12.75.FD.5D.42.5C.40.3A.C7.D5.AE.B4.02.13.CF.81.93.ED.8B.19.06.4F.4D.B3.53.1F.41.F1.3F.B3.0B.DA.FF.65.5E.08.90.CB.C5.7B.38.08.C4.A3.8E.9C.E0.79.78.F2.5E.DF.E7.67.DF.28.FE.
4D.AE.3B.42.1E.80.B9.58.05.E7.AB.6A.5A.BC.43.59.B0.8E.68.58.66.DB.05.AA.55.A2.A4.57.85.58.DF.EC.0A.3C.20.5E.BA.6B.A9.0B.EB.D8.0D.60.47.16.F6.A2.B7.60.71.FB.1E.2B.E8.23.F0.44.A6.B6.36.7A.C0.CF.
F0.78.79.DE.7F.C1.FE.FB.AE.44.00.4F.F0.7B.67.93.75.3D.DA.9D.4B.13.F1.C3.CD.04.52.FF.06.83.53.F8.9C.8B.27.2A.AB.96.62.75.EA.78.F0.DD.AB.75.88.2C.90.9A.FF.F3.84.4B.F8.3C.89.3F.D1.BD.41.EC.79.FB.
7B.89.E2.1E.1B.17.CC.B8.C2.A6.B7.79.EF.10.68.6E.AC.CB.5F.5C.42.2D.5C.35.9A.05.50.6B.0B.96.2F.70.B0.74.64.5F.64.BE.B3.DA.AB.B1.71.D7.AB.8F.0D.FB.3F.3C.86.5A.72.50.9B.09.9B.EF.A0.56.0D.75.91.4A.
86.7E.F1.D4.F0.0A.4A.2E.69.41.95.F3.DD.C7.99.F9.31.CC.F9.C0.C4.6A.46.29.2D.F6.53.47.CA.A1.68.77.B6.DC.97.91.45.83.26.F1.DA.52.8C.9C.8E.2E.04.5E.82.91.79.7C.EC.42.54.8D.AC.89.9A.78.A9.34.34.FE.
A2.82.C9.7E.5C.ED.12.25.60.1F.78.07.89.F4.91.7B.11.CE.75.F1.50.1C.97.6D.30.68.A9.47.33.96.10.1D.43.EA.36.D5.EA.D1.77.CE.E6.17.2F.B3.3C.74.5E.71.D1.FB.FC.12.15.13.21.4F.B0.E1.1A.C9.39.42.C9.D1.
1F.62.33.21.73.1E.F1.E2.64.04.17.DA.27.E1.C1.45.14.EE.A7.81.32.25.EB.77.07.4F.DC.9D.46.B6.07.65.B1.1C.7D.C7.52.BE.FA.96.29.20.C5.B6.9D.E2.06.93.98.3D.D7.40.39.8A.C8.D3.5C.E2.FF.44.24.47.1D.1D.
E7.A8.AF.64.CD.2D.91.8F.33.2E.84.2B.73.EA.16.56.31.51.1A.4C.64.FD.2C.0E.EF.CC.93.63.C3.D0.A6.AD.86.27.20.26.09.AA.F0.95.79.C6.A1.DF.1E.A0.65.9C.58.B2.D7.FB.51.6C.B5.DD.0D.08.14.35.84.03.DE.2C.
EA.73.C2.C3.25.C3.B6.14.68.25.47.BF.EC.F6.DA.9D.83.EC.F1.EA.6B.C9.5A.18.C5.A2.92.DF.A3.FC.1C.B4.6B.DD.70.32.63.90.57.7B.AC.9A.61.94.7B.54.B6.E6.BF.5F.B0.35.CD.20.06.F0.68.DD.16.5A.52.76.A8.C2.
C1.F0.86.4F.B0.1F.2E.1D.06.94.4A.42.8A.B2.95.38.98.F2.60.56.DA.C6.BE.66.A7.27.DD.C9.B6.78.59.7A.0E.93.3A.A0.E0.C1.72.6D.44.8E.20.73.FE.A1.9A.9F.0A.F4.0D.14.F1.E3.A7.C4.F0.D8.90.44.44.D1.F3.D2.
08.E7.96.A8.D0.16.39.3A.D0.9A.E6.82.DB.4A.39.AF.4B.BB.3B.EC.D1.83.E3.C7.88.BA.FF.43.8C.44.00.91.03.B9.AE.97.3E.79.56.59.B8.35.69.F7.B0.0F.F5.5D.44.39.95.3D.A8.82.F3.0C.2A.B0.06.CB.1F.82.50.D7.
73.E1.74.41.17.8D.CA.2B.6B.DB.5B.B9.FD.74.BC.97.CE.F2.DC.17.C5.45.D8.15.CA.84.9F.D1.67.86.85.CB.F0.5B.C0.CE.35.46.35.6B.C3.65.B2.CA.49.28.E3.8B.FA.0B.8F.81.6C.A0.B2.87.36.DD.C4.9B.done
--------
Testing EEPROM[]++ : 
FD.B3.4B.9D.97.A7.4A.B7.D0.D0.29.06.E9.A2.A7.BB.64.22.73.B5.68.99.99.38.68.12.87.F9.40.C8.8B.F7.7F.55.27.E0.99.8A.DC.44.71.5C.F6.2F.EE.3B.2C.44.2B.2C.92.12.E6.EC.F4.C2.77.D6.9E.10.19.F9.45.7B.
34.F7.55.9A.AE.75.8C.63.E6.09.BD.46.07.61.9E.C8.D1.A2.85.AC.3E.2D.3F.E8.BB.7F.A4.0D.8B.07.75.76.76.40.E7.C1.70.85.D8.22.5E.42.83.FD.4D.DF.D3.21.64.00.A6.C7.D1.94.6A.EA.AB.B0.97.9D.27.6B.78.90.
CF.97.DF.FF.47.B0.1F.50.1A.B7.0B.91.BB.B6.51.3B.03.17.8E.A7.5E.35.54.74.3A.6E.FD.98.07.54.75.BF.59.FB.AD.1A.93.1D.BC.A7.2D.02.F3.8E.54.16.83.96.38.00.0C.25.6C.9F.92.DF.93.4F.4D.6B.04.FC.75.96.
D1.48.5C.98.58.84.AD.73.8F.7A.4F.D3.6E.E5.02.1B.57.9D.FA.F2.BB.28.CB.DD.14.69.BD.8A.73.58.01.06.18.69.B8.7F.C0.CB.D5.12.7E.46.3C.18.AC.EA.F2.71.26.87.D3.FA.B0.AA.CE.3E.96.2A.3A.C7.E9.B2.15.8E.
AD.F8.72.A8.A4.10.78.13.76.FE.5E.43.5D.41.3B.C8.D6.AF.B5.03.14.D0.82.94.EE.8C.1A.07.50.4E.B4.54.20.42.F2.40.B4.0C.DB.00.66.5F.09.91.CC.C6.7C.39.09.C5.A4.8F.9D.E1.7A.79.F3.5F.E0.E8.68.E0.29.FF.
4E.AF.3C.43.1F.81.BA.59.06.E8.AC.6B.5B.BD.44.5A.B1.8F.69.59.67.DC.06.AB.56.A3.A5.58.86.59.E0.ED.0B.3D.21.5F.BB.6C.AA.0C.EC.D9.0E.61.48.17.F7.A3.B8.61.72.FC.1F.2C.E9.24.F1.45.A7.B7.37.7B.C1.D0.
F1.79.7A.DF.80.C2.FF.FC.AF.45.01.50.F1.7C.68.94.76.3E.DB.9E.4C.14.F2.C4.CE.05.53.00.07.84.54.F9.9D.8C.28.2B.AC.97.63.76.EB.79.F1.DE.AC.76.89.2D.91.9B.00.F4.85.4C.F9.3D.8A.40.D2.BE.42.ED.7A.FC.
7C.8A.E3.1F.1C.18.CD.B9.C3.A7.B8.7A.F0.11.69.6F.AD.CC.60.5D.43.2E.5D.36.9B.06.51.6C.0C.97.30.71.B1.75.65.60.65.BF.B4.DB.AC.B2.72.D8.AC.90.0E.FC.40.3D.87.5B.73.51.9C.0A.9C.F0.A1.57.0E.76.92.4B.
87.7F.F2.D5.F1.0B.4B.2F.6A.42.96.F4.DE.C8.9A.FA.32.CD.FA.C1.C5.6B.47.2A.2E.F7.54.48.CB.A2.69.78.B7.DD.98.92.46.84.27.F2.DB.53.8D.9D.8F.2F.05.5F.83.92.7A.7D.ED.43.55.8E.AD.8A.9B.79.AA.35.35.FF.
A3.83.CA.7F.5D.EE.13.26.61.20.79.08.8A.F5.92.7C.12.CF.76.F2.51.1D.98.6E.31.69.AA.48.34.97.11.1E.44.EB.37.D6.EB.D2.78.CF.E7.18.30.B4.3D.75.5F.72.D2.FC.FD.13.16.14.22.50.B1.E2.1B.CA.3A.43.CA.D2.
20.63.34.22.74.1F.F2.E3.65.05.18.DB.28.E2.C2.46.15.EF.A8.82.33.26.EC.78.08.50.DD.9E.47.B7.08.66.B2.1D.7E.C8.53.BF.FB.97.2A.21.C6.B7.9E.E3.07.94.99.3E.D8.41.3A.8B.C9.D4.5D.E3.00.45.25.48.1E.1E.
E8.A9.B0.65.CE.2E.92.90.34.2F.85.2C.74.EB.17.57.32.52.1B.4D.65.FE.2D.0F.F0.CD.94.64.C4.D1.A7.AE.87.28.21.27.0A.AB.F1.96.7A.C7.A2.E0.1F.A1.66.9D.59.B3.D8.FC.52.6D.B6.DE.0E.09.15.36.85.04.DF.2D.
EB.74.C3.C4.26.C4.B7.15.69.26.48.C0.ED.F7.DB.9E.84.ED.F2.EB.6C.CA.5B.19.C6.A3.93.E0.A4.FD.1D.B5.6C.DE.71.33.64.91.58.7C.AD.9B.62.95.7C.55.B7.E7.C0.60.B1.36.CE.21.07.F1.69.DE.17.5B.53.77.A9.C3.
C2.F1.87.50.B1.20.2F.1E.07.95.4B.43.8B.B3.96.39.99.F3.61.57.DB.C7.BF.67.A8.28.DE.CA.B7.79.5A.7B.0F.94.3B.A1.E1.C2.73.6E.45.8F.21.74.FF.A2.9B.A0.0B.F5.0E.15.F2.E4.A8.C5.F1.D9.91.45.45.D2.F4.D3.
09.E8.97.A9.D1.17.3A.3B.D1.9B.E7.83.DC.4B.3A.B0.4C.BC.3C.ED.D2.84.E4.C8.89.BB.00.44.8D.45.01.92.04.BA.AF.98.3F.7A.57.5A.B9.36.6A.F8.B1.10.F6.5E.45.3A.96.3E.A9.83.F4.0D.2B.B1.07.CC.20.83.51.D8.
74.E2.75.42.18.8E.CB.2C.6C.DC.5C.BA.FE.75.BD.98.CF.F3.DD.18.C6.46.D9.16.CB.85.A0.D2.68.87.86.CC.F1.5C.C1.CF.36.47.36.6C.C4.66.B3.CB.4A.29.E4.8C.FB.0C.90.82.6D.A1.B3.88.37.DE.C5.9C.done
--------
Testing --EEPROM[] : 
FC.B2.4A.9C.96.A6.49.B6.CF.CF.28.05.E8.A1.A6.BA.63.21.72.B4.67.98.98.37.67.11.86.F8.3F.C7.8A.F6.7E.54.26.DF.98.89.DB.43.70.5B.F5.2E.ED.3A.2B.43.2A.2B.91.11.E5.EB.F3.C1.76.D5.9D.0F.18.F8.44.7A.
33.F6.54.99.AD.74.8B.62.E5.08.BC.45.06.60.9D.C7.D0.A1.84.AB.3D.2C.3E.E7.BA.7E.A3.0C.8A.06.74.75.75.3F.E6.C0.6F.84.D7.21.5D.41.82.FC.4C.DE.D2.20.63.FF.A5.C6.D0.93.69.E9.AA.AF.96.9C.26.6A.77.8F.
CE.96.DE.FE.46.AF.1E.4F.19.B6.0A.90.BA.B5.50.3A.02.16.8D.A6.5D.34.53.73.39.6D.FC.97.06.53.74.BE.58.FA.AC.19.92.1C.BB.A6.2C.01.F2.8D.53.15.82.95.37.FF.0B.24.6B.9E.91.DE.92.4E.4C.6A.03.FB.74.95.
D0.47.5B.97.57.83.AC.72.8E.79.4E.D2.6D.E4.01.1A.56.9C.F9.F1.BA.27.CA.DC.13.68.BC.89.72.57.00.05.17.68.B7.7E.BF.CA.D4.11.7D.45.3B.17.AB.E9.F1.70.25.86.D2.F9.AF.A9.CD.3D.95.29.39.C6.E8.B1.14.8D.
AC.F7.71.A7.A3.0F.77.12.75.FD.5D.42.5C.40.3A.C7.D5.AE.B4.02.13.CF.81.93.ED.8B.19.06.4F.4D.B3.53.1F.41.F1.3F.B3.0B.DA.FF.65.5E.08.90.CB.C5.7B.38.08.C4.A3.8E.9C.E0.79.78.F2.5E.DF.E7.67.DF.28.FE.
4D.AE.3B.42.1E.80.B9.58.05.E7.AB.6A.5A.BC.43.59.B0.8E.68.58.66.DB.05.AA.55.A2.A4.57.85.58.DF.EC.0A.3C.20.5E.BA.6B.A9.0B.EB.D8.0D.60.47.16.F6.A2.B7.60.71.FB.1E.2B.E8.23.F0.44.A6.B6.36.7A.C0.CF.
F0.78.79.DE.7F.C1.FE.FB.AE.44.00.4F.F0.7B.67.93.75.3D.DA.9D.4B.13.F1.C3.CD.04.52.FF.06.83.53.F8.9C.8B.27.2A.AB.96.62.75.EA.78.F0.DD.AB.75.88.2C.90.9A.FF.F3.84.4B.F8.3C.89.3F.D1.BD.41.EC.79.FB.
7B.89.E2.1E.1B.17.CC.B8.C2.A6.B7.79.EF.10.68.6E.AC.CB.5F.5C.42.2D.5C.35.9A.05.50.6B.0B.96.2F.70.B0.74.64.5F.64.BE.B3.DA.AB.B1.71.D7.AB.8F.0D.FB.3F.3C.86.5A.72.50.9B.09.9B.EF.A0.56.0D.75.91.4A.
86.7E.F1.D4.F0.0A.4A.2E.69.41.95.F3.DD.C7.99.F9.31.CC.F9.C0.C4.6A.46.29.2D.F6.53.47.CA.A1.68.77.B6.DC.97.91.45.83.26.F1.DA.52.8C.9C.8E.2E.04.5E.82.91.79.7C.EC.42.54.8D.AC.89.9A.78.A9.34.34.FE.
A2.82.C9.7E.5C.ED.12.25.60.1F.78.07.89.F4.91.7B.11.CE.75.F1.50.1C.97.6D.30.68.A9.47.33.96.10.1D.43.EA.36.D5.EA.D1.77.CE.E6.17.2F.B3.3C.74.5E.71.D1.FB.FC.12.15.13.21.4F.B0.E1.1A.C9.39.42.C9.D1.
1F.62.33.21.73.1E.F1.E2.64.04.17.DA.27.E1.C1.45.14.EE.A7.81.32.25.EB.77.07.4F.DC.9D.46.B6.07.65.B1.1C.7D.C7.52.BE.FA.96.29.20.C5.B6.9D.E2.06.93.98.3D.D7.40.39.8A.C8.D3.5C.E2.FF.44.24.47.1D.1D.
E7.A8.AF.64.CD.2D.91.8F.33.2E.84.2B.73.EA.16.56.31.51.1A.4C.64.FD.2C.0E.EF.CC.93.63.C3.D0.A6.AD.86.27.20.26.09.AA.F0.95.79.C6.A1.DF.1E.A0.65.9C.58.B2.D7.FB.51.6C.B5.DD.0D.08.14.35.84.03.DE.2C.
EA.73.C2.C3.25.C3.B6.14.68.25.47.BF.EC.F6.DA.9D.83.EC.F1.EA.6B.C9.5A.18.C5.A2.92.DF.A3.FC.1C.B4.6B.DD.70.32.63.90.57.7B.AC.9A.61.94.7B.54.B6.E6.BF.5F.B0.35.CD.20.06.F0.68.DD.16.5A.52.76.A8.C2.
C1.F0.86.4F.B0.1F.2E.1D.06.94.4A.42.8A.B2.95.38.98.F2.60.56.DA.C6.BE.66.A7.27.DD.C9.B6.78.59.7A.0E.93.3A.A0.E0.C1.72.6D.44.8E.20.73.FE.A1.9A.9F.0A.F4.0D.14.F1.E3.A7.C4.F0.D8.90.44.44.D1.F3.D2.
08.E7.96.A8.D0.16.39.3A.D0.9A.E6.82.DB.4A.39.AF.4B.BB.3B.EC.D1.83.E3.C7.88.BA.FF.43.8C.44.00.91.03.B9.AE.97.3E.79.56.59.B8.35.69.F7.B0.0F.F5.5D.44.39.95.3D.A8.82.F3.0C.2A.B0.06.CB.1F.82.50.D7.
73.E1.74.41.17.8D.CA.2B.6B.DB.5B.B9.FD.74.BC.97.CE.F2.DC.17.C5.45.D8.15.CA.84.9F.D1.67.86.85.CB.F0.5B.C0.CE.35.46.35.6B.C3.65.B2.CA.49.28.E3.8B.FA.0B.8F.81.6C.A0.B2.87.36.DD.C4.9B.OK
--------

Testing lgt_eeprom_write_block() :
Writing 512 bytes, please wait ...done.
--------

Testing lgt_eeprom_read_block() :
Reading and verifying 512 bytes ...
OK
--------

Testing lgt_eeprom_write32() :
Writing ...done.
--------

Testing lgt_eeprom_read32() :
Reading ...
OK
--------

Testing lgt_eeprom_writeSWM() :
Generating 512 bytes buffer ...
FC.B2.4A.9C.96.A6.49.B6.CF.CF.28.05.E8.A1.A6.BA.63.21.72.B4.67.98.98.37.67.11.86.F8.3F.C7.8A.F6.7E.54.26.DF.98.89.DB.43.70.5B.F5.2E.ED.3A.2B.43.2A.2B.91.11.E5.EB.F3.C1.76.D5.9D.0F.18.F8.44.7A.
33.F6.54.99.AD.74.8B.62.E5.08.BC.45.06.60.9D.C7.D0.A1.84.AB.3D.2C.3E.E7.BA.7E.A3.0C.8A.06.74.75.75.3F.E6.C0.6F.84.D7.21.5D.41.82.FC.4C.DE.D2.20.63.FF.A5.C6.D0.93.69.E9.AA.AF.96.9C.26.6A.77.8F.
CE.96.DE.FE.46.AF.1E.4F.19.B6.0A.90.BA.B5.50.3A.02.16.8D.A6.5D.34.53.73.39.6D.FC.97.06.53.74.BE.58.FA.AC.19.92.1C.BB.A6.2C.01.F2.8D.53.15.82.95.37.FF.0B.24.6B.9E.91.DE.92.4E.4C.6A.03.FB.74.95.
D0.47.5B.97.57.83.AC.72.8E.79.4E.D2.6D.E4.01.1A.56.9C.F9.F1.BA.27.CA.DC.13.68.BC.89.72.57.00.05.17.68.B7.7E.BF.CA.D4.11.7D.45.3B.17.AB.E9.F1.70.25.86.D2.F9.AF.A9.CD.3D.95.29.39.C6.E8.B1.14.8D.
AC.F7.71.A7.A3.0F.77.12.75.FD.5D.42.5C.40.3A.C7.D5.AE.B4.02.13.CF.81.93.ED.8B.19.06.4F.4D.B3.53.1F.41.F1.3F.B3.0B.DA.FF.65.5E.08.90.CB.C5.7B.38.08.C4.A3.8E.9C.E0.79.78.F2.5E.DF.E7.67.DF.28.FE.
4D.AE.3B.42.1E.80.B9.58.05.E7.AB.6A.5A.BC.43.59.B0.8E.68.58.66.DB.05.AA.55.A2.A4.57.85.58.DF.EC.0A.3C.20.5E.BA.6B.A9.0B.EB.D8.0D.60.47.16.F6.A2.B7.60.71.FB.1E.2B.E8.23.F0.44.A6.B6.36.7A.C0.CF.
F0.78.79.DE.7F.C1.FE.FB.AE.44.00.4F.F0.7B.67.93.75.3D.DA.9D.4B.13.F1.C3.CD.04.52.FF.06.83.53.F8.9C.8B.27.2A.AB.96.62.75.EA.78.F0.DD.AB.75.88.2C.90.9A.FF.F3.84.4B.F8.3C.89.3F.D1.BD.41.EC.79.FB.
7B.89.E2.1E.1B.17.CC.B8.C2.A6.B7.79.EF.10.68.6E.AC.CB.5F.5C.42.2D.5C.35.9A.05.50.6B.0B.96.2F.70.B0.74.64.5F.64.BE.B3.DA.AB.B1.71.D7.AB.8F.0D.FB.3F.3C.86.5A.72.50.9B.09.9B.EF.A0.56.0D.75.91.4A.
Writing, please wait ...done.
--------

Testing lgt_eeprom_readSWM() :
Reading 512 bytes ...
Verifying ...
00.01.02.03.04.05.06.07.08.09.0A.0B.0C.0D.0E.0F.10.11.12.13.14.15.16.17.18.19.1A.1B.1C.1D.1E.1F.20.21.22.23.24.25.26.27.28.29.2A.2B.2C.2D.2E.2F.30.31.32.33.34.35.36.37.38.39.3A.3B.3C.3D.3E.3F.
40.41.42.43.44.45.46.47.48.49.4A.4B.4C.4D.4E.4F.50.51.52.53.54.55.56.57.58.59.5A.5B.5C.5D.5E.5F.60.61.62.63.64.65.66.67.68.69.6A.6B.6C.6D.6E.6F.70.71.72.73.74.75.76.77.78.79.7A.7B.7C.7D.7E.7F.
80.81.82.83.84.85.86.87.88.89.8A.8B.8C.8D.8E.8F.90.91.92.93.94.95.96.97.98.99.9A.9B.9C.9D.9E.9F.A0.A1.A2.A3.A4.A5.A6.A7.A8.A9.AA.AB.AC.AD.AE.AF.B0.B1.B2.B3.B4.B5.B6.B7.B8.B9.BA.BB.BC.BD.BE.BF.
C0.C1.C2.C3.C4.C5.C6.C7.C8.C9.CA.CB.CC.CD.CE.CF.D0.D1.D2.D3.D4.D5.D6.D7.D8.D9.DA.DB.DC.DD.DE.DF.E0.E1.E2.E3.E4.E5.E6.E7.E8.E9.EA.EB.EC.ED.EE.EF.F0.F1.F2.F3.F4.F5.F6.F7.F8.F9.FA.FB.FC.FD.FE.FF.
00.01.02.03.04.05.06.07.08.09.0A.0B.0C.0D.0E.0F.10.11.12.13.14.15.16.17.18.19.1A.1B.1C.1D.1E.1F.20.21.22.23.24.25.26.27.28.29.2A.2B.2C.2D.2E.2F.30.31.32.33.34.35.36.37.38.39.3A.3B.3C.3D.3E.3F.
40.41.42.43.44.45.46.47.48.49.4A.4B.4C.AF.BE.AD.DE.51.52.53.54.55.56.57.58.59.5A.5B.5C.5D.5E.5F.60.61.62.63.64.65.66.67.68.69.6A.6B.6C.6D.6E.6F.70.71.72.73.74.75.76.77.78.79.7A.7B.7C.7D.7E.7F.
80.81.82.83.84.85.86.87.88.89.8A.8B.8C.8D.8E.8F.90.91.92.93.94.95.96.97.98.99.9A.9B.9C.9D.9E.9F.A0.A1.A2.A3.A4.A5.A6.A7.A8.A9.AA.AB.AC.AD.AE.AF.B0.B1.B2.B3.B4.B5.B6.B7.B8.B9.BA.BB.BC.BD.BE.BF.
C0.C1.C2.C3.C4.C5.C6.C7.C8.C9.CA.CB.CC.CD.CE.CF.D0.D1.D2.D3.D4.D5.D6.D7.D8.D9.DA.DB.DC.DD.DE.DF.E0.E1.E2.E3.E4.E5.E6.E7.E8.E9.EA.EB.EC.ED.EE.EF.F0.F1.F2.F3.F4.F5.F6.F7.F8.F9.FA.FB.FC.FD.FE.FF.
Err : 512
----------------
Final test : OK : there is still a 0xDEADBEEF at 0

and then disconnexion reconnexion and press reset:

-----------328D (rare) detected
lgt_eeprom_size( true  ) = 1024
lgt_eeprom_size( false ) = 1020
EEPROM.length()          = 1020
EEPROM E2END             = 1019
--------
Writing using EEPROM[] = xx : 
FC.B2.4A.9C.96.A6.49.B6.CF.CF.28.05.E8.A1.A6.BA.63.21.72.B4.67.98.98.37.67.11.86.F8.3F.C7.8A.F6.7E.54.26.DF.98.89.DB.43.70.5B.F5.2E.ED.3A.2B.43.2A.2B.91.11.E5.EB.F3.C1.76.D5.9D.0F.18.F8.44.7A.
33.F6.54.99.AD.74.8B.62.E5.08.BC.45.06.60.9D.C7.D0.A1.84.AB.3D.2C.3E.E7.BA.7E.A3.0C.8A.06.74.75.75.3F.E6.C0.6F.84.D7.21.5D.41.82.FC.4C.DE.D2.20.63.FF.A5.C6.D0.93.69.E9.AA.AF.96.9C.26.6A.77.8F.
CE.96.DE.FE.46.AF.1E.4F.19.B6.0A.90.BA.B5.50.3A.02.16.8D.A6.5D.34.53.73.39.6D.FC.97.06.53.74.BE.58.FA.AC.19.92.1C.BB.A6.2C.01.F2.8D.53.15.82.95.37.FF.0B.24.6B.9E.91.DE.92.4E.4C.6A.03.FB.74.95.
D0.47.5B.97.57.83.AC.72.8E.79.4E.D2.6D.E4.01.1A.56.9C.F9.F1.BA.27.CA.DC.13.68.BC.89.72.57.00.05.17.68.B7.7E.BF.CA.D4.11.7D.45.3B.17.AB.E9.F1.70.25.86.D2.F9.AF.A9.CD.3D.95.29.39.C6.E8.B1.14.8D.
AC.F7.71.A7.A3.0F.77.12.75.FD.5D.42.5C.40.3A.C7.D5.AE.B4.02.13.CF.81.93.ED.8B.19.06.4F.4D.B3.53.1F.41.F1.3F.B3.0B.DA.FF.65.5E.08.90.CB.C5.7B.38.08.C4.A3.8E.9C.E0.79.78.F2.5E.20.73.68.6F.75.
6C.64.20.62.65.20.32.20.65.72.72.6F.72.73.20.29.00.45.52.52.4F.52.20.3A.20.74.68.65.72.65.20.73.68.6F.75.6C.64.20.62.65.20.61.20.30.78.44.45.41.44.42.45.45.46.20.61.74.20.30.00.4F.4B.20.3A.20.
74.68.65.72.65.20.69.73.20.73.74.69.6C.6C.20.61.20.30.78.44.45.41.44.42.45.45.46.20.61.74.20.30.00.00.00.00.69.00.49.04.00.00.29.63.04.00.00.0E.01.00.00.E8.03.00.00.00.00.00.00.C5.00.C4.00.C0.
00.C1.00.C2.00.C6.00.01.00.00.2B.2F.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.
Err : 197
-----------328D (rare) detected
lgt_eeprom_size( true  ) = 1024
lgt_eeprom_size( false ) = 1020
EEPROM.length()          = 1020
EEPROM E2END             = 1019
--------
Writing using EEPROM[] = xx : 
FC.B2.4A.9C.96.A6.49.B6.CF.CF.28.05.E8.A1.A6.BA.63.21.72.B4.67.98.98.37.67.11.86.F8.3F.C7.8A.F6.7E.54.26.DF.98.89.DB.43.70.5B.F5.2E.ED.3A.2B.43.2A.2B.91.11.E5.EB.F3.C1.76.D5.9D.0F.18.F8.44.7A.
33.F6.54.99.AD.74.8B.62.E5.08.BC.45.06.60.9D.C7.D0.A1.84.AB.3D.2C.3E.E7.BA.7E.A3.0C.8A.06.74.75.75.3F.E6.C0.6F.84.D7.21.5D.41.82.FC.4C.DE.D2.20.63.FF.A5.C6.D0.93.69.E9.AA.AF.96.9C.26.6A.77.8F.
CE.96.DE.FE.46.AF.1E.4F.19.B6.0A.90.BA.B5.50.3A.02.16.8D.A6.5D.34.53.73.39.6D.FC.97.06.53.74.BE.58.FA.AC.19.92.1C.BB.A6.2C.01.F2.8D.53.15.82.95.37.FF.0B.24.6B.9E.91.DE.92.4E.4C.6A.03.FB.74.95.
D0.47.5B.97.57.83.AC.72.8E.79.4E.D2.6D.E4.01.1A.56.9C.F9.F1.BA.27.CA.DC.13.68.BC.89.72.57.00.05.17.68.B7.7E.BF.CA.D4.11.7D.45.3B.17.AB.E9.F1.70.25.86.D2.F9.AF.A9.CD.3D.95.29.39.C6.E8.B1.14.8D.
AC.F7.71.A7.A3.0F.77.12.75.FD.5D.42.5C.40.3A.C7.D5.AE.B4.02.13.CF.81.93.ED.8B.19.06.4F.4D.B3.53.1F.41.F1.3F.B3.0B.DA.FF.65.5E.08.90.CB.C5.7B.38.08.C4.A3.8E.9C.E0.79.78.F2.5E.20.73.68.6F.75.
6C.64.20.62.65.20.32.20.65.72.72.6F.72.73.20.29.00.45.52.52.4F.52.20.3A.20.74.68.65.72.65.20.73.68.6F.75.6C.64.20.62.65.20.61.20.30.78.44.45.41.44.42.45.45.46.20.61.74.20.30.00.4F.4B.20.3A.20.
74.68.65.72.65.20.69.73.20.73.74.69.6C.6C.20.61.20.30.78.44.45.41.44.42.45.45.46.20.61.74.20.30.00.00.00.00.69.00.49.04.00.00.29.63.04.00.00.0E.01.00.00.E8.03.00.00.00.00.00.00.C5.00.C4.00.C0.
00.C1.00.C2.00.C6.00.01.00.00.2B.2F.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.
Err : 197
-----------

run clear demo and read demo, proved all zero.

0	0
1	0
2	0
3	0
.....omitted.....
1017	0
1018	0
1019	0

write test again!

328D (rare) detected
lgt_eeprom_size( true  ) = 1024
lgt_eeproB⸮328D (rare) detected
lgt_eeprom_size( true  ) = 1024
lgt_eeprom_size( false ) = 1020
EEPROM.length()          = 1020
EEPROM E2END             = 1019
--------
Writing using EEPROM[] = xx : 
FC.B2.4A.9C.96.A6.49.B6.CF.CF.28.05.E8.A1.A6.BA.63.21.72.B4.67.98.98.37.67.11.86.F8.3F.C7.8A.F6.7E.54.26.DF.98.89.DB.43.70.5B.F5.2E.ED.3A.2B.43.2A.2B.91.11.E5.EB.F3.C1.76.D5.9D.0F.18.F8.44.7A.
33.F6.54.99.AD.74.8B.62.E5.08.BC.45.06.60.9D.C7.D0.A1.84.AB.3D.2C.3E.E7.BA.7E.A3.0C.8A.06.74.75.75.3F.E6.C0.6F.84.D7.21.5D.41.82.FC.4C.DE.D2.20.63.FF.A5.C6.D0.93.69.E9.AA.AF.96.9C.26.6A.77.8F.
CE.96.DE.FE.46.AF.1E.4F.19.B6.0A.90.BA.B5.50.3A.02.16.8D.A6.5D.34.53.73.39.6D.FC.97.06.53.74.BE.58.FA.AC.19.92.1C.BB.A6.2C.01.F2.8D.53.15.82.95.37.FF.0B.24.6B.9E.91.DE.92.4E.4C.6A.03.FB.74.95.
D0.47.5B.97.57.83.AC.72.8E.79.4E.D2.6D.E4.01.1A.56.9C.F9.F1.BA.27.CA.DC.13.68.BC.89.72.57.00.05.17.68.B7.7E.BF.CA.D4.11.7D.45.3B.17.AB.E9.F1.70.25.86.D2.F9.AF.A9.CD.3D.95.29.39.C6.E8.B1.14.8D.
AC.F7.71.A7.A3.0F.77.12.75.FD.5D.42.5C.40.3A.C7.D5.AE.B4.02.13.CF.81.93.ED.8B.19.06.4F.4D.B3.53.1F.41.F1.3F.B3.0B.DA.FF.65.5E.08.90.CB.C5.7B.38.08.C4.A3.8E.9C.E0.79.78.F2.5E.DF.E7.67.DF.28.FE.
4D.AE.3B.42.1E.80.B9.58.05.E7.AB.6A.5A.BC.43.59.B0.8E.68.58.66.DB.05.AA.55.A2.A4.57.85.58.DF.EC.0A.3C.20.5E.BA.6B.A9.0B.EB.D8.0D.60.47.16.F6.A2.B7.60.71.FB.1E.2B.E8.23.F0.44.A6.B6.36.7A.C0.CF.
F0.78.79.DE.7F.C1.FE.FB.AE.44.00.4F.F0.7B.67.93.75.3D.DA.9D.4B.13.F1.C3.CD.04.52.FF.06.83.53.F8.9C.8B.27.2A.AB.96.62.75.EA.78.F0.DD.AB.75.88.2C.90.9A.FF.F3.84.4B.F8.3C.89.3F.D1.BD.41.EC.79.FB.
7B.89.E2.1E.1B.17.CC.B8.C2.A6.B7.79.EF.10.68.6E.AC.CB.5F.5C.42.2D.5C.35.9A.05.50.6B.0B.96.2F.70.B0.74.64.5F.64.BE.B3.DA.AB.B1.71.D7.AB.8F.0D.FB.3F.3C.86.5A.72.50.9B.09.9B.EF.A0.56.0D.75.91.4A.
86.7E.F1.D4.F0.0A.4A.2E.69.41.95.F3.DD.C7.99.F9.31.CC.F9.C0.C4.6A.46.29.2D.F6.53.47.CA.A1.68.77.B6.DC.97.91.45.83.26.F1.DA.52.8C.9C.8E.2E.04.5E.82.91.79.7C.EC.42.54.8D.AC.89.9A.78.A9.34.34.FE.
A2.82.C9.7E.5C.ED.12.25.60.1F.78.07.89.F4.91.7B.11.CE.75.F1.50.1C.97.6D.30.68.A9.47.33.96.10.1D.43.EA.36.D5.EA.D1.77.CE.E6.17.2F.B3.3C.74.5E.71.D1.FB.FC.12.15.13.21.4F.B0.E1.1A.C9.39.42.C9.D1.
1F.62.33.21.73.1E.F1.E2.64.04.17.DA.27.E1.C1.45.14.EE.A7.81.32.25.EB.77.07.4F.DC.9D.46.B6.07.65.B1.1C.7D.C7.52.BE.FA.96.29.20.C5.B6.9D.E2.06.93.98.3D.D7.40.39.8A.C8.D3.5C.E2.FF.44.24.47.1D.1D.
E7.A8.AF.64.CD.2D.91.8F.33.2E.84.2B.73.EA.16.56.31.51.1A.4C.64.FD.2C.0E.EF.CC.93.63.C3.D0.A6.AD.86.27.20.26.09.AA.F0.95.79.C6.A1.DF.1E.A0.65.9C.58.B2.D7.FB.51.6C.B5.DD.0D.08.14.35.84.03.DE.2C.
EA.73.C2.C3.25.C3.B6.14.68.25.47.BF.EC.F6.DA.9D.83.EC.F1.EA.6B.C9.5A.18.C5.A2.92.DF.A3.FC.1C.B4.6B.DD.70.32.63.90.57.7B.AC.9A.61.94.7B.54.B6.E6.BF.5F.B0.35.CD.20.06.F0.68.DD.16.5A.52.76.A8.C2.
C1.F0.86.4F.B0.1F.2E.1D.06.94.4A.42.8A.B2.95.38.98.F2.60.56.DA.C6.BE.66.A7.27.DD.C9.B6.78.59.7A.0E.93.3A.A0.E0.C1.72.6D.44.8E.20.73.FE.A1.9A.9F.0A.F4.0D.14.F1.E3.A7.C4.F0.D8.90.44.44.D1.F3.D2.
08.E7.96.A8.D0.16.39.3A.D0.9A.E6.82.DB.4A.39.AF.4B.BB.3B.EC.D1.83.E3.C7.88.BA.FF.43.8C.44.00.91.03.B9.AE.97.3E.79.56.59.B8.35.69.F7.B0.0F.F5.5D.44.39.95.3D.A8.82.F3.0C.2A.B0.06.CB.1F.82.50.D7.
73.E1.74.41.17.8D.CA.2B.6B.DB.5B.B9.FD.74.BC.97.CE.F2.DC.17.C5.45.D8.15.CA.84.9F.D1.67.86.85.CB.F0.5B.C0.CE.35.46.35.6B.C3.65.B2.CA.49.28.E3.8B.FA.0B.8F.81.6C.A0.B2.87.36.DD.C4.9B.done
--------
Testing EEPROM[]++ : 
FD.B3.4B.9D.97.A7.4A.B7.D0.D0.29.06.E9.A2.A7.BB.64.22.73.B5.68.99.99.38.68.12.87.F9.40.C8.8B.F7.7F.55.27.E0.99.8A.DC.44.71.5C.F6.2F.EE.3B.2C.44.2B.2C.92.12.E6.EC.F4.C2.77.D6.9E.10.19.F9.45.7B.
34.F7.55.9A.AE.75.8C.63.E6.09.BD.46.07.61.9E.C8.D1.A2.85.AC.3E.2D.3F.E8.BB.7F.A4.0D.8B.07.75.76.76.40.E7.C1.70.85.D8.22.5E.42.83.FD.4D.DF.D3.21.64.00.A6.C7.D1.94.6A.EA.AB.B0.97.9D.27.6B.78.90.
CF.97.DF.FF.47.B0.1F.50.1A.B7.0B.91.BB.B6.51.3B.03.17.8E.A7.5E.35.54.74.3A.6E.FD.98.07.54.75.BF.59.FB.AD.1A.93.1D.BC.A7.2D.02.F3.8E.54.16.83.96.38.00.0C.25.6C.9F.92.DF.93.4F.4D.6B.04.FC.75.96.
D1.48.5C.98.58.84.AD.73.8F.7A.4F.D3.6E.E5.02.1B.57.9D.FA.F2.BB.28.CB.DD.14.69.BD.8A.73.58.01.06.18.69.B8.7F.C0.CB.D5.12.7E.46.3C.18.AC.EA.F2.71.26.87.D3.FA.B0.AA.CE.3E.96.2A.3A.C7.E9.B2.15.8E.
AD.F8.72.A8.A4.10.78.13.76.FE.5E.43.5D.41.3B.C8.D6.AF.B5.03.14.D0.82.94.EE.8C.1A.07.50.4E.B4.54.20.42.F2.40.B4.0C.DB.00.66.5F.09.91.CC.C6.7C.39.09.C5.A4.8F.9D.E1.7A.79.F3.5F.E0.E8.68.E0.29.FF.
4E.AF.3C.43.1F.81.BA.59.06.E8.AC.6B.5B.BD.44.5A.B1.8F.69.59.67.DC.06.AB.56.A3.A5.58.86.59.E0.ED.0B.3D.21.5F.BB.6C.AA.0C.EC.D9.0E.61.48.17.F7.A3.B8.61.72.FC.1F.2C.E9.24.F1.45.A7.B7.37.7B.C1.D0.
F1.79.7A.DF.80.C2.FF.FC.AF.45.01.50.F1.7C.68.94.76.3E.DB.9E.4C.14.F2.C4.CE.05.53.00.07.84.54.F9.9D.8C.28.2B.AC.97.63.76.EB.79.F1.DE.AC.76.89.2D.91.9B.00.F4.85.4C.F9.3D.8A.40.D2.BE.42.ED.7A.FC.
7C.8A.E3.1F.1C.18.CD.B9.C3.A7.B8.7A.F0.11.69.6F.AD.CC.60.5D.43.2E.5D.36.9B.06.51.6C.0C.97.30.71.B1.75.65.60.65.BF.B4.DB.AC.B2.72.D8.AC.90.0E.FC.40.3D.87.5B.73.51.9C.0A.9C.F0.A1.57.0E.76.92.4B.
87.7F.F2.D5.F1.0B.4B.2F.6A.42.96.F4.DE.C8.9A.FA.32.CD.FA.C1.C5.6B.47.2A.2E.F7.54.48.CB.A2.69.78.B7.DD.98.92.46.84.27.F2.DB.53.8D.9D.8F.2F.05.5F.83.92.7A.7D.ED.43.55.8E.AD.8A.9B.79.AA.35.35.FF.
A3.83.CA.7F.5D.EE.13.26.61.20.79.08.8A.F5.92.7C.12.CF.76.F2.51.1D.98.6E.31.69.AA.48.34.97.11.1E.44.EB.37.D6.EB.D2.78.CF.E7.18.30.B4.3D.75.5F.72.D2.FC.FD.13.16.14.22.50.B1.E2.1B.CA.3A.43.CA.D2.
20.63.34.22.74.1F.F2.E3.65.05.18.DB.28.E2.C2.46.15.EF.A8.82.33.26.EC.78.08.50.DD.9E.47.B7.08.66.B2.1D.7E.C8.53.BF.FB.97.2A.21.C6.B7.9E.E3.07.94.99.3E.D8.41.3A.8B.C9.D4.5D.E3.00.45.25.48.1E.1E.
E8.A9.B0.65.CE.2E.92.90.34.2F.85.2C.74.EB.17.57.32.52.1B.4D.65.FE.2D.0F.F0.CD.94.64.C4.D1.A7.AE.87.28.21.27.0A.AB.F1.96.7A.C7.A2.E0.1F.A1.66.9D.59.B3.D8.FC.52.6D.B6.DE.0E.09.15.36.85.04.DF.2D.
EB.74.C3.C4.26.C4.B7.15.69.26.48.C0.ED.F7.DB.9E.84.ED.F2.EB.6C.CA.5B.19.C6.A3.93.E0.A4.FD.1D.B5.6C.DE.71.33.64.91.58.7C.AD.9B.62.95.7C.55.B7.E7.C0.60.B1.36.CE.21.07.F1.69.DE.17.5B.53.77.A9.C3.
C2.F1.87.50.B1.20.2F.1E.07.95.4B.43.8B.B3.96.39.99.F3.61.57.DB.C7.BF.67.A8.28.DE.CA.B7.79.5A.7B.0F.94.3B.A1.E1.C2.73.6E.45.8F.21.74.FF.A2.9B.A0.0B.F5.0E.15.F2.E4.A8.C5.F1.D9.91.45.45.D2.F4.D3.
09.E8.97.A9.D1.17.3A.3B.D1.9B.E7.83.DC.4B.3A.B0.4C.BC.3C.ED.D2.84.E4.C8.89.BB.00.44.8D.45.01.92.04.BA.AF.98.3F.7A.57.5A.B9.36.6A.F8.B1.10.F6.5E.45.3A.96.3E.A9.83.F4.0D.2B.B1.07.CC.20.83.51.D8.
74.E2.75.42.18.8E.CB.2C.6C.DC.5C.BA.FE.75.BD.98.CF.F3.DD.18.C6.46.D9.16.CB.85.A0.D2.68.87.86.CC.F1.5C.C1.CF.36.47.36.6C.C4.66.B3.CB.4A.29.E4.8C.FB.0C.90.82.6D.A1.B3.88.37.DE.C5.9C.done
--------
Testing --EEPROM[] : 
FC.B2.4A.9C.96.A6.49.B6.CF.CF.28.05.E8.A1.A6.BA.63.21.72.B4.67.98.98.37.67.11.86.F8.3F.C7.8A.F6.7E.54.26.DF.98.89.DB.43.70.5B.F5.2E.ED.3A.2B.43.2A.2B.91.11.E5.EB.F3.C1.76.D5.9D.0F.18.F8.44.7A.
33.F6.54.99.AD.74.8B.62.E5.08.BC.45.06.60.9D.C7.D0.A1.84.AB.3D.2C.3E.E7.BA.7E.A3.0C.8A.06.74.75.75.3F.E6.C0.6F.84.D7.21.5D.41.82.FC.4C.DE.D2.20.63.FF.A5.C6.D0.93.69.E9.AA.AF.96.9C.26.6A.77.8F.
CE.96.DE.FE.46.AF.1E.4F.19.B6.0A.90.BA.B5.50.3A.02.16.8D.A6.5D.34.53.73.39.6D.FC.97.06.53.74.BE.58.FA.AC.19.92.1C.BB.A6.2C.01.F2.8D.53.15.82.95.37.FF.0B.24.6B.9E.91.DE.92.4E.4C.6A.03.FB.74.95.
D0.47.5B.97.57.83.AC.72.8E.79.4E.D2.6D.E4.01.1A.56.9C.F9.F1.BA.27.CA.DC.13.68.BC.89.72.57.00.05.17.68.B7.7E.BF.CA.D4.11.7D.45.3B.17.AB.E9.F1.70.25.86.D2.F9.AF.A9.CD.3D.95.29.39.C6.E8.B1.14.8D.
AC.F7.71.A7.A3.0F.77.12.75.FD.5D.42.5C.40.3A.C7.D5.AE.B4.02.13.CF.81.93.ED.8B.19.06.4F.4D.B3.53.1F.41.F1.3F.B3.0B.DA.FF.65.5E.08.90.CB.C5.7B.38.08.C4.A3.8E.9C.E0.79.78.F2.5E.DF.E7.67.DF.28.FE.
4D.AE.3B.42.1E.80.B9.58.05.E7.AB.6A.5A.BC.43.59.B0.8E.68.58.66.DB.05.AA.55.A2.A4.57.85.58.DF.EC.0A.3C.20.5E.BA.6B.A9.0B.EB.D8.0D.60.47.16.F6.A2.B7.60.71.FB.1E.2B.E8.23.F0.44.A6.B6.36.7A.C0.CF.
F0.78.79.DE.7F.C1.FE.FB.AE.44.00.4F.F0.7B.67.93.75.3D.DA.9D.4B.13.F1.C3.CD.04.52.FF.06.83.53.F8.9C.8B.27.2A.AB.96.62.75.EA.78.F0.DD.AB.75.88.2C.90.9A.FF.F3.84.4B.F8.3C.89.3F.D1.BD.41.EC.79.FB.
7B.89.E2.1E.1B.17.CC.B8.C2.A6.B7.79.EF.10.68.6E.AC.CB.5F.5C.42.2D.5C.35.9A.05.50.6B.0B.96.2F.70.B0.74.64.5F.64.BE.B3.DA.AB.B1.71.D7.AB.8F.0D.FB.3F.3C.86.5A.72.50.9B.09.9B.EF.A0.56.0D.75.91.4A.
86.7E.F1.D4.F0.0A.4A.2E.69.41.95.F3.DD.C7.99.F9.31.CC.F9.C0.C4.6A.46.29.2D.F6.53.47.CA.A1.68.77.B6.DC.97.91.45.83.26.F1.DA.52.8C.9C.8E.2E.04.5E.82.91.79.7C.EC.42.54.8D.AC.89.9A.78.A9.34.34.FE.
A2.82.C9.7E.5C.ED.12.25.60.1F.78.07.89.F4.91.7B.11.CE.75.F1.50.1C.97.6D.30.68.A9.47.33.96.10.1D.43.EA.36.D5.EA.D1.77.CE.E6.17.2F.B3.3C.74.5E.71.D1.FB.FC.12.15.13.21.4F.B0.E1.1A.C9.39.42.C9.D1.
1F.62.33.21.73.1E.F1.E2.64.04.17.DA.27.E1.C1.45.14.EE.A7.81.32.25.EB.77.07.4F.DC.9D.46.B6.07.65.B1.1C.7D.C7.52.BE.FA.96.29.20.C5.B6.9D.E2.06.93.98.3D.D7.40.39.8A.C8.D3.5C.E2.FF.44.24.47.1D.1D.
E7.A8.AF.64.CD.2D.91.8F.33.2E.84.2B.73.EA.16.56.31.51.1A.4C.64.FD.2C.0E.EF.CC.93.63.C3.D0.A6.AD.86.27.20.26.09.AA.F0.95.79.C6.A1.DF.1E.A0.65.9C.58.B2.D7.FB.51.6C.B5.DD.0D.08.14.35.84.03.DE.2C.
EA.73.C2.C3.25.C3.B6.14.68.25.47.BF.EC.F6.DA.9D.83.EC.F1.EA.6B.C9.5A.18.C5.A2.92.DF.A3.FC.1C.B4.6B.DD.70.32.63.90.57.7B.AC.9A.61.94.7B.54.B6.E6.BF.5F.B0.35.CD.20.06.F0.68.DD.16.5A.52.76.A8.C2.
C1.F0.86.4F.B0.1F.2E.1D.06.94.4A.42.8A.B2.95.38.98.F2.60.56.DA.C6.BE.66.A7.27.DD.C9.B6.78.59.7A.0E.93.3A.A0.E0.C1.72.6D.44.8E.20.73.FE.A1.9A.9F.0A.F4.0D.14.F1.E3.A7.C4.F0.D8.90.44.44.D1.F3.D2.
08.E7.96.A8.D0.16.39.3A.D0.9A.E6.82.DB.4A.39.AF.4B.BB.3B.EC.D1.83.E3.C7.88.BA.FF.43.8C.44.00.91.03.B9.AE.97.3E.79.56.59.B8.35.69.F7.B0.0F.F5.5D.44.39.95.3D.A8.82.F3.0C.2A.B0.06.CB.1F.82.50.D7.
73.E1.74.41.17.8D.CA.2B.6B.DB.5B.B9.FD.74.BC.97.CE.F2.DC.17.C5.45.D8.15.CA.84.9F.D1.67.86.85.CB.F0.5B.C0.CE.35.46.35.6B.C3.65.B2.CA.49.28.E3.8B.FA.0B.8F.81.6C.A0.B2.87.36.DD.C4.9B.OK
--------

Testing lgt_eeprom_write_block() :
Writing 512 bytes, please wait ...done.
--------

Testing lgt_eeprom_read_block() :
Reading and verifying 512 bytes ...
OK
--------

Testing lgt_eeprom_write32() :
Writing ...done.
--------

Testing lgt_eeprom_read32() :
Reading ...
OK
--------

Testing lgt_eeprom_writeSWM() :
Generating 512 bytes buffer ...
FC.B2.4A.9C.96.A6.49.B6.CF.CF.28.05.E8.A1.A6.BA.63.21.72.B4.67.98.98.37.67.11.86.F8.3F.C7.8A.F6.7E.54.26.DF.98.89.DB.43.70.5B.F5.2E.ED.3A.2B.43.2A.2B.91.11.E5.EB.F3.C1.76.D5.9D.0F.18.F8.44.7A.
33.F6.54.99.AD.74.8B.62.E5.08.BC.45.06.60.9D.C7.D0.A1.84.AB.3D.2C.3E.E7.BA.7E.A3.0C.8A.06.74.75.75.3F.E6.C0.6F.84.D7.21.5D.41.82.FC.4C.DE.D2.20.63.FF.A5.C6.D0.93.69.E9.AA.AF.96.9C.26.6A.77.8F.
CE.96.DE.FE.46.AF.1E.4F.19.B6.0A.90.BA.B5.50.3A.02.16.8D.A6.5D.34.53.73.39.6D.FC.97.06.53.74.BE.58.FA.AC.19.92.1C.BB.A6.2C.01.F2.8D.53.15.82.95.37.FF.0B.24.6B.9E.91.DE.92.4E.4C.6A.03.FB.74.95.
D0.47.5B.97.57.83.AC.72.8E.79.4E.D2.6D.E4.01.1A.56.9C.F9.F1.BA.27.CA.DC.13.68.BC.89.72.57.00.05.17.68.B7.7E.BF.CA.D4.11.7D.45.3B.17.AB.E9.F1.70.25.86.D2.F9.AF.A9.CD.3D.95.29.39.C6.E8.B1.14.8D.
AC.F7.71.A7.A3.0F.77.12.75.FD.5D.42.5C.40.3A.C7.D5.AE.B4.02.13.CF.81.93.ED.8B.19.06.4F.4D.B3.53.1F.41.F1.3F.B3.0B.DA.FF.65.5E.08.90.CB.C5.7B.38.08.C4.A3.8E.9C.E0.79.78.F2.5E.DF.E7.67.DF.28.FE.
4D.AE.3B.42.1E.80.B9.58.05.E7.AB.6A.5A.BC.43.59.B0.8E.68.58.66.DB.05.AA.55.A2.A4.57.85.58.DF.EC.0A.3C.20.5E.BA.6B.A9.0B.EB.D8.0D.60.47.16.F6.A2.B7.60.71.FB.1E.2B.E8.23.F0.44.A6.B6.36.7A.C0.CF.
F0.78.79.DE.7F.C1.FE.FB.AE.44.00.4F.F0.7B.67.93.75.3D.DA.9D.4B.13.F1.C3.CD.04.52.FF.06.83.53.F8.9C.8B.27.2A.AB.96.62.75.EA.78.F0.DD.AB.75.88.2C.90.9A.FF.F3.84.4B.F8.3C.89.3F.D1.BD.41.EC.79.FB.
7B.89.E2.1E.1B.17.CC.B8.C2.A6.B7.79.EF.10.68.6E.AC.CB.5F.5C.42.2D.5C.35.9A.05.50.6B.0B.96.2F.70.B0.74.64.5F.64.BE.B3.DA.AB.B1.71.D7.AB.8F.0D.FB.3F.3C.86.5A.72.50.9B.09.9B.EF.A0.56.0D.75.91.4A.
Writing, please wait ...done.
--------

Testing lgt_eeprom_readSWM() :
Reading 512 bytes ...
Verifying ...
00.01.02.03.04.05.06.07.08.09.0A.0B.0C.0D.0E.0F.10.11.12.13.14.15.16.17.18.19.1A.1B.1C.1D.1E.1F.20.21.22.23.24.25.26.27.28.29.2A.2B.2C.2D.2E.2F.30.31.32.33.34.35.36.37.38.39.3A.3B.3C.3D.3E.3F.
40.41.42.43.44.45.46.47.48.49.4A.4B.4C.4D.4E.4F.50.51.52.53.54.55.56.57.58.59.5A.5B.5C.5D.5E.5F.60.61.62.63.64.65.66.67.68.69.6A.6B.6C.6D.6E.6F.70.71.72.73.74.75.76.77.78.79.7A.7B.7C.7D.7E.7F.
80.81.82.83.84.85.86.87.88.89.8A.8B.8C.8D.8E.8F.90.91.92.93.94.95.96.97.98.99.9A.9B.9C.9D.9E.9F.A0.A1.A2.A3.A4.A5.A6.A7.A8.A9.AA.AB.AC.AD.AE.AF.B0.B1.B2.B3.B4.B5.B6.B7.B8.B9.BA.BB.BC.BD.BE.BF.
C0.C1.C2.C3.C4.C5.C6.C7.C8.C9.CA.CB.CC.CD.CE.CF.D0.D1.D2.D3.D4.D5.D6.D7.D8.D9.DA.DB.DC.DD.DE.DF.E0.E1.E2.E3.E4.E5.E6.E7.E8.E9.EA.EB.EC.ED.EE.EF.F0.F1.F2.F3.F4.F5.F6.F7.F8.F9.FA.FB.FC.FD.FE.FF.
00.01.02.03.04.05.06.07.08.09.0A.0B.0C.0D.0E.0F.10.11.12.13.14.15.16.17.18.19.1A.1B.1C.1D.1E.1F.20.21.22.23.24.25.26.27.28.29.2A.2B.2C.2D.2E.2F.30.31.32.33.34.35.36.37.38.39.3A.3B.3C.3D.3E.3F.
40.41.42.43.44.45.46.47.48.49.4A.4B.4C.AF.BE.AD.DE.51.52.53.54.55.56.57.58.59.5A.5B.5C.5D.5E.5F.60.61.62.63.64.65.66.67.68.69.6A.6B.6C.6D.6E.6F.70.71.72.73.74.75.76.77.78.79.7A.7B.7C.7D.7E.7F.
80.81.82.83.84.85.86.87.88.89.8A.8B.8C.8D.8E.8F.90.91.92.93.94.95.96.97.98.99.9A.9B.9C.9D.9E.9F.A0.A1.A2.A3.A4.A5.A6.A7.A8.A9.AA.AB.AC.AD.AE.AF.B0.B1.B2.B3.B4.B5.B6.B7.B8.B9.BA.BB.BC.BD.BE.BF.
C0.C1.C2.C3.C4.C5.C6.C7.C8.C9.CA.CB.CC.CD.CE.CF.D0.D1.D2.D3.D4.D5.D6.D7.D8.D9.DA.DB.DC.DD.DE.DF.E0.E1.E2.E3.E4.E5.E6.E7.E8.E9.EA.EB.EC.ED.EE.EF.F0.F1.F2.F3.F4.F5.F6.F7.F8.F9.FA.FB.FC.FD.FE.FF.
Err : 512
----------------
Final test : OK : there is still a 0xDEADBEEF at 0

so the test is ok when the eeprom is clear.is this the test's bug or the lib's bug? write to a clear eeprom is ok, write to a dirty eeprom is wrong! 328p is not test.

@SuperUserNameMan
Copy link
Contributor Author

SuperUserNameMan commented Apr 2, 2021

Well, I confirm there is at least one bug in the lib with the implementation of lgt_eeprom_writeSWM() which emulate SWM write mode for 328D and x88 variants :

EEPROM.cpp, line 375 :

	void lgt_eeprom_writeSWM( uint16_t address, uint32_t *pdata, uint16_t len) 
	{ 
		// Emulation :
		lgt_eeprom_read_block( (uint8_t*)pdata, address, len*sizeof(uint32_t) );
	}
	void  lgt_eeprom_readSWM( uint16_t address, uint32_t *pdata, uint16_t len) 
	{ 
		// Emulation :
		lgt_eeprom_read_block( (uint8_t*)pdata, address, len*sizeof(uint32_t) );
	}

This lgt_eeprom_writeSWM() calls lgt_eeprom_read_block() where it should obviously call lgt_eeprom_write_block() ...

@SuperUserNameMan
Copy link
Contributor Author

I opened a new PR : #129

@SuperUserNameMan
Copy link
Contributor Author

@youxiaojie : Thanks for the tests already.

This part of your test result here is bizarre :

328D (rare) detected
lgt_eeprom_size( true  ) = 1024
lgt_eeproB⸮328D (rare) detected
lgt_eeprom_size( true  ) = 1024
lgt_eeprom_size( false ) = 1020
EEPROM.length()          = 1020

It started the test, and it was interrupted quickly.
I had similar issues once with a bad "USB to serial" adapter : sketch upload was often corrupted.

Could you tell me what board and serial adapter you are using ?

@LaZsolt
Copy link
Collaborator

LaZsolt commented Apr 2, 2021

@youxiaojie :
According to my opinion, too high speed in Serial.begin() could cause communication errors between MCU and PC.

@youxiaojie
Copy link

youxiaojie commented Apr 2, 2021

it is mostly because of mcu and wch340 are not using crystal there exist inaccuracy. Chip of usb-ttl, ch340,according to the ch340's engineer, the baud of ch340 to mcu is 1% tolerance; mcu to ch340 is 2% tolerance. when runing demo "characteranalysis" is obviously, sending from mcu to computer is all correct, but the received "input character" are bizarre. this situation is better in linux than in windows.

maybe this is why the bootloader using 19200, a lower speed. I hope to test common communication in a high speed, to see is there bizarre. in the test, when the bizarre, I redo all, but the screen is not clear.copy and paste from the serial monitor.

@youxiaojie
Copy link

youxiaojie commented Apr 2, 2021

what is SWM here?

@SuperUserNameMan
Copy link
Contributor Author

@youxiaojie :
regarding issues related to ch340, there is this wiki page : https://github.com/dbuezas/lgt8fx/wiki/USB-to-serial-converter-timing-issues

what is SWM here?

On the LGT8F328-P, it is the most optimized and fastest way to write a buffer to the EEPROM.

SWM does not exist on LGT8Fx8-D.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants