Go to Post If you are old then our lead mentor is ancient. Oh wait, he is. Oh wait, that makes me ancienter. - JaneYoung [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 18-03-2008, 14:12
de_ de_ is offline
Registered User
AKA: Dave Edwards
FRC #1310 (Runnymede Robotics)
Team Role: Mentor
 
Join Date: Apr 2005
Rookie Year: 2005
Location: Toronto, Ontario
Posts: 256
de_ is a jewel in the roughde_ is a jewel in the roughde_ is a jewel in the roughde_ is a jewel in the rough
HELP - Link Error "Will Not Fit Section" 8520PIC

I have read other posts on this and mine seems to be different

Note this error occurs when the target is 8520 but not on the 8722. However my development test CPU setup is an 8520 which is essential for testing..

Error - section '.idata_user_routines.o_i' can not fit the section....

It appears my statically initialized user variables won't fit in one FF "bank" or "section"??? . I have apparently not been successfully in modifying the linker script to combine banks. No matter what I do in terms of #pragma idata commands and script commands, all idata is combined and seems to be limited to FF even though the bank is merged and has 1FF. I am not aware of any large initialized arrays etc.

I don't believe splitting code out to other modules will help, idata is idata and will be merged by the linker to one common section ??? I can't see any major opportunity to shrink the size yet.

Also, how do I get a listing ? I would love to be able to identify the source of each item in the idata section.
  #2   Spotlight this post!  
Unread 18-03-2008, 14:25
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,754
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: HELP - Link Error "Will Not Fit Section" 8520PIC

There are a few ways to check your memory allocation:

-- The Memory Gauge in MPLAB under View will give you a grand total, however, you need to be able to compile it completely. Try using the 8722 as the target processor just for the purpose of getting a complete map.

-- The xxx.map file with a complete listing is your best resource. To generate it go to Project->Build Options->Project, then the "MPLINK linker" tab and click "Generate map file." It'll be created in your project folder.

Splitting out your data declarations can help, but it depends on how well you are heeding the chip limitations.
The linker will divide and reorganize your data locations to fit it into the various data blocks available. I wouldn't modify the linker script or use pragmas unless absolutely necessary and you don't have to ask these kinds of questions.

Remember too that the default code you may be using will have it's own data to allocate space for, so you won't have the full 2048 bytes of a PIC18F8520, you'll have more like 1340 bytes, unless you streamline the code. You also need to allow room for the stack and temporary variables.
Also, if your data fits on an 8722, then data block size probably isn't your problem. The data banks are the same size on both chips. The 8722 just has twice as many of them. 0xFF is all you get for a single block, but you have several of those blocks available to you. That size is a limit if you have an array that is greater than 256 of type char or 128 of type int.

Remember the limits before you combine data blocks:
  • 256 bytes of global variables declared within any one MPLAB file (typical error message "udata..." or "idata...").
  • 120 bytes of variables declared within a single routine (typical error message "stack frame too large").
but if you can compile for an 8722 then this isn't your problem.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 19-03-2008 at 12:30.
  #3   Spotlight this post!  
Unread 18-03-2008, 17:58
de_ de_ is offline
Registered User
AKA: Dave Edwards
FRC #1310 (Runnymede Robotics)
Team Role: Mentor
 
Join Date: Apr 2005
Rookie Year: 2005
Location: Toronto, Ontario
Posts: 256
de_ is a jewel in the roughde_ is a jewel in the roughde_ is a jewel in the roughde_ is a jewel in the rough
Re: HELP - Link Error "Will Not Fit Section" 8520PIC

Thanks for the insights. Now my 8722 project gets the same error.

I will try split stuff up into separate files. Its getting too long anyway.

Is that limit of 256 bytes of global memory declared per file limitation documented somewhere (in the C18 manual) ?
  #4   Spotlight this post!  
Unread 18-03-2008, 19:36
de_ de_ is offline
Registered User
AKA: Dave Edwards
FRC #1310 (Runnymede Robotics)
Team Role: Mentor
 
Join Date: Apr 2005
Rookie Year: 2005
Location: Toronto, Ontario
Posts: 256
de_ is a jewel in the roughde_ is a jewel in the roughde_ is a jewel in the roughde_ is a jewel in the rough
Re: HELP - Link Error "Will Not Fit Section" 8520PIC

On last 8520 build before linker problems, program mem was 12800 out of 16k. Data memory 963 out of 2k

After I split user_routines.c into two files...
-8722 builds with 15871 of 65K program memory, 1145 out of 3935 data memory.

- 8520 fails to link with Error - section '.code_putc.o' can not fit the section. Section '.code_putc.o' length=0x00000084

If the 8520 only has 16K program memory, then maybe I have run out of it given I'm up at 15,871 on the 8722.

However, this is a different problem than I originally reported, that being being out of idata (which sounds like your 256b global memory per file). But that might have been solved by splitting the files.

I am going to have to read up on the architecture.
  #5   Spotlight this post!  
Unread 19-03-2008, 10:56
dcbrown dcbrown is offline
Registered User
AKA: Bud
no team
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Hollis,NH
Posts: 236
dcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud of
Re: HELP - Link Error "Will Not Fit Section" 8520PIC

It sounds like the linker cannot find a contiguous chunk of RAM to place this fairly large section of ram (132 bytes).

For example, lets say you have 2k of ram available in 8 banks and create 9 129 byte arrays for a total of 1161 bytes. The linker won't be able to find any place large enough for the 9th 129 byte array to fit into because each bank only has 127 bytes of room left -- lots of space but too fragmented to use.

If you'd like a hand, zip up the project and private message me and I'll take a look. I'll bet it can be tweaked to do what you want, it might just need some more linker persuasion via pragmas.

There isn't a full 16k available for the user on the 8720, the first 2k of program space is reserved for the protected boot loader code (0-0x800).

Merging ram blocks in the linker file elminates the default maximum of 256 bytes per module -- its just not recommended because then the bank register is then not guarenteed to be the same for all variables in a module which has compiled code size implications.

One thing that odd, but noteworthy. If I create lots of udata variables, the linker will automatically place it in the large ram segment without prompting. But if I create lots of idata variables, it doesn't. In this case I needed to add the specific pragma line

Code:
#pragma idata bigidata=0x600

int vars1[11][5]={0};   // 110 bytes (idata)
int vars2[11][5]={0};   // 110 bytes (idata)
unsigned char pad;  //   1 byte (udata)
int vars3[11][5]={0};   // 110 bytes (idata)
The linker map merged 0x600-0x7FF into one ram segment.

Last edited by dcbrown : 19-03-2008 at 11:39.
  #6   Spotlight this post!  
Unread 19-03-2008, 11:33
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,754
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: HELP - Link Error "Will Not Fit Section" 8520PIC

The 15,871 (specified as 2-byte words BTW, so 31,742 bytes) certainly looks pretty full. There is some overhead that doesn't appear but is responsible for 1k or so of lost program memory space. If I recall correctly you really only get 30,720 bytes or roughly 90% of the total available as reported by MPLAB for the PIC18F8522. MPLAB doesn't tell you about everything.
If it were a data memory limit you'd see udata or idata as part of the error message. The idata error is for static initialized variables but often works out to be a secondary indicator that your program memory is also filling up (seems to be a psychological thing).

A quick test/solution would be to turn on some of the built-in compiler optimizing to automatically reduce the amount of program memory you're using and that'll probably fit your code at least into the 8522 chip.

In MPLAB go to:
Project->Build Options->Project
then the MPLAB C18 tab
Unclick "Use Alternate Settings" (if it's checked off).
then at the top of that you'll see "Categories:" with a pull-down menu where you can select "Optimization"
On that menu just click "Enable all"
Apply it, but make sure all the "-Ou- -Ot-" etc. are not still set in the General MPLINK C18 tab. MPLAB can make it difficult to hold onto these setting changes. If you want to use Alternate Settings just remove the -O flags.

Re-compile and see how much program space you save. You'll probably see a 30% reduction.

The optimizations can be individually selected if you like. Each are described in the C18 manual.

P.S. I'd editing this a bit as I remember stuff.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 19-03-2008 at 13:44.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MPLAB 8.0 error "Can not fit section" billbo911 Programming 7 20-02-2008 15:26
complie error can not fit the section. Section xxxx Doug Leppard Programming 5 12-02-2008 09:44
Program error - "can not fit the section" miketwalker Programming 9 20-02-2005 01:21
Error - section 'UTIL_LIB' can not fit the section. Section 'UTIL_LIB' length=0x00000 BookerT Programming 13 27-01-2005 09:49
Linking Errors: "section '????' can not fit the section. ..." Astronouth7303 Programming 3 16-01-2005 21:36


All times are GMT -5. The time now is 14:08.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi