Jump to content

Complete Tiva IDE using Eclipse on Mac including flash and debug

Recommended Posts

I recently installed openOCD on my computer and was able to get command line debugging working. Reading the gdb tutorials, I started doubting whether this was something I wanted to learn and wanted to see if I could get a GUI debugger working instead. I started fiddling around with Eclipse on my Mac and wanted to get a complete Tiva IDE. I followed a great tutorial for installing Stellarisware on Linux at http://kernelhacks.blogspot.com/2012/11/the-complete-tutorial-for-stellaris_25.html


Perhaps because of the changes from Stellarisware to Tivaware and/or Linux to Mac, there were many things that needed to be tweaked, adjusted, and fiddled with. But in the end, everything works!


First, off, I have Energia.app in /Applications. I installed openOCD using macports and installed Eclipse IDE for C/C++ Developers. Make sure gdb and openOCD are working properly before trying to get it to work in eclipse. I will describe here the changes from the tutorial above-- do all the other steps in the tutorial above.


I copied the TivaWare files extracted on a Windows machine (because TI distributes this as an EXE file!) to ~/Projects/TivaWare_C_Series-1.1 (you can choose elsewhere but will need to change paths accordingly). I also created a folder for openOCD in ~/Projects/openocdDir containing the file ek-lm4f230xl.cfg which contains

# TI Stellaris Launchpad ek-lm4f120xl Evaluation Kits
# http://www.ti.com/tool/ek-lm4f120xl

# NOTE: using the bundled ICDI interface is optional!
# This interface is not ftdi based as previous boards were
source [find interface/ti-icdi.cfg]

#set CHIPNAME lm4f120h5qr
set CHIPNAME lm4f230h5qr
source [find target/stellaris_icdi.cfg]

Step 6: in Cross Settings, change Prefix to arm-none-eabi- and set Path to /Applications/Energia.app/Contents/Resources/Java/hardware/tools/lm4f/bin/


Step 7: Same except define PART_TM4C123GH6PM instead of PART_LM4F120H5QR. I don't know if this makes a difference but be consistent.


Step 8: set include path to /Users/pjkim/Projects/TivaWare_C_Series-1.1


Step 9: Misc section. Set other flags to "-c -fmessage-length=0 -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections -fdata-sections -MD -std=c99 -Wall -pedantic"


Step 9.5: Change Cross Gcc Linker to ld. I think it defaulted to gcc for some reason.


Step 10: Linker Libraries. Leave Libraries blank. Change search path to /Applications/Energia.app/Contents/Resources/Java/hardware/tools/lm4f/lib/gcc/arm-none-eabi/4.7.1


Step 11: Linker Misc. Change linker flags to "--gc-sections -T../LM4F.ld"


Once everything is done, check your flags. If you click on the "Cross GCC Compiler" item under Tool Settings, you can see "All options:" it should look like 

-DARM_MATH_CM4 -DTARGET_IS_BLIZZARD_RA1 -DPART_TM4C123GH6PM -I/Users/pjkim/Projects/TivaWare_C_Series-1.1 -O0 -g3 -Wall -c -fmessage-length=0 -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections -fdata-sections -MD -std=c99 -Wall -pedantic

Check the Cross GCC Linker options. They should be something like this.

-L/Applications/Energia.app/Contents/Resources/Java/hardware/tools/lm4f/lib/gcc/arm-none-eabi/4.7.1 --gc-sections -T../LM4F.ld

You will need to supply a linker description file LM4F.ld in the main folder of your project. You can copy any one of the .ld files from the TivaWare examples folder. You basically needs this in the file:

* This is part of revision 1.1 of the EK-TM4C123GXL Firmware Package.

    FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000
    SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000

    .text :
        _text = .;
        _etext = .;
    } > FLASH

    .data : AT(ADDR(.text) + SIZEOF(.text))
        _data = .;
        _edata = .;
    } > SRAM

    .bss :
        _bss = .;
        _ebss = .;
    } > SRAM

