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 N6NZ
Subject: Re: [avr-gcc-list] Sharing code between a bootloader and an application.
Date: Mon, 29 Dec 2008 10:28:38 -0800
User-agent: Thunderbird 1.5 (X11/20051201)

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?

Well, I started down the path of creating a general solution, but haven't done sufficient QA to release it to the world yet... perhaps you would like to alpha test?

I added a small, upward compatible tweak to the linker scripts to insert an "entry jump" section right after the interrupt vectors. Then a simple set of conditional assembler macros is used to build two different .o files from a single, trivial .S file that defines the shared functions. One .o is the actual trampoline jumps that go in the bootloader. The other .o is external definitions for the application to link against. As long as you do not change the order of the entry jumps and only add, and do not delete functions, the bootloader and application can be independently updated.

The linker script changes are upward compatible, in that if there is no entry jump section the script yields the same result as the production scripts, so it can become your regular linker script.

I have gotten as far as trying a tiny handful of non-functional examples and examining the disassembled binary. It looks OK, but has not yet been smoke tested. Let me know if you would like to try it out and I'll bundle up the code for you. I'm not going to get around to more testing until I finish my current (PIC... yuch) contract.

The idea is not original to me. I started with some code that Joerg sent to me that was sent to him by somebody else. And Data General, I believe, used the "entry jump" concept to call system functions and switch to protected mode in 1960's and 70's era mini-computers.

-dave

Thanks,

David



------------------------------------------------------------------------

_______________________________________________
AVR-GCC-list mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list





reply via email to

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