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.

CCS/TM4C1290NCPDT: Embedding a different firmware image as a binary resource

Part Number: TM4C1290NCPDT
Other Parts Discussed in Thread: CC1310,

Tool/software: Code Composer Studio

My application is that I want to program a CC1310 part via its serial system boot loader from a tm4c1290 processor. Both firmware projects are developed under ccs9.

Currently the CC1310 firmware is compiled and has produced a .out file. I have used arm-none-eabi-objcopy.exe to create a flat binary file (.bin) with undefined memory filed in with 0xFF's. using the command

arm-none-eabi-objcopy.exe -Obinary --gap-fill 0xff cc131x-davistalk-receiver.out Davistalk_Rx.bin

Using the method described  in the linked article below I have "converted" this binary file into an ELF file, with automatically generated linker symbols for the beginning and end of the binary resource but when I try to include the generated .out file into my TIVA-C project, I get the error message

fatal error #10178: attempt to link an object file that is not built for Advanced RISC Machines ARM
("C:/MyFirmware/workspace_v9/Angelia-Baremetal/DavisTalkSupport/Davistalk_Rx_0_5_5_38_RGZ.out" = no machine)

The article I got this from was targeted for a "TI C6x" device and suggested using the parameter "--alt-machine-code=140" to set the machine type, but since I am doing this on an ARM part, I don't know if this is the correct machine code to use. Can someone tell me what machine code to use for ARM processors in order for the linker to accept the binary blob?

While in this case the binary data happens to be a firmware image for a different processor, the inclusion of raw binary data into the program flash could have other uses, such as embedded graphic files (.jpg etc).

Please also let me know if this issue has been addressed in ccs10. If so I will upgrade to it.

Note, I have successfully included, or at least appended, binary data to an image file using the gcc compiler and linker outside of Code Composer Studio. It is the css linker I am having trouble with.

Related issue:

