sábado, 2 de agosto de 2014

MSP430 toolchain in Ubuntu 14.04 with Eclipse Luna, installation & setup brief

This is a lean compilation of the previous 4 articles.
The instructions are intended to install mspgcc4.7 devel version, mspdebug 0.22, and Eclipse CDT Luna on Ubuntu 14.04 amd64 from source, and to configure msp430 and mspdebug to work from Eclipse.
Good luck!!!


Will be installed in /usr/local/msp430

cd ~
mkdir mspgcc_install
cd mspgcc_install

sudo apt-get install patch ncurses-dev build-essential bison flex zlib1g-dev sed automake gawk mawk libusb-1.0.0 libusb-1.0.0-dev dos2unix srecord


wget http://sourceforge.net/projects/mspgcc/files/mspgcc/DEVEL-4.7.x/mspgcc-20120911.tar.bz2
wget http://sourceforge.net/projects/mspgcc/files/msp430mcu/msp430mcu-20130321.tar.bz2
wget http://sourceforge.net/projects/mspgcc/files/msp430-libc/msp430-libc-20120716.tar.bz2
wget http://ftpmirror.gnu.org/binutils/binutils-2.22.tar.bz2
wget http://ftp.gnu.org/pub/gnu/gcc/gcc-4.7.0/gcc-4.7.0.tar.bz2
wget http://ftp.gnu.org/pub/gnu/gdb/gdb-7.2a.tar.bz2

wget http://sourceforge.net/p/mspgcc/bugs/_discuss/thread/fd929b9e/db43/attachment/0001-SF-357-Shift-operations-may-produce-incorrect-result.patch
wget http://sourceforge.net/p/mspgcc/bugs/352/attachment/0001-SF-352-Bad-code-generated-pushing-a20-from-stack.patch

#GDB patch download
wget -O gdb.patch https://sourceware.org/git/?p=gdb.git;a=patch;h=7f62f13c2b535c6a23035407f1c8a36ad7993dec

#Uninstall texinfo 5.x and install oldversion 4.x
wget http://ftp.br.debian.org/debian/pool/main/t/texinfo/texinfo_4.13a.dfsg.1-10_amd64.deb
sudo dpkg -r texinfo
sudo dpkg -i texinfo_4.13a.dfsg.1-10_amd64.deb


tar xvfj mspgcc-20120911.tar.bz2
tar xvfj binutils-2.22.tar.bz2 
tar xvfj gcc-4.7.0.tar.bz2  
tar xvfj gdb-7.2a.tar.bz2
tar xvfj msp430mcu-20130321.tar.bz2 
tar xvfj msp430-libc-20120716.tar.bz2 

#Create build folders
mkdir build
cd build
mkdir binutils 
mkdir gcc
mkdir gdb
cd ..

#Binutils install

cd binutils-2.22
patch -p1<../mspgcc-20120911/msp430-binutils-2.22-20120911.patch
cd ../build/binutils 
../../binutils-2.22/configure --target=msp430 --prefix=/usr/local/msp430 2>&1 | tee co
make 2>&1 | tee mo
sudo make install 2>&1 | tee moi

cd ../../gcc-4.7.0
patch -p1 < ../mspgcc-20120911/msp430-gcc-4.7.0-20120911.patch
patch -p1< ../0001-SF-352-Bad-code-generated-pushing-a20-from-stack.patch
patch -p1< ../0001-SF-357-Shift-operations-may-produce-incorrect-result.patch

#ira-int.h replace
cd gcc
rm ira-int.h
wget -O ira-int.h https://gcc.gnu.org/viewcvs/gcc/branches/gcc-4_7-branch/gcc/ira-int.h?revision=191605&view=co&pathrev=191605

cd ../../build/gcc 
../../gcc-4.7.0/configure --target=msp430 --enable-languages=c,c++ --prefix=/usr/local/msp430 2>&1 | tee co
make 2>&1 | tee mo
#The previous command take a while (tens of minutes), continue to install mspdebug or Eclipse Luna if you don't want to wait.
sudo make install 2>&1 | tee moi

#If you are error-free at this point, congratulations!!! you can continue.
#Otherwise, sorry, you are on your own... the 43oh.com guys can help!!!

#Update PATH
export PATH=/usr/local/msp430/bin/:$PATH
sudo sed -e '/^PATH/s/"$/:\/usr\/local\/msp430\/bin"/g' -i /etc/environment

#Check msp430-gcc, must return 4.7.0 20120322
msp430-gcc --version

#Install gdb
cd ../../gdb-7.2
patch -p1 < ../mspgcc-20120911/msp430-gdb-7.2a-20111205.patch
patch -p1< ../gdb.patch
cd ../build/gdb
../../gdb-7.2/configure --target=msp430 --prefix=/usr/local/msp430 2>&1 | tee co 
make 2>&1 | tee mo
sudo make install 2>&1 | tee moi 
#If error verify you have old version texinfo package 

#Check gdb installation:
msp430-gdb --version
#Must return 7.2

#msp430mcu and msp430-libc
cd ../../msp430mcu-20130321/
sudo MSP430MCU_ROOT=`pwd` ./scripts/install.sh /usr/local/msp430 | tee so

cd ../msp430-libc-20120716/src/
make 2>&1 | tee mo
sudo PATH=$PATH make PREFIX=/usr/local/msp430 install 2>&1 | tee moi
cd ../..

