View previous topic :: View next topic |
Author |
Message |
russk2txb
Joined: 30 Mar 2008 Posts: 109 Location: New Jersey
|
Understanding boot loading |
Posted: Mon Jan 23, 2017 12:39 pm |
|
|
Hi. I'm just starting to try doing a boot loader for a PIC18F4680. A portion of he code I have is: Code: | #org LOADER_END+2,LOADER_END+4
void application ()
{
// do {
// output_bit (PIN_E2, 1); // flash the led
// delay_ms (500);
// output_bit (PIN_E2, 0);
// delay_ms (500);
// }
while (TRUE);
}
void main () {
if (! input (PUSH_BUTTON)) {
printf ("\r\nBootloader Version 1.0\r\n");
// Let the user know it is ready to accept a download
printf ("\r\nWaiting for download...");
LoadProgram ();
}
application ();
}
#int_global
void isr ()
{
jump_to_isr (LOADER_END + 5 * (getenv ("BITS_PER_INSTRUCTION") / 8));
}
|
Note that in Application, the commented out code makes it the same as the example code. If that code is enabled then the segment is too large and I get an out of ROM error, as expected. But I can not understand how to adjust the #org statements to fix the problem. I don't understand the statement: #org LOADER_END+2,LOADER_END+4
It looks like it is reserving just 2 bytes to hold the application and main routines, but that can't be. Anyway when I try to change it, I get an invalid #org range error. Can someone explain how this works?
Thanks, Russ |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Mon Jan 23, 2017 1:04 pm |
|
|
For the bootloader, 'application' is just a 'placeholder'. It is not designed to hold any code at all (hence the size).
The actual 'application', is what is then loaded _by_ the bootloader.
The #org only affects the application. Read the manual. What does it say #org does?. |
|
|
russk2txb
Joined: 30 Mar 2008 Posts: 109 Location: New Jersey
|
|
Posted: Mon Jan 23, 2017 2:28 pm |
|
|
Ok, I wanted to have something that would show me that the loader had been bypassed - the button had not been pressed. So there must be a way to do that? I had already read the manual on #org. It says that it reserves space from the start address to the end address. So what is the point of reserving just 2 bytes?
Thanks, Russ |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Wed Jan 25, 2017 2:54 am |
|
|
It is just enough for the jump to say this is where the code is 'going' to sit.
If you want to include a 'real' non functioning application, do a search here. You can build an application, and then #include it into the bootloader.
Try "combine* files bootloader", and 'search for all terms'. |
|
|
russk2txb
Joined: 30 Mar 2008 Posts: 109 Location: New Jersey
|
|
Posted: Wed Jan 25, 2017 4:21 am |
|
|
Thanks Ttelmah. I did get past this issue and have my boot portion working. I posted a different question yesterday and will continue there.
Russ |
|
|
|