This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Modifying linker file in IAR

Other Parts Discussed in Thread: MSP430F5438A

I dont know how to modify linker file in IAR

Anyone please help

  • 1. Tell us what you need to modify or what you need to accomplish.

    2. Post your existing linker file here so that we can help.

    Other than that, you just open the .xcl file in your project directory and edit it like you would a source code file.

    Edit: I would also recommend that you read the IAR documentation on the linker. You can find it in "C:\Program Files (x86)\IAR Systems\Embedded Workbench 6.4\430\doc\xlink.ENU.pdf" or similar (depending on installed location and version of your IAR toolset).

  • I am trying to write a code which sits in location 5C00-8D90 this code receives the packets and writes into the location 0x30000,after writing the entire code i sholud jump to the location 0x30000 and exectute the code in that location, but when i give jump to that location the microcontroller is getting resetted.

  • Raghavendra Chintapalli said:
    d writes into the location 0x30000,after writing the entire code i sholud jump to the location 0x30000 and exectute the code in that location,

    The code that you are programming into the Flash at location 0x30000 needs to have been compiled and linked to execute from upper memory (large memory model setting). In your linker file you need to define the (CODE) segment (and any other non-volatile data, like CONST) to be in the 0x30000 - 0x3FFFF memory region.

    Additionally, this will preclude your new code from using interrupts, since interrupt vectors cannot point to Flash above 0xFFFF (the vectors are only 16-bits).

  • thank u for help i will try this

  • Also how to call 0x30000 location from my main i used  void(*new)(void)=0x30000;

    new();

  • Raghavendra Chintapalli said:

    Also how to call 0x30000 location from my main i used  void(*new)(void)=0x30000;

    new();

    That should work... have you tried setting a breakpoint on that line and then stepping into it to see if it works? Have you checked the linker map section of the html results file to make sure that CSTART is placed at 0x30000 in the binary image?

  • i have modified the linker file like this

    // ************************************************
    //
    // XLINK configuration file for MSP430F5438A
    //
    // Copyright 1996-2013 IAR Systems AB.
    //
    // See the file 430/doc/licenses/IARSourceLicense.txt for detailed
    // license information.
    //
    // $Revision: $
    //
    // ************************************************

    // ---------------------------------------------------------
    // Description
    //

    //
    // Usage:
    //
    // xlink [file file ...] -f lnk430f5438a.xcl
    //
    // -----------------------------------------------
    // Device summary
    //

    //
    // Core: MSP430X
    //
    // Interrupt vectors: 64
    //
    // Peripheral units: 0-00FFF
    //
    // Information memory (FLASH): 01800-019FF
    //
    // Read/write memory (RAM): 01C00-05BFF
    //
    // Read-only memory (FLASH): 05C00-0FFFF
    // 10000-45BFF
    //


    // -----------------------------------------------
    // Segments
    //

    // -------------------------------------
    // Data read/write segments (RAM)
    //

    //
    // The following segments are available for both
    // the DATA16 and DATA20 segment groups.
    //
    // segment Usage
    // ------- --------------------------
    // DATA<nn>_Z Data initialized to zero
    // DATA<nn>_I Data initialized by copying from DATA<nn>_ID
    // DATA<nn>_N Data defined using __no_init
    // DATA<nn>_HEAP The heap used by 'malloc' and 'free'
    //
    // segment Usage
    // ------- --------------------------
    // CSTACK Runtime stack
    // TLS16_I Thread-local storage for main thread
    // (require custom runtime library)
    //


    // -------------------------------------
    // Program and data read-only segments (FLASH)
    //

    //
    // The following segments are available for both
    // the DATA16 and DATA20 segment groups.
    //
    // segment Usage
    // ------- --------------------------
    // DATA<nn>_C Constant data, including string literals
    // DATA<nn>_ID initializers for DATA<nn>_I
    //
    // segment Usage
    // ------- --------------------------
    // INFO Information memory
    // INFOA Information memory, bank A
    // INFOB Information memory, bank B
    // INFOC Information memory, bank C
    // INFOD Information memory, bank D
    // CSTART Program startup code
    // CODE Program code
    // ISR_CODE Program code for interrupt service routines
    // DIFUNCT Dynamic initialization vector used by C++
    // CHECKSUM Checksum byte(s) generated by the -J option
    // INTVEC Interrupt vectors
    // RESET The reset vector
    // TLS16_ID Thread-local initializers for main thread
    // (require custom runtime library)
    //
    // Notes:
    //
    // * The segments CSTART, ISR_CODE, and DIFUNCT, as well as the segments in
    // the DATA16 and TLS16 segment groups must be placed in in the range
    // 0000-FFFD.
    //
    // * The INFOx and INFO segments overlap, this allows data either to be
    // placed in a specific bank or anywhere in the info memory.
    //
    // * The INTVEC and RESET segments overlap. This allows an application to
    // either use the reset vector provided by the runtime library, or
    // provide a reset function by defining an interrupt function associated
    // with the reset vector.
    //


    // ---------------------------------------------------------
    // Configuation
    //

    // -----------------------------------------------
    // Stack and heap sizes
    //

    // Uncomment for command line use
    //-D_STACK_SIZE=160
    //-D_DATA16_HEAP_SIZE=160
    //-D_DATA20_HEAP_SIZE=160


    // -----------------------------------------------
    // Define cpu
    //

    -cmsp430

    // Compensate for hardware bug in CPU
    -D?CPU30_OFFSET=2


    // -----------------------------------------------
    // Support for placing functions in read/write memory
    //

    -QCODE_I=CODE_ID


    // -----------------------------------------------
    // Support for thread local storage
    //

    -QTLS16_I=TLS16_ID


    // ---------------------------------------------------------
    // Placement directives
    //

    // -----------------------------------------------
    // Read/write memory
    //

    -Z(DATA)DATA16_I,DATA16_Z,DATA16_N,TLS16_I,DATA16_HEAP+_DATA16_HEAP_SIZE=1C00-5BFF
    -Z(DATA)CODE_I
    -Z(DATA)CSTACK+_STACK_SIZE#
    -Z(DATA)DATA20_I,DATA20_Z,DATA20_N,DATA20_HEAP+_DATA20_HEAP_SIZE


    // -----------------------------------------------
    // Read-only memory
    //

    // -------------------------------------
    // Information memory
    //

    -Z(CONST)INFO=1800-19FF
    -Z(CONST)INFOA=1980-19FF
    -Z(CONST)INFOB=1900-197F
    -Z(CONST)INFOC=1880-18FF
    -Z(CONST)INFOD=1800-187F

    // -------------------------------------
    // Low memory 0-0FFFF
    //

    // ---------------------------
    // Code
    //

    -Z(CODE)CSTART=30000-3FFFF

    // ---------------------------
    // Constant data
    //

    -Z(CONST)DATA16_C,DATA16_ID,TLS16_ID,DIFUNCT,CHECKSUM=30000-3FFFF


    // -------------------------------------
    // All memory 0-FFFFF
    //

    // ---------------------------
    // Code
    //

    -P(CODE)CODE=30000-3FFFF
    -Z(CODE)CODE_ID

    // ---------------------------
    // Constant data
    //

    -Z(CONST)DATA20_C,DATA20_ID=30000-3FFFF


    // -------------------------------------
    // Interrupt vectors
    //

    -Z(CODE)INTVEC=FF80-FFFF
    -Z(CODE)RESET=FFFE-FFFF

  • Brian Boorman said:

    Also how to call 0x30000 location from my main i used  void(*new)(void)=0x30000;

    new();

    That should work... have you tried setting a breakpoint on that line and then stepping into it to see if it works? Have you checked the linker map section of the html results file to make sure that CSTART is placed at 0x30000 in the binary image?

    [/quote]yeah thats working thanks

    Now if i want to enable interrupts in that code how do i do is there any procedure to do so??

  • Raghavendra Chintapalli said:
    Now if i want to enable interrupts in that code how do i do is there any procedure to do so??

    Not if all your code is at 0x30000 in Flash. Interrupt vectors can only point to addresses less than 0xFFFF. You would need some code programmed in lower Flash memory that magically knows where to jump in upper memory. That could be a jump table to another jump table in upper memory. The table in upper memory would need to be in a fixed location (separate segment defined and placed via linker file or compiler pragmas). That is one way.

    Perhaps the better question is why you need to have your whole program run from high-memory Flash?

  • Brian Boorman said:

    Now if i want to enable interrupts in that code how do i do is there any procedure to do so??

    Not if all your code is at 0x30000 in Flash. Interrupt vectors can only point to addresses less than 0xFFFF. You would need some code programmed in lower Flash memory that magically knows where to jump in upper memory. That could be a jump table to another jump table in upper memory. The table in upper memory would need to be in a fixed location (separate segment defined and placed via linker file or compiler pragmas). That is one way.

    Perhaps the better question is why you need to have your whole program run from high-memory Flash?

    [/quote]

    I have a custom bootloader application sitting from 5c00-8A90 which write from the location 9400 to the entire flash now if the application code wants to use the interrupts where exactly the dummy vector table should be present and how do i create a dummy vector table in c using IAR pls help with some example code or any documents

    Thanks,

**Attention** This is a public forum