I have been deveoping an Arduino projecct with some image data in PROGMEM that pushes the total PROGMEM usage above 64K. The problem is that once this boundary is exceeded several core functions that use PROGMEM structures start playing up. In particular the portInputRegister macros don't work and all the I/O fails!

The pgm_read_byte_far() macro (refered to in other posts and forums) is not really practical in this situation as all PROGMEM access would have to change. A better solution is to leave the core data in the low 64K and have another segment in a higher area of memory.

After much experimentation I found that the following will push the data into the highest area of the .text segment above the code:

The ideal solution would be a section specifically to serve this purpose and a macro like PROGMEM to force data into that section.

Normally, the .finiN sections are used for shutdown code. When main returns, the run-time library executes code in all the .finiN sections with the final section essentially being a halt.

In the Arduino world, main never returns which leaves the .finiN sections free for you to use as you wish.

I have no idea if the .finiN sections are guaranteed to be placed after all other sections (at the highest addresses). You may want to spend some time with the GCC linker documentation to determine if the guarantee is or is not made.

I have no idea if the .finiN sections are guaranteed to be placed after all other sections (at the highest addresses).

yes. they are. For reasons that aren't entirely clear, progmem data is normally put in the flash address space FIRST.This is controlled by the linker scripts, ie /hardware/tools/avr/avr/bin/../lib/ldscripts/avr6.xAccording to that, .fini7 is for "C++ destructors", and I don't see anything that looks significantly more appropriate for "high" progmem...