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

Creating a combined HEX file

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



Joined: 21 Oct 2006
Posts: 19

View user's profile Send private message

Creating a combined HEX file
PostPosted: Tue Jan 23, 2007 3:57 pm     Reply with quote

Hello,

I have a bootloader and an application hex file that works. Currently the only way to load the application hex file onto the PIC is through a USB cable after the bootloader is running on the PIC.

I would like to combine the bootloader and application code into one hex file for production reasons. I wanted to know if anybody had experience with this.

Is this possible without combining the codes in C? I was hoping there was an easy way to edit the hex files to accomplish this.

Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jan 23, 2007 9:21 pm     Reply with quote

http://www.keil.com/support/docs/2666.htm
davekelly



Joined: 04 Oct 2006
Posts: 53
Location: Berkshire, England

View user's profile Send private message

PostPosted: Wed Jan 24, 2007 1:55 am     Reply with quote

Another way is using MPLAB.

Select Configure, Settings, Program Loading.

Uncheck 'Clear Program memory upon loading'

Import one hex file, then import the other.

Then export to the combined one.
kuriken



Joined: 21 Oct 2006
Posts: 19

View user's profile Send private message

MPLAB
PostPosted: Wed Jan 24, 2007 3:29 pm     Reply with quote

Dave Kelly,

Thanks for replying. I followed your directions as best as I could. Below is what I did but does not work for me:

Installed Evaluation Copy of MPLAB
Created a temp project with PIC18F4620
Unchecked 'Clear Program Memory Upon Loading'
File,Import bootloader.hex
File,Import application.hex
File,Export combined.hex

I get a combined.hex file larger than application.hex. The first time it runs it runs fine. Once I turn the switch off and then on, it does not run properly.

Am I missing a crucial step some where? Is there a procedure to combine the hex files once both are loaded? Also is there a type of bootloader that I have to use for combining the code to work?

I noticed that if I import application.hex first, then bootloader.hex the combined.hex does nothing.
davekelly



Joined: 04 Oct 2006
Posts: 53
Location: Berkshire, England

View user's profile Send private message

PostPosted: Thu Jan 25, 2007 1:53 am     Reply with quote

Sorry, assumed you were familiar with MPLAB.

Set the correct processor first, under Configure, Select Device.

To ensure memory is completely cleared initially, select Debugger, Clear Memory, Program Memory.

Import the application code first.
Import the bootloader code.

Ensure all of the configuration bits are correct from Configure, Configuration bits (in case the bootloader and application had different settings)

Export the combined code. Disable the EEPROM export if there is no data for the EEPROM stored in the file - this may be why yours increased size.

The only caveat for the bootloader, is make sure all unused memory is cleared. When the second file is imported, any location which contains the blank code (eg 0x3FFF) gets skipped, any other value overwrites the original ocde. This of course may cause an error if there is a genuine 0x3FFF code in the bootloader!
kuriken



Joined: 21 Oct 2006
Posts: 19

View user's profile Send private message

Boot loader location
PostPosted: Wed Jan 31, 2007 9:13 pm     Reply with quote

Dave Kelly,

I've followed all of your instructions carefully. The combined code works the first time its run, but not after a hardware reset.

The only thing that I deverged from your instructions was that I loaded bootloader.hex first then the application.hex. My bootloader lives in lower memory.

Could it be that because my bootloader is in lower memory that the code does not work after a hardware reset? Is there anyway I can get my bootloader in lower memory to work with MPLAB to create a combined hex file?

Thanks
kuriken



Joined: 21 Oct 2006
Posts: 19

View user's profile Send private message

Got It Working!
PostPosted: Wed Jan 31, 2007 9:54 pm     Reply with quote

Dave Kelly,

Thank you for the support. I got it working! Eariler it wasn't working because I was power cycling the unit too fast and I had set the NO_BROWNOUT fuse. The hardware was never reset.

I now set the BROWNOUT fuse and everything works. Very Happy
mattam.ramesh



Joined: 30 Jun 2010
Posts: 3

View user's profile Send private message

Include Hex file in MPLAB
PostPosted: Wed Jun 30, 2010 3:12 am     Reply with quote

Hi kuriken and Dave Kelly,

I understand from your discussion on how to combine to Hex files which are of different memory locations. I may need your help on how to Include Hex file(Project_A Hex) into another Project(Project_B) and use the functions of Project A Hex file in Project_B and generate a Single Hex file from Project_B?

Your Help is greatly appreciated.
Regards,
Ramesh
Rohit de Sa



Joined: 09 Nov 2007
Posts: 282
Location: India

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

PostPosted: Wed Jun 30, 2010 11:04 pm     Reply with quote

I've read elsewhere on the forum on ways to use the '#import' directive.
http://www.ccsinfo.com/forum/viewtopic.php?t=38730

But I do it the simple and no-brain way :-P

-Burn the bootloader hex onto my chip
-Use the bootloader to burn my application hex
-Use a PICKit2 to read the chip
-Save the hex as "combined.hex"
-Use this hex to program other chips

This allows me to ensure that the bootloader+application works on a microcontroller before I mass burn it.

Rohit
mattam.ramesh



Joined: 30 Jun 2010
Posts: 3

View user's profile Send private message

Two application Hex in one Hex file
PostPosted: Wed Jun 30, 2010 11:29 pm     Reply with quote

Hi Rohit,
Thank you for the quick reply.
My requirement is different. My supplier gives me an application Hex file to upload in my chip. Our company will give set of .c & .h files(our own logic) to that supplier to include(integrate) in his project file and generate application Hex file.
We have decided not to share our code/logic to the supplier, instead give a Hex file or Library file.I have done creating Library file, but the disadvantage is, I also need to give .h files along with the .lib file to my supplier. So, my plan is just to give the Hex file and the function names to call in his project (application Hex file).

Hope I have explained better :-)
Is this a meaningfull idea? I am pretty new to firmware coding.

Regards,
Ramesh
Rohit de Sa



Joined: 09 Nov 2007
Posts: 282
Location: India

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

PostPosted: Wed Jun 30, 2010 11:39 pm     Reply with quote

Hi Mattam:

From what I understand, you (and your supplier) don't want to share source code. I suppose this is to protect your IP. Do bear in mind though, that giving him your hex doesn't really 'protect' you intellectual property. It may make it harder for him to get to your code, since he'll have to disassemble it and go through it line by line. But with time and effort it is entirely possible that he gets a hold of your logic.

That aside, if IP protection is not of importance, I would recommend you use the "#import" directive. Look at the CCS help for more info. The directive allows you to directly import a hex (the complete hex or just certain location ranges) into your code. If your supplier also uses CCS, then he can use this method to incorporate the hex that you provide into his compiled code.

Rohit
mattam.ramesh



Joined: 30 Jun 2010
Posts: 3

View user's profile Send private message

Two application Hex in one Hex file
PostPosted: Thu Jul 01, 2010 12:01 am     Reply with quote

Hi Rohit,

Thank you for valid information, I think I will have to work as you suggest.

Regards,
Ramesh
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