背景
遇到的问题
最近在做关于Contiki操作系统在TelosB节点上的一些实验,但是在编译一些Contiki样例的时候遇到了".text"和".rodata"段出现重合无法成功编译的情况,查阅资料显示需要更新Instant Contiki中自带的msp430-gcc来解决这个问题。
本文将我的操作过程做一个记录,希望对读者有所帮助。
硬软件环境
Instant Contiki3.0(Ubuntu 14.04LTS)
1. 安装编译安装必需的应用
sudo apt-get install patch ncurses-dev build-essential bison flex libgmp3-dev libmpfr-dev libmpc-dev texinfo zlib1g-dev
外网上也有不少关于重新编译msp430-gcc的教程,但是他们的要求都是TEXINFO版本<5,但是上一步直接安装的texinfo的版本>5,需要卸载后从源码安装其4.xx版本:
TEXINFO
Remove Latest TEXINFO package using Synaptics.
ubuntu应该直接用apt卸载即可
从源码安装TEXINFO-4.13
wget http://ftp.gnu.org/gnu/texinfo/texinfo-4.13.tar.gz
解压源码:
gzip -dc < texinfo-4.13.tar.gz | tar -xf -
cd texinfo-4.13
Configure, build and install:
./configure
make
sudo make install
删除旧版msp430-gcc
仍然是使用apt卸载,不再赘述
编译安装新版msp430-gcc
准备工作
INSTALL_PREFIX="${HOME}/mspgcc-4.7.2"
echo The installatoin prefix:$INSTALL_PREFIX
创建放置源码的文件夹
# Switch to the tmp directory
mkdir tmp
cd tmp
下载所需源码
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-20120716.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://mirror.ibcp.fr/pub/gnu/gcc/gcc-4.7.2/gcc-4.7.2.tar.bz2
wget http://sourceforge.net/p/mspgcc/bugs/352/attachment/0001-SF-352-Bad-code-generated-pushing-a20-from-stack.patch
wget http://sourceforge.net/p/mspgcc/bugs/_discuss/thread/fd929b9e/db43/attachment/0001-SF-357-Shift-operations-may-produce-incorrect-result.patch
# Unpacking the tars
tar xvfj binutils-2.22.tar.bz2
tar xvfj gcc-4.7.2.tar.bz2
tar xvfj mspgcc-20120911.tar.bz2
tar xvfj msp430mcu-20120716.tar.bz2
tar xvfj msp430-libc-20120716.tar.bz2
将msp430相关的patch合并到binutils和gcc中,编译并安装
# 1) Incorporating the changes contained in the patch delievered in mspgcc-20120911
cd binutils-2.22
patch -p1<../mspgcc-20120911/msp430-binutils-2.22-20120911.patch
cd ..
# 2) Incorporating the changes contained in the patch delievered in mspgcc-20120911
cd gcc-4.7.2
patch --force -p1<../mspgcc-20120911/msp430-gcc-4.7.0-20120911.patch
patch --force -p1<../0001-SF-352-Bad-code-generated-pushing-a20-from-stack.patch
patch --force -p1<../0001-SF-357-Shift-operations-may-produce-incorrect-result.patch
cd ..
# 3) Creating new directories
mkdir binutils-2.22-msp430
mkdir gcc-4.7.2-msp430
安装patch过的binutil
# 4) installing binutils in INSTALL_PREFIX
cd binutils-2.22-msp430/
../binutils-2.22/configure --target=msp430 --program-prefix="msp430-" --prefix=$INSTALL_PREFIX
make
make install
安装patch过的gcc
# 5) Download the prerequisites
cd ../gcc-4.7.2
./contrib/download_prerequisites
# 6) compiling gcc-4.7.0 in INSTALL_PREFIX
cd ../gcc-4.7.2-msp430
../gcc-4.7.2/configure --target=msp430 --enable-languages=c --program-prefix="msp430-" --prefix=$INSTALL_PREFIX
make
make install
编译和安装msp430所需的硬件描述文件与库文件
# 7) compiping msp430mcu in INSTALL_PREFIX
cd ../msp430mcu-20120716
MSP430MCU_ROOT=`pwd` ./scripts/install.sh ${INSTALL_PREFIX}/
# 8) compiling the msp430 lib in INSTALL_PREFIX
cd ../msp430-libc-20120716
cd src
PATH=${INSTALL_PREFIX}/bin:$PATH
make
make PREFIX=$INSTALL_PREFIX install
检查是否安装完毕
使用命令查看msp430-gcc的版本,如果是4.7.2则完成
msp430-gcc --version
references
Blog1
Blog2
Github1
上一篇:MSP430的BSL下载经验
下一篇:初学MSP430F5529时钟以及FLL配置