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

Calling bootloader from application

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



Joined: 19 Feb 2010
Posts: 8

View user's profile Send private message

Calling bootloader from application
PostPosted: Mon May 01, 2017 3:41 am     Reply with quote

Hi,
I'm starting using bootloader on PIC24FJ128GA306. I've used the CCS serial bootloader and it works, now I'm adding the option to load from external flash. Application download the new firmware on ext flash and bootloader will program PIC.
Bootloader at start, application compiled with
Code:
#build (reset=0x2000, interrupt=0x2008)
#org 0, 0x1FFF {}

how to call bootloader from application if reset address point to application?
do I need to use ASM?

Thank you very much for your advise.
Ttelmah



Joined: 11 Mar 2010
Posts: 19339

View user's profile Send private message

PostPosted: Mon May 01, 2017 4:59 am     Reply with quote

The bootloader sits at address 0.
Calling the 'reset_cpu' command will take you there.

Understand, that the address 0x2000, is where your main code puts _it's_ entry point. The bootloader after deciding that it is not to execute, jumps to this address. reset_cpu, always takes you back to the hardware reset point, which is always at address 0.
Normally the bootloader will look at something like a switch, to decide that it is either to execute or not to execute it's 'load' code.
Your bootloader, will need to be modified, so that it can be signalled to ignore the switch when called from inside the code.
temtronic



Joined: 01 Jul 2010
Posts: 9163
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon May 01, 2017 5:33 am     Reply with quote

To expand Mr T's comments, one method to 'signal' to load the code from the external flash would be to have the loader look at a 'token' in the program in the ext. flash. One byte could contain ,say the 'version' number. A simple test like 'if ext flash program version number is > PIC version, then install ext flash program into PIC'.
Doing something like this ensures the newest version is always put into the PIC.

Obviously there are dozens of other 'signals' one could use, this is just what I did decades ago.

Jay
raffaele



Joined: 19 Feb 2010
Posts: 8

View user's profile Send private message

PostPosted: Mon May 01, 2017 6:35 am     Reply with quote

Thank you very much, I wrote here because it didn't seem to me that reset_cpu was launching bootloader and I'm newbie with bootloader.
Anyway now I'm finishing to write everthing, I've put flag, CRC32, and failing counter in the ext flash while the code to receive from serial is active (for a limited time) only on power up event when I suppose there is somebody switching on machine.
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