Here I got an image of Raspberry Pi (re-designed). Let's call it pi2-16gb.img
Emulate ARM Raspberry Pi 2 model B v1.1 on a Ubuntu PC
Now I want to emulate it before inserting it to a Pi 2 physically.
I created a startup script start_arm_pi.sh
as this:
#!/bin/bash
# Starts raspberry pi image in configuration mode
qemu-system-arm -kernel ./boot_for_pi2/kernel.img \
-cpu arm1176 -m 1024 \
-M versatilepb -no-reboot -serial stdio \
-append "root=/dev/mapper/crypt_sdcard cryptdevice=/dev/mmcblk0p2:crypt_sdcard panic=1 rootfstype=ext4 rw init=/bin/bash" \
-hda /path/to/pi2-16gb.img
But with error:
pulseaudio: set_sink_input_volume() failed
pulseaudio: Reason: Invalid argument
pulseaudio: set_sink_input_mute() failed
pulseaudio: Reason: Invalid argument
About the image
Actually there's two partitions of the image file pi2-16gb.img
.
/boot/
from /dev/mmcblk0p1
and /
from /dev/mmcblk0p2
. But the /dev/mmcblk0p2
is encrypted by LUKS encryption.
the kernel.img
is derived from the un-encrypted partition /dev/mmcblk0p1
All the files in the partition /dev/mmcblk0p1
(will be mounted as /boot/
are in this picture.
And I think the file cmdline.txt and the file config.txt may be helpful.
Content of cmdline.txt
dwc_otg.fiq_fix_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 elevator=deadline root=/dev/mapper/crypt_sdcard cryptdevice=/dev/mmcblk0p2:crypt_sdcard rootfstype=ext4 rootwait
Content of config.txt
initramfs initramfs.gz 0x00f00000 hdmi_ignore_hotplug=1
Do you have some ideas that emulate Pi on a my Ubuntu PC?
Thank you a million!!
updated
I had a physical Pi 2 running this image.
And from the TTL serial port (Tx, Rx), I received messages as the following)
pastebin(dot)com/Y7Xg5WRg
Found a info line about kernel command:
[ 0.000000] Kernel command line: dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2709.boardrev=0xa21041 bcm2709.serial=0x2925606f smsc95xx.macaddr=B8:27:EB:25:60:6F bcm2708_fb.fbswap=1 bcm2709.disk_led_gpio=47 bcm2709.disk_led_active_low=0 sdhci-bcm2708.emmc_clock_freq=250000000 vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000 dwc_otg.fiq_fix_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 elevator=deadline root=/dev/mapper/crypt_sdcard cryptdevice=/dev/mmcblk0p2:crypt_sdcard rootfstype=ext4 rootwait
Will this be helpful?
updated
I had found that qemu
has support Raspberry Pi 2 from version 2.6.0 according to its doc page: wiki.qemu(dot)org/ChangeLog/2.6
So I compiled qemu
version 2.6.0 on my Ubuntu 14.04 x86_64 PC. And I went to boot it using this command.
/usr/local/src/qemu-2.6.0/bin/debug/native/arm-softmmu/qemu-system-arm \
-kernel /path/to/boot_for_pi2/kernel7.img \
-cpu arm1176 -m 256 \
-M raspi2 \
-no-reboot \
-serial stdio \
-sd /path/to/pi2-16gb.img \
-append "dwc_otg.fiq_fix_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 elevator=deadline root=/dev/mapper/crypt_sdcard cryptdevice=/dev/mmcblk0p2:crypt_sdcard rootfstype=ext4"
And here's the output now.
WARNING: Image format was not specified for '/path/to/pi2-16gb.img' and probing guessed raw.
Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
Specify the 'raw' format explicitly to remove the restrictions.
Uncompressing Linux... done, booting the kernel.
But it stopped here and the qemu window is black with nothing...
Does this mean something's wrong with the kernel?
File kernel7.img
is derived from its /boot/
partition actually.
updated
I started the emulator successfully but with an error...
/usr/local/src/qemu-2.6.0/bin/debug/native/arm-softmmu/qemu-system-arm \
-kernel /path/to/kernel-qemu-4.4.11-jessie \
-m 256 \
-cpu arm1176 \
-M versatilepb \
-no-reboot \
-serial stdio \
-hda /media/alex/F049-1FB6/2016-05-27-raspbian-jessie.img \
-append "dwc_otg.lpm_enable=0 root=/dev/sda2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait init=/bin/bash" \
The driver can be mounted. Here I tested it with a latest rasbian image 2016-05-27-raspbian-jessie.img
The qemu kernel I used is from :
github(dot)com/dhruvvyas90/qemu-rpi-kernel
But I had a kernel panic...
Here's the error in detail.
#!
and the/bin/bash
I believe the space is required for your script to work. – sir_ian Jun 29 '16 at 19:30qemu
2.6? – dotslash Jul 04 '16 at 19:00kernel.img
,kernel7.img
andkernel-qemu-4.4.11-jessie
) and I'm struggling to understand which one you really need to boot and what happened when you tried out each of those. Providing context is good, but in this case the actual question is completely hidden in the non-essential info. – Dmitry Grigoryev Dec 14 '16 at 09:04