The easiest way to run mspgcc in ubuntu is to install it by typing:
sudo apt-get install gcc-msp430
That will install a sensible toolchain for msp430-gcc. If for any reason you need to build the toolchain by yourself, then this script will help you accomplish this.
This repo has a script to install mspgcc uniarch (C compiler for msp430 microcontrollers) in Ubuntu, along with some utilities for it. It installs the LTS (Long Term Support) version of the compiler, which is the most up-to-date version. Currently, this is LTS 20120406. Update: There are special branches for different mspgcc flavors:
- The 'master' branch was tested with Ubuntu 14.04, using gcc 4.8.2.
- Branch '20120911' contains a script to install the 20-bit development compiler, based on gcc 4.7.
- Branch 'redhat' builds the RedHat version of mspgcc.
Checkout those branches for specific instructions:
git checkout 'branchname'
Use commit 6df3dabca
: git checkout 6df3dabca
.
Use master branch
Install and use gcc-4.7:
sudo apt-get install gcc-4.7
sudo update-alternatives --install /usr/bin/gcc-4.7 50
sudo update-alternatives --set gcc /usr/bin/gcc-4.7
Remember to switch back to your previous version of gcc after running this script.
To build mspgcc you will need to install at least the following packages:
sudo apt-get install patch ncurses-dev build-essential bison flex libgmp3-dev libmpfr-dev libmpc-dev texinfo zlib1g-dev libusb-dev libreadline6-dev libz-dev
The installation folder is /usr/local/msp430
(modifiable in the script). If you already have contents in this folder I recommend you to move it to a backup folder, i.e.:
sudo mv /usr/local/msp430 /usr/local/msp430-backup
To install go to the console and run:
git clone https://github.com/jlhonora/mspgcc-install.git
cd mspgcc-install
./install-all
You should be careful to watch for error messages.
If everything goes well, I recommend you to add the msp430-gcc path to your environment path. For that, append the following line to your .bashrc
:
export PATH=/usr/local/msp430/bin:/usr/local/msp430/lib:/usr/local/msp430/include:$PATH
Also paste it in the command line to use the modified $PATH right away.
To check that everything is ok, type:
cd tests
msp430-gcc -mmcu=msp430g2553 hello_world.c
The mmcu option should match the microcontroller you will be using.
The previous command should generate a compiled file named a.out
, ready to install in the microcontroller. If you have a MSP430 Launchpad Board at reach you can install the compiled file with mspdebug. It can be installed with the install-mspdebug
script ($ ./install-mspdebug
) or by running the following commands:
sudo apt-get install libusb-dev libreadline6-dev
./install_mspdebug
Update: If you're using Ubuntu 13.04 I strongly recommend installing mspdebug via the install-mspdebug
script, since there's a modification that should be made to the source for it to compile successfully.
USB permissions should be added to the FET interface of the Launchpad (source). As root, create the file /etc/udev/rules.d/71-persistent-msp430.rules
and add AATR{idVendor}=="0451", ATTRS{idProduct}=="f432", MODE="0660", GROUP="plugdev"
. Then run
sudo addgroup YOUR_USERNAME plugdev
sudo restart udev
If everything goes well, you can install the compiled program:
sudo mspdebug rf2500 "prog a.out"
This should also work with the MSP-EXP430F5529 board, but changing the compile options to -mmcu=msp430f5529
.
To install the development version of the compiler, do:
git checkout 20120911
And then follow the instructions above.
- This guide is loosely based on Sergio Campama's guide and the README files of mspgcc.
- Gunnar Henne