Embedded Linux emulation with QEMU (on LPC313X by NXP) - linux-kernel

I'm starting to work with Embedded Linux and I've got a LPC313x based board (Embedded Artists). I've built apex and kernel with ELDK (as suggested here: http://www.lpclinux.com/LPC313x/LPC313xGettingstartedELDK).
The kernel is built correctly (apparently no error occurs) with the default settings, and I am using a pre-made ramdisk, provided at the same link.
Now I want to use QEMU to emulate my system prior to load all the stuff in the physical board. To do that, I'm using the command:
qemu-system-arm -kernel kernel/work_2.6.28.2/arch/arm/boot/zImage -initrd ../eldk42/arm/images/ramdisk_image.gz
I cannot get it work! QEMU starts but the emulator screen remains black, nothing happens. What am I missing here?

You board is not supported by Qemu. You have to write your own Board Support Package, if you can't find one on the Internet. Try checking the kernel source tree, you might find one there.
Plus you have to know the exact internal details of your SoC and board.

Try this:
qemu-system-arm -kernel
kernel/work_2.6.28.2/arch/arm/boot/zImage
-initrd ../eldk42/arm/images/ramdisk_image.gz
-append "root=/dev/ram"
Try with -m:
qemu-system-arm -m 128 -kernel
kernel/work_2.6.28.2/arch/arm/boot/zImage
-initrd ../eldk42/arm/images/ramdisk_image.gz
-append "root=/dev/ram"
Try with -M:
qemu-system-arm -M versatilepb -m 128 -kernel
kernel/work_2.6.28.2/arch/arm/boot/zImage
-initrd ../eldk42/arm/images/ramdisk_image.gz
-append "root=/dev/ram"
You are basically making /dev/ram (which you provide with -initrd argument) as your system's root directory. You can find more information here.

You're probably interested in the linux option console=ttyS0 which you can add to -append of qemu.

Related

Having trouble mounting .ISO file when using QEMU

I'm running a MacBook Air M1 with Big Sur 11.4 installed
I'm trying to mount an ISO image of the Virtio-Win networking driver, using the following commands in my start.sh file.
-drive file=/Users/username/Downloads/windows-10/virtio-win-0.1.190.iso,media=cdrom,if=none,id=drivers \
-device usb-storage,drive=drivers
The drive does not show up when I run the QEMU Windows 10 ARM instance, everything else works just fine.
Are there other options for moving files or images from my host to the QEMU instance?
In my case, I need to use -cdrom and -boot d
This works for me:
-bios ./bios.fd \
-drive if=virtio,format=raw,file=./debian.qcow2,discard=on \
-cdrom ./ubuntu-21.04-live-server-arm64.iso \
-boot d

Qemu can't load bios-256k.bin when running on Windows

I was trying to test qemu on Windows OS and when I tried to start an ubuntu iso whith the following command:
qemu-system-x86_64.exe -boot d -cdrom .\ubuntu-20.04.1-desktop-amd64.iso -m 2048
Then I getting the following error:
qemu: could not load PC BIOS 'bios-256k.bin'
Qemu folder is set in Enviroment Varibles and the bios-256k.bin file is in the folder
How can I solve this problem?
Add an option for bios file directory entry with -L switch. Your command should look like this:
qemu-system-x86_64.exe -boot d -cdrom .\ubuntu-20.04.1-desktop-amd64.iso -m 2048 -L "C:\Program Files\qemu"
Of course in case your default qemu installation is in C:\Program Files\qemu and bios files are inside that directory. For some reason, qemu has a bug that doesn't search bios files in defined path and look for them in current working directory.
Edit: I found a bug report that mentions this issue. It also seems to be fixed in newest version. Anyway, here is the link: https://bugs.launchpad.net/qemu/+bug/1915794
This is a known and documented problem with a simple workaround: "Known issue: currently requires start from installation directory or -L option to specify the location of the firmware files."
And it is already fixed in the newer installer.

Failed to install ubuntu on QEMU for macOS host

