I notice two things with this command:
-
usb-ehcidevice is used, which attaches to a PCI bus.$ qemu-system-aarch64 -device help | grep -i usb-ehci name "ich9-usb-ehci1", bus PCI name "ich9-usb-ehci2", bus PCI name "usb-ehci", bus PCI
- The
raspi4emulated QEMU machine does not support PCI
bcm2711-rpi-4-b.dtbdevicetree is passed, but the emulated machine israspi3, rather thanraspi4
- You should match the
dtbfile passed to the emulated hardware machine - In this case, the
raspi3machine would need thebcm2710-rpi-3-b.dtb
Note that for raspi4, the bcm2711-rpi-4-b.dtb devicetree file has disabled the USB controller. So, to enable USB keyboard & mouse, the .dtb file must be decompiled to .dts, patched, and recompiled back to .dtb. I have created a Makefile-based qemu-raspbian project here to assist with this.
Whichever machine you choose to emulate, use the corresponding .dtb devicetree file that matches that machine. Also, keep in mind that some of the raspi* machines don’t support a PCI bus. Therefore, avoid using PCI devices on those QEMU machine types and opt for the usb-* devices instead.
For the Raspbian USB driver, you may choose between using the usb_otg and the dwc2 drivers. For example, my project disabled usb_otg and used dwc2, configuring these in /boot/config.txt. If you choose usb_otg, nothing else needs to be done, because the current Raspbian bookworm image already has this enabled by default.