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 (loader.c) troubles...

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



Joined: 03 Oct 2003
Posts: 13

View user's profile Send private message

Bootloader (loader.c) troubles...
PostPosted: Mon Dec 01, 2003 2:16 pm     Reply with quote

I used the CCS bootloader sample, loader.c to make a simple boot loader for a PIC18F252. It seems to work very well when working with a toy/example program.

I went and tried to retrofit an existing (large) program with it, and immediately ran into trouble.

real_load_program
Seg 7C0A-7FFE, 033E left, need 0340
Seg 0000-0002, 0000 left, need 0340
Seg 0004-0006, 0004 left, need 0340
Seg 0008-00A2, 0000 left, need 0340

load_program

When I remove the "load.c" from my include list, I have 50% of my ROM free on the device, so I suspect that an individual segment is overflowing. I have gone through and used the #segment directive on all my functions, but it still doesn't seem to break things up enough. Does anyone have any suggestions on things I can do to get around the problem?

Thanks,

- Ted
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Mon Dec 01, 2003 3:04 pm     Reply with quote

I hope you meant #separate. Look at the lst file and the functions and see which ones are really large. Take those and break them up into smaller functions.
tedlarson



Joined: 03 Oct 2003
Posts: 13

View user's profile Send private message

PostPosted: Mon Dec 01, 2003 5:00 pm     Reply with quote

Whew!

After lots of looking at the list file, and breaking things up more....still no luck. Then, I started commenting things out until it would compile.

I isolated the problem to the following.
I have two global arrays in the program:

long vlist[25];
int vstat[25];

I notice that when I reduce the array size to something small....I suddenly can compile. I have a feeling that the compiler is trying to shove these into the same segment as the loader and having trouble. How can I move these out to somewhere else in memory, so they won't get in the way?

Thanks,

-Ted
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Mon Dec 01, 2003 6:57 pm     Reply with quote

Those are ram based and the problem you are having is rom shortage. sometimes moving variables around reduces the code size due to the bank switching instructions.
tedlarson



Joined: 03 Oct 2003
Posts: 13

View user's profile Send private message

PostPosted: Tue Dec 02, 2003 11:59 am     Reply with quote

Mark wrote:
Those are ram based and the problem you are having is rom shortage. sometimes moving variables around reduces the code size due to the bank switching instructions.


That is what I thought too. Although, I have noticed that I can reduce the total code size...so that the compiler will report to me that only 10% of the rom is being used. Then, I add-in the loader.c code, and I suddenly run out.

I have noticed that reducing the number of global variables I have affects it's ability to compile. Other than bank switching, is there something else about global variables that would cause an out-of-rom situation?

The behavior the compiler is giving me just doesn't make sense.

- Ted
tedlarson



Joined: 03 Oct 2003
Posts: 13

View user's profile Send private message

PostPosted: Tue Dec 09, 2003 8:36 pm     Reply with quote

Ok....CCS tech support replied with an answer to the problem. I thought I would post my results, so the next guy who has the same trouble will know what to do.

LOADER_SIZE is incorrect for the PCH compiler.
It is too small. Currently I am using 0x41F
and it seems to all work now....although that value was
obtained by trial and error.

The next problem I am having is, when using it on a PIC16F876, it sucks up 50% of the available ram. Sooo...I am stuck again, with a different problem now.

Anyone out there know the answer to this one?

Thanks,

- Ted
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Wed Dec 10, 2003 7:18 am     Reply with quote

Do you have
Code:

#device *=16

in your code?
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