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.

ARM-CGT: Hex Utility generates output file with missing sections

Part Number: ARM-CGT


Tool/software:

I am trying to build code and instruct the Linker to locate the CMSIS_DSP code and constants in a special reserved location in Flash memory. When I build my code with the Hex Utility enabled, the project.map file looks correct but the project.hex file is missing the .text and .const sections associated with the DSP library.

It looks like the Linker is ok with the Linker.cmd file, but the Hex Utility is not. I'm guessing my Linker.cmd file syntax is not quite correct. The Hex Utility "warning: duplicate section name" is a clue. Any help would be appreciated.

I have copied edited snippets of my Linker.cmd file and the Build Console output below:

MEMORY
{
    BOOT_VECTORS      (RX) : origin = 0x00000000, length = 0x00000200
    MAIN                          (RX) : origin = 0x00003200, length = 0x000FCE00
    MUF_VECTORS        (RX) : origin = 0x00100000, length = 0x00000100
    MODEL                      (RX) : origin = 0x00100100, length = 0x000FFF00
    INFO                          (RX) : origin = 0x00200000, length = 0x00008000

    ALIAS
    {
    SRAM_CODE        (RWX): origin = 0x01000000
    SRAM_DATA        (RW) : origin = 0x20000000
    } length = 0x00040000


SECTIONS
{
    .intvecs:    > BOOT_VECTORS

    .text    :    > MAIN
    .text    :    > MODEL
    {
        --library=DSP_CMSIS580_CM4F.lib (.text)
    }

    .const    :    > MAIN
    .const    :    > MODEL
    {
        --library=DSP_CMSIS580_CM4F.lib (.const)
    }

    .emuf_vect    :           > MUF_VECTORS
     .cinit    :    > MAIN
    .pinit    :    > MAIN
    .binit    :    {} > MAIN
    .data    :    > SRAM_DATA
    .bss    :    > SRAM_DATA
    .sysmem    :    > SRAM_DATA
    .stack    :    > SRAM_DATA (HIGH)

    /* INFO flash memory is intended to be used for the following device specific purposes:     */
    .flashMailbox    : > 0x00200000    /* Flash mailbox for device security operations                */
    .tlvTable        : > 0x00201000    /* TLV table for device identification and characterization    */
    .bslArea        : > 0x00202000    /* BSL area for device TI bootstrap loader                    */

    .TI.ramfunc    :    {} load=MAIN, run=SRAM_CODE, table(BINIT)
}

Invoking: Arm Hex Utility
"C:/ti/ccs1210/ccs/tools/compiler/ti-cgt-arm_18.12.8.LTS/bin/armhex" --memwidth=8 --romwidth=8 --diag_wrap=off --intel -o "eCBM_V45_MUF.hex"  "eCBM_V45_MUF.out" 
Translating to Intel format...
   "eCBM_V45_MUF.out" .intvecs ==> .intvecs
   "eCBM_V45_MUF.out" .text ==> .text
   "eCBM_V45_MUF.out" .TI.ramfunc ==> .TI.ramfunc
   "eCBM_V45_MUF.out" .const ==> .const
   "eCBM_V45_MUF.out" .cinit ==> .cinit
   "eCBM_V45_MUF.out" .binit ==> .binit
   "eCBM_V45_MUF.out" .emuf_vect ==> .emuf_vect
   "eCBM_V45_MUF.out" .MODELCODE ==> .MODELCODE
   "eCBM_V45_MUF.out" .MODELDATA ==> .MODELDATA
Finished building secondary target: "eCBM_V45_MUF.hex"
 
warning: duplicate section name eCBM_V45_MUF.out(.text) (ignored)
warning: duplicate section name eCBM_V45_MUF.out(.const) (ignored)

**** Build Finished ****

  • I think there's two problems.

    1. You're trying to create the .text output section twice. You should only create it once.

    2. The linker script is applied sequentially so line 1 below "captures" all the code (.text) including your library code and puts in in MAIN. When line 2 is reached, there are no remaining .text to allocate, so it is empty.

    I think:

        .text    :    > MAIN
        .text    :    > MODEL
        {
            --library=DSP_CMSIS580_CM4F.lib (.text)
        }

    should be:

        .any_out_section_name_you_want_to_use : > MODEL
        {
            --library=DSP_CMSIS580_CM4F.lib (.text)
        }
        .text    :    > MAIN

    This way your library code will go into MODEL and any other code will go into MAIN.

    Ditto for .const.

  • The reply by Kier is correct.  Thank you!  I can add a bit more color.

    The article Linker Command File Primer explains many of the details.

    I am nearly certain the second .text and .const sections are empty (length is zero).  Look in the linker map file.

    Thanks and regards,

    -George

  • Thank you Kier and George for your fast response.

    The repeat .text and .const do seem to be problematic. However, refer to my project.map file (truncated snippet below). I am not so certain the second .text and .const are empty. The Linker does seem to be parking my DSP_CMSIS stuff into my reserved Flash memory space (MODEL) and it does not seem to mind the double section references. I think the warnings are coming from the ARM Hex Utility (it doesn't like the double references). And it is the project.hex file that is missing the DSP_CMSIS .text and .const sections. There are gaps in the IHex records where the CMSIS code and constants should be.

    I will try the '.any_out_section_name_you_want_to_use' Kier suggested. I just thought you had to use the 'standard' .text section name for executable code that would have been used when compiling the CMSIS Library. I also read the spnu118u Assembly/Linker Tools document. It was kind of useless and did not provide any insight into how to achieve my goal. It assumes everybody just wants to collect a bunch of sections and push them into a single Memory location. I want to split my section and push them into two different Memory locations. I'll also check out the Primer you mentioned.

    With thanks again,

    Jim Eno

    .text      0    00003200    00010070     
                      00003200    00000c98           StateMac.obj (.text:StateMachine)
                      00003e98    00000a4e           rtsv7M4_T_le_v4SPD16_eabi.lib : _printfi.c.obj (.text:__TI_printfi)
                      000048e6    00000002           BootIntVectRed.obj (.text:defaultISR)

    .text      0    001e0788    0000c2ec     
                      001e0788    0000a184            DSP_CMSIS580_CM4F.lib : TransformFunctions.obj (.text)
                      001ea90c    00000fc8                    : BasicMathFunctions.obj (.text)
                      001eb8d4    00000920                    : ComplexMathFunctions.obj (.text)
                      001ec1f4    00000880                     : FastMathFunctions.obj (.text)

    .const     0    00013310    00000698     
                      00013310    00000101     rtsv7M4_T_le_v4SPD16_eabi.lib : ctype.c.obj (.const:.string:_ctypes_)
                      00013411    000000e7     WirelessHandler.obj (.const:.string:dataset)
                      000134f8    000000c8     rtsv7M4_T_le_v4SPD16_eabi.lib : strtod.c.obj (.const:$O1$$)

    .const     0    00100100    000e0688     
                      00100100    00010000     DSP_CMSIS580_CM4F.lib : CommonTables.obj (.const:WeightsQ31_8192)
                      00110100    00010000                           : CommonTables.obj (.const:Weights_8192)
                      00120100    00010000                           : CommonTables.obj (.const:twiddleCoefF64_4096)

  • I just thought you had to use the 'standard' .text section name for executable code that would have been used when compiling the CMSIS Library.

    There's input sections and output sections. You do (usually) have to use .text for input sections because you have little control over that but you can name your output sections whatever you like. It's just a notional label to group a bunch of input sections but has to be unique. It seems the non-uniqueness is causing the HEX program to skip one of the output sections.

  • Kier,

    A eureka moment for me. When reading the literature, it wasn't clear that the output section names were arbitrary as you pointed out below. Anyway, it works. I verified the project.hex file now contains the missing CMSIS sections and there are no warnings. You are a professional.

        .any_out_section_name_you_want_to_use : > MODEL
        {
            --library=DSP_CMSIS580_CM4F.lib (.text)
        }

    Many thanks,

    Jim Eno