[ECOS] moving functions into RAM

Andrew Lunn andrew@lunn.ch
Tue Sep 20 02:07:00 GMT 2005


On Mon, Sep 19, 2005 at 01:54:43PM +0100, Matt Sartori wrote:
> Hi all,
> I've looked through all the archived posts that mention the 
> 	Relocation truncated to fit: R_ARM_PC24
> and any mention of
> 	__attribute__ (section(
> 

Take the intel Strata as an example:

int flash_erase_block(volatile flash_t *block, unsigned int block_size)
        __attribute__ ((section (".2ram.flash_erase_block")));
int flash_erase_block(volatile flash_t *block, unsigned int block_size)
{
    volatile flash_t *ROM;
    flash_t stat = 0;

This will cause the code to be placed in ram. 

The fact you are getting a relocation error, suggests this is working
for you. Your ROM and RAM are too far apart to be able to make a
branch. You need to make a jump instead. Now the io flash driver code
knowns how to do this properly. 

// Use this function to make function pointers anonymous - forcing the
// compiler to use jumps instead of branches when calling driver
// services.
static void* __anonymizer(void* p)
{
  return p;
}

and:

    _flash_query = (code_fun*) __anonymizer(&flash_query);

    HAL_FLASH_CACHES_OFF(d_cache, i_cache);
    (*_flash_query)(data);
    HAL_FLASH_CACHES_ON(d_cache, i_cache);

But going through the anonymizer the compiler is forced to use a jump
rather than a branch.

        Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list