• AVR Freaks

Hot!Additional linker options via MPLAB X IDE

Author
stevemat
New Member
  • Total Posts : 12
  • Reward points : 0
  • Joined: 2012/06/18 04:04:32
  • Location: 0
  • Status: offline
2012/10/05 05:49:20 (permalink)
0

Additional linker options via MPLAB X IDE

Hi,  I recently upgraded to MPLAB X IDE v1.41 with XC8 v1.10 and I have two issues...
1) I can't seem to apply additional linker options via the properties dialog... I have tried inserting the following option  -L-Amyclass=190h-1EFh into the Additional options field.  I have tried this field for both the XC8 Compiler and XC8 Linker categories but cannot get any resulting change to the Generated command line.  Has anyone figured out how to apply additional linker options?
 
2) I am trying to use the new __section() specifier to assign global variables to a new psect using:
unsigned char __section("mySection") MyArray[48];
According to the details in the user manual, this specifier is supposed to work as a replacement for the psect pragma when you don't want the new psect to inherit the properties of the psect whose vars are being redirected.  The target device is a 16F877A.  I receive the error: 'Unable to resolve identifier __section'  Any thoughts on what I'm missing?  I have included the default files:
 
#include <xc.h>           /* Global Header File */
#include <stdlib.h>
#1

