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 CCS Technical Support

If I wanted to do a bootloader on a PIC24 - what choices?

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



Joined: 23 Apr 2007
Posts: 91
Location: Rochester, England

View user's profile Send private message Visit poster's website

If I wanted to do a bootloader on a PIC24 - what choices?
PostPosted: Wed Sep 26, 2018 8:28 am     Reply with quote

Hi Folks,

Hypothetical question. I've got a PIC24 in a system running great, and doing just what I need it to. It's connected via a modem to a web server that we've also created and all is hunky dory.

If I wanted to add to the system the ability to reprogram the processor remotely, what options do I have?

I do have a spare EEPROM space on the board - where potentially I could fit a 1Mbit I2C eeprom - if that is an option, although there is always the phobia of it not copying across the code right and failing.

Don't mind changing the board, don't mind adding a 2nd processor to do it.

Needs to be pretty bullet proof though.

Ideas on a postcard please.

Thanks

James
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Wed Sep 26, 2018 9:00 am     Reply with quote

Bootloader: http://www.smallridge.com.au/ (why reinvent the wheel?)

Very satisfied customer of Andrew's SD card driver. If I had a need for an ethernet bootloader, Andrew would be the first person to whom I would turn.

On a side note, my present employer is facing the same issues and questions you are presently contemplatiing. We're leaning toward a 1Mb SPI EEPROM with extra overhead code running in the main application to do a rigorous check on any new image. We are also looking at a mechanism to keep not only the new image but also the last image. In that manner, if there is something very obviously wrong with the new image, at least the end user can force it to revert to the previous image.
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Wed Sep 26, 2018 10:09 am     Reply with quote

Newguy makes the critical point. "rigorous check on any new image".
At the end of the day you can do a bootloader in protected memory space on the PIC24. Have it load from the EEPROM. Then have extra code in your "main" that reads the file, and does checksum and validity checks on this before storing this, and setting a bit to signal to the bootloader code to actually perform the programming.
You can do exactly the same with an external PIC, which then programs the main chip.
In both cases the bootloader/programming code looks for a flag in the EEPROM to perform the programming. This is only set once you have verified the code is correct.
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Thu Sep 27, 2018 9:36 am     Reply with quote

Ttelmah wrote:

In both cases the bootloader/programming code looks for a flag in the EEPROM to perform the programming. This is only set once you have verified the code is correct.


Another trick is to have the bootloader implement a WDT timer, enabling it when it passes control to the application. This does require the application to handle the WDT. The, if more than X WDTs occur since the application was initially bootloaded, then bootload the alternative image. For this to work, the bootloader would need to have write access to a very small part of the SPI EEPROM to store information. This technique works better if the HW implements a RTC that the bootloader can read, in this way you would count the number of WDT resets over a given time period.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
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