-2

I am trying to build a linux image for raspberrypi3 with buildroot and run it on qemu. Once the make process is done i can copy the sdcard.img file into a SD card and correctly run the OS on a real raspberry pi device without any issue.

but when i try to use the same image file and try to run it on qemu the bootup fails.

  1. qemu-system-aarch64 -M raspi3 -kernel zImage -dtb generated dtb -sd generated .img => qemu window opens but blank. nothing on the terminal as well.
  2. qemu-system-arm -M raspi2 -kernel zImage -dtb generated dtb -sd generated .img => qemu window opens. raspberry image appears on top left corner. but in the teminal window there is a kernel panic. VFS mount failed
  3. same as 1st step but with a freshly compiled qemu from source => same as 1st step. nothing on the qemu window or in the terminal.

am i doing something wrong?

OmegaKi113r
  • 99
  • 3
  • 14
  • 2
    Stack overflow is for questions about software development. This question might be a better fit over at https://raspberrypi.stackexchange.com or https://unix.stackexchange.com. – larsks Mar 28 '22 at 22:52

2 Answers2

2

After few days of googling around a lot i found the answer to my issue. The Kernel image zImage I use in the terminal command which is built by the buildroot make process is not compatible with the QEMU. To solve that I had to compile my own QEMU compatible raspberry pi kernel.

I followed this link to compile my own kernel. raspberry pi cross-compile kernel then when I used QEMU to run a OS there was another kernel panic saying VFS mount failed. When I read the terminal outputs before that, it says not enough space on the media. So expanded the scared.img file to 1G and ran the same terminal command.

Now the QEMU is running perfectly

OmegaKi113r
  • 99
  • 3
  • 14
0

Using the same kernel image for both these command lines is definitely wrong. raspi3 needs a 64-bit kernel, and raspi2 needs a 32-bit one.

Your command line appears to be missing the argument to the '-dtb' option, and also may be missing an '-initrd' option passing the initial ramdisk, and an '-append' option passing the kernel suitable command line arguments including the correct device to use for the root filesystem.

Peter Maydell
  • 9,707
  • 1
  • 19
  • 25
  • for the 1st and 2nd steps i recompiled everything. so the kernel file,dtb file,img file are indeed different in those 2 cases. -dtb files also i typed in when i ran the qemu commands. i have forgotten to type them in the question. i will edit it. i will check with -initrd and -append commands. – OmegaKi113r Mar 29 '22 at 14:30