Linux下使用Eclipse搭建ARM开发环境
系统:
新装 ubuntu 14.04.5 64bits
1.安装交叉编译环境
- 解压
tar xjf arm-linux-gcc-3.4.5-glibc-2.3.6.tar.bz2
- 添加环境变量
$ export PATH=$PATH:/work/tools/gcc-3.4.5-glibc-2.3.6/bin
- 检查是否成功
arm-linux-gcc -v
若提示无该命令,需安装 ia32-libs,因为系统为64位。
- 安装ia32-libs
sudo apt-get install ia32-libs
若提示无此安装包,需执行以下命令:
sudo apt-get install g++-multilib libncurses5:i386 libc6:i386 libgcc1:i386 gcc-4.6-base:i386 libstdc++5:i386 libstdc++6:i386
再次执行arm-linux-gcc -v,现在应该成功了。
注:需要更改源,提高下载速度。
方法:
sudo
cp
/etc/apt/sources
.list
/etc/apt/sources
.list.bak
#备份
sudo
vi
/etc/apt/sources
.list
#修改
sudo
apt-get update
#更新列表
deb http:
//mirrors
.aliyun.com
/ubuntu/
trusty main restricted universe multiverse
deb http:
//mirrors
.aliyun.com
/ubuntu/
trusty-security main restricted universe multiverse
deb http:
//mirrors
.aliyun.com
/ubuntu/
trusty-updates main restricted universe multiverse
deb http:
//mirrors
.aliyun.com
/ubuntu/
trusty-proposed main restricted universe multiverse
deb http:
//mirrors
.aliyun.com
/ubuntu/
trusty-backports main restricted universe multiverse
deb-src http:
//mirrors
.aliyun.com
/ubuntu/
trusty main restricted universe multiverse
deb-src http:
//mirrors
.aliyun.com
/ubuntu/
trusty-security main restricted universe multiverse
deb-src http:
//mirrors
.aliyun.com
/ubuntu/
trusty-updates main restricted universe multiverse
deb-src http:
//mirrors
.aliyun.com
/ubuntu/
trusty-proposed main restricted universe multiverse
deb-src http:
//mirrors
.aliyun.com
/ubuntu/
trusty-backports main restricted universe multiverse
2.安装Eclipse
- 安装java运行环境
将文件jdk-8u131-linux-x64.gz移动到/usr/java/下,解压压缩包:
tar xzf jdk-8u131-linux-x64.tar.gz
- 配置环境变量:
vi /etc/profile
编辑文件,在最后添加:
export JAVA_HOME=/usr/java/jdk1.8.0_131
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$JAVA_HOME/bin:$PATH
保存退出后,执行source /etc/profile使修改的环境变量生效
- 使用java -version命令测试是否成功
- 解压eclipse压缩包到/opt目录,并修改属性
sudo tar xzf eclipse-cpp-neon-3-linux-gtk-x86_64.tar.gz /opt
sudo chmod 775 eclipse -R
- 添加脚本文件eclipse 到/usr/bin目录,并增加可执行属性
eclipse文件内容
#!/bin/sh
export MOZILLA_FIVE_HOME="/usr/lib/mozilla/"
export ECLIPSE_HOME="/opt/eclipse"
$ECLIPSE_HOME/eclipse $*
修改文件属性:
sudo chmod 775 /usr/bin/eclipse
3.安装 OpenOCD、GDB、oflash
- 将 openocd.tar.bz2 解压到根目录,把 arm-linux-gdb、oflash 复制到/usr/bin 目录下,并设置为 root 用户、增加“可执行”属性。
sudo tar xjf /work/tools/openocd.tar.bz2 -C /
sudo cp /work/tools/arm-linux-gdb /usr/bin/
sudo cp /work/tools/oflash /usr/bin/
sudo chown root:root /usr/local/bin/openocd /usr/bin/arm-linux-gdb /usr/bin/oflash
sudo chmod +xs /usr/local/bin/openocd /usr/bin/arm-linux-gdb /usr/bin/oflash
注意:一定要给/usr/bin/arm-linux-gdb 加上可执行权限“x”,超级用户权限“s”