arm系统启动后运行 helloworld ("hello world" 被封装为ramdisk)

----------------------------------------
arm系统启动后运行 helloworld
----------------------------------------
编译环境:arm交叉环境:

1. 交叉编译linux 内核。 注意make 时, ARCH=arm

   交叉编译前缀为 CROSS_COMPILE=arm-none-linux-gnueabi-

   建议直接修改Makefile, 修改ARCH, CROSS_COMPILE 变量为:

  ARCH        ?= arm
CROSS_COMPILE   ?= arm-none-linux-gnueabi-


 make defconfig 或者 make versatile_defconfig

 此时make 会生成 arch/arm/boot/zImage, 但这个内核文件运行时会出问题:

:Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000004


解决办法:重新配置内核支持EABI

make clean

make menuconfigKernel Features  --->
     [*] Use the ARM EABI to compile the kernel
     [*]   Allow old ABI binaries to run with this kernel (EXPERIMENTAL)

为什么出现这个问题没有深究,也许是qemu或者代码本身问题,这样解决也就可以了。



2. 编译一个arm 执行程序hello
    参考:http://blog.csdn.net/hejinjing_tom_com/article/details/46788283

3. 令内核启动完成后跳入hello

甲: 将hello打包为ramfs
$ echo hello | cpio -o --format=newc > initramfs

乙: 模拟运行
$ qemu-system-arm -M versatilepb -kernel zImage -initrd initramfs -append "root=/dev/ram rdinit=/hello"
root=/dev/ram 指明根文件系统在ram, -initrd 模拟根文件系统。 rdinit= ... 第一个运行程序


$ qemu-system-arm -M versatilepb -kernel zImage -initrd initramfs -nographic -append "root=/dev/ram rdinit=/hello console=ttyAMA0"

这里模拟了串口,控制台输出从那个挺难看的小窗口挪到了本地,字体好看多了。

-nographic      disable graphical output and redirect serial I/Os to console


Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre <nico@fluxnic.net>
smc91x smc91x.0 eth0: SMC91C11xFD (rev 1) at c89c8000 IRQ 57
 [nowait]
smc91x smc91x.0 eth0: Ethernet addr: 52:54:00:12:34:56
mousedev: PS/2 mouse device common for all mice
TCP: cubic registered
NET: Registered protocol family 17
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
Freeing unused kernel memory: 124K (c03c2000 - c03e1000)
---------- hello qemu ------------
input: AT Raw Set 2 keyboard as /devices/fpga:06/serio0/input/input0
input: ImExPS/2 Generic Explorer Mouse as /devices/fpga:07/serio1/input/input2

(qemu)

hello qemu 出来的真不容易!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值