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.

Compiling examples on Linux with gcc

Other Parts Discussed in Thread: UNIFLASH, TM4C1294NCPDT, SYSBIOS, EK-TM4C1294XL

I'm a newbie at rtos so bear with me please :)  I'm trying to build a dev environment on linux using gcc.  I've succeeded using just using tivaware.  It seems like I have succeeded using tirtos as well but the "file" I upload to the EK-4C129XL board doesn't seem to do anything.  I'm trying to compile and run the pwmled example.

Using just tivaware I uploaded the bin file for the blinky program and it worked  but there is no bin file after the build process with tirtos.    I tried uploading the obj and .out files but no luck.  The tirtos installation left a whole bunch of hardcoded c:\ references which I had to change to match my directory structure in linux so maybe I missed something even though the build process gives no errors.

this is the tail end of the build process:

Build of libraries done.
clm4fg package/cfg/pwmled_pm4fg.c ...
Building pwmled.obj
Building EK_TM4C1294XL.obj
linking...

Thanks

  • Douglas,

    TI-RTOS Makefile examples generate .out files, which are in ELF format. Can the flash loader support ELF formats?

    We generally use CCS to load these executables .out files to the target. If CCS isn't an option, I'm pretty sure that if you look in the tivaware projects setting you will find a "post-build" stage command shell call that you can adopt into the TI-RTOS generated makefiles to generate .bin files.

    #
    # The rule for linking the application.
    #
    ${COMPILER}${SUFFIX}/%.axf:
    	@if [ 'x${SCATTERgcc_${notdir ${@:.axf=}}}' = x ];                    \
    	 then                                                                 \
    	     ldname="${ROOT}/gcc/standalone.ld";                              \
    	 else                                                                 \
    	     ldname="${SCATTERgcc_${notdir ${@:.axf=}}}";                     \
    	 fi;                                                                  \
    	 if [ 'x${VERBOSE}' = x ];                                            \
    	 then                                                                 \
    	     echo "  LD    ${@} ${LNK_SCP}";                                  \
    	 else                                                                 \
    	     echo ${LD} -T $${ldname}                                         \
    	          --entry ${ENTRY_${notdir ${@:.axf=}}}                       \
    	          ${LDFLAGSgcc_${notdir ${@:.axf=}}}                          \
    	          ${LDFLAGS} -o ${@} $(filter %.o %.a, ${^})                  \
    	          '${LIBM}' '${LIBC}' '${LIBGCC}';                            \
    	 fi;                                                                  \
    	${LD} -T $${ldname}                                                   \
    	      --entry ${ENTRY_${notdir ${@:.axf=}}}                           \
    	      ${LDFLAGSgcc_${notdir ${@:.axf=}}}                              \
    	      ${LDFLAGS} -o ${@} $(filter %.o %.a, ${^})                      \
    	      '${LIBM}' '${LIBC}' '${LIBGCC}'
    	@${OBJCOPY} -O binary ${@} ${@:.axf=.bin}
    endif

    The ${OBJCOPY} command converts the .axf file to a .bin. It should be possible to do something similar with the .out files.

  • You are correct the lm4flash utility does not support elf files. Okay so I tried installing CCS Uniflash and managed to get it to run after installing mondo dependencies, but I couldn't get the emulator part to run. I seem to be having udev rule issues. Even after copying the permissions file I still can't run lm4flash as a normal user. I ran uniflash as root but still no luck. What is the name of the onboard emulator I should use with the EK-TM4C129XL board?

    I then tried your second suggestionnd quickly realized that I had to specify only some sections to copy to the bin file as in:

    arm-none-eabi-objcopy -j .isr_vector -j .text -O binary pwmled.out pwmled.bin

    But alas uploading this with lm4flash results in nothing. Perhaps I don't understand this example? Shouldn't it do about the same as the blinky example and flash an onboard led? I tried pressing reset and no luck

    I did verify that that the above command generates the proper bin file for the tivaware example blinky. Maybe I need to copy more than those two sections for a tirtos program?
  • Back to solution 1. I surmised that I should probably be using the Stellaris in-circuit debug interface and selected Tiva TM4C1294NCPDT as the target device but I get this error:

    [18:34:41] ERROR >> Unable to load /home/developer/Launchpad/uniflashv3/ccs_base/DebugServer/drivers/libstellaris_emu.so: libnspr4.so: cannot open shared object file: No such file or directory
    [18:34:42] com.ti.debug.engine.IApplication$InitializationException: Unable to load /home/developer/Launchpad/uniflashv3/ccs_base/DebugServer/drivers/libstellaris_emu.so: libnspr4.so: cannot open shared object file: No such file or directory
  • Hi Douglas,

    The pwmled example should fade in and fade out 2 different LEDs. If you're not connecting to an emulator at runtime, then you need to disable the target's semihosting option. Unfortunately, this is not done by default and I can see how frustrating it can be not to have an example just work out of the box. I've created a bug ID to track this (SDOCM00115174).

    To turn off the semihosting, you need to modify the .cfg file and adjust the makedefs linker option. (Here's a wiki all about semihosting...)

    In the makedefs file, you need to replace "-lrdimon" with "-lnosys". (This links in a no semihosting library to the System_printf() calls)

    In the pwmled.cfg file, you need to comment out "var SemiHost = xdc.useModule('ti.sysbios.rts.gnu.SemiHostSupport');"

    I've played around with the Uniflash tool on Windows. I was able to load .out files, but for some reason I wasn't able to load .bin files and I don't know why. This problem might be better answered by the Code Composer Studio forum, but in the meantime using the .out files did the trick for me.

  • Basically no luck. I'm still having problems flashing files using uniflash. Neither the gui or the cmdline uniflash will work for me. I tried making a bin from the .out file and flashing with lmflash but that did not seem to work. I agree with you that I should probably ask about uniflash in the CCS forum. But I would like to confirm with you first that changing the above two lines should be sufficient to get the pwmled exammple working notwithstanding my flash problems before I go over to the other forum. Thanks.

    As an aside there does not seem to be much support in the way of wiki information or otherwise on compiling tirtos programs using gcc from the command line under linux. It was a comparatively simple matter to get the tivaware examples to compile and flash even though it involved multiple post tivaware installation steps. The linux tirtos installation left many hardcoded c:\ references and other paths that didn't make sense under linux in the makefiles which I had to change. Fortunately using bash scripts its a trivial manner to change a 100 files all at once. I've been keeping detailed notes of the steps involved. Once I get everything working is there someone at TI that I can direct these notes to who might be interested in making a wiki page specifically addressing using tivaware and tirtos under linux from the command line? Of course there are more challenges to come after the flashing like debugging using gdb.
  • Can someone from TI please solve the problem of the example tirtos programs not working out of the box if you are compiling and running from the cmdline?  Also neither uniflash or loadti will work under linux.  I had to resort to using the windows version of uniflash to load .out files which >I did successfully.

    I modified the makedefs and pwmled.cfg files acording to the instructions given and flashed the board EK-TM4C1294XL using uniflash under windows.  The program still doesn't run.  This is not a board problem.  I can compile and flash tivaware examples such as blinky no problem using lm4flash.


    Seriously this makes me want to find a new development platform for my project.  Please do something TI.  Thank you.

  • Douglas,

    sorry for the late reply. What version of TI-RTOS are you using? I'm assuming you are using tirtos_tivac_2_10_01_38, but please let me know if you're using something else. The TI-RTOS examples out of box experience was designed to work in the CCS development environment with an attached emulator. As mentioned before, I've filed a bug ID to have this changed.

    In regards to the hard coded c:/ references; update tirtos.mak with your Linux paths instead of the c:/ paths and then generate your own set of examples, See the TivaC Getting Started Guide (3.3 Creating Examples to Build via a Command Line).

    Since you are interested in GCC, you can set CCS_BUILD=false and GCC_BUILD=true. Run make -f tirtos.mak examplesgen DEST="/home/<username>/examples" to generate the new set of TI-RTOS examples.

    Afterwards, update makedefs file in /home/<username>/examples/GNU/EK_TM4C1294XL to use the "nosys" library and then update /home/<username>/examples/GNU/EK_TM4C1294XL/pwmled/pwmled.cfg and uncomment the "var SemiHost = xdc.useModule('ti.sysbios.rts.gnu.SemiHostSupport');".

    After all that, I was able to call make from within /home/<username>/examples/GNU/EK_TM4C1294XL/pwmled/ to build the example. I tested the target application without an attached emulator and it worked for me. Can you load the .out file from a windows machine onto your target and verify that it works (e.g. LED fading in and out)?