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.

Compiler/CC2642R: Unable to Place a variable at absolute address in my CC2642 Code

Part Number: CC2642R

Tool/software: TI C/C++ Compiler

HI Team,

My requirement is to place a set of variables at specific absolute address location for boot loader header creation purpose.

For that I have used the below instruction:

__root const unsigned char productcode[16] __attribute__((section(".ARM.__at_0x00005fd6"))); with this i am getting following liker Internal error.

Internal Error: [CoreUtil/General]: Failed to place absolute section <Section .ARM.__at_0x00005fd6 (bootloader.o #9)> at its designated address (0x5fd6).

For that i want to do any changes in liker file (.icf ) or any changes IAR Workspace settings.

Could any body give me clarity on this issue, it is very urgent for me.

Regards,

Srinivas.V

  • Hi S,

    Could you try using the following syntax:

    In code:

    static __no_init char my_buffer[SIZE] @ BASE_ADDRESS = some data

  • HI Team,

    Thanks for a valuable reply.

    It helps me lot for creating the variable at absolute address. Is there any document for referring these type of commands, which are very much useful for creating sections, symbols and Blocks in code as well as in liker file(.icf).

    I will use the same commands in my Boot loader project for linker file creation in terms of creating Boot loader header at specific sections and creating blocks with fixed order and other things.

    Regards,

    Srinivas.V

  • Hi S,

    When it comes to IAR, this would be part of the IAR compiler and linker documentation. 

  • HI M-W,

    Thanks for your fast response.

    I am able map the absolute address to variable by using the below code line.

    static __no_init char productcode[32] @ 0x00005fd6;

    But the issue was, we are unable to update the date to productcode[ ] variable. If we initialize the variable by using the below change, we are getting the error.

    Code Change:

    static __no_init char productcode [32] @ 0x00005fd6 = {0x12,0x12,0x12};

    Error Message:

    Error[Be025]: variable must be __no_init in order to have a location address    C:\ti\simplelink_cc13x2_26x2_sdk_2_40_00_81\examples\rtos\CC26X2R1_LAUNCHXL\ble5stack\SFFL_Bootloader\src\bootloader.c 151

    Could you please suggest how to initialize these variables which are created at absolute address.

    Regards,

    Srinivas.V

  • Hi S,

    Personally I have worked with custom sections before which has worked for me. In IAR this would look something like:

    CODE:

    __ro_placement const unsigned char test[4] @ ".my_section" = {1, 2, 3, 4};

    LINKER:

    define region MY_AREA = mem:[from 0x00004000 to 0x00004004];
    ".my_section":
    place in MY_AREA { readonly section .my_section};

    You could also simply do something like this:

    __ro_placement const unsigned char test[4] @ 0x00004000 = {1, 2, 3, 4};

  • HI M-W,

    Thanks for your reply,

    I have tried with both the ways what you have suggested to me in previous reply,

    Code:

    1.  __ro_placement const unsigned char productcode[4]@ 0x00005fd6 = {1, 2, 3, 4}; , with this we are getting the below compiler error.

    Error[Be025]: variable must be __no_init in order to have a location address 

    If we tried with __no_init instead of __ro_placement also we are getting same error.

    Code:

    2. __ro_placement unsigned char productcode[4] @ ".my_section" = {1, 2, 3, 4};

    Linker File:

    define region MY_AREA = mem:[from 0x00005fd6 to 0x00005fd9];
    place in MY_AREA {section .my_section};

    with this option we are not getting any compile and linking errors. But in map file Observed the below message and unable to see any data at that address in .hex file.

    No sections matched the following patterns:

    section .my_section  in "P1"

    In both ways my issue was not resolved. I tried with CC2642(ARM -M4) Controller with IAR Version 8.32.Is there any dependency on IAR or compiler version for this issue or any specific IAR options are interlinked with this issue?

    Could you please resolve my issue.

    Regards,

    Srinivas.V

  • Hi Srinivas

    I tested it out using IAR 8.32.2 and had no issue with either solution. In both cases I would actually need to make use of the data in code to avoid having the compiler/linker optimizing it out.

    This feature is something that depend on the IAR compiler / linker which I can not really support as it is developed by IAR. I would suggest you try out the second approach again and make sure the data is used somewhere in your application to avoid it being optimized away. 

    If this does not work, can you create a basic test project (based on the "empty" project) and share it with me?

  • Hi M-W,

    Thanks for your reply,

    I followed the second method,

    Code:

    __ro_placement const unsigned char productcode[8]  @".my_section" = {0x1,0x2,0x3,0x4,0x11,0x22,0x33,0x44};

    Linker file:
    define region MY_AREA = mem:[from 0x00005fd0 to 0x00005ff0];
    place in MY_AREA {readonly section .my_section};

    with above mentioned changes it is working fine for me.

    Could you please elaborate more on first and second methods. If I want to create group of data members with in a given section with contiguous memory location, which method is best. if you have any example code please share the same to me.

    Once again thanks for your replies and suggestions.

    Regards,

    Srinivas.V

  • Hi Srinivas,

    I think the "const" is the key as this clearly indicates that it is read only (and thus no_init). 

    As you describe it, it seems you want to stick with the "my_section" approach as each placement in code would be contiguously added to the section (assuming there is space).