• AVR Freaks

Custom Linker script

Author
arigead
Super Member
  • Total Posts : 408
  • Reward points : 0
  • Joined: 2011/02/07 06:58:31
  • Location: 0
  • Status: offline
2012/05/09 05:05:34 (permalink)
0

Custom Linker script

I've added a linker script into my project directory and added it to the project in Linker Files but it's being ignored. I've looked through the project properties but don't see where in the MPLAB-X project I force it to use the linker script I've just added to the project.

Any help would be great.
#1

11 Replies Related Threads

    arigead
    Super Member
    • Total Posts : 408
    • Reward points : 0
    • Joined: 2011/02/07 06:58:31
    • Location: 0
    • Status: offline
    Re:Custom Linker script 2012/05/09 07:44:30 (permalink)
    0
    My MPLAB-X project has gotten itself confused. The linker scrip it's using is specified in the make file:

    nbproject/Makefile-default.mk

    I looked at it in the editor but it stated that it's auto generated and should not be edited. Nowhere else in the file system (using grep) can I find any occurrence of "p24FJ256GB110.gld" So where's this file being specified? I tried to edit my project properties to give it a "-T" option so now my build has the options:

    -Tp24FJ256GB110.gld,-Tlinker/boot.gld

    I'll simply have to delete the entire project and start again. I have no idea where to specify a linker script file in MPLAB-X. Starting from scratch might sort the problem.
    #2
    Jose Diaz
    Administrator
    • Total Posts : 1676
    • Reward points : 0
    • Joined: 2010/06/23 11:10:56
    • Location: 0
    • Status: offline
    Re:Custom Linker script 2012/05/15 08:40:19 (permalink)
    0
    arigead,
    You can add a linker script to a project by right clicking on the Linker Files logical folder (in the Projects view) and adding an existing .gld. MPLAB X will then use that linker script.  In the attached picture, please see that I added myLinker.gld and that cause the command line to the linker to include ;--script="myLinker.gld"'
     
     
    Jose

    Attachment(s)

    Attachments are not available: Download requirements not met
    #3
    arigead
    Super Member
    • Total Posts : 408
    • Reward points : 0
    • Joined: 2011/02/07 06:58:31
    • Location: 0
    • Status: offline
    Re:Custom Linker script 2012/06/27 16:34:20 (permalink)
    0
    Back again I'm afraid :-(
     
    I had this working by adding the my linker script file to the project but now I've hit a slight problem as I've changed my Processor so have two versions of Hardware. One with a 24FJ256GB110 and one with a 24FJ64GB106. Same family but smaller. I started by using the same project but adding a new configuration for the different processor. All is working but to get the project to build for each processor I have to remove the current linker script from the MPLAB-X project and add the linker script for my current configuration. If I change configuration i have to remove and replace the linker script again.
    It seems like an issue with MPLAB-X which doesn't seem to comprehend this kind of configuration difference. If I remove all linker scripts from the project but manually add the --script="linker/myLinker.gld" to the build options then the MPLAB-X Build system prepends to that a -Tp24FJ64GB256.gld so I have:
    -Tp24FJ64GB256.gld --script="linker/myLinker.gld"
    Build system don't much like that either.
     
    Maybe this is not an oversight by MPLAB-X but a misunderstanding by me. I'd be pleased to hear if I've missed something again.
     
    #4
    Jose Diaz
    Administrator
    • Total Posts : 1676
    • Reward points : 0
    • Joined: 2010/06/23 11:10:56
    • Location: 0
    • Status: offline
    Re:Custom Linker script 2012/06/27 16:41:34 (permalink)
    0
    You are on the right track. Create two configurations (one for each processor). Then add both gld files to the linker files folder. Then right click on each gld file and select exclude from the configuration that you do not want the .gld to be in...
    Jose
     
    #5
    arigead
    Super Member
    • Total Posts : 408
    • Reward points : 0
    • Joined: 2011/02/07 06:58:31
    • Location: 0
    • Status: offline
    Re:Custom Linker script 2012/07/02 12:00:26 (permalink)
    0
    Sorry only getting back to this now. Thanks a million for that advice. should have twigged that one.
    #6
    arigead
    Super Member
    • Total Posts : 408
    • Reward points : 0
    • Joined: 2011/02/07 06:58:31
    • Location: 0
    • Status: offline
    Re:Custom Linker script 2012/07/13 02:05:36 (permalink)
    0
    I've been using this for a while now, as in two different configurations and linker scripts for two devices. There is one small problem with it. Sometimes when I select the Active config in the drop box at the top the build system still builds for the other HW device. No amount of changing makes any difference.
     
    What I have to do is select the config I want, Quit MPLAB-X and restart it. That then works. One problem with this is that it's only happening 25% of the time and I've not been able to discern any pattern as yet. Having said that I'm probably on an older version "MPLAB X IDE Beta7.12"
     
    I'll maybe try and upgrade over the next few days if there's a newer verison
    #7
    Jose Diaz
    Administrator
    • Total Posts : 1676
    • Reward points : 0
    • Joined: 2010/06/23 11:10:56
    • Location: 0
    • Status: offline
    Re:Custom Linker script 2012/07/13 15:14:19 (permalink)
    0
    We posted v1.30 last week. Beta 7.12 was the last beta before v1.00. So you are 4 releases away from the latest. Beta v7.12 -> v1.30 is a big jump!.  Before you upgrade, I'd make a back up of your project source files and project files just in case there is a problem with project metadata format (there should not be). 
     
    #8
    Hybird
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2011/05/05 12:52:36
    • Location: 0
    • Status: offline
    Re:Custom Linker script 2013/10/24 18:20:42 (permalink)
    0
    Just a heads up for anyone coming across this thread. If you want to use custom linker files in version 1.9 of MPLABX, and you have multiple target architectures set up as separate configurations, just add all of the linker files to the linker folder. Then select your first configurations in the drop down (or set in project properties), then for each of the linker files you don't want to use for that target architecture you right click on the linker file and go to properties, and then check the check box that says exclude. The post above seems to indicate the exclude option could be reached by simply right clicking on the file, but it seems it may have moved into the properties dialogue in new builds.

    Thanks for this info, I was having a heck of a time trying to figure out how to do this! 
    #9
    ElderCasey
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2014/02/04 13:30:28
    • Location: 0
    • Status: offline
    Re:Custom Linker script 2014/02/04 13:34:20 (permalink)
    0
    I have a project where I want to use a custom link script, but the original Linker Files folder was removed and if I simply add a folder and name it "Linker Files" MPLAB X seems to ignore the linker script.
     
    Am I going to have to recreate the project from scratch just to re-generate a "Linker Files" folder MPLAB X will use?
    #10
    mvollmer
    Junior Member
    • Total Posts : 88
    • Reward points : 0
    • Joined: 2013/08/20 22:58:04
    • Location: Germany
    • Status: offline
    Re:Custom Linker script 2014/02/04 23:55:04 (permalink)
    +1 (1)
    You could edit the configurations.xml in your project folder and add this:

        <logicalFolder name="LinkerScript" 
                       displayName="Linker Files"
                       projectFiles="true">
        </logicalFolder>

    in the branch of 
    <logicalFolder name="root" displayName="root" projectFiles="true"> </> 


    Reload the Project and it should show the Folder again. Any other simplier solutions are welcome, but this was the first way to get it back without recreate the project as i thought of.

    with kind regards
    mvolllmer
     
    PIC Experience with PIC24FJ256GB110 and PIC32MX3XX_4XX Family
    #11
    ElderCasey
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2014/02/04 13:30:28
    • Location: 0
    • Status: offline
    Re:Custom Linker script 2014/02/05 08:09:18 (permalink)
    0
    That got it!
     
    After manually creating a folder and renaming it "Linker Files" I have this entry in the configurations.xml.
     
    <logicalFolder name="f1" displayName="Linker Files" projectFiles="true">      <itemPath>../app_hid_boot_p24FJ256GB110.gld</itemPath>    </logicalFolder>

     
    All I had to do was change the name from "f1" to "LinkerScript" and MPLAB X recognized it's contents as linker scripts.
     
    Thank you mvolllmer!
    #12
    Jump to:
    © 2019 APG vNext Commercial Version 4.5