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

1 hexfile containing all : bootloader, program, eeprom

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



Joined: 23 Apr 2009
Posts: 42

View user's profile Send private message

1 hexfile containing all : bootloader, program, eeprom
PostPosted: Tue Apr 28, 2009 7:27 am     Reply with quote

Hi,

For production I use a PM3 from Microchip.
So to make a production hexfile I use mplab ICD2 to read out my complete flash and eeprom.

1) first i program the bootloader
2) with the tinyBld.exe i program my 18F4525
3) using ICD2 i read out the complete flash and eeprom
4) export this file to use it for production with PM3


After using the PM3 my bootloader is not working annymore.
It jumps directly to the actual program.

Checking the programmemory shows the bootloader is there

I use the tiny bootloader.

Did someone else encountered this problem?
Or does someone have a solution?



Help is appreciated Laughing

Kind regards

Koen
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Tue Apr 28, 2009 11:16 am     Reply with quote

I prefer to include the bootloader image with an #import statement to the application.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Apr 28, 2009 11:52 am     Reply with quote

Quote:
After using the PM3 my bootloader is not working annymore.
It jumps directly to the actual program.
Have you compared the fuses in the original PIC and the new programmed PIC?
Guest








PostPosted: Tue Apr 28, 2009 1:03 pm     Reply with quote

Hi,

Thanks for the reply. Laughing
I have inserted this #import (HEX=tinybld18F4525.HEX) but no luck.
The error below is cannot find file.
I have placed this in the same directory.



Code:


#include <18F4525.h>
   
#device adc=10


#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES HS//INTRC_IO                       //High speed osc with HW enabled 4X PLL
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES NOBROWNOUT               //No brownout reset
#FUSES BORV21                   //Brownout reset at 2.1V
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOCPD                    //No EE protection
#FUSES NOSTVREN                 //Stack full/underflow will not cause reset
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOWRTD                   //Data EEPROM not write protected
#FUSES NOEBTR                   //Memory not protected from table reads
#FUSES NOCPB                    //No Boot Block code protection
#FUSES NOEBTRB                  //Boot block not protected from table reads
#FUSES NOWRTC                   //configuration not registers write protected
#FUSES NOWRTB                   //Boot block not write protected
#FUSES NOFCMEN                  //Fail-safe clock monitor disabled
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES NOPBADEN                 //PORTB pins are configured as digital I/O on RESET
#FUSES RESERVED                 //Used to set the reserved FUSE bits
#FUSES MCLR                     //Master Clear pin enabled

#use delay(clock=20000000)



#import (HEX=tinybld18F4525.HEX)

#define MAX_FLASH 0xC000 //for PICs with 48KB of mem

#define LOADER_SIZE   0xFF   //tinybld size + a bit more (200 bytes is enough)

#org MAX_FLASH-LOADER_SIZE , MAX_FLASH-1 {}




Clean: Done.
Executing: "C:\Program files\Picc\CCSC.exe" +FH "blinkleds.c" +DF +LN +T -A +M +Z +Y=9 +EA
*** Error 18 "blinkleds.c" Line 105(8,32): File can not be opened
     File: .o
      1 Errors,  0 Warnings.
Halting build on first failure as requested.
BUILD FAILED: Tue Apr 28 20:42:39 2009
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Tue Apr 28, 2009 1:51 pm     Reply with quote

The correct syntax is:
Code:
#import (FILE=tinybld18F4525.HEX,HEX)

Depending on your bootloader design, also a range statement must be included with #import, to strip the part, that is replaced by the main application.
misperry



Joined: 03 Mar 2009
Posts: 40

View user's profile Send private message

PostPosted: Tue May 19, 2009 9:45 am     Reply with quote

Hello, I am getting the same problem. However, you will have to type in the path of where to find the hex file that you are importing.

But it still does not work. The Tiny bootloader will not let you overwrite the bootloader which is what the #import option does.

My MCLR does not work as well once the bootloader has been put on the chip. When I burn the chip with just the main code I want to run it works fine and MCLR will reset like it should. However, once the bootloader is placed on the chip as well as the main code the MCLR stops working? I wonder if tiny bootloader does not have the MCLR fuse set in its program. I don't know how to program in assembly so if any one knows how to enable the MCLR pin in asm that would be great
KaraMuraT



Joined: 16 May 2006
Posts: 65
Location: Ankara/Turkey

View user's profile Send private message Send e-mail

PostPosted: Sat May 23, 2009 2:33 am     Reply with quote

Hello,

@misperry, I think you should check the FUSE lines in the generated hex file (after the import).

