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.

CC1310: How do I specify a fixed location in Flash for a 32-bit serial number?

Part Number: CC1310

Hi there,

I would like to store a 32-bit serial number at a fixed location in Flash, preferably just after the interrupt vector table, so that it is easy for an automation script to modify the HEX file and insert a new serial number for each device.

In GCC I would declare the serial number like this:

/// Device address stored in fixed location 0x080000c0 (After Vector Table)
const uint32_t serial_nr __attribute__ ((section (".fixed"))) = 0xaabbccdd;

And then I would modify the linker script like this:

SECTIONS
{    
    /* ISR_VECTOR section contains the ARM vector table */
    .isr_vector :
    {
          KEEP (*(.isr_vector))
          . = ALIGN(4);
    } > FLASH

    /* Constants stored at a fixed location; after ISR vector table */
    .fixed :
    {
        KEEP(*(.fixed))
	. = ALIGN(4);
    } > FLASH

I'm using CCS 11.0.0.00012 and Simple Link CC13x0 SDK 4.20.01.03 and it is a NoRTOS app.

Thanks in advance,

Pieter

https://piconomix.com

  • Hi

    someone supporting CCS will come back to you with an answer

    BR

    Siri

  • Hello Pieter,

    I will bring this thread to the attention of our compiler expert for more details.

    Thanks

    ki

  • I'm using CCS 11.0.0.00012 and Simple Link CC13x0 SDK 4.20.01.03 and it is a NoRTOS app.

    Please select an example from this SDK which comes the closest to what your program does.  Please understand that I am not familiar with this SDK, and thus I cannot help you with this step.  Plan on using the linker command file which comes with this example.  Please attach it to your next post.  So that the forum will accept it, add the file extension .txt to it.  I'll take a look at it and advise you on how to ...

    store a 32-bit serial number at a fixed location in Flash, preferably just after the interrupt vector table

    Thanks and regards,

    -George

  • Hi George,

    I selected the rfEchoRx_CC1310_LAUNCHXL_nortos_ccs project.

    Here is the unmodified linker script:

    /*
     * Copyright (c) 2017, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    /*
     *  ======== CC1310_LAUNCHXL_NoRTOS.cmd ========
     */
    
    --retain=g_pfnVectors
    
    --stack_size=1024   /* C stack is also used for ISR stack */
    
    --heap_size=256
    
    /* Override default entry point.                                             */
    --entry_point resetISR
    /* Allow main() to take args                                                 */
    --args 0x8
    /* Suppress warnings and errors:                                             */
    /* - 10063: Warning about entry point not being _c_int00                     */
    /* - 16011, 16012: 8-byte alignment errors. Observed when linking in object  */
    /*   files compiled using Keil (ARM compiler)                                */
    --diag_suppress=10063,16011,16012
    
    /* The starting address of the application.  Normally the interrupt vectors  */
    /* must be located at the beginning of the application.                      */
    #define FLASH_BASE              0x0
    #define FLASH_SIZE              0x20000
    #define RAM_BASE                0x20000000
    #define RAM_SIZE                0x5000
    
    /* System memory map */
    
    MEMORY
    {
        /* Application stored in and executes from internal flash */
        FLASH (RX) : origin = FLASH_BASE, length = FLASH_SIZE
        /* Application uses internal RAM for data */
        SRAM (RWX) : origin = RAM_BASE, length = RAM_SIZE
    }
    
    /* Section allocation in memory */
    
    SECTIONS
    {
        .intvecs        :   > FLASH_BASE
        .text           :   > FLASH
        .TI.ramfunc     : {} load=FLASH, run=SRAM, table(BINIT)
        .const          :   > FLASH
        .constdata      :   > FLASH
        .rodata         :   > FLASH
        .cinit          :   > FLASH
        .pinit          :   > FLASH
        .init_array     :   > FLASH
        .emb_text       :   > FLASH
        .ccfg           :   > FLASH (HIGH)
    
        .vtable_ram     :   > SRAM
        .data           :   > SRAM
        .bss            :   > SRAM
        .sysmem         :   > SRAM
        .nonretenvar    :   > SRAM
    
        .stack          :   > SRAM (HIGH)
    }
    

    Thanks in advance,

    Pieter

  • Hi George,

    I declared a ".fixed" section between the ".intvecs" section and ".text" section. Here is my modified linker script file:

    /*
     * Copyright (c) 2017, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    /*
     *  ======== CC1310_LAUNCHXL_NoRTOS.cmd ========
     */
    
    --retain=g_pfnVectors
    
    --stack_size=1024   /* C stack is also used for ISR stack */
    
    --heap_size=256
    
    /* Override default entry point.                                             */
    --entry_point resetISR
    /* Allow main() to take args                                                 */
    --args 0x8
    /* Suppress warnings and errors:                                             */
    /* - 10063: Warning about entry point not being _c_int00                     */
    /* - 16011, 16012: 8-byte alignment errors. Observed when linking in object  */
    /*   files compiled using Keil (ARM compiler)                                */
    --diag_suppress=10063,16011,16012
    
    /* The starting address of the application.  Normally the interrupt vectors  */
    /* must be located at the beginning of the application.                      */
    #define FLASH_BASE              0x0
    #define FLASH_SIZE              0x20000
    #define RAM_BASE                0x20000000
    #define RAM_SIZE                0x5000
    
    /* System memory map */
    
    MEMORY
    {
        /* Application stored in and executes from internal flash */
        FLASH (RX) : origin = FLASH_BASE, length = FLASH_SIZE
        /* Application uses internal RAM for data */
        SRAM (RWX) : origin = RAM_BASE, length = RAM_SIZE
    }
    
    /* Section allocation in memory */
    
    SECTIONS
    {
        .intvecs        :   > FLASH_BASE
        .fixed          :   > FLASH
        .text           :   > FLASH
        .TI.ramfunc     : {} load=FLASH, run=SRAM, table(BINIT)
        .const          :   > FLASH
        .constdata      :   > FLASH
        .rodata         :   > FLASH
        .cinit          :   > FLASH
        .pinit          :   > FLASH
        .init_array     :   > FLASH
        .emb_text       :   > FLASH
        .ccfg           :   > FLASH (HIGH)
    
        .vtable_ram     :   > SRAM
        .data           :   > SRAM
        .bss            :   > SRAM
        .sysmem         :   > SRAM
        .nonretenvar    :   > SRAM
    
        .stack          :   > SRAM (HIGH)
    }
    

    Here is how I specified that the serial_nr constant must be stored in the ".fixed" section:

    #pragma DATA_SECTION(serial_nr, ".fixed");
    const volatile uint32_t serial_nr = 0xaabbccdd;

    Unfortunately the ".fixed" section is located after the ".text" section by the linker so the serial_nr constant ends up at address 0x00005d1c

    Here is the MAP file:

    serial_nr_CC1310_LAUNCHXL_nortos_ccs.map.txt

    Best regards,

    Pieter

  • The way to tell the linker to allocate the output sections .intvecs and .fixed next to each other is to GROUP them.

        GROUP
        {
            .intvecs
            .fixed
        } > FLASH_BASE
    

    To understand why, please read the Group Output Sections Together part of the larger article Linker Command File Primer.

    Since you are familiar with GCC linker scripts, the article Linking: Migrate from Arm GCC to tiarmclang is likely to be helpful.

    Thanks and regards,

    -George

  • Hi George,

    Thanks, that is a perfect solution :) Also thanks for sharing the documentation, it was insightful and is much appreciated.

    Best regards,

    Pieter

    https://piconomix.com