|
From: | Stefan Ernst |
Subject: | Re: [avr-gcc-list] Reusing code and variables from bootloader in main program |
Date: | Sat, 26 Jun 2010 23:15:31 +0200 |
User-agent: | Thunderbird 2.0.0.24 (Windows/20100228) |
Andrey Demenev schrieb:
link the bootloader with filesystem libraries, and in main program have a set of pointers to filesystem library functions in .noinit section. When bootloader is started , it upgrades main program if necessary, and then initializes the prointers with correct addresses and jumps to address zero, starting the main program. Since variables are in .noinit, main program would not initialize them, preserving the addresses.
Needlessly complicated. Place a table of jumps to the filesystem functions in the bootloader section at a fixed address (e.g. at the very end of the Flash). Then that functions have a (virtual) known fixed address, because you can simply "call" the table entries in the main program.
Obviously, main program also needs to know addresses of all global variables used by filesystem lib.
Best way is to *not* use any global variables in that functions. Instead let them operate on structures passed in by pointer. E.g. like this: FileStruct file; open(&file, ... read(&file, ...
[Prev in Thread] | Current Thread | [Next in Thread] |