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/TMS320F280049: Storing linker generated CRC table pointer

Part Number: TMS320F280049

Tool/software: TI C/C++ Compiler

Linker Experts,

I'm trying to store a pointer to a crc table in a known location in flash.  The intention is that a bootloader will be able to verify the application and it won't matter if the crc table changes in size since I have a pointer to it instead of the table in a fixed location.

The problem I'm having is getting my special pointer location populated with the address of the crc table.  Currently I'm doing this in a global scope:

extern const CRC_TABLE testTable; //Linker gen CRC table name

#pragma DATA_SECTION(crcTablePtr,"crcTablePtr");
#pragma RETAIN(crcTablePtr)
const CRC_TABLE * crcTablePtr = &testTable;  //CRC table ptr in fixed location

When I build and program this code, crcTablePtr = 0xFFFFFFFF.  However if I create a CRC_TABLE * in my main and set it to &testTable it gets the correct value.  I feel like I'm close, but I'm missing something.  Could one of you give me a nudge in the right direction?

Thanks,
Trey

  • Hi Trey,

    What did the map file show?  Did it show the section using any bytes or not?  

    May be you can try declaring it as static or volatile.  Also, you can try retaining that variable in the linker cmd file (using --retain).

    Thanks and regards,
    Vamsi

  • Hey Vamsi!

    It does show up in the map file, but it shows as uninitialized:

    crcTablePtr 
    *          0    00082002    00000002     UNINITIALIZED
                      00082002    00000002     gpio_ex2_toggle.obj (crcTablePtr:retain)

    I've tried static and volatile, but they don't have any effect.  I've also tried --retain and #pragma retarin. My guess is it has something to do with the initializer of this variable being generated at link time.  Perhaps the CRC table generation happens after constants are taken care of in the linking process?

    Trey

  • Trey,

    Let me assign this to the compiler team.  They may get back to you early next week.

    Thanks and regards,
    Vamsi

  • Trey German8 said:
    My guess is it has something to do with the initializer of this variable being generated at link time.

    The code was specifying a non-constant pointer:

    const CRC_TABLE * crcTablePtr = &testTable;  //CRC table ptr in fixed location

    Which means the pointer is initialised by the C run time initialisation, rather than the linker.

    Changing to a constant pointer:

    extern const CRC_TABLE testTable; //Linker gen CRC table name
    
    #pragma DATA_SECTION(crcTablePtr,".crcTablePtr");
    #pragma RETAIN(crcTablePtr)
    const CRC_TABLE *const crcTablePtr = &testTable;  //CRC table ptr in fixed location

    Then causes the section to be be initialised by the linker, as shown in the map file:

    .TI.crctab 
    *          0    000810fc    0000000a     
                      000810fc    0000000a     (.TI.crctab:_testTable)
    
    .crcTablePtr 
    *          0    0008f000    00000002     
                      0008f000    00000002     main.obj (.crcTablePtr:retain)
    

    While I haven't attempted to run the code, running dis2000 on the generated .out file showed that .crcTablePtr was initialised data with the pointer to the testTable:

    DATA Section .crcTablePtr (Little Endian), 0x2 words at 0x0008f000 
    0008f000        _crcTablePtr:
    0008f000   10fc    .word 0x10fc
    0008f001   0008    .word 0x0008