[En-Nut-Discussion] UROM, GCC and files linked over 64K

Andrej Taran fant at vinnitsa.com
Thu Aug 17 14:50:10 CEST 2006


UROM not work with files which linked over 64K.
It  because pointer prog_char has size 16 bit, and memcpy_P, strcmp_P 
work with arguments in the lower 64 KB of the flash ROM (see pgmspace.h)
This solve this problem, I did so:

1.Write function far_memcpy_P, far_strcmp_P and correct uromfs.c.

void *far_memcpy_P(void *dest, uint32_t src, uint16_t size) {
  char *tmp = (char *) dest;

  while ( size-- )
    *tmp++ = pgm_read_byte_far(src++);

  return dest;
}

int far_strcmp_P(const char * cs, uint32_t ct) {
    char __res;

    while (1) {
        if ((__res = *cs - pgm_read_byte_far(ct++)) != 0 || !*cs++)
            break;
    }

    return __res;
}

2. Correct uromfs.h
struct _ROMENTRY {
    ROMENTRY *rome_next;  /*!< Link to next ROMENTRY structure. */
    uint32_t rome_name;   /*!< Filename. */
    u_short  rome_size;   /*!< File size. */
    uint32_t rome_data;   /* __attribute__ ((progmem));  !< File data. */
};

3. Create filecfg.c with crurom.exe

4. Correct filecfg.c. Comment //static ROMENTRY file1entry = {... and other

5. Add initialization file1entry and other

ROMENTRY file1entry;
ROMENTRY file2entry;
ROMENTRY file3entry;
ROMENTRY file4entry;
ROMENTRY *romEntryList = &file4entry;

void initcfg(void){
   file1entry.rome_next = 0;
   file1entry.rome_name = (uint32_t)&file1name+0x10000;
   file1entry.rome_size = 31070;
   file1entry.rome_data = (uint32_t)&file1data+0x10000;
... and other
}

2. Add in linker script
 .cfgfile 0x10000 : { cfgfile.o (.progmem.data) }

This is work. All files UROM linked to 0x10000 and we have 64k for they.
But so much for tangled, can know someone other way?

Best Regards,
Andrej








More information about the En-Nut-Discussion mailing list