Page 1 of 3

linker scripts

PostPosted: Fri Apr 04, 2014 5:35 pm
by Jerry Messina
Is there a way of specifying a different linker script other than the default one, either in the FW IDE or MPLAB?

I'm looking at trying to put a program into the Aux Flash of a 24EP (like what the microchip CE417 bootloader example does), and the code/int vector/rst vector layout is a lot different.

Re: linker scripts

PostPosted: Fri Apr 04, 2014 5:58 pm
by David John Barker
You cannot specify a different linker script.

Re: linker scripts

PostPosted: Fri Apr 04, 2014 6:12 pm
by Jerry Messina
Ok then, could I use FW to generate a C file and then compile/link it using XC16 and a different script in MPLAB?

Re: linker scripts

PostPosted: Fri Apr 04, 2014 6:38 pm
by David John Barker
Yes, you could do that. Or you could point the toolsuite to an alternative XC16 install (using the toolsuite *.ini method) and modify the default linker script. That way you can build and link in Firewing. Perhaps I should look at adding a linker script #option?

Re: linker scripts

PostPosted: Fri Apr 04, 2014 6:46 pm
by Jerry Messina
>> Or you could point the toolsuite to an alternative XC16 install

That's a better idea... at least it's all done in one step. Thanks for the suggestion.

Re: linker scripts

PostPosted: Sat Apr 05, 2014 12:15 pm
by David John Barker
OK, I've taken a look and this and have created some gcc options which can be passed to XC16. First, you need to download the latest Firewing BETA:

http://www.firewing.info/downloads/firewing.1003.B22.exe

Next, download and install the latest XC16 toolsuite:

http://www.firewing.info/pmwiki.php?n=FirewingUser.XC32Toolsuite

The two new options are "_gccOptimise" and "_gccLink". For example,
Code: Select all
#option _gccLink = "C:\Program Files\Microchip\xc16\v1.11\support\PIC24H\gld\p24HJ128GP502.gld"
#option _gccOptimise = 0

will use the default linker file with an optimisation level of 0 (off). If your version of XC16 (or C30) allows it, the different optimisation levels are 0,1,2,3 or "s". Please note this is all experimental and I would appreciate if you could let me know if it works for you.

Re: linker scripts

PostPosted: Sat Apr 05, 2014 1:19 pm
by Jerry Messina
Nice! I'll give it a try.

Dumb question... do the '#option' statements go in the toolsuite .ini file? They look like source file preprocessor options.

Re: linker scripts

PostPosted: Sat Apr 05, 2014 1:21 pm
by David John Barker
They are source code options, not *.ini file. They go at the top of your main program (or module if you prefer). Just use them like any other #option.

Re: linker scripts

PostPosted: Sat Apr 05, 2014 2:17 pm
by Jerry Messina
I tried a few linker scripts and the #option seems to be picking up the right files from what i can tell. That'll definitely be easier than the other methods!

I also tried the #option _gccOptimise setting. It definitely gets used, and things change, so it seems ok at first glance. The thing is I'm not sure the resulting code will actually work. I tried XC16v1.11 with the 'progUART' sample, and there seems to be some missing code with _gccOptimise =1 or s (not sure about the other settings).

I'll have to take a closer look though. Maybe the optimizers smarter than me... it wouldn't be the first time that's for sure. Or, maybe it's the same sort of thing that happened back when I tried switching to later versions of XC1.20/1.21. They didn't work out too well either for whatever reason.

Re: linker scripts

PostPosted: Sat Apr 05, 2014 3:02 pm
by David John Barker
> I tried a few linker scripts and the #option seems to be picking up the right files from
> what i can tell. That'll definitely be easier than the other methods!

Yes, I think it is a really useful addition...

> I also tried the #option _gccOptimise...it seems ok at first glance...I'm not sure the resulting code will actually work

At least it's being picked up by the compiler - however, what XC16 decides to do with it is another matter. Unless you have a licensed version of XC16, there is little point in using any optimisation other than "0". Please let me know what you find...