Search code examples
ubunturaspberry-pikeyboardmouseqemu

No keyboard and Mouse when using qemu to emulate raspiberry3 on Ubuntu


I have no keybord and mouse responding when i try emulates Raspberry Pi3 on Ubuntu with qemu. This is my call:

qemu-system-aarch64 -M raspi3b -append "rw earlyprintk loglevel=8 console=ttyAMA0,115200 dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootdelay=1" -dtb bcm2710-rpi-3-b.dtb -sd 2023.img -kernel kernel8.img -m 1G -smp 4 -usb -device usb-mouse -device usb-kbd

Everything runs fine, except i can't use mouse and keyboard

my qemu-system-aarch64 version is:

QEMU emulator version 7.0.50 (v7.0.0-2530-g8482ab545e) Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers

I running on Ubuntu 18.04

Any ideias of what is going on?


Solution

  • I just found what was going on. During RaspiOS boot messages i saw a message about some kernel issue. So, i ended founding that i was using a kernel8.img file different from what it should be(an old version). The right file should be inside the RaspiOS image file. So what i did:

    #this way, you will see the partitions inside img. You should pay 
    #attention to the start number of first partition(that is the
    #boot partition of .img file)
    fdisk -l RaspiOS.img
    
    #you must multiply this number by 512
    losetup -o $[ 8192 * 512 ] /dev/loop30 RaspiOS.img
    
    #now, you must mount this partition to some folder
    mkdir /mnt/raspi    
    mount /dev/loop30 /mnt/raspi
    
    #finally, you shoud copy kernel8.img to your host folder
    cp /mnt/raspi/kernel8.img .
    
    #and end all this
    umount /mnt/raspi    
    losetup -d /dev/loop30    
    rmdir /mnt/raspi
    

    So, this way i got the right kernel8.img version. I also grab the .dtb files too.

    Hope this info can help.