I've made a quick shell script to emulate Raspberry Pi on a regular Linux PC. You can use any real disk image to boot from and write the image
back to a SD card after working on it. It's even much faster than on real hardware.
Save this as raspi.sh and give it execute permissions:
#
# Script to start Raspberry Pi emulation on QEMU.
#
# You'll need:
# - qemu installed
# - kernel file (in the same directory)
# http://xecdesign.com/downloads/linux-qemu/kernel-qemu
# - a bootable disk file (such as Raspbian image)
#
# Usage:
# raspiemu.sh
#
# Source:
# http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=37386
#!/bin/sh
imagefile=$1
rpiroot=/tmp/rpidisk
kernel=kernel-qemu
# Sanity checks
if [ -f "$imagefile" ]
then
echo Image is $imagefile - mounting to $rpiroot
else
echo "$imagefile not found."
exit
fi
if [ -f "$kernel" ]
then
echo Kernel is $kernel
else
echo "$kernel not found."
exit
fi
# Mount the image
mkdir -p $rpiroot
sudo mount -t auto $imagefile -o offset=62914560 $rpiroot
# Modify preload
sudo mv $rpiroot/etc/ld.so.preload $rpiroot/etc/ld.so.preload-copy
sudo umount $rpiroot
# Kill qemu with ctrl-c, not this script
trap 'killall qemu-system-arm' 2
# Run qemu
qemu-system-arm -kernel $kernel -cpu arm1176 -M versatilepb -no-reboot -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" -hda $imagefile -m 256 -serial stdio -redir tcp:5022::22 -redir tcp:5080::80
# Reset the image to be bootable on rpi
echo "Resetting image file to bootable state.."
sudo mount -t auto $imagefile -o offset=62914560 $rpiroot
sudo mv $rpiroot/etc/ld.so.preload-copy $rpiroot/etc/ld.so.preload
sudo umount $rpiroot
Comments
There are currently no comments
New Comment