View previous topic :: View next topic |
Author |
Message |
ferrumvir
Joined: 01 Feb 2006 Posts: 64 Location: England
|
bootloader: start up options and interupts |
Posted: Sun Dec 03, 2006 4:24 pm |
|
|
Hi,
I'm about to write my own bootloader. And was hoping that you might be able to give me a thumbs up/down on what I'm hoping to achieve.
There are several different bootloader startup options I was thinking of using.
1/ If RS232 recieves [ESC] during the first N seconds then run boot loader else start application. The RS232 will use kbhit and not the interupts. This bootloader will work every time on power up and could be triggered by a reset called from the application.
2/ If a value at a know location in EEPROM is set correctly run bootloader, else start application. If the bootloading process is not started in N seconds reset the EPPROM to the "Don't boot load" state and restart PIC. Once the bootloading process is complete reset the EEPROM. This requires that all applications must have a routine (triggerable through RS232) to set a value in EEPROM and reset the PIC. If the application bootloaded does not have this facility then the PIC will require re-flashing with the bootloader.
3/ Same as above but the value is stored at a known location in PROGRAM memory.
At the moment I believe all to be workable startup options.
All these will use the RS232 connection to load the program. A second option will be to swap out the RS232 and replace with CAN, but will only function on 18Fxx8x PICs, the other bootloader should work for all PICs with an UART.
I would like to use one interupt (timer2) in the bootloader, this is just to flash a heart beat LED at double time when bootloading, so I have an obvious visual as to what the PIC is doing. This interupt will then be used in the main application at the slower rate. This interupt will also be used for the time out (N seconds, not bootloading, start). I believe this will possible, if not I can just use delays to delay the start of the application while waiting for bootlload communications.
I do appreciate that the falshing LED is a nice to have and will cost me program memory, I'll probably take it out of the final version, but to speed development I think it will be invaluable.
All the above will require specific PC programs to initiate bootload (except option 1) and actually bootload the applications. This is the only part of this that I have full confidence in.
Any comments would be most welcome, especially those that indicate that what I propose is a non-starter.
Thanks for any comments.
I still have a few question about where to put the various parts of the bootloader/application in PROGRAM_MEMORY in another thread, final clarification of my understanding would be appreciated from anyone willing to take the time to read the last post in http://www.ccsinfo.com/forum/viewtopic.php?p=72887
Cheers Scott |
|
|
EdWaugh
Joined: 07 Dec 2004 Posts: 127 Location: Southampton, UK
|
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Mon Dec 04, 2006 6:38 am |
|
|
You don't need to use an interrupt for the bootloader. It adds unnecessary complexity. Just use a timer and periodically check if the timer flag is set and use this to toggle the LED. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
ferrumvir
Joined: 01 Feb 2006 Posts: 64 Location: England
|
|
Posted: Tue Dec 05, 2006 2:29 pm |
|
|
EdWaugh,
Thank you, yes I have. Unfortunately this is just an serial bootloader (unless I missed somehting), and I eventually need a version on CAN. So though this would perform half the job beautifully, I'd be no further up the learning curve.
asmalli,
Thanks, I was way over complicating things. Well that solves that problem.
Cheers Scott |
|
|
EdWaugh
Joined: 07 Dec 2004 Posts: 127 Location: Southampton, UK
|
Hi |
Posted: Wed Dec 06, 2006 2:23 am |
|
|
Hi,
I see, although if you wanted CAN couldn't you just add a can to RS232 converter on the serial port. This would save a massive amount of hassle, if your not going big quantities commercial it probably doesn't matter.
cheers
ed |
|
|
ferrumvir
Joined: 01 Feb 2006 Posts: 64 Location: England
|
|
Posted: Thu Dec 07, 2006 2:40 pm |
|
|
EdWaugh,
Thanks again for your suggestion. At the moment we either directly flash the chips (insitue with chip clips) or use a 3rd party serial bootloader (which involves MAX232, caps. etc.). Unfortunately we're short of both pins and PCB space and moving everything to CAN if definitely the way forward.
The first stage is to remove our dependance to the 3rd party and secondly to clean up the whole design, free two pins and section of PCB.
Cheers Scott |
|
|
|