Getting Started with Tiva TM4C123G LaunchPad
This article describes about setting up an opensource environment for Texs Instruments Tiva C Series TM4C123G LaunchPad Evaluation Board (EK-TM4C123GXL) using CodeSourcery toolchain, eclipse, and OpenOCD.
Setting up the ARM Lab
It is Assumed that, youe have setup an Embedded ARM Lab, If not, Please do so before proceeding further.
Download TivaWare library, and unzip into a folder, lets call “tivaware” folder in your home directory:
mkdir ~/tivaware sudo apt-get install -y unzip &>> /dev/null unzip -u ~/Downloads/SW-TM4C-184.108.40.206.exe -d ~/tivaware cd ~/tivaware make
- Start Eclipse with new workspce.
- Instead of creating a new project, we will Import an existing Project from the file system.
- Download Eclipse ek-TM4C123GXL Blinky Project and extract to your home folder.
- Import Eclipse ek-TM4C123GXl Blinky Project into the Eclipse workspace
Toolchain Prefix and Path
To make sure that the toolchain Prefix and Path are correct, Select Project > Properties > C/C++ Build > Settings > Cross Settings. The Prefix field is set to arm-none-eabi- and modify the Path field to the folder where you have installed the CodeSourcery toolchain.
if you have accepted the default installation folder.
Setting Compiler, Assembler and Linker Options
Since we have imported a pre-configured project, various options for compiler, assembler, and linker for Debug Configuration are already set. Then, let's build the project.
- To Build the Project on demand, click on the Project menu and un-select Build Automatically.
- From the main menu, Select Project > Build Project.
- If everything goes well, you will see in the console window something like the following:
GDB, OpenOCD and Eclipse
To use OpenOCD with our projects, we need to do more than just connecting the ek-TM4C123GXL board to PC through USB cable and then starting the OpenOCD server.
- We need to configure OpenOCD server so that it knows about the adapter(Dongle) and the board(CPU).
- We also need to configure OpenOCD such that it communicates to GDB using Eclipse GUI for flashing the code and debugging.
- The Eclipse GUI environment will also needs to be configured such that both GDB and OpenOCD are integraed with in the IDE
OpenOCD Project Setup
It is assumed that OpenOCD v0.9.0 is compiled and is available in your home folder such as:
with all the necessary configuration files.
- To configure OpenOCD, select Run > External Tools > External Tools Configurations... from the main menu.
- In the External Tools Configurations window, enter (browse to the) openocd executable as
- OpenOCD in the Name,
- $(HOME)/openocd-0.9.0-bin/openocd in the Location,
- $(HOME)/openocd-0.9.0-bin in the Working Directory, and
- -f board/ek-tm4c123gxl.cfg in the Arguments fields.
- Next, Select Common tab in the same External Tools Configurations window and Select Externals Tools to Display in favourite menu as shown in the following screen.
Make sure that Launch in background option is checked. Next, select Apply followed by Close button.
Configuring the Debugger
- To configure the Debugger, select Run > Debug Configurations... from the main menu.
- In the Debug Configurations window, select GDB Hardware Debugging from the left pane, and make sure that C/C++ Application, Project and Build Configuration fields are selected properly from the main tab as shown in the following screen.
- In the same Debug Configurations window, select Debugger tab. In this window tab, specify :
- $(HOME)/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-eabi-gdb as GDB Command,
- Check Use remote target option
- Select Generic TCP/IP for JTAG Device,
- localhost for Host Name and
- 3333 for Port Number as shown in the screen.
- Select the Startup tab and enter the following Commands in the text window:
- monitor reset init
- monitor halt
- monitor sleep 500
- monitor poll on
- Select the Common tab and check Debug to Display in favourites menu as shown in the following screen.
That’s it. We have completed the Debug Configurations. Click on Apply followed by Close button to complete the Debug Configurations.
The TM4C123GXL LaunchPad Board ICDI USB port (marked DEBUG and shown in the picture below) is a composite USB port and consists of three connections:
- Stellaris ICDI JTAG/SWD Interface - debugger connection
- Stellaris ICDI DFU Device - firmware update connection
- Stellaris Virtual Serial Port - a serial data connection
Using the included USB cable, ► connect the USB emulation connector on your evaluation board (marked DEBUG) to a free USB port on your PC. A PC’s USB port is capable of sourcing up to 500 mA for each attached device, which is sufficient for the evaluation board. If connecting the board through a USB hub, it must be a powered hub.
Make sure that the power switch in the upper left hand corner of your board is in the right-hand DEBUG position as shown:
We have already configured OpenOCD, just select OpenOCD from the External Tools Tool Bar.
Note: OpenOCD will be running in the background, don’t terminate.
Launching the Debugger
To launch the debugger, select the Debug icon from the tool bar.
When we launch the Debugger for the first time, eclipse tries to switch the Perspective from C/C++ to debug, select Remember my decision and click YES.
The Debugger should break at C main function as we have configured it.
if Debugger launch gets stuck at "Configuring GDB" then may be 32-bit libncurses library is missing.
To install use following command
sudo apt-get install lib32ncurses5 lib32ncurses5-dev
If you reached this step without any problems, then congratulations, you have a perfect environment to develop firmware for the ARM platform. Now you can use all the debugging commands like, single step, examine registers, examine data etc.