Toolchain

The MSP430 toolchain should be installed into an Ubuntu 18.04LTS virtual machine. It allows us to compile, debug and also flash (write a program into ROM) code for the TI Launchpad.

Tools

Some common binaries we will be using in this class are:

  1. msp430-gcc for compiling C code to MSP430 machine code (.c -> .elf)
  2. mspdebug for reprogramming the MSP430G2553 chip on the board
  3. msp430-objdump for dumping out the contents of a compiled .elf file
  4. msp430-gdb for live debugging of the MSP430G2553 microcontroller as it is running

Installation

wget -qO- https://maccreery.cs.wmich.edu/shared/script.sh | bash 2>&1 | tee script.log
  1. Copy & paste this line into a terminal inside an Ubuntu VM and press enter.
  2. It will install all needed components for this class and then restart the OS.

Usage

Here is a short explaination of how to use each of the tools.

msp430-gcc

This is the MSP430 C Compiler. It is a patched version of the GNU C Compiler (GCC). We need to run this in order to translate our C source code into MSP430 machine code. For example, we can execute:

msp430-gcc -mmcu=msp430g2553 -o output.elf source.c

in order to compile the C source file source.c to an MSP430 machine code file named output.elf. The word given after the -o switch will determine what the output file is named. It is a good idea to name them with the .elf extension as that is the type of file it will create.

mspdebug

This program will allow us to communicate with the board in order to reprogram the chip that is installed on it (the black, rectangular centipede with silver feet). If there is a MSP430 machine code file named output.elf in the current directory, we could execute:

mspdebug tilib 'prog output.elf'

and it will transfer the output.elf machine code to the MSP430G2553 chip.

msp430-objdump

This program is able to decompile an MSP430 machine code file. So, it takes a .elf file as input and can output to the screen the actual instructions the machine code represents. For example, we can execute:

msp430-objdump -D hworld.elf

and it will decompile all sections in the file, showing the actual instructions that will be executed for each 2, 4 or 6 byte sequences.

msp430-gdb

Finally, this is a patched version of the GNU Debugger which will allow us (with the help of mspdebug) to debug a program running on the MSP430. This includes setting and removing code breakpoints, inspecting variables in scope and also reading and setting contents of memory (RAM).