Archive

Posts Tagged ‘L4Linux’

L4Linux Patch for MV643xx Ethernet

April 12, 2012 2 comments

A while ago I posted a tutorial on how to run Linux virtualized on top of L4 on the Sheevaplug. But one problem with the solution is that Sheevaplug’s hardware components (e.g. network, sd-card, etc.) aren’t working out of the box. In the menuconfig of L4Linux you can’t even select the driver (…for L4 architecture). So for all who want to run L4Linux on the Sheevaplug and want to use the physical network interface, this patch is for you mv643xx.patch. Copy the patch beside your ‘L4Linux’ folder and call

patch -p0 < mv643xx_eth.patch

to patch your Linux tree. Then enable

Device Drivers -->
    Network device support -->
        Ethernet (1000 Mbit) -->
            Marvell Discovery (643XX) and Orion ethernet support

in your ‘menuconfig’ and use the following configuration when you build your L4 image (at least the *.io file)

modules.list:

modaddr 0x01100000

entry L4Linux ARM
kernel fiasco -serial_esc
roottask moe rom/l4lx.cfg
module l4re
module ned
module l4lx.cfg
module io
module arm-sheevaplug.io
module vmlinuz.arm
module ramdisk.rd

arm-sheevaplug.io:

hw-root
{
  NIC => new Device()
  {
    .hid = "mv643xx"; 
    new-res Mmio(0xF1000000 .. 0xF100FFFF);
    new-res Mmio(0xF1020000 .. 0xF102FFFF);
    new-res Mmio(0xF1070000 .. 0xF107FFFF);
    new-res Irq(46);
    new-res Irq(11);
  }

  DMA => new Device()
  {
    .hid = "dmamem";
    new-res Mmio_ram(8388608,0);
  }
}

l4lx_bus => new System_bus()
{
  DMA => wrap(hw-root.DMA);
  NIC => wrap(hw-root.NIC);
}

l4lx.cfg:

-- vim:set ft=lua:

require("L4");

local io_caps = {
    sigma0 = L4.cast(L4.Proto.Factory, L4.Env.sigma0):create(L4.Proto.Sigma0);
    l4lx_bus = L4.default_loader:new_channel():svr();
    icu = L4.Env.icu;
};

local linux_caps = {
    log  = L4.Env.log:m("rws"),
    vbus = io_caps.l4lx_bus    
};

L4.default_loader:start(
{
    caps = io_caps,
    log = { "io", "blue" }
}, "rom/io -vvv rom/arm-sheevaplug.io");

L4.default_loader:start(
{
    caps = linux_caps,
    log = {"l4linux", "yellow"},
    l4re_dbg = L4.Dbg.Warn
}, "rom/vmlinuz.arm mem=64M console=ttyLv0 l4x_rd=rom/ramdisk.rd \
root=1:0 ramdisk_size=11000 rw");

Depending on the name/size of your ramdisk you have to adapt the parameters in the config files.

The patch is tested and working, I’m using the device every day. But sometimes L4Linux jumps into the debugger JDB with the message ‘IRET returned’, I’m not 100% sure if the problem arises from my patch but could be. When this happens, restarting the device is your only chance. When you are in the debugger hit ‘^^’ twice to restart.
Leave a comment when you have questions about the patch…

Have fun!

Advertisements
Categories: tech foo Tags: , , , ,

L4 versus the world and sheevaplug

November 25, 2011 Leave a comment

The Story

For my master thesis I work with the L4 microkernel and it should run on the Sheevaplug. Sheevaplug is a small plug computer with an ARMv5TE with 1.2Ghz, 512MByte Ram and 512MByte Flash for the operating system.
L4 is a small Microkernel developed at the Technical University of Dresden, which allows to run operating systems on top of it, in a virtualized environment.

Setup chroot with debootstrap

Original: http://wiki.debian.org/Debootstrap
I’m working on a Laptop with Ubuntu 11.04 on it, and since I had some problems building the L4 stuff on it, I’m using a chroot environment which runs Debian Squeeze 32Bit. To setup this toolchain you have to follow these steps

  1. Open a shell and install debootstrap, sudo apt-get install debootstrap
  2. Call the following commands to create the new chroot
    sudo su
    cd /opt
    mkdir squeeze_chroot
    debootstrap --arch i386 squeeze squeeze_chroot http://ftp.us.debian.org/debian

    It takes some time until the chroot is created. When it’s done call the following commands still as root to get procfs and sysfs in your chroot

    echo "proc /opt/squeeze_chroot/proc proc defaults 0 0" >> /etc/fstab
    mount proc /opt/squeeze_chroot/proc -t proc
    echo "sysfs /opt/squeeze_chroot/sys sysfs defaults 0 0" >> /etc/fstab
    mount sysfs /opt/squeeze_chroot/sys -t sysfs
    cp /etc/hosts /opt/squeeze_chroot/etc/hosts
  3. When everything is setup you can change into your newly created chroot by calling chroot /opt/squeeze_chroot /bin/bash
  4. !!!Everything that follows, is executed in the chroot, we do not use the main system anymore!!!
  5. Cross Compiling Toolchain

    Now that we are done setting up the chroot, it’s time to install our toolchain. The Sheevaplug is an ARM based device, thus we need a cross compiling toolchain. But don’t be scared the days are over where you have to compile your toolchain. With EmDebian, the Debian project provides a repository with a ready to use arm toolchain.

  6. Add the following line to your /etc/apt/sources.list file
    deb http://www.emdebian.org/debian/ squeeze main
  7. Now you should be able to install all tools you need, by running apt-get install gcc-4.4-arm-linux-gnueabi g++-4.4-arm-linux-gnueabi binutils-arm-linux-gnueabi
  8. Now we have to set some softlinks so that our build scripts later can find the toolchain
    ln -s /usr/bin/arm-linux-gnueabi-ar /usr/bin/arm-linux-ar
    ln -s /usr/bin/arm-linux-gnueabi-as /usr/bin/arm-linux-as
    ln -s /usr/bin/arm-linux-gnueabi-cpp /usr/bin/arm-linux-cpp
    ln -s /usr/bin/arm-linux-gnueabi-g++ /usr/bin/arm-linux-g++
    ln -s /usr/bin/arm-linux-gnueabi-gcc /usr/bin/arm-linux-gcc
    ln -s /usr/bin/arm-linux-gnueabi-ld /usr/bin/arm-linux-ld
    ln -s /usr/bin/arm-linux-gnueabi-nm /usr/bin/arm-linux-nm
    ln -s /usr/bin/arm-linux-gnueabi-objcopy /usr/bin/arm-linux-objcopy
    ln -s /usr/bin/arm-linux-gnueabi-objdump /usr/bin/arm-linux-objdump
    ln -s /usr/bin/arm-linux-gnueabi-ranlib /usr/bin/arm-linux-ranlib
    ln -s /usr/bin/arm-linux-gnueabi-readelf /usr/bin/arm-linux-readelf
    ln -s /usr/bin/arm-linux-gnueabi-strip /usr/bin/arm-linux-strip
  9. That’s it the cross compiling toolchain is setup… easy right?!

Get L4re + Fiasco + L4Linux

Before we can build the L4 kernel we need some software

  1. Call apt-get install make gawk g++ binutils pkg-config subversion uboot-mkimage to get the software we need to build L4.
  2. Now that we have installed svn we can checkout the L4 repository, change to /opt and call svn cat http://svn.tudos.org/repos/oc/tudos/trunk/repomgr | perl - init http://svn.tudos.org/repos/oc/tudos fiasco l4re to check out the L4re.
  3. Then change into the newly checked out ‘src’ directory and call
    svn co http://svn.tudos.org/repos/oc/l4linux/trunk l4linux
  4. In addition to the L4RE, Fiasco and L4Linux we need some modules that are not in the default ‘checkout’. Change into the directory /opt/src/l4/pkg and call
    svn update drivers l4re_vfs libloader loader shmc drivers-frst l4sys libsigma0 log sigma0 acpica fb-drv l4util libstdc++-headers lua uclibc boehm_gc hello ldscripts libstdc++-v3 lxfuxlibc uclibc-headers bootstrap input ldso libstdc++-v3-minimal mag uclibc-minimal crtn io libc_backends libsupc++ mag-gfx x86emu cxx l4re libio-io libsupc++-minimal moe cxx_libc_io l4re_c libirq libvbus ned cxx_thread l4re_kernel libkproxy libvcpu rtc

    It is very important to have all these packets, otherwise the L4Linux will not build/run. When you want to check which additional packets are available you can browse the repository with your webbrowser. The url is

    http://svn.tudos.org/repos/oc/tudos/trunk/l4/pkg/
  5. One thing we still need is a ramdisk, get the latest one from the website of TU Dresden, by executing wget -O /tmp/ramdisk-arm.rd http://os.inf.tu-dresden.de/download/ramdisk-arm.rd
  6. Now we have everything we need and can go to the next chapter…

