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.

TI ARM CLang Compiler ROM image file output

compiler.zip

The goal is to migrate from the ARMCC compiler to the TI ARM CLang compiler for an ARM Cortex M0+ device.

The flow used currently for the ARMCC compiler is as follows

  1. Compile all source files into object files
  2. Link them with the arm linker to produce an ELF format file
  3. Input the output from the previous step to the fromelf tool to output a hex32 file that is preloaded into a ROM.
    1. The hex32 file is ROM Size lines in size
    2. Each line is 2x 16-bit thumb instructions

To try and replicate this with the tiarmclang compiler, the sequence is:

  1. Compile all source files into object files. The options used are:
    1. -std=c99
    2. -O3
    3. -g
    4. -c
    5. -mcpu=cortex-m0
    6. -march=thumbv6m
    7. --target=armv6m-ti-none-eabi
  2. To link the options passed are:
    1. -Xlinker --disable_auto_rts
    2. -Xlinker --search_path=$(CLANG_GENERIC_LIB_DIR)
    3. -Xlinker <command file that utilizes the MEMORY and SECTIONS directives>
  3. Pass the output of the previous step to the tiarmhex tool with the following switches:
    1. --byte
    2. --binary

The desired output looks roughly like:

One example of the output I am getting looks like:

I have tried all variations as described on the compiler documentation and I have toyed with the ROMS directive inside of a command file. Nothing I have tried has output a file of word aligned thumb machine code.

Thanks in advance for any feedback.

Edit: I have added a zip file that shows an example of the behavior with armcc and the attempts to make that behavior work with clang.

  • Hello Austin,

    Please provide more information - what processor are you using in this design?  

    Thank you,

    ~Leonard 

  • If you want an Intel Hex file output then --binary is the wrong option. You need --intel instead.

  • This is an ARM Cortex M0+

  • Hi, I have tried all of the output options and none of them output the desired format.

  • Thank you for ...

    a zip file that shows an example of the behavior with armcc

    I used that to see how you use fromelf.  I am not familiar with fromelf, but I searched on the options you use, and learned a few details.  There is no tool from TI which can produce the exact same output you get with fromelf.  

    But I can make a suggestion.  Please understand this is only a suggestion,  and not a well known method we have long supported.  I am unable to test this suggestion.  All that said, I am confident enough to describe it.

    There are two steps.

    1. Create a binary file (this is supported)
    2. Dump that binary file in the desired format (the suggestion)

    Please see the article An Introduction to Binary Files to learn about those files, and how to create one.  The key command is ...

    $ tiarmobjcopy -O binary executable_file.out binary_file.bin

    There are lots of ways to dump out a binary file, and format it as desired.  One is to use a utility named od, which is available on most Unix-like systems.  Unfortunately, the command line options to od are not standardized.  The implementation I have is from Cygwin.  This is how to use it to get output similar to what you get with fromelf.

      

    $ od -Anone -t x4 -w4 -v binary_file.bin

    When you use your implementation of od, you probably have to change those options.  Here is what the options mean in this case.

    • -Anone : Do not output any file offsets
    • -t x4 : Format hexadecimal 4-byte units
    • -w4 : 4-bytes per line
    • -v : Output all the lines, even if they are duplicates

    Thanks and regards,

    -George

  • George-

      Thank you for the suggestion. I have attempted what you have said and while the output formatting does match the desired formatting, the contents are questionable. I expect the first line in the output file to be the stack pointer address (hardcoded to 0x200003FC in the example) and the following lines to be the isr vector table. The output does not indicate to me this has occurred and now I question if it's even possible to get raw machine code output from the tiarmclang compiler. Does the tiarmclang compiler support the legacy arm compiler through a switch that I am overlooking?

      Thanks.

    -Austin

  • I expect the first line in the output file to be the stack pointer address (hardcoded to 0x200003FC in the example) and the following lines to be the isr vector table.

    I was unaware of that requirement.  I suppose fromelf works that way.  The first word in the hex dump is the first word in the binary file.  The first word in the binary file is the contents at the lowest initialized address in the executable.

    With all that in mind, I conclude there is no straightforward way to use tools from the tiarmclang toolchain to exactly duplicate the output of fromelf.  

    What about the following step that uses the output of fromelf as an input?  Can it be changed to work with input in a different format?  Maybe Intel hex format?

    Thanks and regards,

    -George