e2e.ti.com/.../792875

  • As a follow up I have made some progress using the command line (executed from Cygwin):

    arm-none-eabi-objcopy --input-target=binary -B arm --output-target=elf32-littlearm  --rename-section .data=.const Davistalk_Rx_0_5_5_38_RGZ.bin  Davistalk_Rx_0_5_5_38_RGZ.out

    Where -B specifies a binary conversion into an ARM architecture, and --rename-section is used to move the resulting binary resource out of the .data section.

    I am now getting the error message:

    error #16006-D: ABI version of "C:/MyFirmware/workspace_v9/Angelia-Baremetal/DavisTalkSupport/Davistalk_Rx_0_5_5_38_RGZ.out" (0) is incompatible with "./tm4c1290ncpdt_startup_ccs.obj" (5)

    Even though an .out file is not created, I see the resource added into the map file, with the expected start, end, and size symbols created.

     

  • Edward Blair said:
    Can someone tell me what machine code to use for ARM processors in order for the linker to accept the binary blob?

    All of them are listed here.  The value for ARM is 40.

    Edward Blair said:
    Please also let me know if this issue has been addressed in ccs10. If so I will upgrade to it.

    Unfortunately, it has not.

    Thanks and regards,

    -George

  • Edward Blair said:
    Can someone tell me what machine code to use for ARM processors in order for the linker to accept the binary blob?

    There are some updated examples for ARM Cortex-M4 processors on Compiler/MSP432P401R: Loading a binary object into flash during programing to be read by NVS later

  • I have figured out how to do this and will give general instructions below. They should work for any arbitrary binary file.

    Step 1 - Prepare your binary resource file.

    How you do this is beyond the scope of these instructions. Whatever you end up with will become an exact image
    copied into the program flash of the ARM processor. For this example it will be named BinaryFile.bin

    Step 2 - Create an ELF file from the binary file using GCC objcopy command

    arm-none-eabi-objcopy --input-target=binary -B arm --output-target=elf32-littlearm --rename-section .data=.image,alloc,load,readonly,data,contents BinaryFile.bin BinaryFile.out

    Here the options --input-target=binary and --output-target=elf32-littlearm specify the input and output file formats.
    -B arm says you are doing a binary to object resource conversion, and specifies the architecture of the ELF file
    --rename-section .data=.image,alloc,load,readonly,data,contents does two things:

    By default the binary object created will be placed in a section named .data. Using this option allows you to place the new resource into a separate section so it will not be linked together with other resources. In this case the new section is named .image.
    Adding the section flags "alloc,load,readonly,data,contents" will make the new section a read only section, that is allocated space in your final program image, and will have the binary data copied into your final executable.

    Step 3 - Edit the .out file to have the correct ELF e_flags value

    Open up the BinaryFile.out file in a binary (hex) editor. Change the value of byte 0x27 from 00 to 05.
    This will allow the ccs linker to accept the ELF file, otherwise it generates an error.

    This step is the only one that is not really documented anywhere. The number 5 came from a ccs error message.

    Alternatively, as suggested by ,  add --diag_warning=16006 to the linker options; under CCS Build -> ARM Linker -> Advanced Options -> Diagnostics add 16006 to "Treat diagnostic <id> as warning (--diag_warning)". This changes diagnostic 16006 from a linker error to a warning, to allow the program to link.

    Step 4 - Add the .out file to your project

    (These are the instructions for ccs9)
    Place the BinaryFile.out file in the project folder.
    Open up the project options and navigate to the CCS Build > File Search Path controls
    under the "Include library file or command file as input", add the BinaryFile.out file.
    (Hint, click "Add..." then click on "Workspace..." then navigate to the file. This will use build variables
    to locate the file instead of an absolute file path.)

    Step 5 - Add the new section to your linker command file

    You will need to add the new section(s) created in step 2 into your liker command file so the linker will know where to put them in memory. If you are using a default linker script, copy it into your project so you can edit it, and change the linker command script used in the linker project settings. Then add the highlighted line to the SECTIONS section:

    SECTIONS
    {
        .intvecs:   > 0x00000000
        .text   :   > FLASH
        .const  :   > FLASH
        .cinit  :   > FLASH
        .pinit  :   > FLASH
        .image  :   > FLASH  /* Add this line using your section name */
        .init_array : > FLASH
    
        .vtable :   > 0x20000000
        .data   :   > SRAM
        .bss    :   > SRAM
        .sysmem :   > SRAM
        .stack  :   > SRAM
    }
    

    Step 6 - Use the resource in your code

    When you create the ELF file in step 2, three linker symbols are created that allow you to access the data:
    _binary_BinaryFile_bin_start (holds the starting address of the binary resource)
    _binary_BinaryFile_bin_end   (holds the ending address of the binary resource)
    _binary_BinaryFile_bin_size  (holds the size of the binary resource)

    The _start, and _end values are relocatable, so the final linking process will give these variables the location that the
    resource ends up in the final build.

    Note: The variable names are based on the name of the binary file used in step 1.

    _binary_<file name>_start  etc.

    Since these are linker generated variables, they work slightly differently from normal C variables

    Declare them in a header file, or at file scope with:

    extern const uint8_t * _binary_BinaryFile_RGZ_bin_start;
    extern const uint8_t * _binary_BinaryFile_RGZ_bin_end;
    extern const uint8_t * _binary_BinaryFile_bin_size;

    The easiest way to use them is to assign the values to regular C variable like this:

    int size = &_binary_BinaryFile_RGZ_bin_size;
    const uint8_t * ptr = &_binary_BinaryFile_RGZ_bin_start;

    Now you can do things like:

    for (i=0; i<size; i++)
    {
       printf("%02X ", ptr[i]);
    }

    I hope this is helpful.

  • Edward Blair said:
    This will allow the ccs linker to accept the ELF file, otherwise it generates an error.

    I found a different workaround was to add --diag_warning=16006 to the linker options; under CCS Build -> ARM Linker -> Advanced Options -> Diagnostics add 16006 to "Treat diagnostic <id> as warning (--diag_warning)"

    This is because the armobjcopy command generates the ELF output file with an ABI version of "0", which by default the linker considers incompatible with the ABI version of "5" generated by the TI ARM compiler.

    The above setting changes diagnostic 16006 from a linker error to a warning, to allow the program to link. I have been unable to find how to make armobjcopy insert an ABI version of "5" in the generated object file.

  • I can shed some light on ...

    Edward Blair said:

    Step 3 - Edit the .out file to have the correct ELF e_flags value

    Open up the BinaryFile.out file in a binary (hex) editor. Change the value of byte 0x27 from 00 to 05.
    This will allow the ccs linker to accept the ELF file, otherwise it generates an error.

    This step is the only one that is not really documented anywhere. The number 5 came from a ccs error message.

    All recent ARM compilers conform to the ARM Extended Application Binary Interface standard.  That page contains a collection of about 20 documents.  Focus on the one titled ELF for the ARM Architecture.  Obtain the related PDF file and search it for e_flags.  It shows the following ...

    Thanks and regards,

    -George