Go back to the appropriate sections to fix any errors. My username is pjkim. Change to yours. This should give you a working IDE for compiling your projects into an .elf and .bin file. Get this working before going to the next step,  "Flashing Programs."


Step 3: He was flashing the Release version which doesn't include the debug symbols in the .elf file. I chose to use the Debug version for this reason. Name "Debug flash." Location "/Applications/Energia.app/Contents/Resources/Java/hardware/tools/lm4f/bin/lm4flash" Working Directory: "${workspace_loc:/${project_name}/Debug}" and Arguments: "${project_name}.bin"


This should give you compile and flashing capabilities.

N.B. lm4flash in the current version of Energia (0101E0010) is broken. You will need to replace it from the prior version or as I did, build from source (https://github.com/utzig/lm4tools).


The last part of the puzzle is in IDE debugging. This part works now but it was tricky to get working and I am not exactly why it is so fidgety. If it is not working properly, I suggest trying to isolate the problem by running openocd in a terminal window and gdb from eclipse. If this works, do it the other way around, run openocd in eclipse and connect to the board using gdb in a terminal window. That way you can narrow down where you need to fix things.




Step 2: Location: "/opt/local/bin/openocd" Working Directory: "/Users/pjkim/Projects/openocdDir" and Arguments: "--file ek-lm4f230xl.cfg" You will need to create a openocdDir folder and put in the file ek-lm4f230xl.cfg. The contents are:

# Comments go here
source [find interface/ti-icdi.cfg]

set CHIPNAME lm4f230h5qr
source [find target/stellaris_icdi.cfg]

Step 7: There is a known bug in gdb or openocd that can cause connection problems. The workaround is described in http://www.verious.com/tutorial/the-complete-tutorial-for-stellaris-launchpad-development-with-gnu-linux-ii


Get the target.xml file from http://pastebin.com/download.php?i=0Lu3Bu0R and rename it. Put the file in your Project/Debug folder. If anyone knows how to do this better/automatically, I would appreciate it.


Change the Initialization commands to

set tdesc filename ../target.xml
target extended-remote :3333
monitor reset halt

And you should have a working IDE. Here is a screenshot of the IDE in action:



Wouldn't it be nice if TI could package all of this into a .dmg file?

Share this post

Link to post
Share on other sites

Hi pjkim,


Wow, that is pretty awesome, I develop iPhone apps that work with the Tiva.....


.....So I got quite excited when I read your post.....then I realised, I have begun user TI-RTOS in my projects, which means I am pretty much stuck with Code Composer Studio. I could get rid of TI-RTOS and just use SYS/BIOS standalone, but I'd miss all Instrumentation and other cool debug and monitoring tools. Damn!


And yes, it would be awesome if TI could package a .dmg that works on the Mac, especially one that supported their entire toolchain.



Share this post

Link to post
Share on other sites

Hi all,

I agree with you - on the Code Composer forum there is a thread asking for tools for Mac, signed by less than one hundred persons if I remember well, but no reaction until now (while other brands offer such tools).

@pjkim: if your posted linker file works for you it is OK, but I have doubts - that file is from CCS, and is incomplete for GCC! since his linker asks for some sections like .eidx - or such sections are hidden in other file ? (Did not followed the whole chain to verify) - can you clarify? Thanks.


Share this post

Link to post
Share on other sites

@Lyon: Not quite sure I fully understand the crux/doubt of your question. The posted linker file (.ld) is from the examples/boards/ek-tm4c123gxl folder from the Tivaware package. All of the examples have a .ld file and they look identical except for the comments at the top which I edited out for brevity-- perhaps I should put that back in for clarity.  As for completeness, it builds fully into a a .elf and .bin file which can be flashed to the Launchpad so fairly complete.


Hope that answers your question. And where is this petition? I will sign it.


Edit: found the thread. Posted information about this thread there. It might have <100 sigs but greater than 47,000 views! A lot of people are interested in this. Or one person is REALLY interested. TI has commented that they are considering Mac support in CCS.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now