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.

TMS320F280025C: Generating .bin image file with only executable data

Part Number: TMS320F280025C

Hi team,

I am trying to generate a .bin image file of a program which can be serially downloaded by a bootloader and programmed into flash memory using Flash API. For this, it is crucial that the image file must contain only the data that needs to be written in the memory sectors. I am able to generate a .bin file of my application using the Hex Utility tool, but the size of .bin file reaches 28KB, whereas the application only uses 13KB in the ROM. I am assuming this is happening because the generated .bin file also contains debug and other information which is not required. I was able to search for a few methods to deal with this problem...

1) Using the -image option in the hex utility tool, but it requires a ROM directive to be included in its linker command file.

2) Using Strip Utility tool, strip2000, to remove symbol table and debug information from the object file directly.

Please suggest how do I proceed with this issue or if there is any other method to get the desired output.

Thanks,

Mahesh

  • Hello,

    I have brought this thread to the attention of the compiler experts. Please note that the responses may be delayed this week due to the local holiday.

    Thanks

    ki

  • The raw binary will not have any symbol or relocation information or debug information; it is strictly the contents of your application sections -- a memory dump.  Please see this link for more information about raw binaries.

    It's possible your raw binary has holes that are filled, increasing the size.  Also, how are you building your application? Have you turned on compiler optimization favoring code size reduction?

  • Hi Alan,

    Thanks for your reply. 

    Have you turned on compiler optimization favoring code size reduction?

    No, I haven't used any optimization for the code size. Although after some digging, I was able to find a solution to the problem. As mentioned earlier:

    1) Using the -image option in the hex utility tool, but it requires a ROM directive to be included in its linker command file.

    I used the hex utility tool and selected the -image option. This required a custom ROM directive .cmd file created outside the project(so that it is not confused with the linker command file), which specifies the starting address and data length of the device memory which I need to convert into .bin format.

    ROMS 
    {
        all_mem: o = 0x85000, l = 0x036C3
    }
    //Here o = [Starting address], l = [length]
    //In my case, reads memory from 0x85000 to 0x886C3

    To use this ROM directive, we need to add the file name to command-line pattern under the Hex Utility tool tab in project properties.

    "${command} ${flags} ${output_flag} ${output} ${inputs}C:\...\ROMdirective.cmd"

    The only drawback of this method is that I have to first check the ROM usage of my application and make changes to the ROM directive every time I update my application. This gives me only the executable data that I need, hence, I don't even need to worry about holes in my .bin file. Sharing this information for other users facing this issue in the future.

    Although this issue has been resolved, I would like to know more about the optimization you mention earlier:

    compiler optimization favoring code size reduction

    It would be great if you could provide me a link to the related documentation for the same.

    Thanks and regards,

    Mahesh

  • Sure -- please search the C28x compiler manual for the sub-chapter titled "Invoking Optimization" and "Controlling Code Size Versus Speed"