Skip to content

msp430 elf

Anonymous1157 edited this page Jun 20, 2017 · 1 revision

Cross-compiling to the Texas Instruments MSP430 microcontrollers is easily done with a GNU toolchain and a text editor of your choice rather than their closed-source CCS IDE. This target uses Newlib, so the build process for the toolchain is relatively idiot-proof!

Create a combined build tree. The order in which the trees are combined is important!

mkdir combined
cd combined
ln -sf path/to/newlib-cygwin/* .
ln -sf path/to/gdb-7.12.1/* .
ln -sf path/to/binutils-2.28/* .
ln -sf path/to/gcc-6.3.0/* .
cd ..

Create a build directory and configure the toolchain. GCC 6.3.0 needs some patching for libstdc++-v3 to compile for this target and I haven't taken the time to find and backport a fix from one of a few places they may be, so we only build the C compiler for now.

mkdir combined-build
cd combined-build
../combined/configure \
	--prefix=$HOME/.local/share/cross \
	--target=msp430-elf \
	--with-system-zlib \
	--with-system-readline \
	--with-gmp=$HOME/.local/share/cross \
	--with-mpc=$HOME/.local/share/cross \
	--with-mpfr=$HOME/.local/share/cross \
	--with-isl=SHOME/.local/share/cross \
	--disable-libssp \
	--with-newlib \
	--enable-languages=c \
	--enable-version-specific-runtime-libs \
	--enable-host-shared \
	--enable-shared \
	--with-{stage1,boot}-ldflags="-Wl,-rpath=$HOME/.local/share/cross/lib"
cd ..

Build and install the whole toolchain.

cd combined-build
make -j8
make install
cd ..

Install headers and linker scripts for the supported MSP430 targets.

cd msp430-gcc-support-files

for i in include/*.ld
do
	install -m644 $i $HOME/.local/share/cross/msp430-elf/lib/
done

for i in include/*.h
do
	install -m644 $i $HOME/.local/share/cross/msp430-elf/include/
done
cd ..

Build and install mspdebug, an application that can program and debug MSP430 targets connected to a couple of different programmers.

cd mspdebug
make clean
make PREFIX=$HOME/.local/share/cross
make PREFIX=$HOME/.local/share/cross install
cd ..

That's it! You should have a working msp430-elf toolchain and programmer now. Check out my other repositories for sample applications you can try compiling, or look around on the Internet for a tutorial to make the LEDs on the MSP430 Launchpad blink.

Clone this wiki locally