From Qi-Hardware
Jump to: navigation, search

This is currently a work in progress. The objective is to make a reliable set of instructions that can be used to provide a directly bootable Emdebian system. See the "Further Work" section for areas of improvement.

Emdebian is a project that provides cross-compilation toolchains, tools for cross-building packages, and tools for making root filesystems for deployment on devices, particularly embedded devices with "foreign" architectures. Such tools permit the time-consuming and resource-intensive work of preparing a system image to be done on "normal" personal computers and workstations, with the finished result then being deployed on the target device.

Where Emdebian differs from other projects and toolchains is in its relationship to Debian. It is able to draw upon the extensive selection of Debian packages that are already available, up-to-date, and maintained for a selection of architectures. This means that it should be possible to benefit from the considerable effort invested in Debian packaging by the community and be able to obtain usable packages for specific technologies without being obliged to take on the work of tracking upstream development, dependency relationships, fixing portability issues, and performing packaging work just to be able to use some particular piece of software.


[edit] The Workflow

Making an installable Emdebian system involves the following steps:

  1. Obtain the necessary tools.
  2. Obtain a kernel image.
  3. Choose a suitable configuration.
  4. Prepare a root filesystem.
  5. Configure the installation.
  6. Format the boot medium.
  7. Complete the installation.
  8. Boot into the new system.

[edit] Obtaining the Tools

To prepare a root filesystem, the multistrap tool is needed. On Debian-based systems, this tool should be available from the usual package repository, and can thus be installed as follows:

apt-get install multistrap

Since multistrap is under active development, it may be the case that a later version of the tool is required. If this proves to be the case when following these instructions, you may need to enable the appropriate "backports" repository (using /etc/apt/sources.list and/or /etc/apt/sources.d), update the packaging system...

apt-get update

...and then try to install such a newer version. If no readily available newer version exists in a usable repository, you may need to backport the package from a later Debian release. Such an activity is currently outside the scope of this document, but the following package versions have been used for certain distributions:

Host Distribution Target Distribution Multistrap Version Notes
Debian Squeeze Emdebian Squeeze/Debian Squeeze 2.1.20 Source package obtained from Debian Sid (unstable) and built for Squeeze
Debian Squeeze Emdebian Wheezy-Grip/Debian Wheezy 2.1.22 Source package obtained from Debian Sid (unstable) and built for Squeeze

[edit] Downloads

The scripts and files related to this activity are provided in the following archive:


A repository also provides the scripts and files in their different versions.

[edit] Obtaining a Kernel Image

It can be easier to obtain an existing kernel image prepared by the OpenWrt-based toolchain, typically called openwrt-xburst-qi_lb60-uImage.bin and found in the software image release folders.

With the existing available kernels, there should be no need for any kernel modules to get started. However, the intention is to provide a more reliable way of obtaining the kernel and any additional modules using either the appropriate Debian packages or through other methods.

[edit] Choosing a Configuration

The multistrap package and documentation provide several example configurations. However, a specific configuration for the NanoNote should look like this for the Debian Squeeze release:

bootstrap=Grip Debian
aptsources=Grip Debian

packages=udev busybox-static


This minimal configuration installs a base system from Emdebian Grip packages, which should be smaller than conventional Debian packages, using such conventional packages for those which are not present in the Grip repository. In addition, the udev and busybox-static packages are added; this latter package is essential for the initial configuration of the system.

For Debian Wheezy, various details must be changed in the configuration and an example file is provided in the qi-emdebian distribution for guidance.

[edit] Preparing a Root Filesystem

With a suitable configuration file called, for example, multistrap-squeeze-mipsel.conf a root filesystem can be constructed in a location such as rootfs as follows. Note that you must be root or use sudo for this to work properly:

multistrap -f multistrap-squeeze-mipsel.conf -d rootfs

If this operation fails with errors related to repository public keys, you may need to install a newer version of multistrap as described above.

[edit] Configuring the Installation

On its own, multistrap does not provide all the files required for a running system. Moreover, a filesystem prepared by the tool will not be configured, and any attempt to boot into such a filesystem will probably fail. Thus, additional configuration must be performed.

[edit] Conventional Configuration Files

A number of configuration files, missing from the root filesystem, must be defined for the installation:

  • /etc/fstab
  • /etc/hostname
  • /etc/network/interfaces
  • /etc/resolv.conf

Such files can be placed in a directory called, for example, files while retaining the necessary filesystem structure, so that fstab would reside at files/etc/fstab, and so on. This reflects their typical locations in a real system.

[edit] Pre-Initialisation Files

