/********************************************************************************
* RPi 2B QEMU 模拟树莓派
* 说明:
* 网络上又找到一些资料,不过在我的电脑上运行会出一些问题,经验证,需要提前
* 修改文件系统中的链接库和分区挂载表。
*
* 2017-5-21 * 中和区 曾剑锋
*******************************************************************************/
一、参考文档:
1. Emulating Jessie image with 4.x.xx kernel
https://github.com/dhruvvyas90/qemu-rpi-kernel/wiki/Emulating-Jessie-image-with-4.x.xx-kernel
2. Change Screen Resolution?
https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=136280
3. CONFIG.TXT
https://www.raspberrypi.org/documentation/configuration/config-txt/README.md
二、下载内核:
https://github.com/dhruvvyas90/qemu-rpi-kernel
三、下载树莓派系统:
1. https://downloads.raspberrypi.org/raspbian_lite_latest
2. https://downloads.raspberrypi.org/raspbian_latest
四、操作流程:
1. 文件系统修改:
1. fdisk -l <树莓派系统镜像>
[email protected]:~/rpi$ sudo fdisk -l 2017-03-02-raspbian-jessie-lite.img
[sudo] password for zengjf:
Disk 2017-03-02-raspbian-jessie-lite.img: 1.3 GiB, 1393557504 bytes, 2721792 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xb2455b06
Device Boot Start End Sectors Size Id Type
2017-03-02-raspbian-jessie-lite.img1 8192 137215 129024 63M c W95 FAT
2017-03-02-raspbian-jessie-lite.img2 137216 2721791 2584576 1.2G 83 Linux
2. 磁盘偏移计算:137216 * 512 = 70254592
3. mount -v -o offset=70254592 -t ext4 your-image-file.img /mnt
4. cd /mnt
5. sudo vim ./etc/ld.so.preload
注释掉所有的内容就可以了,一般里面只有一行,直接注释掉就OK了。
6. sudo vim ./etc/fstab
看到和/dev/mmcblk有关的都可以注释掉。
7. cd ~
8. sudo umount /mnt
2. 参考运行命令:
1. lite版参考执行命令
qemu-system-arm -kernel kernel-qemu-4.4.26-jessie -cpu arm1176 -m 256 -M versatilepb -serial stdio -append "root=/dev/sda2 rootfstype=ext4 rw" -hda 2017-03-02-raspbian-jessie-lite.img
2. desktop版参考执行命令
qemu-system-arm -kernel kernel-qemu-4.4.26-jessie -cpu arm1176 -m 256 -M versatilepb -serial stdio -append "root=/dev/sda2 rootfstype=ext4 rw" -hda 2017-04-10-raspbian-jessie.img