One of the main issues with using the Arduino IDE with the mega 2560 is that flash storage above 64KB is rather painful to access. Because the address goes from 16 bits to 18 bits to access all of flash (256KB in total) you end up having to call pgm_get_far_address and pgm_read_byte_far, pgm_read_dword_far, pgm_read_float_far to name a few.
QUESTION 1:
What my question is is whether there is a compiler that supports 24bits for a flash address natively. Having such a compiler would mean that using things like:
const char sSomething1[] PROGMEM = "First string";
const char sSomething2[] PROGMEM = "Second string";
...
const char * const Sstrings[] PROGMEM = {(const char *)&sSomething1, (const char *)&sSomething2...};
would work because 24 bits addresses would be put into Sstrings. Both sSomething1 etc and Sstrings would be in flash. At present this is not possible as doing so will have 16 bit values in Sstrings which will break if the strings go above 64KB.
It is also not possible, in Arduino IDE, to try to get the address (above 64KB) using something like:
... pgm_get_far_address (Sstring[1])....
I know that the existing libraries, which primarily work on 16 bit flash addresses will either need rewriting or perhaps a (uint16_t) flashaddress could be used for the passed flash address to revert to 16 bit address when you know it is in the bottom 64KB for backward compatibility.
QUESTION 2:
Can anyone explain how the existing compiler and linker work when dealing with flash addresses over 64KB on 2560?
It would appear that what is roughly happening is that 16 bit addresses are being created by the compiler for flash addresses and the linker is then remapping this to addresses above 64KB in some cases.
The issue that occurs here is when the total flash data storage is over 64KB (which, in my view, would be the main reason to use a mega 2560) the compiler must be well aware of this.
In essence I want to know what the voodoo magic is that deals with these issues and resolves the 16 bit compiler to a larger address at linking time.
Many thanks in advance for any answers...
Geoffrey.