-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
EEPROM at wrong location for devices with flash size other than 128K? #379
Comments
The only way to do this correctly is to add another define into boards.txt which holds the Flash size. We can't do this at the variant level, as F103C8 and F103CB use the same variant folder In reality this is hardly ever and issue as virtually all F103C8's have 128k However looking in the class there is a init() function which you can pass the page addresses Which looks like it solves the problem in the sort term |
This could lead to a really hard to find bug on a device with 256k flash and a large sketch. |
Here's what I am thinking: In platform.txt, for both c and c++ building, add:
Then in EEPROM.h we can put:
|
Yes. That would work But we may be able to do the calculation in C rather than in a complex macro, as I think ultimately the EEPROM_START_ADDRESS gets put into a variable |
I'm still not used to modern compilers and being able to count on them to optimize all complex constant expressions away. Yes, one could put it in a const variable. An additional good thing one could do is to use the flash size and the table here to figure out if it's a low, medium or high density device, and then set the page size to 1k for low/medium and 2k for high density. (There are also connectivity-line devices, stm32f105/7, where the page size would be incorrectly determined by this method, but the core doesn't support them.) |
I put in a PR that handles this issue (from a different github username, for my convenience). |
Is this still actual? |
It is. EEPROM library still needs manual setting of EEPROM location for devices with flash memory size !=128K. |
hello
so I swithced to using init(uint32,uint32,uint32) and calculation in my code, which works:
as the only parameter which library requires to calculate offsets correctly is flash size, I add this init version, and it works for 64 and also 128k, but for now, I stick with init function which takes base0, base1 and pagesize as parameters, for compatibility after upgrade of stm32core
|
If I am reading the code wrong, just close this.
The only place I can find EEPROM_START_ADDRESS to be defined is EEPROM.h. But as I read EEPROM.h, because of the hack of defining MCU_STM32F103RB on all MCUs, EEPROM_START_ADDRESS is set to 0x8000000 plus 124K always. This means that on devices with 64K flash (e.g., those STM32F103C8 units that have only 64K), the EEPROM is outside the available memory, and on devices with more than 128K flash, the EEPROM storage may overwrite program code.
Maybe EEPROM_START_ADDRESS is defined somewhere else in the codebase and I just can't find it?
The text was updated successfully, but these errors were encountered: