avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Is some special attribute or qualifier required to ma


From: Dave Hylands
Subject: Re: [avr-gcc-list] Is some special attribute or qualifier required to make C function tables to use the right linker stubs?
Date: Wed, 30 Apr 2014 10:03:51 -0700

Hi David,

On Wed, Apr 30, 2014 at 8:49 AM, David Fernandez <address@hidden> wrote:
>
> Hi there (likely Joerg Wunsch will know this),
>
> In devices like ATxMega256xxx, I see that the C function tables I
> declare, and the function pointers, end up being 16-bit, and so-far
> everything seems to assume that EIND is 0 and functions will be in the
> first 64K (my current code is not that big yet).

The assembler uses word addresses, so a 16-bit entry can refer to 128K
So check the addresses from the linker map (which are byte addresses) and compare those to what is stored. My recollection is that if you use function pointers, then everything just works.

> Will avr-gcc use the right relocation when picking one function from the
> array and calling it? or should I declare the functions with some
> special attribute and/or do some assembler magic with gs() operator when
> calling those kind of functions.
>
> So far I see that gcc put some trampoline calls after the interrupt
> vectors for some functions, but everything fits within the first 64K so far.
>
> I'm just trying to be sure that when code begin to fall off the first
> 64K, I'm not going to get funny problems a few weeks later, after I
> completely forgot about this thing.

I wrote an i2c bootloader for the 128, and I ran into some issues similar to what you describe.

If you look in http://svn.gumstix.com/gumstix-buildroot/branches/projects/robostix/i2c-BootLoader/vectors.S at jump_table, I declare 3 16-bit pointers into my bootloader.

Then, in this file: http://svn.gumstix.com/gumstix-buildroot/branches/projects/robostix/Common/i2c-slave-boot.c The BootloaderJumpTable just contains ordinary function pointers. I copy the jump table from flash into RAM in the I2C_SlaveBootInit function and then just call through the function pointers to call into the bootloader.

I had to be able to copy data from anywhere in the flash, so I created an addr32 macro that returns a 32-bit address of an arbitrary object in flash:
http://svn.gumstix.com/gumstix-buildroot/branches/projects/robostix/i2c-BootLoader/BootLoader.c
Search for addr32

Anyways, not exactly what you're looking for, but hopefully a few ideas to help you along. Feel free to ask questions.

--
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com

reply via email to

[Prev in Thread] Current Thread [Next in Thread]