arm系统启动后运行 helloworld ("hello world" 被封装为ramdisk)
2015-07-07 16:51
465 查看
----------------------------------------
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 出来的真不容易!
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 出来的真不容易!
相关文章推荐
- solr 异常:missing content stream
- 获取操作系统信息(本机IP地址,Java版本,安装路径等)
- Java初学练习答案(循环)
- C++类的复习
- js作用域
- 数组循环位移K位
- root权限对SYSTEM目录拷贝文件,adb通过wifi连接android设备的方法
- zookeeper browser 工具
- 四舍六入五考虑
- PHP正则表达式
- LeetCode17:Letter Combinations of a Phone Number
- 负面偏好
- Oracle数据库之PL/SQL触发器
- DeepLearnToolBox笔记
- 文本分类特征选择方法——卡方检验信息增益
- 汉诺塔的简单实现
- Python的函数
- 输入10个数,求出最大元素是第几个数(数组作为函数参数)
- 打印1到最大的n位数
- thinkphp 内存查询表 防止多次查库