Monday, July 9, 2012

Update  30th March 2014:  
This guide is not longer valid as a better alternative is available and the current CVS MSPGCC does not compile as per the below technique any more

You might be aware of our transition to linux, we pledge to provide support and tutorial to help more people to migrate to Linux. The first thing that scares away many electronics enthusiast is the non-availability of tools. However, that's only a myth created by novices. In this article we would like to summarize our resent adventure with 'compiling the compiler' on our favourite microcontroller MSP430 from Texas Instruments(r). Although the process is detailed in the MSP430GCC wiki still we thought it would be worthwhile to demonstrate it step by step, explaining the ways to get it dome faster.

[1] Preparation
First of all we need to prepare the linux machine for the compilation. We used  Ubuntu 11.04 Linux based machine. Here are the packages that you need to install:
  • GCC System
    • gcc-4.x (>=4.4.6) :- we used the one available from the Ubuntu software distribution
    • make (>=3.81-8.1)
    • gcc-4.x-base (>=4.6)
    • g++ (>=4.6) :- if needed to support the C++ compiler (recommended)
  • Auto Make bindings
    • sed (>=4.2.1-9)
    • bison (>=1:2.4.1)
    • automake (>=1.11.1)
    • gawk (>=3.1.8)
    • mawk (>=3.1.8)
  • For Debugger(mspdebug)
    • libusb-1.0.0
    • libusb-1.0.0-dev
  • Lib dependency
    • libreadline6-dev
  • Generic
    • bzip2
To install these packages we can use 'apt get' or software center or synaptic package manager. For Ubuntu the software repository already offers all the above packages.

[2] Downloads
Now we need to get the per-requisites for the compiler packages and the msp-gcc patches. These need to be downloaded into a specific directory say '~/Downloads/MSP430' where '~' means home directory of the user. We would also specify if you prefer to have the LTS release files or just have whatever is updated one.
Once you all these files then you are ready to go on with the next step.
Note: If you go for the '.bz2' files they are smaller than '.gz' files.

[3] Arranging the Files
We need to make sure the files have been extracted and placed in the correct locations to begin the compilation.
We assume that you have kept all these files at a common location
.e.g. 'msp430-build' We would first look at the Latest version compile. The LTS version can also be compiled in the similar manner. So here is the 'msp430-build' directory:
binutils-2.22.tar.gz                 msp430-gdb-7.2a-20111205.patch
gcc-4.7.0.tar.gz                     msp430-libc-20120425.tar.bz2
gdb-7.2a.tar.gz                      msp430mcu-20120425.tar.bz2
msp430-binutils-2.22-20120407.patch  mspdebug-0.19.tar.gz
Now you need to extract all the files:
tar -xvf binutils-2.22.tar.gz
tar -xvf gcc-4.7.0.tar.gz
tar -xvf gdb-7.2a.tar.gz
tar -xvjf msp430-libc-20120425.tar.bz2
tar -xvjf msp430mcu-20120425.tar.bz2
tar -xvf mspdebug-0.19.tar.gz
After this lets create the Build Directory structure since you would need it for running the custom builds:
mkdir binutils-2.22-msp430
mkdir gcc-4.7.0-msp430
mkdir gdb-7.2-msp430

[4] Apply the PATCH and Special Settings
In order to build the compiler toolchain we need to add the PATCH supplied.
cd binutils-2.22
patch -p1<../msp430-binutils-2.22-20120407.patch
cd ..
cd gdb-7.2
patch -p1<../msp430-gdb-7.2a-20111205.patch
cd ..
Before we Apply the Patch to GCC we need to make sure that the dependencies are taken care of.
cd gcc-4.7.0
cd ..
This will download the dependencies that are needed by the GCC.
Now after the downloading is complete, PATCH the file(Assuming you are in.
cd gcc-4.7.0
patch -p1<../msp430-gcc-4.7.0-20120425.patch
cd ..
Now we need to setup the Install location so that the build works accordingly:
mkdir -p ~/local/msp430
export PREFIX="$HOME/local/msp430/"
We would like to install into '<HOME DIR>/local/msp430'

[5] Build the Toolchain And Install  
(Long Step so be ready to spend some time)
cd binutils-2.22-msp430
../binutils-2.22/configure --prefix=$PREFIX --target=msp430 --program-prefix="msp430-"
make install
cd ..
cd gcc-4.7.0-msp430
../gcc-4.7.0/configure --prefix=$PREFIX --target=msp430 --enable-languages=c,c++ --program-prefix="msp430-"
make install
cd ..
cd gdb-7.2-msp430
../gdb-7.2/configure --prefix=$PREFIX --target=msp430 --program-prefix="msp430-"
make install
cd ..
Now the Toolchain is ready to do the basics.
First We need to Install the MCU files:
cd msp430mcu-20120425
export MSP430MCU_ROOT=`pwd`
./scripts/ $PREFIX
cd ..
Now we need to compile and install the libc module(You will also come to know if the mspgcc installation really worked or not here).
cd msp430-libc-20120425/src
make PREFIX=$HOME/local/msp430 install
cd ../..

[6] Building the mspdebug
cd mspdebug-0.19
make install
Now  mspdebug is ready

Finally you need to insert the PATH variable so that the msp430gcc install works all times.
echo 'PATH=$PATH:$HOME/local/msp430/bin' >> .bashrc

Let us know your tryst with 'compiling the compiler' for MSP430 or if you are having any troubles with the compilation.
We are also trying to develop a script that can automatically download the required packages and then do the compile for you. This make it like the 'setup' wizards from the windows times.

Welcome to Boseji's Blog

Popular Post

Blogger templates


Creation by Electronics Hobbyists from Bharat(India) to encourage & help people. This blog hosts the numerous innovations, discoveries and projects we provide.
Our Research Wing Adhar Labs
Contact Form | Email Address
We Support Open Source Hardware Definition v1.0
Creative Commons License
All works on this blog are licensed under a
Creative Commons Attribution-ShareAlike 3.0 Unported License.
Based on a work at and

Permissions beyond the scope of this license may be available at
Thank you for all your support.

© A.D.H.A.R Labs Research 2008-2013 . Powered by Blogger.

Follow by Email


PCB Unit Converter


- Copyright © Electronics for Bharat -Robotic Notes- Powered by Blogger - Designed by Johanes Djogan -