View previous topic :: View next topic |
Author |
Message |
raffaele
Joined: 19 Feb 2010 Posts: 8
|
Calling bootloader from application |
Posted: Mon May 01, 2017 3:41 am |
|
|
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: 19539
|
|
Posted: Mon May 01, 2017 4:59 am |
|
|
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: 9243 Location: Greensville,Ontario
|
|
Posted: Mon May 01, 2017 5:33 am |
|
|
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
|
|
Posted: Mon May 01, 2017 6:35 am |
|
|
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. |
|
|
|