|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
MPLAB 8.0 error "Can not fit section"
I am getting the following error when compiling some code:
Code:
MPLINK 4.1 Linker Copywrite... Error - section '.udata_bob.o' can not fit section. Section ' udata_bob.o length= 0x00000158 Is this more than MPLAB can handle??? |
|
#2
|
|||
|
|||
|
Re: MPLAB 8.0 error "Can not fit section"
If I remember correctly, the PIC can't have more than 256 bytes in one memory segment. 2x11x5x3 will be 330 bytes, which is too big. You'll have to use a #pragma statement to put each array into its own chunk of memory. Take a look at section 2.9 of the C18 manual.
|
|
#3
|
|||
|
|||
|
Re: MPLAB 8.0 error "Can not fit section"
386 had this problem...
our solution was changing some static variables to non-static, or making them global. I apologize in advance for the lack of verbose response, I'm recovering from the all-nighters. --Chris |
|
#4
|
||||
|
||||
|
Re: MPLAB 8.0 error "Can not fit section"
Steve and Chris,
Thanks for the replies, I had a feeling it was something like this. I will see if I can find a different approach. All nighters are probably why I tried something like this in the first place. ![]() |
|
#5
|
||||||
|
||||||
|
Re: MPLAB 8.0 error "Can not fit section"
You could also break those declarations into separate files.
|
|
#6
|
|||
|
|||
|
Re: MPLAB 8.0 error "Can not fit section"
If your arrays are tables of constants, you can put them into the much-less-limited ROM by:
Code:
rom const int name [11][5]; |
|
#7
|
||||
|
||||
|
Re: MPLAB 8.0 error "Can not fit section"
That would be difficult, but not impossible. We use all three arrays in our Autonomous navigation code. It would be more of an inconvenience than anything else. I believe I found the reason we were having difficulty that made me try this approach. I had initialized an array as a LONG, but tried to dump ints into it without any indication they were ints. (In fact, I don't even know the correct way to do this, but I know it exists.
), I then called the data out without typecasting the values as ints. What I got was garbage. I re-declared the array as an int array, that should fix the original issue.Quote:
Thanks to both for your input. These are both techniques I/we should master in the off season. Thanks for adding to our list of things to learn!!! |
|
#8
|
|||
|
|||
|
Re: MPLAB 8.0 error "Can not fit section"
This is a linker default limitation. There is a method for supporting stacks > 256 as outlined in the MCC18 user guide, it involves merging multiple banks of registers. This seems to work for variable space too, but there may be limitations I'm unaware of. The code would need to be thoroughly reviewed and tested but this should work as I've seen it used on other PIC projects.
In the linker file, change: Code:
DATABANK NAME=gpr6 START=0x600 END=0x6FF DATABANK NAME=gpr7 START=0x700 END=0x7FF to DATABANK NAME=gpr6 START=0x600 END=0x7FF //DATABANK NAME=gpr7 START=0x700 END=0x7FF I built three int [11][5] arrays and got the same linker error. Then I merged the banks and did it again and it will link. I poked at some of the arrays with C code and looked at the machine code -- it looks correct. Code:
int vars1[11][5];
int vars2[11][5];
int vars3[11][5];
void testtest1( void )
{
static int var;
static int *ptr;
static int row,col;
var = vars1[4][3];
var = vars2[8][4];
376: var = vars3[3][1];
05762 C6FF MOVFF 0x6ff, 0x74d
05764 F74D NOP
05766 C700 MOVFF 0x700, 0x74e
05768 F74E NOP
377: var = vars3[3][2];
0576A C701 MOVFF 0x701, 0x74d
0576C F74D NOP
0576E C702 MOVFF 0x702, 0x74e
05770 F74E NOP
var = vars3[6][2];
for (row=0; row<11; row++)
for (col=0; col<5; col++)
var = vars2[row][col];
ptr = &vars3[0][0];
var = *ptr++;
}
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 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 |
| Error - section 'UTIL_LIB' can not fit the section. Section 'UTIL_LIB' length=0x00000 | BookerT | Programming | 0 | 25-01-2005 19:17 |
| Linking Errors: "section '????' can not fit the section. ..." | Astronouth7303 | Programming | 3 | 16-01-2005 21:36 |