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 support@ccsinfo.com

Understanding boot loading

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



Joined: 30 Mar 2008
Posts: 109
Location: New Jersey

View user's profile Send private message

Understanding boot loading
PostPosted: Mon Jan 23, 2017 12:39 pm     Reply with quote

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: 19439

View user's profile Send private message

PostPosted: Mon Jan 23, 2017 1:04 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jan 23, 2017 2:28 pm     Reply with quote

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: 19439

View user's profile Send private message

PostPosted: Wed Jan 25, 2017 2:54 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jan 25, 2017 4:21 am     Reply with quote

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