您的位置:首页 > 其它

ubuntu下使用qemu模拟ARM(五)-------应用程序Hello World

2017-01-23 23:12 489 查看
在前面四章建立好的开发环境基础上我们来写一个应用程序,然后将它在Qemu模拟出来的ARM开发板中运行

首先写程序

#include <stdio.h>

int main()

{
printf("hello linux world!!!");
return 0;

}

编译程序

 arm-none-linux-gnueabi-gcc hello.c -o hello

将程序拷到rootfs目录下,然后执行如下:

sudo mount -t ext3 a9rootfs.ext3 tmpfs/ -o loop

sudo cp -r rootfs/* tmpfs/

sudo umount tmpfs

用Qemu测试

qemu-system-arm -M vexpress-a9 -m 512M -kernel /qemu_arm/linux-kernel/linux-3.16.39/arch/arm/boot/zImage -nographic -append "root=/dev/mmcblk0  console=ttyAMA0" -sd /qemu_arm/root_system/a9rootfs.ext3

在启动完成后的提示符下输入 /hello显示结果如下:

input: ImExPS/2 Generic Explorer Mouse as /devices/mb:kmi1/serio1/input/input2

kjournald starting.  Commit interval 5 seconds

EXT3-fs (mmcblk0): mounted filesystem with writeback data mode

VFS: Mounted root (ext3 filesystem) readonly on device 179:0.

Freeing unused kernel memory: 244K (805d6000 - 80613000)

random: nonblocking pool is initialized

mount: mounting proc on /proc failed: No such file or directory

Processing /etc/profile... Done

/ # /hello

hello linux world!!!/ # 

可见程序已经运行起来了,并且输出了文字.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: