CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Bootloader, where?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
tae
Guest







Bootloader, where?
PostPosted: Wed Feb 15, 2006 12:01 pm     Reply with quote

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 Laughing 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
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Wed Feb 15, 2006 3:52 pm     Reply with quote

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. Wink
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
tan
Guest







PostPosted: Thu Feb 16, 2006 8:45 am     Reply with quote

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
tan
Guest







PostPosted: Thu Feb 16, 2006 2:16 pm     Reply with quote

Sorry 'bout that, had a big black out Embarassed 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?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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