View Single Post
  #8   Spotlight this post!  
Unread 17-01-2007, 12:48
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: _entry_scn error on building

Build all and look at the last line before MPLINK in the output window, is it similar/identical to the following:

Quote:
Executing: "E:\mcc18\bin\mplink.exe" /l"C:\mcc18\lib" "C:\CPrj\2007\Default\18f8722.lkr" "C:\CPrj\2007\Default\main.o" "C:\CPrj\2007\Default\user_routines_fast.o" "C:\CPrj\2007\Default\user_SerialDrv.o" "C:\CPrj\2007\Default\ifi_startup.o" "C:\CPrj\2007\Default\ifi_utilities.o" "C:\CPrj\2007\Default\user_routines.o" "C:\CPrj\2007\Default\FRC_library_8722.lib" /m"FrcCode.map" /o"FrcCode.cof"
In your .mcw project window, find and double click the 18f8722.lkr file to open it. This is the linker file. In it should be the following near the top:

Quote:
//FILES c018i.o
FILES clib.lib
FILES p18f8722.lib
This is what the "FILES" comment refers to. The libraries are pulled from $(LIBDIR), which you can find when you open Project -> Build Options -> Project and select "General" tab. Under the same view, verify that the "Linker-Script Path" which is located at the bottom of the window is blank (see attached figure) - otherwise the project could pull in the default linker file... which as we will get to shortly can cause this error.

NOTE: The ifi provided linker file is different from the default linker file that comes from Microchip - the ifi version has the c018i.o reference commented out. If the line is missing the '//', add them in and rebuild all. If the linker file is ok, take a close look at the "Executing... mplink..." line in the build output window. Is the project picking up the linker file from the project directory or from the Microchip default directory? Referencing the wrong one will cause the problem.

I changed my linker file by uncommenting the "FILES c018i.o" line as follows to force the error in my project:

Quote:
FILES c018i.o
FILES clib.lib
FILES p18f8722.lib
The error message appears, as expected in this case:

Quote:
Copyright (c) 2004 Microchip Technology Inc.
Error - section '_entry_scn' type is non-overlay and absolute but occurs in more than one input file.
Errors : 1
That's because the linker file is now the same as Microchip's which includes the entry section in c018i.o (you can see this in \mcc18\lkr directory).

So the error message is indicating that somewhere in the link procedure it is encountering multiple modules that are defining the _entry_scn, but it only wants one definition. See section 2.9.1.4 of the C18 user guide under reserved section names for a description of this reserved section. Hopefully you haven't attempted to create another section of this name. If you don't think so, then you didn't. You'd have to add pragma statements defining the section name.

I used mplib /t on the libraries, but they look clean. I then looked into the View -> Disassembly Listing of the project and found that this section is declared in ifi_startup.c:

Quote:
27: #pragma code _entry_scn=RESET_VECTOR
28: void _entry (void)
29: {
30: _asm goto _startup _endasm
00800 EF9E GOTO 0x393c
00802 F01C NOP
31:
32: }
00804 0012 RETURN 0
Neither map or listing file will be generated if there are linker errors. So, if you want to trouble shoot this more you can change the ifi_startup.c temporarily by adding "#ifdef NEVER" just before the pragma statement in ifi_startup.c and adding an "#endif" at the end of that file.

Quote:
#ifdef NEVER
#pragma code _entry_scn=RESET_VECTOR
void _entry (void)
{
_asm goto _startup _endasm

}
:
.
#endif
Rebuild all.

Now, View -> Disassembly Listing (this assumes it now builds without errors). In this file do a View->Find for _entry_scn - scroll up and you will find which file is definining this section. Now at least you know which file is causing the problem and you can figure out how the linker is getting this file.

In my example:

Quote:
--- C:\mcc18\src\traditional\startup\c018i.c ---------------------------------------------------
1: /* $Id: c018i.c,v 1.3 2004/07/30 17:28:43 ConnerJ Exp $ */
2:
3: /* Copyright (c)1999 Microchip Technology */
4:
5: /* MPLAB-C18 startup code, including initialized data */
6:
7: /* external reference to the user's main routine */
8: extern void main (void);
9: /* prototype for the startup function */
10: void _entry (void);
11: void _startup (void);
12: /* prototype for the initialized data setup */
13: void _do_cinit (void);
14:
15: extern volatile near unsigned long short TBLPTR;
16: extern near unsigned FSR0;
17: extern near char FPFLAGS;
18: #define RND 6
19:
20: #pragma code _entry_scn=0x000000
21: void
If this doesn't help or there are still problems, then cut and paste the "Executing ... mplink... " line from the mplab output window so we can see what is being linked together.

AND DON'T FORGET to remove the #ifdef NEVER...#endif from the ifi_startup.c file when done troubleshooting!


Bud
Attached Thumbnails
Click image for larger version

Name:	project.JPG
Views:	67
Size:	37.4 KB
ID:	4895  

Last edited by dcbrown : 18-01-2007 at 12:31.