虚拟机arm虚拟环境搭建

【qemu】虚拟工具模拟A9开发板
1、sudo apt-get update
2、sudo apt-get install qemu qemu-system qemu-utils
3、qemu-system-arm --h //查看

【gcc】交叉编译器的安装(下载
1、gcc-4.6.4.tar.xz 放到 ubuntu的目录下 ~/work/fs4412/
2、cd ~/work/fs4412/
3、tar -xvf gcc-4.6.4.tar.xz
4、确认命令是否有: cd gcc-4.6.4/bin ls arm-none-linux-gnueabi-gcc
5、pwd 查看绝对路径 /home/work/fs4412/gcc-4.6.4/bin
6、vi ~/.bashrc
export PATH=/home/work/fs4412/gcc-4.6.4/bin:$PATH
7、把所有的终端窗口关闭,再新开就有了。
8、确认命令是否存在 arm-none-linux-gnueabi-gcc -V

【写代码】
新建一个目录:
mkdir /home/mydir/armcode
cd armcode

vim test.S

.global _start
_start:
mov r1, #3
nop

【程序编译】
arm-none-linux-gnueabi-gcc test.S -o test.o -c -g
arm-none-linux-gnueabi-ld -Ttext 0x00000000 test.o -o test.elf
//链接

【开启虚拟目标板】
在第一个终端执行下面命令:
qemu-system-arm -machine vexpress-a9 -m 256M -serial stdio -kernel test.elf -S -s

【调试端】
在另外一个终端 执行下面命令:
arm-none-linux-gnueabi-gdb test.elf
进入GDB后,执行
(gdb) target remote localhost:1234
(gdb) s
p $r1

命令解释:
s: 单步调试
b: 设置断点
c: 继续运行
p: 显示变量值
x: 显示内存值 如要显示内存地址0x10 开始的10块连续地址 x/10 0x10

发布了9 篇原创文章 · 获赞 2 · 访问量 8569

猜你喜欢

转载自blog.csdn.net/hhl_work/article/details/82530695
今日推荐