Or If you have problems with combining two hex files (as you mentioned) you can check the hex files separately.

The fuse settings line is the line just before this: ":00000001FF"

If they are not equal, than copy your good old applications fuse setting line to the bootloader hex (with deleting the old one in the bootloader). I think it will solve your MCLR problem.

(related new topic)

Speaking about the fuse settings, if I use the #import statement, OK, combines to hex files (ugly but working Smile, with a slight disturbance. Combined hex file includes 2 fuse settings lines. That means the programmer will write that ROM space twice. And that means your PIC's flash endurance will be half of the defined. It's not a big deal for usual 100.000 cycle PIC's but it is a bit annoying for 1000 cycle products like J series.

I know removing the line with Notepad (I prefer Notepad++) is an easy task but I'm curious, is there any simpler method? Like adding a variable to the #import statement?

Thanks.
_________________
/// KMT
/// www.muratursavas.com
misperry



Joined: 03 Mar 2009
Posts: 40

View user's profile Send private message

PostPosted: Wed Aug 18, 2010 4:05 pm     Reply with quote

That is totally awesome!!!! Thanks so much that has taken care of a bunch of problems. That did the trick!!

Thanks again!!!
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Wed Aug 18, 2010 4:13 pm     Reply with quote

KaraMuraT wrote:

(related new topic)

Speaking about the fuse settings, if I use the #import statement, OK, combines to hex files (ugly but working Smile, with a slight disturbance. Combined hex file includes 2 fuse settings lines. That means the programmer will write that ROM space twice. And that means your PIC's flash endurance will be half of the defined. It's not a big deal for usual 100.000 cycle PIC's but it is a bit annoying for 1000 cycle products like J series.

I know removing the line with Notepad (I prefer Notepad++) is an easy task but I'm curious, is there any simpler method? Like adding a variable to the #import statement?



You are correct about the .HEX containing 2 sets of stuff that write to the same space.

I recently did a PIC32 bootloader that had to jostle around the .HEX file so I'm used to reading it and just delete the duplicate lines.

I don't know if there's an easier way other than that. Never dug in that deep since the case where I combined HEX files into 1 was for a seldom programmed PIC18.

I should try the importing Hex file to see what the resulting code is. (I'd imagine it carries the duplication issue.)
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
KaraMuraT



Joined: 16 May 2006
Posts: 65
Location: Ankara/Turkey

View user's profile Send private message Send e-mail

PostPosted: Thu Aug 19, 2010 4:08 am     Reply with quote

@misperry, I'm happy to hear, that worked for you.

@bkamen: I think there is no option in the #import statement. But there is a little, manual solution.

Copy the bootlader.hex file to your main projects folder. Name it "bootloader_import.hex" and delete the fuse line. You'll be good until you need another update in your bootloader code. When updated, same easy solution Smile

If you think about your working style, after a good working bootloader code, you'll need to update it very rarely.
_________________
/// KMT
/// www.muratursavas.com
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Thu Aug 19, 2010 9:56 am     Reply with quote

KaraMuraT wrote:

@bkamen: I think there is no option in the #import statement. But there is a little, manual solution.

Copy the bootlader.hex file to your main projects folder. Name it "bootloader_import.hex" and delete the fuse line. You'll be good until you need another update in your bootloader code. When updated, same easy solution Smile


That's fairly legit and would work just as well.

Cheers,

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Aug 19, 2010 11:15 am     Reply with quote

I'm surprized reading the above discussion about data contained twice in the hexfile. Although I doubt, that it will be actually written twice to the Flash (how do you think is it verified?), the unwanted entry can easily be removed.
Just use #import with a range specification, e.g.:
Code:
#import(FILE=my_usb_bootloader.hex,HEX,RANGE=0:0x17FF)
KaraMuraT



Joined: 16 May 2006
Posts: 65
Location: Ankara/Turkey

View user's profile Send private message Send e-mail

PostPosted: Sat Aug 21, 2010 5:15 pm     Reply with quote

FvM, your solution is pretty well. Noted...

You'll be surprised about another bug (looks similar with this one). My good old PIC18F66J90 (in fact it's a new series Smile ) gets two different fuse lines for a usual compile. In the beginning everything was normal, but after the firmware got bigger (after about 32K) things gone bad. I investigated it and saw that compiler creates a random fuse line after the correct one.

This is just a proof that MPLab uploads multiple codes for one memory location.

In fact I discussed it in a different topic. And unfortunately, this error still exists in the latest version.
_________________
/// KMT
/// www.muratursavas.com
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