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 traditionally provided 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. Many of the things developed under the Emdebian umbrella are now provided in Debian itself, and thus Emdebian is no longer really distinct from Debian and is certainly not a separate distribution (as it once was).

The approach cultivated by Emdebian is to draw upon the extensive selection of Debian packages that are already available, up-to-date, and maintained for a selection of architectures, rather than to cross-build an entire distribution from scratch and either offer a monolithic result or one which offers less sophisticated methods for managing the deployed software. By building on Debian, 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.

[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 Jessie release:


packages=udev busybox-static

This minimal configuration installs a base system from Debian packages. (Previously, qi-emdebian used special Emdebian Grip packages which were meant to be smaller than conventional Debian packages, but the Emdebian project considered the effort of producing such packages for an arguably marginal benefit to be a costly distraction from other work.) In addition, the udev and busybox-static packages are added; this latter package is essential for the initial configuration of the system. Various other packages may be needed in practice, and so example files for various distributions are provided in the qi-emdebian distribution for guidance.

It is important to note that for Debian Jessie, systemd provides the init system. Where older kernels are used on the NanoNote, such as the default OpenWrt kernels, this will most likely cause the system to hang when booting because systemd requires kernel features that were not previously enabled. One solution is to specify sysvinit-core in the package list, thus continuing the use of the init system previously enabled by default in Debian.

[edit] Preparing a Root Filesystem

With a suitable configuration file called, for example, multistrap-jessie-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 may ask for elevated privileges.

multistrap -f multistrap-jessie-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. A selection of configuration files can be found in the conf directory in the qi-emdebian distribution.

[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.

It is important to realise that due to the state of various essential packages as deployed by multistrap, the init system cannot be run immediately: not even the default shell is configured at initial boot. Consequently, a means of running a shell is required for the package configuration process, and only then may the init process be started. The solution to this configuration problem is provided by installing the busybox package and having the shell it provides be the one to run the pre-initialisation scripts.

[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] Swap Partition

Debian programs can use a lot of memory - more than the 32MB of program memory that the NanoNote has available - and so it becomes necessary to allocate additional swap memory so that all running programs can fit in memory. Making a swap partition is largely the same process as that described above for the root partition, but it is likely that you will want to choose a much smaller size. 128M is likely to be enough for the NanoNote: anything larger is probably entertaining a misplaced belief that the computer is powerful to efficiently run the kinds of programs needing such larger amounts of memory.

If you create a swap partition, be sure to edit the files/etc/fstab file and to remove the comment marker for the line describing the swap partition.

[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. You should then eject the card as follows (adjusting for the appropriate device name):

eject sdb

[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...

nanonote 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 Configuration

To set the clock to a UTC time, run the following command:

date -u -s '2015-06-17 13:08:00'

To set the time zone, run the following:

dpkg-reconfigure tzdata

It may be easier to run this command via a secure shell (ssh) connection to the NanoNote from a computer with a larger screen.

To set up a default locale or to change the locales and their settings, install the appropriate package and reconfigure it:

apt-get install locales
dpkg-reconfigure locales

[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