Você está na página 1de 10


Toan Nguyen
School of Electrical Engineering
Hochiminh International University
A toolchain is a set of software development tool that help developer to turn the source
code into executable machine code. In term of embedded system, a toolchain is a cross
toolchain which is capable of creating excutable code for a target system (eg.
Microcontroller) from a host system (eg.X86/X64 PC) by means of compilers, assemblers,
linker, burner and debugger. In case of the TI MSP430 Ultra-Low-Power MCU, there are
several choices of toolchain which developer may consider. The first group is pre-built
toolchains that come along with some integrated development environment (IDE) such as
Code Composer Studio (CCS) from Texas Instrument (TI) and IAR Embedded Workbench.
The benefit of this kind of toolchain is its easy-to-use, user can jump right into programing
job without any modification. However, the limitation of code size and technical support for
the free version are the disadvantage of this group of toolchain. On the other hand, building
from source is free of charge and strongly supported by the community. The purpose of this
report is to investigate and implement the TI MSP430-GCC, a popular open source toolchain
provided by TI and Red Hat.


TI MSP430-GCC is a port of GNU Toolchain which is a broad collection of programing
tools produced by GNU project. It is the replacement of the former MSPGCC developed
by Peter A. Bitgot. The items that make up the TI-MSP430-GCC are: GNU Compiler
Collection (GCC), GNU Binary Utilities (Binutils), Standard C Library (Newlib),
GNU Debugger (GDB). In order to flash the code to MSP430 Microcontroller, mspdebug
also need to be installed. The table below illustrate the function of these items:

The actual C/C++ Compiler


Including utilities use to manipulate the generated binary file, the most
important tools are the assembler and linker
C library intended for use in embedded system
The debugger allow developer to see what is going on the program while it


is executing


A program to flash the code into non-volatile memory in MSP430


a. Ubuntu
Ubuntu is a Debian-based Linux operating system, with Unity as its default desktop
environment. The benefit of using Linux OS is it totally free and strongly supported
by developer community.
b. Eclipse
Eclipse is an IDE which contains an extensible plug-in system for customizing
programing environment. Thanks to these plug-ins, Eclipse can be used to develop
application in various programing language such as: Java, C/C++, Perl, Python, Ruby
and so on. Furthermore, Eclipse allows user to configure deeply in project setting
which help to launch the appropriate tool in toolchain to produce the desired output,
in this case is an executable machine code. By those reasons, Eclipse has been
adapted as the working IDE.

In order to run the code on a MSP430 MCU, a procedure of building the executable
code has been illustrated in the figure below:

a. Preprocessor
Preprocessor perform several operation to prepare the source code for compiler. Such
duties are macro processing, replacing define, function into the file that would be
b. Compiler
The msp430-elf-gcc is actually a compiler which is used to translate the high level
language to assembly language. In this case is from C to Assembly code. More
specifically, the msp430-elf-gcc is usually called cross compiler since it is not the
original GCC but the ported ones to work with MSP430 MCU.
c. Assembler
The assembler msp-430-elf-as is a utility from Binutils that converts the assembly
code from compiler to object code (eg. main.o) which represent the original C
program by binary (0s, 1s) that the MSP430 MCU could understand the instruction.
d. Linker
The linker is responsible for combining all object code into the single ones. TI has
provided the specific linker for each MSP430 MCU (eg. msp430g2553.ld).
e. Loader
The loader translates the absolute object code from linker to a suitable file
(eg. main.out) for flashing the code to the target system by mspdebug.


Step 1: Get the latest version of MSP43-GCC Linux Installer at http://tinyurl.com/prrm3rn

Step 2: Open the Terminal, change the directory to Download Directory, and execute the

cd Downloads
sudo chmod +x msp430-gcc*.run
sudo ./msp430-gcc*.run

Step 3: The Installer would appear and the Installation Directory should be /opt/ti/gcc

Step 4: Get the mspdebug

sudo apt-get install mspdebug

Step 5: Open Eclipse, create new C project. Choose Empty Project and Cross GCC then Next

Step 6: In Cross GCC Command section , set Cross Compiler Prefix and Cross Compiler Path
as shown in figure below

Step 7: Create new C source file by File New Source File. Enter the file name main.c

Step 8: Setting the toolchain by right click on project name (test_gcc) then choose Properties
On the Properties window, click on C/C++ BuildSetting. At Tool Setting tab, click on
Cross GCC Compiler, edit the Command as:
gcc -mmcu = msp430g2553

Step 9: In Cross GCC Compiler, come to Includes section then add the path to the header file

Step 9: On Cross GCC Linker, also edit the command:

Gcc -mmcu = msp430g2553

Step 10: Add path to linker directory in Cross GCC LinkerLibrariesLibraries Search Path

Step 11: Before click on Build Project, the project should be close then re-open The Console
should be the same in the figure

Step 12: GDP Debug: right click on:

Project Name Debug AsDebug ConfigurationGDP Hardware Debugging
On tab Debugger: Edit GDB Command: msp430-elf-gdb
Port Number: 2000

Step 13: Open terminal, move to the project directory. Run mspdebug and flash the program
Then start the GDB

mspdebug rf2500
prog test_gcc

Step 14: Back to Eclipse then click Debug. A Debug window should be appear with the C code
on the left and equivalent assembly code on the right.