一、安装交叉编译器

1、从网上下载arm-linux-gcc-4.4.3.tar.gz,解压到自己的目录下,我的目录结构/home/cyh/cyh/arm

2、建立目录

sudo mkdir /usr/local/arm

3、复制文件

sudo cp -r /home/cyh/cyh/arm/opt/FriendlyARM/toolschain/4.4.3 /usr/local/arm

4、添加环境变量
修改/etc/environment文件

sudo gedit /etc/environment

将原文件的PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games“
修改为PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/arm/4.4.3/bin”

5、重新启动电脑

6、检查路径是否添加到PATH中

echo $PATH
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/arm/4.4.3/bin

7、测试是否安装成功
在终端中输入arm-linux-gcc -v,如果出现以下内容证明交叉编译器安装成功。

Using built-in specs.
Target: arm-none-linux-gnueabi
Configured with: /opt/FriendlyARM/mini2440/build-toolschain/working/src/gcc-4.4.3/configure --build=i386-build_redhat-linux-gnu --host=i386-build_redhat-linux-gnu --target=arm-none-linux-gnueabi --prefix=/opt/FriendlyARM/toolschain/4.4.3 --with-sysroot=/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root --enable-languages=c,c++ --disable-multilib --with-arch=armv4t --with-cpu=arm920t --with-tune=arm920t --with-float=soft --with-pkgversion=ctng-1.6.1 --disable-sjlj-exceptions --enable-__cxa_atexit --with-gmp=/opt/FriendlyARM/toolschain/4.4.3 --with-mpfr=/opt/FriendlyARM/toolschain/4.4.3 --with-ppl=/opt/FriendlyARM/toolschain/4.4.3 --with-cloog=/opt/FriendlyARM/toolschain/4.4.3 --with-mpc=/opt/FriendlyARM/toolschain/4.4.3 --with-local-prefix=/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-c99 --enable-long-long --enable-target-optspace
Thread model: posix
gcc version 4.4.3 (ctng-1.6.1) 

二、编写自己的程序进行测试

1、在/home/cyh/cyh/arm这个目录下写自己的测试程序hello.c

#include<stdio.h>
int main(){printf("hello world!\nI am Fern.\n");return 0;
}

2、编译hello.c文件

arm-linux-gcc hello.c -o hello

如果出现以下的错误,说明本机是64位的,arm交叉编译环境是32位的,需要安装32位的兼容库。

error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

执行下面的命令:

apt-get install lib32ncurses5 ia32-libs

重新编译即可编译成功。

三、使用arm交叉编译器编译c文件并放入gem5中执行

1、建立自己的目录结构/home/cyh/cyh/gem5/gem5-stable/test

2、将上述编译过的hello文件拷贝到/home/cyh/cyh/gem5/gem5-stable/test这个目录下

3、在终端输入命令,运行hello程序

./build/ARM/gem5.opt ./configs/example/se.py -c test/hello

如果出现以下的错误,说明上述编译hello.c文件需要静态编译

gem5 Simulator System.  http://gem5.org
gem5 is copyrighted software; use the --copyright option for details.
gem5 compiled Dec 21 2016 17:39:13
gem5 started Dec 22 2016 09:48:24
gem5 executing on cyh-Lenovo
command line: ./build/ARM/gem5.opt ./configs/example/se.py -c test/hello
Global frequency set at 1000000000000 ticks per second
fatal: Object file is a dynamic executable however only static executables are supported!Please recompile your executable as a static binary and try again.@ cycle 0
[create:build/ARM/sim/process.cc, line 619]
Memory Usage: 635576 KBytes

4、重新编译hello.c文件

arm-linux-gcc hello.c -o hello -static

将hello替换原来/home/cyh/cyh/gem5/gem5-stable/test目录下的hello文件,在目录/home/cyh/cyh/gem5/gem5-stable下重新运行命令:./build/ARM/gem5.opt ./configs/example/se.py -c test/hello

5、运行结果:

cyh@cyh-Lenovo:~/cyh/gem5/gem5-stable$ ./build/ARM/gem5.opt ./configs/example/se.py -c test/hello
gem5 Simulator System.  http://gem5.org
gem5 is copyrighted software; use the --copyright option for details.
gem5 compiled Dec 21 2016 17:39:13
gem5 started Dec 22 2016 10:20:47
gem5 executing on cyh-Lenovo
command line: ./build/ARM/gem5.opt ./configs/example/se.py -c test/hello
Global frequency set at 1000000000000 ticks per second
0: system.remote_gdb.listener: listening for remote gdb #0 on port 7000
**** REAL SIMULATION ****
info: Entering event queue @ 0.  Starting simulation...
hello world!
I am Fern.
hack: be nice to actually delete the event here
Exiting @ tick 3318500 because target called exit()

至此,使用arm交叉编译器编译的程序可以在gem5中执行。

注意
1、这里gem5的编译应为:scons build/ARM/gem5.opt
2、ARM: gem5 can model up to 64 (heterogeneous) cores of a Realview ARM platform, and boot unmodified Linux and Android with a combination of in-order and out-of-order CPUs. The ARM implementation supports 32 or 64-bit kernels and applications.
3、x86: The gem5 simulator supports a standard PC platform.

