|
|
View previous topic :: View next topic |
Author |
Message |
moutinho
Joined: 12 May 2005 Posts: 31 Location: BRAZIL
|
Code sharing between bootloader and user appl using CCS? |
Posted: Thu May 12, 2005 11:38 am |
|
|
Hi,
I have to implement a bootloader that will update the system using a GSM modem device (wireless update). The code used to access the GSM modem is big and I believe I will not have enough memory if I have to duplicate this code for the bootloader and user application usage.
Question: how can I share this code between the bootloader and user application using C code ?
For instance, supose I have the following function:
receive_GSM_data()
Both bootloader and user application will have to use this function.
I intend to used this shared code at bootloader area.
Thanks,
Andre |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu May 12, 2005 4:07 pm |
|
|
I think your GSM functions (in the bootloader area) need to have
permanent entry points. You'll need to use the #org statement
to set the addresses of the GSM functions. (Or some stubs that
are used as entry points).
Look in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=7791
I have some code that shows how to do this.
When you compile your application program, the source file
should have the bootloader code in it. This way, your application
program will be compiled so that it calls the correct addresses
for the GSM code.
But when the user updates the application program, there is
a danger of over-writing the bootloader code. This problem
is solved by putting some tests in your bootloader code, to
prevent any writing to addresses in ROM which are within
the range where the bootloader is located. |
|
|
moutinho
Joined: 12 May 2005 Posts: 31 Location: BRAZIL
|
|
Posted: Fri May 13, 2005 11:09 am |
|
|
Hi,
Thanks, very good ideias.
Another doubt: can I double the used function or code for the application and bootloader usage.
For instance, supose I have a function read_GSM(). I want a copy of this function in the application memory area and bootloader area. Does the keyword DEFAULT of the #ORG command have something to do with it?
I have tried this:
teste() {
int a;
}
main() {
teste()
}
#ORG LOADER_ADDR, LOADER_END auto=0 default
bootloader() {
teste()
}
After compiling I only had one version of teste in the list file at 0x4 address. The first place where teste() function was defined.
Thanks,
Andre
PCM programmer wrote: | I think your GSM functions (in the bootloader area) need to have
permanent entry points. You'll need to use the #org statement
to set the addresses of the GSM functions. (Or some stubs that
are used as entry points).
Look in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=7791
I have some code that shows how to do this.
When you compile your application program, the source file
should have the bootloader code in it. This way, your application
program will be compiled so that it calls the correct addresses
for the GSM code.
But when the user updates the application program, there is
a danger of over-writing the bootloader code. This problem
is solved by putting some tests in your bootloader code, to
prevent any writing to addresses in ROM which are within
the range where the bootloader is located. |
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|