Stu Bell wrote:
I have an interesting idea/problem and I'm looking for ideas.
I would like to place et_ERR_NO_ERROR and et_ERR_TIMEOUT in high flash
(easy), BUT I then want to place the index dereferenced from .proghigh
(where all of these constants are placed) in ErrorTextTable[].
Here's my suggestion. Not fancy because you have to give the section
start address and define by hand but what's being done is a hack anyway.
This is given to compiler (byte address):
-DEXTPROGMEM_START=0x10008UL
And this to linker (byte address too):
-Wl,-section-start=.extprogmem=0x10008
#include <avr/pgmspace.h>
const char et_ERR_NO_ERROR [] __attribute__((section (".extprogmem"))) =
"No Error";
const char et_ERR_TIMEOUT [] __attribute__((section (".extprogmem"))) =
"Timeout";
#define FARTONEAR(a) ((uint16_t) ((a) - EXTPROGMEM_START))
#define NEARTOFAR(a) ((uint32_t) (a) + EXTPROGMEM_START)
uint16_t ErrorTextTable[2] PROGMEM = {
FARTONEAR(et_ERR_NO_ERROR),
FARTONEAR(et_ERR_TIMEOUT)
};
int main(void)
{
volatile uint32_t farp = NEARTOFAR(pgm_read_word(&ErrorTextTable[1]));
volatile char c = pgm_read_byte_far(farp);
}
-Tero
_______________________________________________
AVR-libc-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev