Linux Arm on Qemu

Reference:

Preparation

sudo apt-get install qemu
sudo apt-get install uboot-mkimage

http://www.codesourcery.com/sgpp/lite/arm/portal/subscription?@template=lite

(gcc version 4.4.1 (Sourcery G++ Lite 2010q1-188)

Build Linux Kernal

http://kernel.org/

version: linux-2.6.35.tar.gz

make ARCH=arm versatile_defconfig
make ARCH=arm menuconfig

enable eabi menu options

kernel Features -->
Memory split (3G/1G user/kernel split) --->
[ ] Preemptible Kernel (EXPERIMENTAL)
[*] Use the ARM EABI to compile the kernel
[*] Allow old ABI binaries to run with this kernel (EXPERIMENTAL)
[ ] High Memory Support (EXPERIMENTAL)
      Memory model (Flat Memory) --->
[ ] Add LRU list to track non-evictable pages
(4096) Low address space to protect from user allocation

make kernel

make ARCH=arm CROSS_COMPILE=arm-linux- all
qemu-system-arm -M versatilepb -m 128M -kernel zImage

Build Busybox file system

(to be verified)

If it can not pass build, usually it is because the version of crosstool (gcc/glib) is not correct.

make ARCH=arm CROSS_COMPILE=arm-linux- defconfig
make ARCH=arm CROSS_COMPILE=arm-linux- menuconfig
Busybox Settings --> Build Options -->
[*] Build BusyBox as a static binary (no shared libs)
[ ] Force NOMMU build
  [*] Build with Large File Support (for accessing files > 2 GB)
  ()  Cross Compiler prefix
  ()  Additional CFLAGS
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- install

this will generate an _install directory:

cd _install
mkdir proc sys dev etc etc/init.d
cd ..

create the file _install/etc/init.d/rcS

#!/bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
/sbin/mdev -s

and change it to executable:

chmod +x _install/etc/init.d/rcS
cd _install
find . | cpio -o --format=newc > ../rootfs.img
cd ..
gzip -c rootfs.img > rootfs.img.gz
qemu-system-arm -M versatilepb -m 128M -kernel zImage -initrd rootfs.img.gz -append "root=/dev/ram rdinit=/sbin/init"

Build U-Boot

ftp://ftp.denx.de/pub/u-boot/u-boot-2010.03.tar.bz2

diff -rupN u-boot-2010.03.orig/common/image.c u-boot-2010.03/common/image.c
--- u-boot-2010.03.orig/common/image.c  2010-03-31 23:54:39.000000000 +0200
+++ u-boot-2010.03/common/image.c       2010-04-12 15:42:15.911858000 +0200
@@ -941,7 +941,7 @@ int boot_get_ramdisk (int argc, char *ar
                        return 1;
                }

-#if defined(CONFIG_B2) || defined(CONFIG_EVB4510) || defined(CONFIG_ARMADILLO)
+#if defined(CONFIG_B2) || defined(CONFIG_EVB4510) || defined(CONFIG_ARMADILLO) || defined(CONFIG_VERSATILE)
                /*
                 * We need to copy the ramdisk to SRAM to let Linux boot
                 */

or comments out above #if line

diff -rupN u-boot-2010.03.orig/include/configs/versatile.h u-boot-2010.03/include/configs/versatile.h
--- u-boot-2010.03.orig/include/configs/versatile.h     2010-03-31 23:54:39.000000000 +0200
+++ u-boot-2010.03/include/configs/versatile.h  2010-04-12 15:43:01.514733000 +0200
@@ -124,8 +124,11 @@
 #define CONFIG_BOOTP_SUBNETMASK

 #define CONFIG_BOOTDELAY       2
-#define CONFIG_BOOTARGS                "root=/dev/nfs mem=128M ip=dhcp "\
-                               "netdev=25,0,0xf1010000,0xf1010010,eth0"
+/*#define CONFIG_BOOTARGS              "root=/dev/nfs mem=128M ip=dhcp "\
+                               "netdev=25,0,0xf1010000,0xf1010010,eth0"*/
+#define CONFIG_BOOTARGS                "root=/dev/ram mem=128M rdinit=/sbin/init"
+#define CONFIG_BOOTCOMMAND   "bootm 0x210000 0x410000"
+#define CONFIG_INITRD_TAG   1

 /*
  * Static configuration when assigning fixed address

make CROSS_COMPILE=arm-none-eabi- versatilepb_config
make CROSS_COMPILE=arm-none-eabi- all
mkimage -A arm -C none -O linux -T kernel -d zImage -a 0x00010000 -e 0x00010000 zImage.uimg
mkimage -A arm -C none -O linux -T ramdisk -d rootfs.img.gz -a 0x00800000 -e 0x00800000 rootfs.uimg
dd if=/dev/zero of=flash.bin bs=1 count=6M
dd if=u-boot.bin of=flash.bin conv=notrunc bs=1
dd if=zImage.uimg of=flash.bin conv=notrunc bs=1 seek=2M
dd if=rootfs.uimg of=flash.bin conv=notrunc bs=1 seek=4M
qemu-system-arm -M versatilepb -m 128M -kernel flash.bin -serial stdio
Wiki comments powered by Disqus