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

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

Re: [avr-gcc-list] Sharing code between a bootloader and an application.


From: Dave Hylands
Subject: Re: [avr-gcc-list] Sharing code between a bootloader and an application.
Date: Mon, 29 Dec 2008 07:31:47 -0800

Hi David (replying to all this time)

On Sun, Dec 28, 2008 at 10:10 PM,  <address@hidden> wrote:
> Since bootloaders need to establish communications in order to function, it
> would seem useful to be able to use some of this functionality by the
> bootloaded application code.  In particular, this is in relation to CAN,
> where the boot-up code will need to establish a node-id, and be able to
> communicate serial number information to a central node.
>
>
>
> Obviously, access to the serial number, and links to the CAN driver
> routines, would be useful in the applications code, and would save
> duplication.
>
>
>
> How would one go about producing a header or library file that would let you
> link references to the routines in the bootloader for use in the
> application?

I did this with an i2c bootloader I wrote. What I did was to store a
header, with a magic number, and the address of a jump table. The jump
table contained word addresses of the various functions I wanted
within the bootloader.

The application code then starts searching from the beginning of the
bootloader looking for the "magic word". Once found, it can then
initialize function pointers to the various functions.

Since my i2c bootloader was interrupt driven, but only needed to use a
few of the interrupts, I was able to create a custom vectors.S file
and put the header and jump table in the middle of the interrupt
vectors.

You can find my code by looking over here:
http://websvn.gumstix.com (use a username of gumstix and password of gumstix)
Click on Buildroot, branches, projects, robostix, i2c-Bootloader.

The vectors.S file contains the header and jump table.

You'll also find some of the code in the Common directory. The
i2c-slave-boot.c file contains the application side of the code which
shares with the bootloader. i2c-slave.c is the file that gets compiled
into the bootloader.

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




reply via email to

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