【问题标题】:Emulating raspberry pi 4 with qemu使用 qemu 模拟树莓派 4
【发布时间】:2021-04-11 13:18:53
【问题描述】:

我想使用 qemu 模拟树莓派 4,但我找不到任何 RPi4 的图像。我需要一个 QEMU 可以模拟 Cortex-A72 的内核。有什么帮助吗?

【问题讨论】:

    标签: qemu raspberry-pi4


    【解决方案1】:

    QEMU 目前没有树莓派 4 的型号(只有 0、1ap、2b、3ap 和 3b)。如果 QEMU 支持的其他机器类型对您来说足够好,您可以为该机器类型构建一个内核并使用它。 (例如,对于很多人来说,他们真正想要的只是“启动 64 位 Linux 用户空间”,他们不需要它来真正完全匹配 Raspberry Pi 板硬件;对于那些人来说,“virt”板通常是不错的选择。)

    无论你做什么,你都需要确保你要求 QEMU 模拟的机器类型与你构建内核的机器类型相匹配——如果你尝试在不支持它的板上启动内核不会工作。

    【讨论】:

      【解决方案2】:

      我只是在 x86 ubuntu 笔记本电脑上启动 raspios bullseye,它可以显示桌面,可以登录。但是速度很慢。

      qemu-system-aarch64 -M virt,highmem=off -smp 8 -m 2G -cpu cortex-a72 -kernel linux-stable/arch/arm64/boot/Image -append root=PARTUUID=d97f5830-02 rw console=ttyAMA0 -serial telnet:localhost:4321,server,nowait -monitor telnet:localhost:4322,server,nowait -device VGA,id=vga1 -device secondary-vga,id=vga2 -object iothread,id=io1 -device virtio-blk-pci,drive=disk0,iothread=io1 -drive data/images/2022-01-28-raspios-bullseye-arm64.img
      

      我按照本指南构建内核映像。

      https://github.com/anholt/linux/wiki/Raspberry-Pi-development-environment#building-the-Kernel

      当然,因为 raspios 是在 x86 笔记本电脑上模拟的,所以速度肯定很慢。所以,如果你可以在 arm64 主机上进行虚拟化,你可以使用 kvm、hvf 等加速器。

          qemu-system-aarch64 \
            -M virt,highmem=off,accel=hvf \
            -cpu host \
            -m 1G \
            -smp 4 \
            -kernel $KERNEL_IMAGE_PATH -append "root=/dev/vda2 rw console=ttyAMA0" \
            -netdev user,id=n1,ipv6=off,hostfwd=tcp::5555-:22 -device e1000,netdev=n1 \
            -hda data/images/2022-01-28-raspios-bullseye-arm64.img \
            -serial telnet:localhost:4321,server,nowait \
            -monitor telnet:localhost:4322,server,nowait \
            -device VGA,id=vga2 \
            -drive file=data/images/2021-10-30-raspios-bullseye-armhf.img,if=virtio
      

      【讨论】:

        【解决方案3】:

        如果你愿意,这里有一个补丁。 你可以用 raspi4b2g 编译 qemu (补丁不是我的)

        https://github.com/0xMirasio/qemu-patch-raspberry4.git

        美好的一天

        【讨论】:

          【解决方案4】:

          或尝试以下分支 (2019),它可能是也可能不是与已经提到的补丁等效的补丁: https://gitlab.com/philmd/qemu/-/tree/raspi4_wip

          【讨论】:

          • 虽然此链接可能会回答问题,但最好在此处包含答案的基本部分并提供链接以供参考。如果链接页面发生更改,仅链接答案可能会失效。 - From Review
          猜你喜欢
          • 1970-01-01
          • 2013-11-23
          • 1970-01-01
          • 2022-01-21
          • 1970-01-01
          • 2020-07-19
          • 2021-03-02
          • 2021-06-10
          • 1970-01-01
          相关资源
          最近更新 更多