Escolar Documentos
Profissional Documentos
Cultura Documentos
Toan Nguyen
School of Electrical Engineering
Hochiminh International University
I. INTRODUCTION
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.
GCC
Binutils
Newlib
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
GDB
is executing
mspdebug
2. BUILDING PROCEDURE
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
compiled
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 2: Open the Terminal, change the directory to Download Directory, and execute the
Installer
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 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 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 13: Open terminal, move to the project directory. Run mspdebug and flash the program
Then start the GDB
mspdebug rf2500
prog test_gcc
gdb
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.