Running FatdogArm in Qemu
The previous article explains the general process of
how to adopt FatdogArm for other platforms.
This article will give an example of doing so for
Qemu, a generic and open source machine
emulator and virtualizer.
This article is similar and is in fact based on the older
how to run Puppy ARM in Qemu article,
but it is slightly different because of architectural differences between
FatdogArm and Puppy Arm (Puppy Arm is a full-install-type distribution,
while FatdogArm is a frugal-install-type distribution - which is
closer to x86 version of Puppy Linux).
Updated 2014/03/10 for
FatdogArm Alpha4 onwards. From Alpha4 onwards,
FatdogArm
no longer ships with image files; so one needs to make an image files from
the SFS for use with Qemu.
Overview
The following table provide a summary of what we will do to make FatdogArm
boots on Qemu; it is based on the steps outlined from AdoptingFatdogArm.
As you can see most of the steps can be skipped because they are not needed
on Qemu.
Adopting FatdogArm for Qemu
|
Steps from Adopting FatdogArm |
What we will do |
1 |
Platform-specific bootloader |
Not needed, Qemu can
boot kernel directly. |
2 |
Platform-specific kernel |
Provided, we will use
Vexpress or Realview
compatible kernel. |
3 |
Platform-specific kernel-modules |
Not needed, we will
compile all our needed
drivers are built-in,
but we will use an initrd
with all the modules taken
away so it is smaller. |
4 |
Modify fd-arm.sfs |
Not needed, Qemu will boot
with fd-arm.sfs for Mele
image. |
Pre-requisites
- Familiarity with terminal operation, most of the commands given are meant
to be typed into terminal.
- Qemu 1.5.0 or newer (tested with Qemu 1.5.3; in theory it should work
with earlier Qemu as well, down to 1.2.2, but I have not tested that and
Qemu 1.5.0 is oh so much faster than 1.2.2 ...)
- About 500MB of free disk space
- A relatively powerful machine, emulation is slow ...
Ingredients
- FatdogArm SFS from http://distro.ibiblio.org/fatdog/arm/releases
- Qemu initrd image from http://distro.ibiblio.org/fatdog/arm/releases/qemu
- Qemu kernels from from http://distro.ibiblio.org/fatdog/arm/releases/qemu
- If your machine has plenty of RAM and can afford to give 1GB for playing
with Qemu, get the zImage-vexpress kernel.
- Otherwise, get the zImage-realview kernel (this one will use 512MB RAM)
- And of course, the qemu-fatdog-arm.sh script, also from
http://distro.ibiblio.org/fatdog/arm/releases/qemu . You don't need this
script, but it helps to get you started.
Basic steps
- Get all the pre-requisites and ingredients.
Especially for qemu - get it from your favorite repository, if it is not
available there, pester your favorite pet maker to make one for you :)
Note for pet maker: Building qemu takes a very long time if you build
all of its targets, but you don't need all of them. The only target that
you need is arm-softmmu
.
- Install qemu pet.
- Move the rest of the ingredients (the startup script, initrd, kernel
and the FatdogArm SFS) the into a directory (e.g. /mnt/sdb1/fdarm)
- Open terminal within that directory.
- Create an image file (
fd-arm.img
) that will contain the SFS
(this will also enable you to save settings)
head -c 512M /dev/zero > fd-arm.img
mount -o loop fd-arm.img /mnt/data
mv fd-arm.sfs /mnt/data
umount -d /mnt/data
Notes: You can of course change that 512M
to any other figure as needed.
/mnt/data
is a temporary mountpoint, you can use any other.
If you want to keep the SFS for something else, use cp
instead of
mv
. You can skip this step and use an alternate step
to use the SFS directly, but you will not be able to save your session.
- Launch it from terminal like this:
./qemu-fatdog-arm.sh vexpress
Launching FatdogArm using vexpress kernel, with 1GB RAM
or
./qemu-fatdog-arm.sh realview
Launching FatdogArm using realview kernel, with 512MB RAM
- That's it! FatdogArm will boot straight to desktop. Depending on
your machine, however, you may need to be patient, as emulation is
slow ...
- To turn off, just use the power-off function from inside FatdogArm
as usual. At one point the screen will turn black showing the message
System Halted; at this stage you can break (Ctrl-C) the script that
launches FatdogArm. Sometimes Qemu can finish and exit by itself
without the Ctrl-C, sometimes you do need that Ctrl-C.
Saving your changes
When you shutdown your session, FatdogArm will ask you where to keep
the changes you made during the session - this includes the additional
programs you install, data that you download, etc.
If you don't want to save anything, just click Cancel.
This is only possible if you use an image file. If you don't, it will still
ask you but there is nowhere to save.
Networking and sound
- To enable network, just type
udhcpc -qi eth0
from a terminal inside
FatdogArm itself (it should be automatically be started anyway).
- If Qemu is compiled to support sound, you can output sound too,
for example type one of these:
aplay /usr/share/sounds/alsa/Front_Left.wav
speaker-test -t wav -c 2
in terminal (from within Qemu) and you should hear something.
Adjusting the screen size
- From the console, you can change the screen size by typing (for example):
to get 800x600 resolution. To see the available modes, check out
/etc/fb.modes
. Not all modes can be used.
- If you want to change the screen size for the graphical desktop,
create a text file in
/etc/X11/xorg.conf.d/
and called it
30-screen-size.conf
; and fill that newly created file with the
following:
Section "Screen"
Identifier "Default Screen"
SubSection "Display"
Depth 16
Modes "800×600" "640×480"
EndSubSection
EndSection
For that to take effect, you need to restart the desktop. Change "800x600"
to whatever resolution you wish (within reason).
Data transfer to/from FatdogArm
How to transfer data to/from the emulated FatdogArm? There are many ways -
here is one of the easier way of doing it.
- On FatdogArm (inside Qemu)
- On FatdogArm - lauch Control Panel, then choose the System tab.
- From the System tab, launch "Manage Servers and Services".
- From there, scroll down to the bottom and highlight "dropbear", then
click "Start".
- On the PC (host machine)
- Start gFTP (available from Network menu), or just type
gftp
from terminal.
- Enter localhost for Host, enter 2222 for Port,
enter root for User, and enter woofwoof for Pass
(or whatever you set FatdogArm's root password), and lastly set the
transfer type as SSH2.
- Click the big computer icon on the leftmost of the toolbar.
- If asked to verify the keys etc - click Yes.
- You are connected. You can upload/download files to/from FatdogArm
as needed.
- When done, just close gftp on the host and stop the dropbear
service on FatdogArm.
This instruction will also work on the FatdogArm running on real hardware,
not only Qemu. Instead of "localhost" and port "2222", use the real
machine's IP address and port "22". Everything else is the same.
Notes: Running directly from fd-arm.sfs
You can run the emulation directly using fd-arm.sfs
instead of creating
image file first, but you wouldn't be able to save any sessions (since
the SFS is read-only). To do this, you would need to "pad" the SFS into
a multiple of 256K. The following script will do so:
#!/bin/sh
# $1-path to original sfs
# $2-output (optional: ./fd-arm.sfs)
[ -z $1 ] && exit
INSFS=$1
OUTSFS=${2:-fd-arm.sfs}
ORIGSIZE=$(stat -c %s $INSFS)
BLOCKS256K=$(( ((ORIGSIZE/1024/256)+1) ))
#echo $ORIGSIZE $BLOCKS256K $((BLOCKS256K*256*1024))
cp $INSFS $OUTSFS
dd if=$INSFS of=$OUTSFS bs=256K seek=$BLOCKS256K count=0
Script to pad SFS to 256K boundary
and then launch qemu like this:
IMAGE=fd-arm.sfs ./qemu-fatdog-arm.sh vexpress basesfs=local:/
The modified SFS is still good and can still be used for use in image files or
for use in booting real hardware.
References
Running Puppy Arm for Raspberry Pi without Raspberry Pi.