The linker attempts to place data in the first 64kB of a big AVR and the code at higher addresses.
In practice, you have 200kB of data with 30kB code. So most data is outside the 64kB address range.
// linker places this first e.g. < 64kB const unsigned char lady_128x127x4_bmp[] PROGMEM = { ... }; // linker places this section after the regular PROGMEM e.g. > 64kB const unsigned char lady_128x127x8_bmp[] __attribute__((section(".fini2")))= { ... }; // you can only access the first 64kB of Flash with xxxx_P() functions // you can access ANY data with the xxxx_PF() functions // you can only use pgm_get_far_address(x) at runtime
I would like to have an array of far pointers at compile time.
// all pointers are 16-bit i.e. < 64kB const uint8_t *bmps[] = { lady_128x127x4_bmp, lady_128x127x8_bmp, }; // I would like to specify 32-bit (or 24-bit) addresses // this simply sign extends the 16-bit address into 32-bits const uint_farptr bmps[] = { lady_128x127x4_bmp, lady_128x127x8_bmp, }; // in an ideal world you could have a far modifier const far uint8_t *bmps[] = { lady_128x127x4_bmp, lady_128x127x8_bmp, };
There must be some sort of mechanism. After all, the linker is happy to put code above 64kB. And you don't need to handle function pointers differently.
Yes, I can write functions that accept farptr and calculate the farptr at runtime with pgm_get_faraddress().
But it would be a lot tidier if struct or array can be initialised at compile time.
Google finds this subject but I could not find the answer.
David.
Edit. Added G++ to Title