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.

How to insert a blob via linker with TIARMCLANG v1.3.1?



Hi,

I am using TIARMCLANG v1.3.1 via CCS 11.2. I want to insert blobs or binary files via linker scripts in my project/application.
GCC gives this option like this - Include .bin Binary Files in a GNU Linker File | MCU on Eclipse

I want to use this feature in a similar fashion. Is there any way ?

GNU method obviously does not work for TIARMCLANG.

Thanks and Regards,
Aakash

  • tiarmclang uses the linker from the TI proprietary Arm compiler.  It does not have a built-in feature for incorporating raw binary files.  

    I developed a way to do it.  Please understand this method is not well tested.  It may require a few more small changes.  All that said, I'm confident it is worth considering.

    The general idea is to get the binary blob into an ordinary object file, then link that file into the system like any other object file.

    Create an empty assembly source file named empty.s.  Build it just like you do any other source file in your system ...

    tiarmclang -c other options empty.s

    The object file empty.o has all the same properties as other object files in your system.

    Use the utility tiarmobjcopy to create a new object file named blob_file.o that has all the same properties as empty.o.  But it also has another section in it which contains the binary blob. Presume the binary blob is in a file named blob_origin.bin.  Here is the command ...

    tiarmobjcopy --add-section blob_section=blob_origin.bin --set-section-flags blob_section=alloc,readonly --add-symbol blob_symbol=blob_section:0,section empty.o blob_file.o

    The option --add-section creates a new section where the contents come from blob_origin.bin.  The option --set-section-flags makes this section part of the target executable, and read only (I presume it goes in flash).  The --add-symbol option creates a symbol named blob_symbol which corresponds to the base address of the binary blob.  Read more about these options in the tiarmobjcopy page of the tiarmclang online manual

    Link the object file blob_file.o into your system like any other object file.  The linker command file creates and allocates the binary blob with a line in the SECTIONS directive similar to ...

    blob_section > FLASH

    This creates an output section named blob_section.  It is made up of all the input sections also named blob_section.  In this case, there is only one such input section.  It is allocated to the FLASH memory range.

    The C code which uses the binary blob must refer to it with the symbol, or the linker ignores it.  Something like this will do it ...

    extern uint8_t blob_symbol[];
    /* ... */
       variable = blob_symbol[i];

    Thanks and regards,

    -George