I am new to QEMU virtual machine.
I am now installing ubuntu16.04 on QEMU virtual machine for macOS catalina host by following this tutorial:
https://graspingtech.com/ubuntu-desktop-18.04-virtual-machine-macos-qemu/
However, after I command to launch QEMU with ubuntu ISO, I didn't get into the ubuntu installer.
I command:
qemu-system-x86_64 \
-m 2048 \
-vga virtio \
-show-cursor \
-usb \
-device usb-tablet \
-enable-kvm \
-cdrom /Users/my_path/QEMU/ubuntu-16.04.6-desktop-amd64.iso \
-drive file=/Users/mt_path/QEMU/ubuntu-16.04.6-live-server-amd64.qcow2,if=virtio \
-accel hvf \
-cpu host
, but I got No bootable device on QEMU
No bootalbe device
Does anyone know how to fix it?
You should also specify a boot drive when launching the vm
Running qemu-system-x86_64 --help on my machine yields this regarding the boot order:
-boot [order=drives][,once=drives][,menu=on|off]
[,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time][,strict=on|off]
'drives': floppy (a), hard disk (c), CD-ROM (d), network (n)
'sp_name': the file's name that would be passed to bios as logo picture, if menu=on
'sp_time': the period that splash picture last if menu=on, unit is ms
'rb_timeout': the timeout before guest reboot when boot failed, unit is ms
In your case that should be -boot c for hard disk (c).
The problem is solved.
That is because I made some dummy to the .qcow2 file.
I tried to re-make the .qcow2 and re-download the .iso, and it works.

how to boot sabrelite linux image on qemu

What is the right command to boot sabrelite linux kernel on qemu.
I've linux kernel zImage and rootfs of type ext3
I'm trying to boot kernel with following command line but there is no any console output.
./qemu-system-arm -M sabrelite -m 1G -kernel zImage -smp 4 -drive file=console-image-mx6q-rootfs.ext3,format=raw,id=mycard -device sd-card,drive=mycard -append "console=ttymxc1,115200 root=/dev/mmcblk0p0 rootfstype=ext3 rw" -dtb zImage-imx6q-sabresd.dtb
QEMU : 3.0.0 version.
I had issues getting the rootfs to mount correctly on IMX6 emulated with Qemu; this Q&A on SO solved the issue:
Qemu Freescale i.MX6 DualLite SABRE : root filesystem does not mount
It did involve patching the Qemu codebase, but that was a year back; so now, using the latest ver, hopefully it works..
FYI, this is the command I used to launch it:
qemu-system-arm -m 2048 -M sabrelite -kernel <path-to-zImage> -drive file=<path-to-my-rfs.img>,format=raw,id=mysdcard -device sd-card,drive=mysdcard -append "console=ttymxc0 rootfstype=ext4 root=/dev/mmcblk0 rw rootwait init=/sbin/init" -no-reboot -nographic -dtb <path-to>/imx6dl-sabresd.dtb
HTH..

Kexec on embeded images

I'm trying to boot my kernel image (bzImage format and which is built using buildroot) with kexec. This bzImage got its embedded initrd too. But when I try kexec, it just hangs. I'm not sure where I can see kexec logs.
[root#localhost boot]# kexec -v
kexec-tools-testing 20070330 released 30th March 2007
[root#localhost boot]# kexec -l /boot/bzImage -d --command-line=quiet noapic ro noswap
setup_linux_vesafb: 800x600x16 # f0000000 +1d4c00
[root#localhost boot]# kexec -e
Older kexec binary clearly mentions in help that it doesn't support bzImage yet but newer ones do support it. So I in fact tried all kexec versions (2.0.0/1/2/3 and some test versions too). But I get same result. I'm trying kexec from Centos 5.5 32 bit and bzImage is built for i386. This is actually VM on Xenserver but I don't think that should matter anyway. Interestingly if I install my bzImage locally with grub.conf (and using same cmdline above), it boots fine with bootloader. So image seems to be fine.
I'm pretty new to Linux boot stuff so probably missing something very obvious here. Any help or pointers provided will be appreciated.
Not sure what played magic here but upgrading busybox package inside kernel image (through buildroot) helped. It started booting fine with all kexec versions. There's one problem which I see is console of box is garbeled for some reason (post kexec) but if I ssh to box it shows everything fine.

Resources