以 https://gist.github.com/tuxmartin/04d85009a3aaa968c3430678096e3ac6 为参考
主要步骤为
1. 获取 vmlinuz 文件
2. 获取 设备树 文件
3. 获取 initrd.img 文件
4. 获取rootfs所在镜像文件
5. qemu-system-arm -machine vexpress-a15 -cpu cortex-a15 -m 512M -kernel "vmlinuz"-initrd "initrd.img"-append "..."-dtb "设备树文件"-drive ...,file="rootfs镜像文件"
但是无法启动
目前已经做到的是
1. 获取了 vmlinuz 文件 : vmlinuz-4.4.0-210-generic-lpae
2. 获取了 initrd 文件 : initrd.img-4.4.0-210-generic-lpae
3.qemu-system-arm -machine virt -m 512M -kernel vmlinuz-4.4.0-210-generic-lpae -initrd initrd.img-4.4.0-210-generic-lpae -nographic
// 注意 : 相对于参考 , 换了// 1. -machine virt (vexpress-a15->virt)// 2. vmlinuz 版本 (111->210)// 3. initrd.img 版本(111->210)
启动做到了 启动到 initramfs(initramfs) uname -a
Linux(none)4.4.0-210-generic-lpae #242-Ubuntu SMP Fri Apr 1611:26:48 UTC 2021 armv7l GNU/Linux
TODO : 设备树文件
rootfs所在镜像文件
xenial-server-cloudimg-armhf-disk1.img 现在获取的版本 中
vmlinuz 的版本 从 vmlinuz-4.4.0-209-generic-lpae 到 vmlinuz-4.4.0-210-generic-lpae
而 linux-image 版本中有
111-210
所以 我会以 210 版本的 xenial-server-cloudimg-armhf-disk1.img 和 210版本的 linux-image 再研究
210 版本的 linux-image 只有一个有效文件 , 且和 xenial-server-cloudimg-armhf-disk1.img 中的文件相同,所以 210 的 linux-image 无需要研究
qemu-system-arm -machine virt -m 512M -kernel vmlinuz-4.4.0-210-generic-lpae -initrd initrd.img-4.4.0-210-generic-lpae -nographic -append "console=ttyAMA0 earlyprintk=serial root=/dev/mmcblk0p1 ro rootfstype=ext4"-drive if=none,file=xenial-server-cloudimg-armhf.img,id=hd0 -device virtio-blk-device,drive=hd0
会有如下打印 :
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ...[14.840245] Btrfs loaded
Scanning for Btrfs filesystems
done.
Begin: Waiting for root file system ... Begin: Running /scripts/local-block ... mdadm: CREATE group disk not found
mdadm: No arrays found in config file or automatically
done.
Begin: Running /scripts/local-block ... mdadm: CREATE group disk not found
mdadm: No arrays found in config file or automatically
done.
Begin: Running /scripts/local-block ... mdadm: CREATE group disk not found
mdadm: No arrays found in config file or automatically
qemu-system-arm -machine virt -m 512M -kernel vmlinuz-4.4.0-210-generic-lpae -initrd initrd.img-4.4.0-210-generic-lpae -nographic \
-append "console=ttyAMA0 earlyprintk=serial root=/dev/vda rw rootfstype=ext4 " \
-drive if=none,file=xenial-server-cloudimg-armhf.img,format=raw,id=hd0 -device virtio-blk-device,drive=hd0
Warning: fsck not present, so skipping root file system
mount: mounting /dev/vda on /root failed: Invalid argument
done.
Begin: Running /scripts/local-bottom ... done.
Begin: Running /scripts/init-bottom ... mount: mounting /dev on /root/dev failed: No such file or directory
done.
mount: mounting /run on /root/run failed: No such file or directory
run-init: current directory on the same filesystem as the root: error 0
Target filesystem doesn't have requested /sbin/init.
run-init: current directory on the same filesystem as the root: error 0
run-init: current directory on the same filesystem as the root: error 0
run-init: current directory on the same filesystem as the root: error 0
run-init: current directory on the same filesystem as the root: error 0
run-init: current directory on the same filesystem as the root: error 0
No init found. Try passing init= bootarg.
BusyBox v1.22.1(Ubuntu 1:1.22.0-15ubuntu1.4) built-in shell(ash)
Enter 'help'for a list of built-in commands.(initramfs) qemu-system-arm: terminating on signal 15 from pid 3319(killall)
Ubuntu 16.04.7 LTS ubuntu ttyAMA0
ubuntu login: root
Password:
Welcome to Ubuntu 16.04.7LTS(GNU/Linux 4.4.0-210-generic-lpae armv7l)* Documentation: https://help.ubuntu.com* Management: https://landscape.canonical.com* Support: https://ubuntu.com/advantage0 updates can be applied immediately.
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
root@ubuntu:~# uname -a
Linux ubuntu 4.4.0-210-generic-lpae #242-Ubuntu SMP Fri Apr 16 11:26:48 UTC 2021 armv7l armv7l armv7l GNU/Linux