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.

TMS320F28335: Include binary data into C-project

Part Number: TMS320F28335
Other Parts Discussed in Thread: TMS320F280049C

Hello

I have been searching the forum for some hours now and have found some similar questions, but no answer that really helped:

In my c project, I need to include data that is not in a usable c-format and I would like to include it it as raw data into the flash.

For of those objects we created a section .blob in the in linker cmd-file and we include one of the files with c-style data (endless list of comma separated values) by

#pragma DATA_SECTION(blobfile,".blob");

static const unsigned char blobfile[] =
{
#include "file.dat"
};

The other file however id contains raw data and I would be happy to avoid post-processing the data to make it c-compatible.

Anyone an idea how to include this data-file when #include will not work?

Thank you in advance for your help!

  • Attached is an example for a TMS320F280049C which gets the linker to link raw data from a file into flash.

    I had to resort to using objcopy from ARM compilers to convert a raw file into an ELF object which can be linked by the C2000 linker.

    The header of TMS320F280049C_link_binary_blob.c attempts to explain how the project was configured.

    TMS320F280049C_link_binary_blob.zip

  • Hi, 

    You can try out the option suggested by Chester. 

    Will check with the compiler team if there is any other way of handling this and get back to you 

    Best Regards

    Siddharth

  • Hello Chester

    Thank you for your answer. I'll look into it today and see if I can make it work.

    Regards
    Lars

  • Lars, 

    Were you able to try this out?

    Best Regards

    Siddharth

  • Hello Siddharth, hello Chester

    I'm still working on it. My build environment for some reason crashed and I had to revert and start over.

    I managed to make my binary into an object-file. I have no GCC installed, but I got objcopy from the binutils.  What I don't completely understand, in the example:

    /* The symbols generated by the conversion of this source file into an object file */
    extern int _binary____TMS320F280049C_link_binary_blob_c_start;
    extern int _binary____TMS320F280049C_link_binary_blob_c_end;

    These symbols or externals, are they generated from the filename during linking process of the project? The scheme seems to be _binary____filename_ext_start/end? Do you have a reference to a manual?

    I'll will get back to you later today or during tomorrow.

  • These symbols or externals, are they generated from the filename during linking process of the project? The scheme seems to be _binary____filename_ext_start/end?

    Those symbols are generated by objcopy when transforming the binary file to an object file.

    The naming convention for those symbols is documented for the objcopy --binary-architecture option. E.g. objcopy contains:

    You can access this binary data inside a program by referencing the special symbols that are created by the conversion process. These symbols are called _binary_objfile_start, _binary_objfile_end and _binary_objfile_size. e.g. you can transform a picture file into an object file and then access it in your code using these symbols. 

    The TI ARM compiler armobjcopy used in the example isn't documented as taking the --binary-architecture option, and instead used a combination of --input-target=binary --output-target=elf32-littlearm

    The filename of the "binary" input file is ../TMS320F280049C_link_binary_blob.c which gets translated into ___TMS320F280049C_link_binary_blob_c as the filename part in the symbols - with the periods and forward-slash in the input filename being converted to underscores in the symbol names.

  • Hello Chester

    I have now understood the underlying principles and thank you very much for your support. After I completed my experiments with the example you supplied, I started putting it into our project. It was now it came to my attention, that this legacy project is still a COFF project and at present I see no tool to convert the ELF to COFF. If you have a solution for this too, It will be very welcome. I have considered converting our project to ELF, but I'm afraid of braking our toolchain. So this will be today's task to check.

    One learning: If the binaries filename contains a "-" (dash or minus) it will in C not be possible to declare the external symbol...

    Hello Siddharth

    I think it would be a useful function to be able to include a binary data in a simple way within the C2000 toolchain.

    Thank you both for your engagement!

    Best regards,
    Lars