RedSleeve Wikia

Host system[]

WARNING! Information in the article may become out of date.
New QEMU (v > 1.5.x) has completely different console support under Windows.

This article was written with "host-independence" in mind. Any system which can run QEMU may be used as a host: any sort of Linux (Ubuntu, SuSe e.t.c.) and even Windows with Cygwin or MinGW.

CentOS or Scientific Linux are recommended for sources and SRPM compatibility with RedSleeve.

QEMU[]

QEMU is a system emulator supporting ARM architecture (among many others). QEMU is widely used as a low-level driver for virtualization platform such as XEN and KVM. To avoid interference with "system" QEMU only minimal ARM version shoul be installed.

Download an QEMU sources from the http://wiki.qemu.org/Download and extract it

./configure --target-list="arm-softmmu" --disable-strip --disable-xen \
            --disable-kvm --disable-user --disable-docs

make
make install

This will install /usr/local/bin/qemu-system-arm and other QEMU tools.

Precompiles Windows binaries (w32 and w64) are available on the http://qemu.weilnetz.de/

Another approach (not discusse in this article) is to integrate QEMU/ARM emulator into virtualization infrastructure. See Fedora ARM HowToQemu.

JFYI: QEMU reaches about 1/10 of the host speed, Core2 Duo E7500 @2.93GHz provides ~400MHz ARM926EJ-S CPU.

Target platform[]

QEMU ARM emulates a wide list of ARM machines and CPUs, including devboard, PDAs and others.

/usr/local/bin/qemu-system-arm -M ?
Supported machines are:
z2                   Zipit Z2 (PXA27x)
xilinx-zynq-a9       Xilinx Zynq Platform Baseboard for Cortex-A9
vexpress-a9          ARM Versatile Express for Cortex-A9
vexpress-a15         ARM Versatile Express for Cortex-A15
versatilepb          ARM Versatile/PB (ARM926EJ-S)
versatileab          ARM Versatile/AB (ARM926EJ-S)
...
...

One popular platform is an ARM Versatile Platform Baseboard with ARM926EJ-S CPU. It provides rich set of periprerals includiing AMBA Bus and AHB controllers includind PL031 realtime clock, PL011 UART (/dev/ttyAMA0) e.t.c. QEMU emulates most of VersatilePB devices including SYM895a SCSI adapter in the PCI slot, Versatile CLDC VGA-like framebuffer and SMC91C11 ethernet.

Linux on QEMU[]

Aurelien Jarno kindly provides a precompiled kernels, initrd and disk images for the Debian on the Versatile PB :

http://people.debian.org/~aurel32/qemu/armel/

This distributive is used as "bootstrap" starting point to create a RS root filesystem on a QEMU disk. Grab these files:

  • vmlinuz-2.6.32-5-versatile
  • initrd.img-2.6.32-5-versatile
  • debian_squeeze_armel_standard.qcow2

Preparing a RS disk image[]

Crate a new empty disk image:

qemu-img create -f qcow2 redsleeve_armel_rootfs.qcow2 16G

Download a big RS rootfs archive and store it into a new folder (rs/).

Create a CD-ROM ISO image containing this rootfs file:

mkisofs -J -R -o rsel6-rootfs.iso rs/

Start a QEMU with Aurelien's kernel and three images:

  • Debian rootfs as /dev/sda
  • New empty disk as /dev/sdb
  • CD-ROM containing rootfs archive as /dev/cdrom
qemu-system-arm -M versatilepb -kernel vmlinuz-2.6.32-5-versatile -initrd initrd.img-2.6.32-5-versatile \
                -hda debian_squeeze_armel_standard.qcow2 \
                -hdb redsleeve_armel_rootfs.qcow2 \
                -cdrom rsel6-rootfs.iso \
                -nographic -append "root=/dev/sda1 console=ttyAMA0"

The login/password is root/root. You have working ARM Debian Linux now.

Make partitions on the new disk:

fdisk -H 255 -S 63 /dev/sdb
...
Command (m for help): p

Disk /dev/sdb: 17.2 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x484c09cc

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        2027    16281846   83  Linux
/dev/sdb2            2028        2088      489982+  82  Linux swap / Solaris

Format a new disk:

mkfs.ext3 /dev/sdb1
mkswap /dev/sdb2

Mount CD-ROM and new disk

mkdir /mnt/cdrom
mkdir /mnt/disk
mount /dev/cdrom /mnt/cdrom
mount /dev/sdb1 /mnt/disk

Extract rootfs onto the new disk

cd /mnt/disk/
tar --strip-components 1 -xJf /mnt/cdrom/rsel6-rootfs-big.tar.xz
cd /
umount /mnt/disk

Exit from QEMU with CTRL-a x

Booting and configuring RS[]

Boot a RS with bash as an init

qemu-system-arm -M versatilepb -kernel vmlinuz-2.6.32-5-versatile -initrd initrd.img-2.6.32-5-versatile \
               -hda redsleeve_armel_rootfs.qcow2 -nographic \
               -append "root=/dev/sda1 console=ttyAMA0 init=/bin/bash"