Building L4Re, the runtime environment

First of all we build the L4Re which is necessary for all following steps.

cd /opt/src/l4
make B=/opt/arm/l4re
make O=/opt/arm/l4re config
# Set 'Target architecture' to 'ARM architecture'
# and 'CPU variant' to 'ARMv5TE type CPU'
make O=/opt/arm/l4re

Building Fiasco, the L4 microkernel

Now it’s time to build the L4 microkernel, just type the following commands

cd /opt/src/kernel/fiasco
make BUILDDIR=/opt/arm/fiasco'
cd /opt/arm/fiasco
make config
# Change 'Architecture' to 'ARM processor family'
# and 'Platform' to 'Marvell Kirkwood platform'
make

Building L4Linux, the Linux Kernel (3.0.0)

Finally we have to build the Linux kernel

cd /opt/src/l4linux
mkdir /opt/arm/l4linux
make L4ARCH=arm O=/opt/arm/l4linux arm_defconfig
make L4ARCH=arm O=/opt/arm/l4linux menuconfig
# Go to 'L4Linux configuration' and set 'L4 tree build directory'
# to '/opt/arm/l4re' !!!IMPORTANT!!!
export CROSS_COMPILE=arm-linux-
export ARCH=arm
export L4ARCH=arm
make O=/opt/arm/l4linux

Building a bootable Image

Now its time to create an image that can be booted via U-Boot on the Sheevaplug.

  1. Before we can create our image we have to edit the file /opt/src/l4/conf/modules.list, attach the following line to the entry L4Linux ARM. Without this entry we aren’t able to use the keyboard later when the L4Linux has booted
    entry L4Linux ARM
    kernel fiasco -serial_esc
    roottask moe rom/l4lx.cfg
    module l4re
    module ned
    module l4lx.cfg
    module io
    module arm-rv.io
    module vmlinuz.arm
    module ramdisk-arm.rd
  2. Now we are ready to build our image. Change into the directory /opt/arm/l4re and call the following command to create a U-Boot bootable image

    make image E="L4Linux ARM" BOOTSTRAP_DO_UIMAGE=y SUPPORT_CC_arm-kirkwood=y MODULE_SEARCH_PATH=/opt/arm/fiasco:/opt/src/l4/conf/examples:/opt/arm/l4linux:/tmp

    It’s important that the ramdisk we downloaded in a previous step is still in the folder /tmp

  3. The generated image can be found under /opt/arm/l4re/pkg/bootstrap/server/src/OBJ-arm_armv5te. The name of the image is bootstrap_L4Linux_ARM.uimage

Booting an image on the Sheevaplug

Now it’s time to leave our chroot, all following steps are made in the main host system!!!

  1. First install libftdi1 by calling sudo apt-get install libftdi-dev. We need this library to have access to the serial interface of the sheevaplug. Also install screen a useful terminal application (sudo apt-get install screen)
  2. Format an USB stick to Fat32. And copy the image we created in the previous chapter (bootstrap_l4linux_arm.uimage) to the root of the stick, cp /opt/squeeze_chroot/opt/arm/l4re/pkg/bootstrap/server/src/OBJ-arm_armv5te/bootstrap_L4Linux_ARM.uimage /media/usbstick.
  3. Then put the stick into the Sheevaplug.
  4. Connect the Sheevaplug with your computer via the MiniUSB USB cable.
  5. Open a terminal and create a softlink, ln -s /dev/ttyUSB0 /dev/ttyUSB1. This is necessary to get access to the JTAG interface of the Sheevaplug and not the simple serial console.
  6. Now oyu can start screen, with the following command screen /dev/ttyUSB1 115200
  7. Start the Sheevaplug device and hit any key to interrupt the normal bootup. Now execute the following commands one after another
    usb start
    fatls usb 0:1 /
    # Should give a list of files on the USB stick
    fatload usb 0:1 0x00800000 /bootstrap_l4linux_arm.uimage
    bootm 0x00800000
  8. Now the L4 Microkernel should boot, and afterwards the L4Linux should also boot.
  9. The Endi…

    Now you can play with a fully virtualized Linux on top of the L4 microkernel. When you want to debug something you can hit the ESC-key to go into the L4 debugger mode. When you want to leave it again hit the q-key and then Enter. To get additional information hit the h-key and then Enter.
    Heave fun!

Categories: tech foo Tags: , , ,