![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
tae Guest
|
Bootloader, where? |
Posted: Wed Feb 15, 2006 12:01 pm |
|
|
Hi, can someone explain to me were the bootloader code can(must) be placed physically? I'm thinking about to use the codeloader from "thebytefactory".
I have a program that are running to day and I want to insert this function.
I know its triggered by pressing the '=' (rs232)during reset. But must I place the main() code in my main()? I wouldnt like to have more code in it.
I'm thinking about if I can instead use a flag and jump to a subroutine in an other file(.c)? and make the re-programming in there? But were should the jump take place? in my main?
When I tryed to set the #org 0x0008 MAX_LOADABLE {}
and use MAX_LOADABLE as 0x6800 it makes an ROM error.
Im using a PIC18F2525, were should the #org be set?
and were must the subroutine be placed?
How do I know from PIC to PIC were to place it everytime?
Its obvius that I havent used a bootloader before, thats why I would like to have someone to explaine the functions of it.
Have a nice day |
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Feb 15, 2006 3:52 pm |
|
|
The bootloader is a seperate program existing next to your application program. After a reset the bootloader is first executed and checks for software updates to be performed, when ready it passes control to your application.
Key to implementing a bootloader is that you must remember the PIC starts program execution at address 0 on power up. The trick is to install a jump to your bootloader at address 0. When the bootloader has finished it passes control to your application by jumping to main() of your user application at a pre-defined address. This pre-defined address is something you have to decide on during design time so both the bootloader and the main application will use this same address.
Two approaches exist for locating the bootloader in program memory: either at the very bottom or at the very end of program memory. This is a design decision where both options have their advantages.
Option 1: Bootlader at memory bottom
Most bootloaders you will find for the PIC will place the bootloader at the start of memory which has the advantage that the bootloader automatically gains access to the important address 0. Disadvantage is that you have to relocate the addresses for the main() and interrupt functions of your application, forgetting to do so will have your bootloader being overwritten by the application.
For relocating main() and the interrupt vectors check the manual for the #build directive.
Option 2: Bootloader at memory end.
This has the advantage that you don't have to relocate your application program and interrupt vectors. Disadvantage is that your bootloader somehow has to find a way of inserting the jump to the bootloader at address 0, with the risk that a failing program update might leave a corrupted jump vector at address 0.
The ByteFactory bootloader is an example of this approach.
Another good bootloader and a short introduction with picture can be found at
Tiny bootloader |
|
![](templates/subSilver/images/spacer.gif) |
tan Guest
|
|
Posted: Thu Feb 16, 2006 8:45 am |
|
|
The tiny looks good, but I want to use the hyperterminal to program with and I dont got any spare pins to use for determinate bootloading.
I tryed to use the "thebytefactory", but I get an ROM error. It seems that no value is valid for the MAX_LOADABLE. I tryed to have the code in the main() and the application (former main) in a func application(), before and after the main code. I thik that I could also have the code in another file, and just call the bootloader function by
void main(void){
bootloader();
}
void application(void){...}
Or....
Must I also make an #org for my isr()'s and application that I had before?
And it should be possible to use a sw rs232, or must I use the hw UART?
So the question still remains, where should the bootloader code be placed?
And how do I put it there in a 18f2525?
Thanks |
|
![](templates/subSilver/images/spacer.gif) |
tan Guest
|
|
Posted: Thu Feb 16, 2006 2:16 pm |
|
|
Sorry 'bout that, had a big black out never used a bootloader before...
Of course I have to make a projekt of it and just program the bootloader in my pic at start...I was trying to make the whole thing at once.
And then use IT for programming the application in to my pic.
Thats what the bootloader is supposed to do.
Quote: |
Key to implementing a bootloader is that you must remember the PIC starts program execution at address 0 on power up. The trick is to install a jump to your bootloader at address 0. When the bootloader has finished it passes control to your application by jumping to main() of your user application at a pre-defined address. This pre-defined address is something you have to decide on during design time so both the bootloader and the main application will use this same address.
|
I'm gone try it tomorrow, and also gone try to use a software rs232. Takes some init work, setting TRIS, hope its not going to give me to much trouble.
Thanks to ckielstra for your breefing.
Hope I did get it right now? |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|