1

EDIT: I significantly updated this after applying @Nikita Kipriyanov's answer.

As of version 5.1 or 5.01 QEMU now supports RPI2 & 3 and USB. As the network on the RPI is behind USB, I should now be able to ssh into RPI2 emulation.

I run:

qemu-system-arm \
  -M raspi2 \
  -kernel kernel7.img \
  -serial stdio \
  -append 'rw earlycon=pl011,0x3f201000 console=ttyAMA0 loglevel=2 root=/dev/mmcblk0p2 f
sck.repair=yes net.ifnames=0 rootwait memtest=1 dwc_otg.fiq_fsm_enable=0' \
  -drive file=Arch.img,format=raw,if=sd \
  -dtb bcm2709-rpi-2-b.dtb \
  -no-reboot \
  -netdev user,id=net0 \
  -usb \
  -device usb-kbd \
  -device usb-tablet \
  -device usb-net,netdev=net0 \
  -device usb-net,netdev=ulan,mac=02:ca:fe:f0:0d:01 \
  -netdev user,id=ulan,hostfwd=tcp::2222-:22

Error messages & success at the end:

qemu-system-arm: warning: netdev net0 has no peer
[    0.000000] Booting Linux on physical CPU 0xf00
[    0.000000] Linux version 5.4.51-2-ARCH (builduser@leming) (gcc version 9.3.0 (GCC)) #1 SMP PREEMPT Sat Aug 8 23:15:12 UTC 2020
[    0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: Raspberry Pi 2 Model B
[    0.000000] earlycon: pl11 at MMIO 0x3f201000 (options '')
[    0.000000] printk: bootconsole [pl11] enabled    
usbnet: failed control transaction: request 0x8006 value 0x600 index 0x0 length 0xa
usbnet: failed control transaction: request 0x8006 value 0x600 index 0x0 length 0xa
usbnet: failed control transaction: request 0x8006 value 0x600 index 0x0 length 0xa

...

[FAILED] Failed to start Load Kernel Modules.
See 'systemctl status systemd-modules-load.service' for details.

...

Arch Linux 5.4.51-2-ARCH (ttyAMA0)

alarmpi login:

This doesn't work, i.e. I can't ssh to port 2222.

ssh -p 2222 alarm@localhost
kex_exchange_identification: read: Connection reset by peer
Connection reset by 127.0.0.1 port 2222

Note my loglevel: it is set to two.

Nothing to be seen here (the date in the emulator is wrong: "Fri Dec 18 18:08:08 UTC 2020"):

[alarm@alarmpi ~]$ journalctl -u sshd
...
Dec 18 17:23:47 alarmpi systemd[1]: Started OpenSSH Daemon.
Dec 18 17:23:49 alarmpi sshd[223]: Server listening on 0.0.0.0 port 22.

Checking systemd:

[alarm@alarmpi ~]$ systemctl status systemd-modules-load.service
* systemd-modules-load.service - Load Kernel Modules
     Loaded: loaded (/usr/lib/systemd/system/systemd-modules-load.service; stat>
     Active: failed (Result: exit-code) since Fri 2020-12-18 17:23:48 UTC; 1min>
       Docs: man:systemd-modules-load.service(8)
             man:modules-load.d(5)
    Process: 209 ExecStart=/usr/lib/systemd/systemd-modules-load (code=exited, >
   Main PID: 209 (code=exited, status=1/FAILURE)

Dec 18 17:23:48 alarmpi systemd[1]: Starting Load Kernel Modules...
Dec 18 17:23:48 alarmpi systemd-modules-load[209]: Failed to look up module ali>
Dec 18 17:23:48 alarmpi systemd[1]: systemd-modules-load.service: Main process >
Dec 18 17:23:48 alarmpi systemd[1]: systemd-modules-load.service: Failed with r>
Dec 18 17:23:48 alarmpi systemd[1]: Failed to start Load Kernel Modules.
lines 1-13/13 (END)

How to troubleshoot failure to ssh into the RPI2 emulation, based on QEMU 5.2?

1
  • Is the Pi network 'behind USB' in emulation - I would have thought the network port would be direct unless you had a USB connected one. I know in real life some boards are but VM / Parallels always used a dedicated lan chip emulation process no matter what a Mac (I know not a Pi) had. Gut feel (and its only gut feel) is to try other options for the network port.
    – user115418
    Dec 19, 2020 at 19:03

1 Answer 1

1

It seems you misunderstood the QEMU network configuration. I think your command line instantiates two network interfaces, one with netdev/device usb-net, another with two nic's. Is this what you really meant to do?

The machine must have been working network through first NIC (from device usb-net/netdev), but you've set up port forwarding in the second NIC configuration, which supposedly doesn't work. This is why your port forwarding also doesn't do anything useful.

I successfully run RPi in QEMU, this is all network configuration in the emulator command line:

-device usb-net,netdev=ulan,mac=02:ca:fe:f0:0d:01 \
-netdev user,id=ulan,hostfwd=tcp::2222-:22 \

It has all the network working. I'm able to ssh into it like this: ssh -p 2222 localhost

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.