Remount root as read/write

mount -o rw,remount /

Edit /etc/fstab

vim /etc/fstab
/dev/sda1       /               ext3    defaults                1 1
/dev/sda2       swap            swap    defaults                0 0

Disable unneeded daemons:

ntsysv

Remove all mmc stuff from the rc.local

vim /etc/rc.d/rc.local

In RHEL6, init from the sysvinit package has been replaced with Upstart, an event-based init system.

rm /etc/init/kexec-disable.conf
mv /etc/init/serial.conf /root

Create a new config file to run getty on the /dev/ttyAMA0

vim /etc/init/ttyAMA.conf
#
start on stopped rc RUNLEVEL=[2345]
stop on starting runlevel [016]

respawn

pre-start exec /sbin/securetty ttyAMA0
exec /sbin/agetty -L /dev/ttyAMA0 9600 vt102

(*)The /etc/init/start-ttys.conf and /etc/init/tty.conf files are for the framebuffer console.

Run QEMU with fresh new RedSleeve system

qemu-system-arm -M versatilepb -kernel vmlinuz-2.6.32-5-versatile -initrd initrd.img-2.6.32-5-versatile \
                -hda redsleeve_armel_rootfs.qcow2 -nographic \
                -append "root=/dev/sda1 console=ttyAMA0"

Login/password is root/password

Networking[]

Firts of all, extract kernel modules from the Debian image. Run QEMU with second drive:

 qemu-system-arm ... -hdb debian_squeeze_armel_standard.qcow2 ..
mkdir /mnt/disk
mount /dev/sdb1 /mnt/disk
cp -R /mnt/disk/lib/modules/2.6.32-5-versatile /lib/modules/2.6.32-5-versatile

Load an ethernet driver

modprobe smc91x

Create /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=52:54:00:12:34:56
ONBOOT=yes
TYPE=ethernet
USERCTL=no
PEERDNS=no

Disable IPV6 in the /etc/sysctl.conf

net.ipv6.conf.all.disable_ipv6 = 1

Restart network subsystem

/etc/rc.d/init.d/network restart

By default QEMU emulates network in "user" mode acting as NAT/Firewall with DHCP, DNS and SMB servers

Setup a DNS server /etc/resolv.conf

nameserver 10.0.2.3

To configure QEMU firewall to redirect incoming connection to the RS add :

qemu-system-arm ... -redir tcp:50022::22 -redir tcp:50080::80 ...

More information:

http://wiki.qemu.org/Documentation/Networking

http://en.wikibooks.org/wiki/QEMU/Networking

http://people.gnome.org/~markmc/qemu-networking.html

Graphics[]

QEMU for VersatileBP also emulates framebuffer and input devices. The Keyboard and Mouse Interfaces (KMI) are implemented with two PrimeCells PL050 incorporated into the system controller FPGA. The framebuffer Color LCD Controller (CLCD) is implemented with PrimeCell PL110.

CLCD: Versatile hardware, VGA display
Console: switching to colour frame buffer device 80x30
mice: PS/2 mouse device common for all mice
input: AT Raw Set 2 keyboard as /devices/fpga:06/serio0/input/input0
input: ImExPS/2 Generic Explorer Mouse as /devices/fpga:07/serio1/input/input1

Linux supports CLCDC as standatd Linux framebuffer. Run RS with framebuffer console (delete -nographic and console=ttyAMA0):

qemu-system-arm -M versatilepb -kernel vmlinuz-2.6.32-5-versatile -initrd initrd.img-2.6.32-5-versatile \
                -hda redsleeve_armel_rootfs.qcow2 \
                -serial stdio \
                -vnc 0.0.0.0:0 -append "root=/dev/sda1"

QEMU opens VNC on the 127.0.0.1 by default, -vnc 0.0.0.0:0 enables incoming connections for all interfeces. Then, quicky connect to your QEMU with VNC client, screen :0 (open port 5900 on the firewall). Use ALT+F2 ALT+Fx to switch between framebuffer screens. The -serial stdio enables /dev/ttyAMA0 and getty on the QEMU stdio (Linux only, see a -serial QEMU option).

Another option is to use SDL.

(*) This disables QEMU monitor interface and CTRL+A x does not work anymore. Use killall qemu-system-arm or configure a -monitor QEMU option.

X.Org Server also supports Linux framebuffer as fbdev device.

RedSleeve "big" rootfs has X-Server and KDE preconfigured for the FBdev. Just run X session :

startx

Sound[]

TODO

USB[]

To add an USB controller :

qemu-system-arm -M versatilepb ... -usb ...

This optin will attach an USB controller to the VersatilePB PCI bus

lspci
00:0c.0 USB Controller: Apple Computer Inc. KeyLargo/Intrepid USB
...
lsusb
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
...

To add an USB tablet (useful for QEMU VNC mouse pointer sychronization )

qemu-system-arm -M versatilepb ... -usb -usbdevice wacom-tablet -show-cursor ...

Other ARM machines[]

TODO