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.
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 “[FONT=Verdana]stack frame too large”)[/FONT].
but if you can compile for an 8722 then this isn’t your problem.
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.
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
#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.
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.