I'm trying to use the flash library to move some constant values into flash memory instead of keeping them in RAM. It appears there is a problem with the flash library.
To reproduce the problem, install the Flash library using the lilbrary manager, and try to compile either of the example programs for an Arduino Uno. The compiler will stop with an internal compiler error.
I've tried this using the Arduino IDE version 1.8.16 under both a Raspberry Pi OS and Windows 10 Pro 64 bit. I can also reproduce the error using Arduino IDE 2.0.0 on the Windows 10 pro machine.
Is there a work around for the issue, or do I have to go back to using the ancient Arduino 0.022 version I originally wrote my program under?
The flash memory involved is the program memory built in to the Atmega 328P on the Uno. Normally it is only used for program code, with all variables in RAM. The problem is that I have run out of RAM, and have to move as many of the constant values like text strings into ROM to free up the RAM. Essentially the library is a wrapper for PROGMEM
As far as I can see, nothing works with this library anymore, even the examples that came with the library. They all fail with an internal compiler error.
By the place you found it? Where it is hosted? It didn't appear in your library folder by magic. Also it should have some documentation with it to help identify it and provide that info if you no longer have it.
Probably to write to flash at run time. But if the "constant values" are known at compile time, the library isn't appropriate.
OP, please follow the forum guidelines and fully explain your need, what these "constant values" are, how many there are, what format they are in, etc... it really sounds like you are way off track.
The constant values are known at compile time. The problem is where the compiler puts them.
By default, all variables, including those defined with the "const' keyword are stored in RAM so that they can be accessed via a pointer if needed. My problem is that the Uno has only 2K of RAM, and I am using the SD card library for datalogging, and two instances of the software serial library for communications with a GPS and a serial display. The GPS and serial display run at different baud rates, so I can't simply use one instance of software serial to handle both.
Between the buffers for the serial ports and the buffers for the SD card access, this program is using 3/4 of the available RAM for variables, leaving only about 500 bytes for the heap. If I use any of that to store the text strings that get sent to the display, the program will start crashing when it runs out of space. I HAVE to put those somewhere else.
The "Flash" library has not been worked on for four years. It looks like something in the library is confusing the compiler. The "Basic" example get the following errors:
In file included from /Users/john/Documents/Arduino/libraries/Flash/examples/Basic/Basic.ino:21:0:
/Users/john/Documents/Arduino/libraries/Flash/src/Flash.h: In instantiation of 'class _FLASH_TABLE<int>':
/Users/john/Documents/Arduino/libraries/Flash/examples/Basic/Basic.ino:70:1: required from here
/Users/john/Documents/Arduino/libraries/Flash/src/Flash.h:159:21: internal compiler error: in type_hash_canon, at tree.c:7158
typedef T PROGMEM _DataType;
^~~~~~~~~
libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
exit status 1
Error compiling for board Arduino Uno.
You could try reporting the problem to the github page.