Two additional files called preinit and preinit-config are required that "glue" the kernel to the Debian system on the first boot of the system. These files must reside in the current directory when running the script below. The preinit file is a convention apparently employed by the OpenWrt distribution used on the NanoNote, and where kernels from other origins are to be used, it is important that the appropriate conventions for invoking the system init program are followed. Thus, if you switch to a different kernel from another project, you may need to change the qi-emdebian-postsetup script to install these files into other locations, potentially giving them different names.

[edit] Running the Script

With the missing files now defined, a script written to automate the remaining configuration activity can be run as follows. Again, it may help to be root or to use sudo to be able to copy the necessary files into the root filesystem:

qi-emdebian-postsetup rootfs openwrt-xburst-qi_lb60-uImage.bin files

Here, rootfs is the root filesystem created above, openwrt-xburst-qi_lb60-uImage.bin is the kernel image obtained above, and files is the directory containing the missing configuration files.

[edit] Formatting the Boot Medium

Currently, only booting from a microSD card is described in these instructions. Eventually, installation to NAND may also be covered.

The microSD card should first be made available to the computer performing this work. On a Linux-based system, it should then appear as a device like /dev/sdb. You should check and make absolutely sure that you know which device has been assigned to the microSD card, perhaps using the dmesg command to see what is reported when plugging in the card. For example:

[25942.832101] sd 20:0:0:0: [sdb] Attached SCSI removable disk
[25942.832148] sd 20:0:0:0: Attached scsi generic sg2 type 0

With this information, you can now partition the card using fdisk. First, as root or using sudo, run the following to look for existing partitions:

fdisk -l /dev/sdb

If the microSD card already has partitions, you should check to see if they have been mounted by the system:


If so, you must first unmount the corresponding devices as follows (as root or using sudo):

umount /dev/sdb1

To preserve existing partitions, you can copy them from the card to your system as follows (as root or using sudo):

dd if=/dev/sdb1 of=sdb1.backup

To add a new partition, run fdisk, use the n command to make a primary partition, and then the w command to write the partition table. Since fdisk will probably suggest a reasonable start of a partition, perhaps the biggest concern is the size of the partition. Choosing +1024M to indicate a partition of 1024MB or 1GB is not unreasonable for modern microSD cards and current Emdebian installations.

It is also possible to accept the partition size suggested by fdisk and assign all the space on the card to a partition as well. This may not be sensible, however, since it may make some operations slower and hinder alternative uses for the space (like the creation of other partitions for purposes like backups).

[edit] Completing the Installation

With a partition in place (/dev/sdb1 in this case), you can now run the following helper script (as root or using sudo):

qi-emdebian-install rootfs /dev/sdb1 --mkfs

This will make a filesystem in the partition and copy the root filesystem to the card.

[edit] Booting into the New System

To boot into the newly prepared system, insert the microSD card into the NanoNote's card slot, then hold down the M key while pressing the power button. The device should now report that it is loading "/boot/uImage" from mmc device. With the conventional OpenWrt-based kernel, the boot splash-screen (or bootsplash) will take up most of the display, but messages will appear at the bottom of the screen.

If everything goes according to plan, a few minutes will be required for the configuration of the system to be done by the device - this is an issue with installing and booting Debian for the first time - but eventually, a message at the bottom of the screen should read something like...

(none) login:

This indicates that the system is now ready to allow you to log in. You should be able to do so as root without providing a password. It is then your responsibility to set a password using the passwd command.

[edit] Further Work

Things to be added include...

  • A selection of sample configuration files plus other files like hostname, group, and so on
  • Network configuration
  • A proper way of getting a kernel and modules (perhaps using Debian-centric methods)
  • Information about essential packages already provided by the existing software image
  • Package fixes, such as the use of integer-only libraries for Vorbis decoding, for example

The initial configuration process should be improved to give nicer visual feedback. Currently, the screen is cleared and the configuration activity is reported to the console. It might be convenient to allow interactivity using the usual curses-based textual user interface that Debian uses when configuring packages.

[edit] Initial Root Filesystems

Use of a separate initial root filesystem has been suggested. Installing a "normal" Debian ARMEL Linux on the Kindle provides one recipe for making such a filesystem. There is also a Debian package - initramfs-tools - which might be of interest, although it seems to be limited to copying files around for the same architecture. There is also a comparison between initramfs-tools and yaird. Another related tool is debirf.

[edit] Related Documents

A document somewhat similar to this one, but employing debootstrap is How to Cross Compile a Kernel and Create the Debian Root File Store. Another similar document describing an initial root filesystem is How to run Debian or Ubuntu GNU/Linux on your Android. And Creating an Initramfs also provides some useful hints.

Personal tools