3

I have compiled an embedded Linux with Buildroot for i386. I didn't edited much, just defaults. Now I want to run it under qemu. But the only thing I see is this: enter image description here

I'm running qemu with these options:

qemu-system-i386 -kernel vmlinux -hda rootfs.ext2 -m 256

Why this is happening? I have compiled like the example in the buildroot documentation.

Ciro Santilli OurBigBook.com
  • 18,092
  • 4
  • 117
  • 102
Majid Azimi
  • 3,098
  • 1
    Without details how/what you did or what the exact problem is we can't help you. Try to use the serial option for qemu to determine problem. You probably want to specify -append as an option to qemu if your kernel has no default parameters, e.g. you should at least specify the root partition. – Ulrich Dangel Jul 26 '12 at 19:42
  • what info I should provide so it can help you? kernel config file? uclibc config file? – Majid Azimi Jul 27 '12 at 07:56
  • Well, rootfs.ext2 is the image from filesystem while you are passing it as a disk image. (it does not contain partition table and MBR). The correct command must be something like: qemu-system-i386 -kernel vmlinux file=rootfs.ext2,format=raw -m 256 – sorush-r Jul 31 '21 at 18:06

1 Answers1

6

Commands that just work

To make absolutely sure that it will work, we can make Buildroot build QEMU for us, and use the exact QEMU CLI provided by Buildroot at: https://github.com/buildroot/buildroot/blob/2019.05/board/qemu/x86_64/readme.txt

git clone https://github.com/buildroot/buildroot
cd buildroot
git checkout 2019.05
make qemu_x86_64_defconfig
printf '
BR2_CCACHE=y
BR2_PACKAGE_HOST_QEMU=y
BR2_PACKAGE_HOST_QEMU_LINUX_USER_MODE=n
BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y
BR2_PACKAGE_HOST_QEMU_VDE2=y
' >> .config
make olddefconfig
time make BR2_JLEVEL="$(nproc)" HOST_QEMU_OPTS='--enable-sdl --with-sdlabi=2.0'
./output/host/bin/qemu-system-x86_64 \
  -M pc \
  -kernel output/images/bzImage \
  -drive file=output/images/rootfs.ext2,if=virtio,format=raw \
  -append "rootwait root=/dev/vda" \
  -net nic,model=virtio \
  -net user \
;

You are now left on a shell and you can login with username root (no password).

enter image description here

Note however that the default Buildroot build does not have an interesting GUI like X11 by default, as that is not the most common use case for this project. I have covered that at: How to install X11 on my own Linux Buildroot system?

But because Buildroot does not focus enough on the run part to my needs (more automation, more boot types, GDB step debug), I extended it with some extra scripts on this project: https://github.com/cirosantilli/linux-kernel-module-cheat

Other ISAs mentioned at: https://cirosantilli.com/linux-kernel-module-cheat/#buildroot-hello-world

Buildroot 2019.08 QEMU build failed because QEMU 3.1.1 release has a broken x86_64 build... QEMU 3.1.1 failed to build

Tested in Ubuntu 19.04.

Ciro Santilli OurBigBook.com
  • 18,092
  • 4
  • 117
  • 102
  • With X11, the keyboard is screwed up when I try to log in. With -nographic + console=ttyAMA0, the output hangs after Booting from ROM... Any idea how to get the nographic mode working? (note I'm doing this over SSH) – Sridhar Sarnobat Nov 07 '19 at 06:19
  • 1
    @SridharSarnobat you have to enable a serial and then telnet into its port as shown at: https://github.com/cirosantilli/linux-kernel-module-cheat/tree/6936bd6ba996dee40f7cd826e5cf01ef39c2cabf#tty You need -serial to enable serial, modify the inittab to place a shell there, and then telnet into the port. The setup in that repo already does this by default, initially for docker usage: https://github.com/cirosantilli/linux-kernel-module-cheat/tree/6936bd6ba996dee40f7cd826e5cf01ef39c2cabf#docker – Ciro Santilli OurBigBook.com Nov 07 '19 at 08:28