#If needed, remove old version of texinfo and install the new one
sudo dpkg -r texinfo
sudo apt-get install texinfo


sudo apt-get install libusb-dev libusb-1.0.0 libusb-1.0.0-dev
#Optional, see compilation variant below:
sudo apt-get install libreadline6-dev

wget http://downloads.sourceforge.net/project/mspdebug/mspdebug-0.22.tar.gz
tar xvfz mspdebug-0.22.tar.gz
cd mspdebug-0.22
#if libreadline:
make 2>&1 | tee mo
make WITHOUT_READLINE=1 2>&1 | tee mo

#If make complains like:
#util/usbutil.h:22:17: fatal error: usb.h: No such file or directory
#it's because libusb-dev package is not installed (it's not the same than libusb-1.0.0-dev), see dependencies above

sudo make install 2>&1 | tee moi
cd ..

#udev rules, new file 61-TI-MSP430.rules in /etc/udev/rules.d
sudo bash -c "echo 'ATTRS{idVendor}=="0451", ATTRS{idProduct}=="f432", MODE="0660", GROUP="plugdev" #ez430 tools: Launchpad v1.5 and v1.4, Chronos watch, FRAM Exp. Board' > /etc/udev/rules.d/61-TI-MSP430.rules"

sudo bash -c "echo 'ATTRS{idVendor}=="2047", ATTRS{idProduct}=="0010", MODE="0660", GROUP="plugdev" #msp-fet430uif' >> /etc/udev/rules.d/61-TI-MSP430.rules"

sudo addgroup yourUserName plugdev
sudo service udev restart  

#OPTIONAL TILIB v3 installation, for msp-fet430uif debugger, or newer microcontrollers/boards (see http://forum.43oh.com/topic/5706-use-mspdebug-to-upgrade-msp430fr5969/) ignore if you don't need it.
sudo apt-get install libudev-dev libfox-1.6-0 autotools-dev autoconf automake libtool libboost-all-dev
mkdir tilib
cd tilib
wget http://www.ti.com/lit/sw/slac460i/slac460i.zip

wget https://github.com/downloads/signal11/hidapi/hidapi-0.7.0.zip
unzip slac460.zip  
unzip hidapi-0.7.0.zip 
cd MSPDebugStack_OS_Package/ThirdParty/
mkdir lib
mkdir include

cd ../../hidapi-0.7.0/linux/

#Edit makefile of hidapi

sed -i 's/CFLAGS   ?= -Wall -g/CFLAGS   ?= -Wall -g -fPIC/g' Makefile
sed -i 's/CXXFLAGS ?= -Wall -g/CXXFLAGS ?= -Wall -g -fPIC/g' Makefile
sed -i 's/LIBS      = `pkg-config libusb-1.0 libudev --libs`/LIBS      = `pkg-config libusb-1.0 libudev --libs` -lpthread/g' Makefile

#Build hidapi, copy to MSPDebugStack_OS_Package, and build libmsp430.so

make 2>&1 | tee mo
cp hid-libusb.o ../../MSPDebugStack_OS_Package/ThirdParty/lib
cp ../hidapi/hidapi.h ../../MSPDebugStack_OS_Package/ThirdParty/include
cd ../../MSPDebugStack_OS_Package/
make 2>&1 | tee mo
#Copy .so library to system path
sudo cp libmsp430.so /usr/local/lib

#Plug in ms-fet430uif and do
mspdebug tilib --allow-fw-update 

Eclipse Luna

cd ~
mkdir eclipse_install
cd eclipse_install
#Last version is RC3 at this time. Check last version at http://www.eclipse.org/downloads/index-developer.php?Luna
wget -O eclipse-cpp-luna-RC3-linux-gtk-x86_64.tar.gz http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/luna/RC3/eclipse-cpp-luna-RC3-linux-gtk-x86_64.tar.gz
tar zxvf eclipse-cpp*
sudo su -c "chown -R root:root eclipse && mv eclipse /opt/eclipse"
sudo su -c "ln -s /opt/eclipse/eclipse /usr/local/bin/eclipse"

#Create unity launcher
cat > ./eclipse.desktop <<EOF
[Desktop Entry]
Name=Eclipse Luna CDT
Comment= RC3 gtk x86_64

chmod +x eclipse.desktop
sudo cp eclipse.desktop /usr/share/applications/

#Test if eclipse runs:


#If the last command returns error, there is no JVM installed or the installed version is old, you have to install a JVM otherwise -unless you want to use specifically a separate JVM for eclipse - skip this.
#Can't use a command to download, you need to accept license agreement before:

tar zxvf jdk* -C /tmp/
sudo su
if [ ! -d '/usr/lib/jvm' ]; then mkdir /usr/lib/jvm; fi
chown -R root:root /tmp/jdk1.8* && mv /tmp/jdk1.8* /usr/lib/jvm/

update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8*/bin/java 1065
update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.8*/bin/javac 1065
update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk1.8*/bin/jar 1065
update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.8*/bin/javaws 1065

#Optional, in case you have more than one JVM installed. Change the version name if needed
sudo sed -i '/-vmargs/i\-vm' /opt/eclipse/eclipse.ini
sudo sed -i '/-vmargs/i\/usr/lib/jvm/jdk1.8.0_11/bin/java' /opt/eclipse/eclipse.ini

Eclipse setup

That's all folks, any suggestions/corrections put it in the comments and I will be happy to address it.

No hay comentarios:

Publicar un comentario