7 Replies Related Threads

    Guest
    Super Member
    • Total Posts : 80502
    • Reward points : 0
    • Joined: 2003/01/01 00:00:00
    • Location: 0
    • Status: online
    Re:Additional linker options via MPLAB X IDE 2012/11/20 15:20:42 (permalink)
    0
    Also, additional compiler options seems to not take effect.
    #2
    rpc48gx
    Super Member
    • Total Posts : 337
    • Reward points : 0
    • Joined: 2003/11/07 12:52:16
    • Location: Brighton, UK
    • Status: offline
    Re:Additional linker options via MPLAB X IDE 2012/11/26 09:34:23 (permalink)
    0
    I have used PSECTs with the old Hitech compiler and am having trouble getting them to work with
    the new environment (MPLAB 1.5 and xc8)
     
    It does seem that you still need to put -L to get stuff sent to the linker
    i.e. -L-prt=5A0h gets to the linker that a psect rt should have been defined in the C.
    You can find the additional linker args dialog in the Project properties
    panel, which is off the main menu RUN drop down (why is it there????)
     
    Anyway, I find the manual vague and wandering on PSECTS, perhaps I will be able to make more
    sense of it tomorrow. I need to define both RAM and PROM psects.... Will post here when I find out
    how to do it.....
    #3
    rpc48gx
    Super Member
    • Total Posts : 337
    • Reward points : 0
    • Joined: 2003/11/07 12:52:16
    • Location: Brighton, UK
    • Status: offline
    Re:Additional linker options via MPLAB X IDE 2012/11/26 09:55:10 (permalink)
    0
    This in the C file:
    #pragma psect bss=rt
     
    This in linker options:
    -L-prt=5A0h
     
    Get this error:
    :: warning: Omniscient Code Generation not available in Free mode
    :0: error: psect "rt" was never defined
    Microchip MPLAB XC8 C Compiler V1.11
    Copyright (C) 2012 Microchip Technology Inc.
    License type: Node Configuration

    make[2]: Leaving directory `/home/robin/projects/canbus_Pt100_temp_sensor/PIC18F25K80/can_bridge_sensor.X'
    make[1]: Leaving directory `/home/robin/projects/canbus_Pt100_temp_sensor/PIC18F25K80/can_bridge_sensor.X'
    (908) exit status = 1
    make[2]: *** [dist/default/production/can_bridge_sensor.X.production.hex] Error 1
    make[1]: *** [.build-conf] Error 2
    make: *** [.build-impl] Error 2

    BUILD FAILED (exit value 2, total time: 2s)
     
     
    Hmmmm well its getting through to the linker, BUT, I don't think its being defined properly in the C code somehow...
     
    #4
    Jose Diaz
    Administrator
    • Total Posts : 1676
    • Reward points : 0
    • Joined: 2010/06/23 11:10:56
    • Location: 0
    • Status: offline
    Re:Additional linker options via MPLAB X IDE 2012/11/26 14:08:53 (permalink)
    0
    Stevemat,
    1) I add " -L-Amyclass=190h-1EFh " to the additional options (please see attached file) and see it pass it down to the linker.
    2) I'll get a compiler guy to look at this.
     

    Attachment(s)

    Attachments are not available: Download requirements not met
    #5
    stevemat
    New Member
    • Total Posts : 12
    • Reward points : 0
    • Joined: 2012/06/18 04:04:32
    • Location: 0
    • Status: offline
    Re:Additional linker options via MPLAB X IDE 2012/11/27 21:34:37 (permalink)
    0
    refer Robin's post:
     
    So I have 2 thoughts on this but not sure how the compiler is trying to deal with it...
    When you use the psect pragma, the new psect called rt inherits the properties of the original psect called bss.  So I'm guessing that rt is being assigned the class that was assigned to bss (whatever it is).  So does the compiler accept trying to redirect rt to a new location if the psect pragma was used? Thats my first thought - perhaps it doesn't like that.
    My second thought which I would probably rule out is whether your subsequent code actually includes any variables that would have been assigned to a bss psect and hence subsequently diverted to rt?  If you don't have anything to divert, does the compiler bother to create the new psect rt? One would normally some uninitialised variables that would be accomodated by the bss psect so guessing this is not the reason?
     
    Going back to the first thought - the CCI alternative to the psect pragma is supposed to be the __section("psect")  statement.  What attracts me to using this alternative is that it does not inherit the properties of another psect that you have to defince as per the psect pragma.  Despite activating the CCI widget, I just cannot seem to get the compiler to recognise the keyword __section.
    post edited by stevemat - 2012/11/27 21:35:53
    #6
    stevemat
    New Member
    • Total Posts : 12
    • Reward points : 0
    • Joined: 2012/06/18 04:04:32
    • Location: 0
    • Status: offline
    Re:Additional linker options via MPLAB X IDE 2012/11/27 21:45:34 (permalink)
    0
    Jose Diaz

    Stevemat,
    1) I add " -L-Amyclass=190h-1EFh " to the additional options (please see attached file) and see it pass it down to the linker.
    2) I'll get a compiler guy to look at this.


    Thx Jose!  I do see the adjustment in the map file - I was originally expecting to see it included in the generated commanline window (within the properties window) and didn't check the map file at the time.  Perhaps it should show there once you apply the change but that is another item for consideration.  Would be great if we can establish how to get the compiler to recognise the __section('mypsect") statement though.  Haven't tried it on >pic16 but according to the manual it should work for the XC8.
     
    Will continue to play some more...
     
    #7
    Ekh4z
    New Member
    • Total Posts : 1
    • Reward points : 0
    • Joined: 2020/04/07 06:43:48
    • Location: 0
    • Status: offline
    Re:Additional linker options via MPLAB X IDE 2020/04/08 01:16:37 (permalink)
    0
    Hi,
    I was wondering if anyone solved that problem and successfully managed to pass on extra option to the compiler. My problem is quite similar, on MPLABv5.15 with XC8v2.10:
     
    For a bootloader on a PIC16F876 I need to keep some memory free at the beginning (bootloader goes at the end) except for the reset vector obviously. By setting the ROM ranges to something like default,-4-FFF I'm able to keep this area free except for one psect (named end_init) which is at 0x4 in Flash memory. 
    By looking at the generated map file, I can see the argument -pintentry=04h,init, end_init meaning that the end_init psect will follow right after the interrupt code (which is not present, so end_init goes right at 0x4)
    According to XC8 manual (section 4.8.6), the solution is simply to pass on an extra option like -L-pend_init= in the extra linker options (this field is showed in section 4.9.3.4). But it doesn't work. 
    The .map file isn't modified (I don't know if it's normal, since it's supposed to be an extra option for the linker only), and even if I can see this extra option passed on to the linker via the command line, nothing changes and this psect remains at 0x4. 
    I tried to pass this option to the other additional option fields (linker, compiler and even general, out of curiosity and despair) and to change the extra command to -L-pend_init=CODE but nothing happened so far...
     
    I link the manual here, for simplicity: http://ww1.microchip.com/downloads/en/devicedoc/50002053g.pdf
     
    Thanks in advance !
    #8
    Jump to:
    © 2020 APG vNext Commercial Version 4.5