Actions

EmSys

Getting Started with Tiva TM4C123G LaunchPad

From EdWiki

Getting Started with Tiva LaunchPad + ARM ToolChain + Eclipse + OpenOCD

Tiva LaunchPad+ARM+Eclipse+OpenOCD


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.

TivaWare

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-2.1.2.111.exe -d ~/tivaware
cd ~/tivaware
make

EK-TM4C123GXL Blinky Project

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.

$(HOME)/MentorGraphics/Sourcery_CodeBench_Lite_for_ARM_EABI/bin

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.

Building Project

  1. To Build the Project on demand, click on the Project menu and un-select Build Automatically.
  2. From the main menu, Select Project > Build Project.
  3. 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.

  1. We need to configure OpenOCD server so that it knows about the adapter(Dongle) and the board(CPU).
  2. We also need to configure OpenOCD such that it communicates to GDB using Eclipse GUI for flashing the code and debugging.
  3. 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:

$(HOME)/openocd-0.9.0-bin

with all the necessary configuration files.

  1. To configure OpenOCD, select Run > External Tools > External Tools Configurations... from the main menu.
  2. 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.
  3. 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

  1. To configure the Debugger, select Run > Debug Configurations... from the main menu.
  2. 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.
  3. 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.
  4. Select the Startup tab and enter the following Commands in the text window:
    • monitor reset init
    • monitor halt
    • monitor sleep 500
    • monitor poll on
  5. 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.

EK-TM4C123GXL Board

Tiva™ C Series TM4C123G LaunchPad

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.

LaunchPad


Make sure that the power switch in the upper left hand corner of your board is in the right-hand DEBUG position as shown:






Running OpenOCD

We have already configured OpenOCD, just select OpenOCD from the External Tools Tool Bar.

Run OpenOCD








OpenOCD Output







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.

Invoking Debugger
















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.

Eclipse Perspective Switch












The Debugger should break at C main function as we have configured it.

Debug Window

















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.

References

  1. Tiva C Series TM4C123G LaunchPad -- Readme First
  2. Tiva C Series TM4C123G LaunchPad Evaluation Kit -- User's Manual
  3. TM4C123GH6PM Microcontroller -- Data Sheet
  4. TivaWare Peripheral Driver Library -- User's Guide
  5. Sensor Hub BoosterPack -- Documentation