Gem5的基础知识(2)相关推荐

  1. 嵌入式Linux的OTA更新,基础知识和实现

    嵌入式Linux的OTA更新,基础知识和实现 OTA updates for Embedded Linux, Fundamentals and implementation 更新的需要 一旦嵌入式Li ...

  2. 计算机基础知识第十讲,计算机文化基础(第十讲)学习笔记

    计算机文化基础(第十讲)学习笔记 采样和量化PictureElement Pixel(像素)(链接: 采样的实质就是要用多少点(这个点我们叫像素)来描述一张图像,比如,一幅420x570的图像,就表示 ...

  3. 嵌入式linux编程,嵌入式Linux学习笔记 - 嵌入式Linux基础知识和开发环境的构建_Linux编程_Linux公社-Linux系统门户网站...

    注:所有内容基于友善之臂Mini2440开发板 一.嵌入式Linux开发环境的构建 嵌入式开发一般分为三个步骤: 1.编译bootloader,烧到开发板 2.编译嵌入式Linux内核,烧到开发板 3 ...

  4. 《计算机网络应用基础》模拟试卷(六),《计算机与网络应用基础知识1》模拟试卷...

    <计算机与网络应用基础知识1>模拟试卷 (4页) 本资源提供全文预览,点击全文预览即可全文预览,如果喜欢文档就下载吧,查找使用更方便哦! 9.9 积分 <计算机与网络应用基础知识1& ...

  5. python向量计算库教程_NumPy库入门教程:基础知识总结

    原标题:NumPy库入门教程:基础知识总结 视学算法 | 作者 知乎专栏 | 来源 numpy可以说是 Python运用于人工智能和科学计算的一个重要基础,近段时间恰好学习了numpy,pandas, ...

  6. python常用变量名_python基础知识整理

    Python Python开发 Python语言 python基础知识整理 序言:本文简单介绍python基础知识的一些重要知识点,用于总结复习,每个知识点的具体用法会在后面的博客中一一补充程序: 一 ...

  7. 计算机基础知识掌握欠缺,《计算机基础知识》实验教学改革探讨.pdf

    <计算机基础知识>实验教学改革探讨.pdf Science& TechnologyVision 科 技 视 界 科技 探·索·争鸣 计<算机基础知识>实验教学改革探讨 ...

  8. python计算wav的语谱图_Python实现电脑录音(含音频基础知识讲解)

    前言 今天开始进入近期系列文章的第一篇,如何用 Python 来实现录音功能. 在开始"造轮子"之前,个人一直强调一个观点,如果有些东西已经有了,不妨直接去 github 上搜,用 ...

  9. 计算机wrod初级考试题及答案,计算机基础知识+Word基础知识+Excel基础知识试题答案解析.doc...

    文档介绍: 计算机基础知识+ Word基础知识+ Excel基础知识 第一部分 一.单项选择题 1.世界上第一台电子数字计算机取名为(    ). A.UNIVAC    B.EDSAC    C.E ...

最新文章

  1. 一个弹出式menu的制作
  2. 通过IEnumerable和IDisposable实现可暂停和取消的任务队列
  3. 『Python』python 弹窗、提示和警告框MessageBox部件
  4. 利用锁分析器进行线程竞争检测
  5. oracle中的sysdba角色,oracle 以sysdba角色 登陆用户
  6. Netty+SpringBoot+FastDFS+Html5实现聊天App详解(四)
  7. Jboss项目部署出现java.lang.UnsupportedClassVersionError 问题的解决方法
  8. JAVA加密C++解密简单方法
  9. HTTP headers 详解 headers 常用属性
  10. 怎样设置台式计算机无线上网,设置无线网络
  11. 【安全系列】beef-xss攻击示例
  12. C语言程序设计笔记(浙大翁恺版) 第二周:计算
  13. AD603+MCP4725+STM32-----自动增益控制电路
  14. 鸿蒙系统概述(HarmonyOS)学习这一篇就够了!
  15. 域名CNAME记录不能同时适配根域名和www的解决方法
  16. DDL和DML的含义与区别
  17. display和visibility的区别
  18. 测试RADIUS服务器
  19. 【赠书】曾因「抢车位」出圈儿,神奇的Mask R-CNN了解一下?
  20. 弹力球C语言课程设计,弹力球游戏c语言代码.docx

热门文章

  1. 如何提高存货周转率?存货周转率真的越高越好吗?
  2. Docker容器修改hosts文件重启不变
  3. TortoiseGit三板斧维护Gitee
  4. 蓝桥杯 提高题 Minesweeper
  5. 基于JAVA Web的航空订票系统
  6. 【转】Excel中的Vlookup等函数用法
  7. 流媒体技术服务器常用部署方式
  8. MapInfo版本选择与使用
  9. iPad Air越狱白苹果怎么办?越狱白苹果修复教程
  10. 一键提取,将视频中的音频提取