EEPROM.put - where does it stores data?
EEPROM.put - where does it stores data?
Hi EveryGuruAtTheForum!
I use EEPROM lib with my STM32F103 in my solution. It writes and reads some data from the flash memory of my chip.
The usage of the lib is very simple just use EEPROM.put(int address, obj) and it does everything for you. But I'd like to understand where exactly at the flash memory my data is stored? How to find out? int as address is not very obviuous.
Thank you for the answers.
I use EEPROM lib with my STM32F103 in my solution. It writes and reads some data from the flash memory of my chip.
The usage of the lib is very simple just use EEPROM.put(int address, obj) and it does everything for you. But I'd like to understand where exactly at the flash memory my data is stored? How to find out? int as address is not very obviuous.
Thank you for the answers.
-
- Posts: 633
- Joined: Thu Dec 19, 2019 1:23 am
Re: EEPROM.put - where does it stores data?
From https://github.com/redbear/STM32-Arduin ... mulation.h
/* EEPROM Emulation using Flash memory
*
* EEPROM provides reads and writes for single bytes, with a default
* value of 0xFF for unprogrammed cells.
*
* Two pages (sectors) of Flash memory with potentially different sizes
* are used to store records each containing the value of 1 byte of
* emulated EEPROM.
*
* Each record contain an index (EEPROM cell virtual address), a data
* byte and a status byte (valid/erased).
*
* The maximum number of bytes that can be written is the smallest page
* size divided by the record size.
*
* Since erased Flash starts at 0xFF and bits can only be written as 0,
* writing a new value of an EEPROM byte involves appending a new record
* to the list of current records in the active page.
*
* Reading involves going through the list of valid records in the
* active page looking for the last record with a specified index.
Re: EEPROM.put - where does it stores data?
That is strange:
1. "Two pages (sectors) of Flash memory " and where are they located in Chip Flash?
2. I use different EEPROM lib, that is called EEPROM.h not emulated_EEPROM.
1. "Two pages (sectors) of Flash memory " and where are they located in Chip Flash?
2. I use different EEPROM lib, that is called EEPROM.h not emulated_EEPROM.
-
- Posts: 633
- Joined: Thu Dec 19, 2019 1:23 am
Re: EEPROM.put - where does it stores data?
In Arduino 16-bit AVR, most of those uC's have dedicated EEPROM affixed to the uC die ... that is completely separate component than the flash memory that stores the compiled sketch. (Ex: Uno, Mega, Micro, Nano...)kvv213 wrote: Tue Apr 07, 2020 7:19 pm That is strange:
1. "Two pages (sectors) of Flash memory " and where are they located in Chip Flash?
2. I use different EEPROM lib, that is called EEPROM.h not emulated_EEPROM.
STM32 ARM uC's like STM32F103 do not have EEPROM, so it is emulated by a software library. There are various libraries, the internals may be written differently, but they all work the same at the sketch level. Essentially, the library stores data in program flash ... so, there is some wear on that flash memory and one should not cycle writes too often; therefore not a great way to datalog fast changing info.
Re: EEPROM.put - where does it stores data?
For the STM32 core, this is stored in the last page/sector of the flash.
Re: EEPROM.put - where does it stores data?
That is for configuration storing only. So, not very often update (even not often update at all)mrburnette wrote: Tue Apr 07, 2020 7:33 pmIn Arduino 16-bit AVR, most of those uC's have dedicated EEPROM affixed to the uC die ... that is completely separate component than the flash memory that stores the compiled sketch. (Ex: Uno, Mega, Micro, Nano...)kvv213 wrote: Tue Apr 07, 2020 7:19 pm That is strange:
1. "Two pages (sectors) of Flash memory " and where are they located in Chip Flash?
2. I use different EEPROM lib, that is called EEPROM.h not emulated_EEPROM.
STM32 ARM uC's like STM32F103 do not have EEPROM, so it is emulated by a software library. There are various libraries, the internals may be written differently, but they all work the same at the sketch level. Essentially, the library stores data in program flash ... so, there is some wear on that flash memory and one should not cycle writes too often; therefore not a great way to datalog fast changing info.

Re: EEPROM.put - where does it stores data?
Thank you, yes, for STM32 Core.fpiSTM wrote: Tue Apr 07, 2020 7:54 pm For the STM32 core, this is stored in the last page/sector of the flash.
I found out a strange behaviour of put method of EEPROM lib. If I write an object with size around 0,5 kb then a part of my sketch memory is ruined. Variables values are destroyed... So, was like to find out where it is written.
-
- Posts: 633
- Joined: Thu Dec 19, 2019 1:23 am
Re: EEPROM.put - where does it stores data?
Flash can hold the bootloader, your sketch, and simulated EEPROM ... flash is finite. You must use an STM32 aware lib for EEPROM, using an AVR library is not supported.kvv213 wrote: Wed Apr 08, 2020 5:20 pmThank you, yes, for STM32 Core.fpiSTM wrote: Tue Apr 07, 2020 7:54 pm For the STM32 core, this is stored in the last page/sector of the flash.
I found out a strange behaviour of put method of EEPROM lib. If I write an object with size around 0,5 kb then a part of my sketch memory is ruined. Variables values are destroyed... So, was like to find out where it is written.
Re: EEPROM.put - where does it stores data?
Yep, it is. But how to check the lib to be STM32 compliant? I took the lib from STM32 Arduino Core and it stores values at flash due to absence of EEPROM at the board.mrburnette wrote: Tue Apr 14, 2020 1:48 am Flash can hold the bootloader, your sketch, and simulated EEPROM ... flash is finite. You must use an STM32 aware lib for EEPROM, using an AVR library is not supported.
I agree that it seems that if I try to store large values (like 500-600 bytes) it goes to symbols area of my RAM (due to flat dressing of entire memory). So that is why I started this thread.
Re: EEPROM.put - where does it stores data?
No, bytes you put to flash cant reach your ram
flash area start address is 800 0000 (hex), when SRAM is starting at 2000 0000 (hex)
in decimals it will be 134 217 728 and 536 870 912, hundreds of millions bytes difference
flash area start address is 800 0000 (hex), when SRAM is starting at 2000 0000 (hex)
in decimals it will be 134 217 728 and 536 870 912, hundreds of millions bytes difference