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

EEPROM storage allocated even though it is not used #31

Open
sslupsky opened this issue Oct 11, 2019 · 3 comments
Open

EEPROM storage allocated even though it is not used #31

sslupsky opened this issue Oct 11, 2019 · 3 comments

Comments

@sslupsky
Copy link

I noticed the following two declarations in EEPROM.cpp

FlashStorage(eeprom_storage, EEPROM_EMULATION);

EEPROMClass EEPROM;

This allocates quite a bit of RAM (1K) when you are not using the EEPROM emulation.

Would it be advantageous to have an initialization method (ie: EEPROM:begin() ) that is called to allocate the storage?

@sslupsky
Copy link
Author

There is already an EEPROM::init() method. Perhaps the allocation could be done there?

The way the FlashStorage define works and the FlashStorageClass is templated, it is not obvious how to move the allocation into a class. I was trying do so using my own class and encountered compiler error. The declaration of the _data array is declared as static storage class and this causes problems with the FlashStorageClass template.

Is there a way to instantiate the FlashStorageClass object from within a class? I have two different types of storage that I would like to create two different FlashStorageClass objects for.

@sslupsky
Copy link
Author

I defined EEPROM_EMULATION_SIZE 0 as follows:

#define BOOT_STATUS_FILE_MAX_RECORDS 16
#include <FlashStorage.h>

but for some reason that does not appear to prevent the allocation of the memory. Here are the relevant allocations from nm:

20000d6c 00000403 B EEPROM
00017800 00000500 t _dataeeprom_storage

There is 1K of RAM and 1.2K of FLASH allocated to the EEPROM storage.

Note that I do not include FlashAsEEPROM.h. So, it appears to me that FlashAsEEPROM.cpp is being compiled and linked regardless of its inclusion. Does this imply that FlashAsEEPROM.* need to be in their own separate library or is there a way to prevent them from being compiled when not used?

@tuxedo0801
Copy link
Contributor

interesting question...

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

No branches or pull requests

2 participants