Skip to content

EEPROM location was changed #6531

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

Closed
byq13 opened this issue Sep 18, 2019 · 10 comments · Fixed by #6537
Closed

EEPROM location was changed #6531

byq13 opened this issue Sep 18, 2019 · 10 comments · Fixed by #6537
Assignees
Milestone

Comments

@byq13
Copy link

byq13 commented Sep 18, 2019

In the thirst place I have update to v2.5.2 and it was working ok, but when I have downloaded the newest branch from GIT, then I have discovered problem with EEPROM.
In the newest branch EEPROM location was changed.
My problem is that I have put authentication key there. Now I have to have access to it.

EEPROM function is working fine. In v2.52 and with the newest. It is just not the same part of the flash memory.

How can I have access to old EEPROM location with the newest Arduino framework from GIT?

ESP-12S with 4MB, - 4M2M=4MB (FS:2MB OTA:~1019KB)

@d-a-v
Copy link
Collaborator

d-a-v commented Sep 18, 2019

Current eeprom location:

(((uint32_t)&_FS_end - 0x40200000) / SPI_FLASH_SEC_SIZE)

: _sector((((uint32_t)&_FS_end - 0x40200000) / SPI_FLASH_SEC_SIZE))

_FS_end in current master:

PROVIDE ( _FS_end = 0x405FA000 );

In 2.5.2:

PROVIDE ( _SPIFFS_end = 0x405FB000 );

By calliing EEPROM.begin((((uint32_t)0x405FB000 - 0x40200000) / SPI_FLASH_SEC_SIZE), you might recover what you had in 2.5.2.
You would then need to close and EEPROM.begin() again to save it to the new location.

Sorry for this change, it should be documented for next release.

@d-a-v d-a-v added this to the 2.6.0 milestone Sep 18, 2019
@d-a-v
Copy link
Collaborator

d-a-v commented Sep 18, 2019

You can also try to add 4096 to the offset of your data, without calling .begin(newaddress) like above.

@byq13
Copy link
Author

byq13 commented Sep 18, 2019

Working. Thank you.
I would like to stay with old data in its place.

For what old address will be reserved in next framework version?
OLD eeprom @0x405FB000 (4KB)
NOW: _FS_end = 0x405FA000 -> EEPROM = 8KB.

@d-a-v
Copy link
Collaborator

d-a-v commented Sep 18, 2019

It should not change anymore.
It was changed because of an oddness in flash mapping (#5989).

@byq13
Copy link
Author

byq13 commented Sep 18, 2019

May I assume, that now we have 8 KB of EEPROM?
Or EEPROM will be on the end of FS and on old EEPROM space will be something else?
At the moment is noones land.

Many thanks for help. It is working perfectly.

@devyte
Copy link
Collaborator

devyte commented Sep 18, 2019

@byq13 #5989 addressed a bug in the calculation of the SPIFFS end address. In a cormer case, it could theoretically corrupt the filesystem. I now realize the fix shifts the location of tbe EEPROM, so after an update the EEPROM data wouldn't be seen by the class.
What you may want to do is copy the EEPROM data from the old address to the new correct address. This would need to be done only once, and only when updating from before that fix to after the fix.

Notes:
-retro-mark #5989 as breaking and include the above description on how to address it.
-size of eeprom doesn't change, stays at 4KB

@earlephilhower
Copy link
Collaborator

For 2.6, I'll fix the EEPROM sector to point back to the same address as it was, by making boards.txt.py calculate it using the old (busted) formula and removing the implicit calculation in eeprom.cpp. This will make EEPROM backwards compat w/o any changes for users. For 3.0 we may move it to the last sector after the FS, but IMO that's probably not worth the trouble and breakage.

@liebman
Copy link
Contributor

liebman commented Sep 18, 2019

@earlephilhower If this was in 2.5.2 maybe a config option? Someone who has built with 2.5.2 may have the same issue if you change the calculation back...... never mind - it looks to be post 2.5.2

@earlephilhower
Copy link
Collaborator

Thanks for checking that. This bug report was very timely and caught a subtle problem!

earlephilhower added a commit to earlephilhower/Arduino that referenced this issue Sep 19, 2019
When the FS_END was adjusted to end on a full block (i.e. rounded down)
to avoid filesystem issues, but _FS_end was changed.  The EEPROM library
used _FS_end to implicitly calculate the start of the EEPROM data, so
this means after the _FS_end fix, EEPROM data written with prior
releases would "disappear."

Avoid the issue by explicitly calculating the EEPROM start location in
the linker, using the same formula as prior release.

Fixes esp8266#6531
@earlephilhower
Copy link
Collaborator

Please try PR #6537 . It should restore the location so you can read old data correctly.

earlephilhower added a commit that referenced this issue Sep 20, 2019
When the FS_END was adjusted to end on a full block (i.e. rounded down)
to avoid filesystem issues, but _FS_end was changed.  The EEPROM library
used _FS_end to implicitly calculate the start of the EEPROM data, so
this means after the _FS_end fix, EEPROM data written with prior
releases would "disappear."

Avoid the issue by explicitly calculating the EEPROM start location in
the linker, using the same formula as prior release.

Fixes #6531
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 a pull request may close this issue.

5 participants