CreatingAGenerici386PlaformForMIC

Add support for a generic i386 platform to Moblin Image Creator (MIC)

Since when the UME project was started I have been looking forward to the introduction of support for a generic i386 platform. While the image creator tool is being actively developed, the primary focus for the project are the new mobile and embedded platforms that came out recently, as Adilson Oliveira from Canonical stated in one recent post in the ubuntu-mobile mailing list:

Canonical sponsors the development of this project but we have to keep the focus to what this project was created for: UMPC-type machines as you noticed.

As a result, building an image for a generic platform has always been possible, but the needed configuration files have not been produced by the UME developer(s). This what this page is all about.

The following is a list of actions to perform in order to be able to enable MIC to build a generic (Gutsy) Ubuntu image.

Download and familiarize with MIC

The primary repository for the source and binary packages is:

http://www.moblin.org/build-results/tools/moblin-image-creator/lpia/

The Image Creator currently allows you to create an image for a Samsung Q1 Ultra* with no modifications. For sake of precision, it allows the creation of an image for the following supported platform:

The basic concept and feature of MIC are described in the moblin site and others; since a physical device is not needed to see the results of the image build, you can start by using the “officially” supported platform, being the mccaslin-lpia the preferred one.

Explore MIC configuration files

Once MIC has been installed, you will be able to start understanding a little bit of the functionalities by inspecting the configuration files – and the Python source files as well. These files are saved under /usr/share/pdk on the host computer; this is the listing of the files and directories installed by MIC:

$ls -l /usr/share/pdk
total 196
-rw-r--r-- 1 root root    481 2008-01-04 21:07 add.png
drwxr-xr-x 2 root root   4096 2008-01-07 10:51 debootstrap-scripts
drwxr-xr-x 2 root root   4096 2008-01-14 17:30 default_config
-rw-r--r-- 1 root root   1579 2008-01-04 21:07 delete.png
drwxr-xr-x 3 root root   4096 2007-11-14 11:03 gnome
-rw-r--r-- 1 root root   1374 2008-01-04 21:07 gnome-terminal.png
-rw-r--r-- 1 root root   2552 2007-11-03 02:28 image-creator-32x32.xcf
-rw-r--r-- 1 root root   1278 2007-11-03 02:28 image-creator-32x32.xpm
-rw-r--r-- 1 root root 132555 2008-01-04 21:07 image-creator.glade
drwxr-xr-x 2 root root   4096 2008-01-15 09:50 lib
drwxr-xr-x 2 root root   4096 2007-11-14 09:38 locale
drwxr-xr-x 9 root root   4096 2008-01-09 15:28 platforms
drwxr-xr-x 2 root root   4096 2008-01-09 15:46 projects
-rw-r--r-- 1 root root     99 2007-11-03 02:28 README
drwxr-xr-x 2 root root   4096 2008-01-07 10:51 utils
-rw-r--r-- 1 root root     52 2008-01-04 21:07 version

Several locations are quite relevant to accomplish the project task, namely the “default_config” and “platforms” directories. The “lib” directory contains the python source files.

Create a generic i386 platform

The default “platform” directory, has the following content:

drwxr-xr-x 5 root root 4096 2008-01-07 10:51 mccaslin-lpia
drwxr-xr-x 4 root root 4096 2007-12-14 16:28 mccaslin-lpia-fedora
drwxr-xr-x 5 root root 4096 2008-01-07 10:51 mccaslin-lpia-ubuntu-hardy
drwxr-xr-x 5 root root 4096 2008-01-07 10:51 menlow-lpia
drwxr-xr-x 5 root root 4096 2008-01-07 10:51 menlow-lpia-ubuntu-hardy
-rw-r--r-- 1 root root  967 2008-01-09 15:32 platforms.cfg

We need to create a new “i386” platform by copying the “mccaslin-lpia” directory, i.e.:

$ sudo cp -R  mccaslin-lpia i386 

and then start modifying some configuration files to enable the default ubuntu repositories and architecture to be used by MIC.

