OK, the following works:
Using the multi-progmem-segment method
1) Store 64k of strings in PROGMEM_SEG2 (doesn't have to be exact or padded) denoted with a memory start location of 0x20000
2) Store ~64K of strings in PROGMEM_SEG3 denoted with memory start location of 0x30000
3) Store 20k of pointers to those strings in the lowest progmem space with PROGMEM_FAR which goes...I dunno where.
Plz note that you cannot deposit into memory a chunk of data larger than 64k, at least not with this version of avr-gcc/ld in the arduino 1.0.3. I believe this will be different once we get to avr-gcc V4.7...someday...maybe.
The strings can be accessed thus:
#include <morepgmspace.h>
if(accessing a char* in a string at a location < size of the 64k of stuff in seg 2){
unsigned int index = pgm_read_word_far(GET_FAR_ADDRESS(dictionary0[0]) +wordNumber*2); //wordNumber is the index into the array of strings called dictionary0
strcpy_PX(newWord,index,PROGMEM_SEG2_BASE);
}
else {
unsigned int index = pgm_read_word_far(GET_FAR_ADDRESS(dictionary0[0])+wordNumber*2); //note that the array dictionary0 also has data in SEG3!
strcpy_PX(newWord,index,PROGMEM_SEG3_BASE);
}
char* strcpy_PX(char* des, uint_farptr_t src,unsigned long base)
{
unsigned long p = base + src;
char* s = des;
do {
*s = pgm_read_byte_far(p++);
}
while(*s++);
return des;
}
Note that you cannot access the data in those SEG2/SEG3 locations through specification of an indexed addressing scheme like
unsigned int index = pgm_read_word_far(GET_FAR_ADDRESS(dictionary0[i]);
I have been utterly unsuccessful in storing and reading out of the SEG 1 location which is denoted with a memory start location of 0x10000. However, I can put 20k of char*s at wherever the attr PROGMEM_FAR puts it. I have to go back to look at the linker script (avr6.x) to see where that's being mapped to. I know it's going into .data (or maybe just past it...)
At least I understand what's happening now. If I try to put anything into PROGMEM_SEG1 I not only get errors trying to read it back, but the bootloader gives me a verification error - which is probably the root cause of the whole problem. I don't have it in me to look into the bootloader at this point... On to another problem!
Cheers to all
Joe