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

Bootloader for PIC24FJ32GA002

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



Joined: 16 Mar 2011
Posts: 19
Location: Melbourne, Australia

View user's profile Send private message

Bootloader for PIC24FJ32GA002
PostPosted: Sun Aug 28, 2011 8:56 pm     Reply with quote

Hi All,

I am trying to do come up with a bootloader who is capable of handle power cycling problems while doing the update.

The bootloader example in PICC/examples/ is basically a serial bootloader which is going to an unknown state upon power cycle during the update is going on.

What I suggest is 3 stage update mechanism with the example bootloader as follows:

Assume now the chip is in bootloader mode, expecting an application through serial port.

step1: send application.hex file without the very first record which contains information to update program memory 0th location with GOTO application's main function. reason: upon power cycle, program memory still have the bootloader's main function at location 0. which restarts the bootloader process.

step2: after sending complete application, sends the application.hex file's very first record which contains information to update program memory 0th location with GOTO application's main function. reason: now it is safe to update location 0 with GOTO application's main function as application successfully downloaded.

The problem here is I can do the step 1 without any issue and can verify by reading the program memory back. But when I execute step 2, it actually erase the program memory 0x00- 0x400, which 0x400 is the application main function's address.

I can see isr are there below 0x200. but they also get deleted and 0th location got updated successfully.

the very first record contains only 8 bytes starting from address 0. It doesn't seems updating anything else except 0th location.

Any ideas why 0x00 - 0x400 deleting when just updating 0th location?

I am using write_record_to_memory as it is in the example bootloader.

Thanks,
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Aug 29, 2011 9:45 am     Reply with quote

Quote:
it actually erase the program memory 0x00- 0x400

erasing 0x00- 0x400 can hardly happen, because full pages have to be erased. 0x000- 0x3ff (0x400 words) is the smallest erasable block including location 0 according to the PIC24F erase size.

Personally, I prefer a fail safe bootloader design according to Microchip AN1157.

Some previous threads related to PIC24 bootloaders:
http://www.ccsinfo.com/forum/viewtopic.php?t=36155
http://www.ccsinfo.com/forum/viewtopic.php?t=39535
http://www.ccsinfo.com/forum/viewtopic.php?t=42363
http://www.ccsinfo.com/forum/viewtopic.php?t=43566
LFern



Joined: 16 Mar 2011
Posts: 19
Location: Melbourne, Australia

View user's profile Send private message

PostPosted: Thu Sep 01, 2011 5:57 pm     Reply with quote

Thanks FvM,

The problem exactly is the full page erase by the write function when try to write on page start address.

With this PIC24F the page size is 0x800 and I successfully handled the fail safe bootloader functionality.

Let me brief what my PM (Program Memory) architecture is:

I have two main functions in side the PM. One is bootloader-main and the other one is application-main.

Bootloader-main is in PM address 0 at factory level. When it comes out from the factory, during the first configuration application program is download through the bootloader. Here application hex file writes except the first record which is trying to override the PM current address 0. So still PM adress 0 is in bootloader-main which is fail safe!

Just before the EOF in application hex, it includes the first record and upon receiving that, bootloader first reads 0x00 - 0x800 on to PIC24F RAM and do the 0x00 change and writes back the 0x00 - 0x800 page ensuring PM address 0 having the application main.

I have tested this and working fine.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Sep 02, 2011 1:29 am     Reply with quote

Your post still refers to unreasonable address ranges like 0 to 0x800. 0x800 belongs to the next page. I guess, this is only a typo.

Personally, I won't erase bootloader parts, even with RAM backup, because it's a possible reason of unrecoverable bootloader failure, at least in case of power loss.

Another possible problem in bootloader operation, that isn't handled by the CCS bootloader exampler sufficiently, is raised by discontinuous hex files. If I remember right, I discussed it in one of my PIC24 bootloader related posts.
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