PlatformIO Community

FlashStorage library not working when in lib-Folder

Hi,

The title says it all and i did not find something in the forum: I use the flashstorage library (https://github.com/cmaglie/FlashStorage) in my own class Memory. A memory object is included in my connection class. Meaning i got a chain of dependencies -> Connection.h->Memory.h->FlashStorage.h
When both my classes “connection” and “memory” reside in the source folder and are beeing built, the flashstorage works as intended, but when I move my classes and their files in the lib folder the flashstorage does not work, although I NEVER get a linker error…and the dependency graph looks ok.
All other functions work as intended, only the flashstorage stops working.

I tried linker deep etc… but nothing helped, altough the dependency graph is the same. I suspect that the flashstorage library is not beeing linked or does not reserve the space in flashstorage…

Has anybody of you expirience with this? How i can get that to work? For the time beeing i leave the files for connectivity class and memory class in my source folder…

Thank you!

With best Regards

Vinc

If you have moved the library’s from global to local have you changed the includes from <> to “” (or specified their paths)

Thanks, but that doesn’t help, and as I said, no compile errors. The memory class with the flashstorage.h header just doesn’t work outside of the source folder…

So in your paths you have blah blah \libs\FlashStorage\src or something similar and if you edit one of the .cpp or .h files in that folder with a deliberate error does the compiler flag it?

Let me explain: my programm is programmed object oriented. For this i have two files containing classes, namely connectivity.h/cpp and memory.h/cpp. The connectivity class contains a memory object and therefore links memory.h.
The memory class contains a Flashstorage object and therefore links Flashstorage.h.
In main the connectivity object is initialized, chaining to memory and then to flashstorage.

For the time beeing i have all three .h and cpp files in the source folder of platformio: main, connectivity and memory.
But i want to move the connectivity and memory files in the lib folder of platformio, to the other helper libraries, just for structure.

But as soon as i move the files of connectivity and memory from the src folder to the lib folder of platformio the error happens:

The project builds fine, all files are found, dependency graph is the same…BUT the flashstorage stops working. I cant store the data anymore. As soon as i move the files back to the src folder everything is fine again.
I tried your tip with „“, i ordered the headers in a different way etc, but nothing helps. No compile error, but flashstorage stops working as soon as i move it from platformio src folder to the lib folder.

For clarification i attached screenshots of the header files.

Its not an big issue, its more a structure thing. I wanna have only the main program in the src folder…

Thanks!

Rgds Vinc

sorry, i can only attach one pic per post… :innocent:

1 Like

No problem, I am just covering some basics while the really smart people do the thinking :thinking: What you are doing seems pretty simple and so should work without issue, if we look at it logically the only difference is the introduction of “\libs” to the files being created.

Is the folder where you project lives very long or use very long directory names? just wanted to see if it was breaking a file name length limit or something like that that is not being caught.

It may be nothing but as I have 6 libraries in my current project that are in the libs folder I am scratching my head a bit.

No, the folders are named lib/memory and lib/connectivity…

I mean as in the full path to the files is it just c:\users\[username]\documents\.platformio\projects\myproject\memory or something much longer?

Also does ANY library work if it is placed in /libs?

That’s exactly the path. And ALL other libraries work, just flashstorage does not, although it compiles

Could you upload your project to github for reproduction please?

Move the memory and connectivity files form the arc folder in folders under /lib and the Flash Memory stops working…

Solved. FlashStorage must be declared in main and then passed as reference to the desired object, flashstorage cannot be declared in a object which is part of a library.

1 Like