Point to ubuntu default repositories

cd i386/sources
sudo rm moblin.org.list
sudo nano ubuntu.org.list

and copy the following lines in the new file:

deb http://archive.ubuntu.com/ubuntu/ gutsy main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ gutsy-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ gutsy-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ gutsy-security universe main multiverse restricted
deb http://archive.canonical.com/ubuntu gutsy partner

Create some basic fsets

The default “feature sets” defined for the LPIA platforms contains several definitions that will not apply to a generic i386 platform. I have trimmed down the fsets to the following:

$ sudo nano base.fset

erase everything and copy the following lines only:

[Core]
DESC=Fundamental fset that provide a basic console based system
PKGS=grub ubuntu-minimal usplash-theme-ubuntu pm-utils vbetool
DEPS=

[i386-Image]
DESC=Packages needed for the i386 platform (Generic i386)
PKGS=linux-image
DEPS=core

Then create some custom fsets to suit your need:

$ sudo nano custom.fset

As an example this is my fset allowing it allows a basic X11+fluxbox Ubuntu system to be built:

[Generic-X11]
DESC=Minimal X11 packages set
PKGS=xorg fluxbox

Set default parameters for the new platform

Some required information related to the platform are saved in a configuration file saved in /usr/share/pdk/default_config. We need to include some details about our new platform there:

$ sudo nano /usr/share/pdk/default_config/defaults.cfg

Add the following lines:

[platform.i386]
buildroot_mirror =  http://archive.ubuntu.com/ubuntu/
buildroot_codename = gutsy
architecture=i386

to the section "Ubuntu Platforms"

Have the new platform used by MIC

The configuration files for the generic platform are in place; now MIC has to be made aware of the new platform. This is achieved by adding the following lines to the platform config file: /usr/share/pdk/platforms/platforms.cfg.

[i386]
description = Generic i386 architecture using Ubuntu Hardy
package_manager = apt
target_os = ubuntu

Start creating your images!

Deal done! You now have a new generic i386 Ubuntu Gusty platform. Playing with fsets a little bit will allow building some ad-hoc systems; MIC is currently able to build read-only live USB image files, r/w USB image files and install USB image files (for installation from a bootable USB disk to a fixed hard disk in target system).

Final remarks

Assuming the disk image is finally created, lots of people will find troubles when booting off a PC from an USB flash disk. Google will be your best friend for this, but I would like to mention that a small modification to the MIC config files we have just created will allow an easier approach to preparing an USB boot disk.

One of the key scripts that gets executed by the image upon booting is located in /usr/share/pdk/platforms/i386/initramfs. Open the file “usb” and locate the following lines:

    echo "will mount root from /dev/${device}"

    mount -o rw /dev/${device} /container 2> /dev/null

    while [ ! -e "/container/rootfs.img" ]; do
        /bin/sleep 0.5
        mount -o rw /dev/${device} /container 2> /dev/null
    done

These lines are responsible for mounting the root file system image file via a loop device. The script identifies the USB flash disks available and expect that there are no partitions on the disk (i.e. it mounts /dev/sda). Unfortunately the common procedure both in Windows and in Linux for creating bootable USB disks is to create a primary partition (e.g /dev/sda1), hence you may find yourself in trouble since the script will loop if you have the image files stored in a partition – the script will enter an loop endless loop and the boot process hangs.

A quick hack to cope with this is to modify the above lines this way:

    echo "will mount root from /dev/${device} or /dev/${device}1"

    mount -o rw /dev/${device} /container 2> /dev/null
    mount -o rw /dev/${device}1 /container 2> /dev/null

    while [ ! -e "/container/rootfs.img" ]; do
        /bin/sleep 0.5
        mount -o rw /dev/${device} /container 2> /dev/null
        mount -o rw /dev/${device}1 /container 2> /dev/null
    done

This way both cases are supported and there will be less chances to face a show-stopper.


CategoryUME

CreatingAGenerici386PlaformForMIC (last edited 2008-08-06 16:21:22 by localhost)