qi-emdebian

Changeset

3:7943d4498eb5
2012-11-25 Paul Boddie raw files shortlog changelog graph Added a copy of the Wiki page describing this work.
README.txt (file)
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/README.txt	Sun Nov 25 20:59:36 2012 +0100
     1.3 @@ -0,0 +1,161 @@
     1.4 +{{infobox|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|"Further Work"]] section for areas of improvement.}}
     1.5 +
     1.6 +[http://www.emdebian.org/ 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.
     1.7 +
     1.8 +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.
     1.9 +
    1.10 +== The Workflow ==
    1.11 +
    1.12 +Making an installable Emdebian system involves the following steps:
    1.13 +
    1.14 +# Obtain the necessary tools.
    1.15 +# Obtain a kernel image.
    1.16 +# Choose a suitable configuration.
    1.17 +# Prepare a root filesystem.
    1.18 +# Configure the installation.
    1.19 +# Format the boot medium.
    1.20 +# Complete the installation.
    1.21 +# Boot into the new system.
    1.22 +
    1.23 +=== Obtaining the Tools ===
    1.24 +
    1.25 +To prepare a root filesystem, the [http://wiki.debian.org/Multistrap 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:
    1.26 +
    1.27 + apt-get install multistrap
    1.28 +
    1.29 +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 <code>/etc/apt/sources.list</code> and/or <code>/etc/apt/sources.d</code>), update the packaging system...
    1.30 +
    1.31 + apt-get update
    1.32 +
    1.33 +...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.
    1.34 +
    1.35 +==== Downloads ====
    1.36 +
    1.37 +The scripts and files related to this activity are provided in the following archive:
    1.38 +
    1.39 +[[File:Qi-emdebian.tar.gz]]
    1.40 +
    1.41 +A [http://hgweb.boddie.org.uk/qi-emdebian repository] also provides the scripts and files in their different versions.
    1.42 +
    1.43 +=== Obtaining a Kernel Image ===
    1.44 +
    1.45 +It can be easier to obtain an existing kernel image prepared by the [[Building Software Image|OpenWrt-based toolchain]], typically called <code>openwrt-xburst-qi_lb60-uImage.bin</code> and found in the [http://downloads.qi-hardware.com/software/images/NanoNote/Ben/ software image release folders].
    1.46 +
    1.47 +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.
    1.48 +
    1.49 +=== Choosing a Configuration ===
    1.50 +
    1.51 +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:
    1.52 +
    1.53 +<pre>
    1.54 +[General]
    1.55 +arch=mipsel
    1.56 +cleanup=true
    1.57 +noauth=false
    1.58 +bootstrap=Grip Debian
    1.59 +aptsources=Grip Debian
    1.60 +
    1.61 +[Grip]
    1.62 +packages=udev busybox-static
    1.63 +source=http://www.emdebian.org/grip
    1.64 +keyring=emdebian-archive-keyring
    1.65 +suite=squeeze
    1.66 +
    1.67 +[Debian]
    1.68 +packages=
    1.69 +source=http://ftp.debian.org/debian
    1.70 +keyring=debian-archive-keyring
    1.71 +suite=squeeze
    1.72 +</pre>
    1.73 +
    1.74 +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 <code>udev</code> and <code>busybox-static</code> packages are added; this latter package is essential for the initial configuration of the system.
    1.75 +
    1.76 +=== Preparing a Root Filesystem ===
    1.77 +
    1.78 +With a suitable configuration file called, for example, <code>multistrap-squeeze-mipsel.conf</code> a root filesystem can be constructed in a location such as <code>rootfs</code> as follows. Note that you should really be <code>root</code> or use <code>sudo</code> for this to work properly:
    1.79 +
    1.80 + multistrap -f multistrap-squeeze-mipsel.conf -d rootfs
    1.81 +
    1.82 +If this operation fails with errors related to repository public keys, you may need to install a newer version of multistrap as described above.
    1.83 +
    1.84 +=== Configuring the Installation ===
    1.85 +
    1.86 +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.
    1.87 +
    1.88 +==== Conventional Configuration Files ====
    1.89 +
    1.90 +A number of configuration files, missing from the root filesystem, must be defined for the installation:
    1.91 +
    1.92 +* <code>/etc/fstab</code>
    1.93 +* <code>/etc/network/interfaces</code>
    1.94 +
    1.95 +Such files can be placed in a directory called, for example, <code>configfiles</code> while retaining the necessary filesystem structure, so that <code>fstab</code> would reside at <code>configfiles/etc/fstab</code>, and so on. This reflects their typical locations in a real system.
    1.96 +
    1.97 +==== Pre-initialisation Files ====
    1.98 +
    1.99 +Two additional files called <code>preinit</code> and <code>preinit-config</code> 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.
   1.100 +
   1.101 +==== Running the Script ====
   1.102 +
   1.103 +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 <code>root</code> or to use <code>sudo</code> to be able to copy the necessary files into the root filesystem:
   1.104 +
   1.105 + qi-emdebian-postsetup rootfs openwrt-xburst-qi_lb60-uImage.bin configfiles
   1.106 +
   1.107 +Here, <code>rootfs</code> is the root filesystem created above, <code>openwrt-xburst-qi_lb60-uImage.bin</code> is the kernel image obtained above, and <code>configfiles</code> is the directory containing the missing configuration files.
   1.108 +
   1.109 +=== Formatting the Boot Medium ===
   1.110 +
   1.111 +Currently, only booting from a microSD card is described in these instructions. Eventually, installation to NAND may also be covered.
   1.112 +
   1.113 +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 <code>/dev/sdb</code>. You should check and '''make absolutely sure''' that you know which device has been assigned to the microSD card, perhaps using the <code>dmesg</code> command to see what is reported when plugging in the card. For example:
   1.114 +
   1.115 +<pre>
   1.116 +[25942.832101] sd 20:0:0:0: [sdb] Attached SCSI removable disk
   1.117 +[25942.832148] sd 20:0:0:0: Attached scsi generic sg2 type 0
   1.118 +</pre>
   1.119 +
   1.120 +With this information, you can now partition the card using <code>fdisk</code>. First, as <code>root</code> or using <code>sudo</code>, run the following to look for existing partitions:
   1.121 +
   1.122 + fdisk -l /dev/sdb
   1.123 +
   1.124 +To add a new partition, run <code>fdisk</code>, use the <code>n</code> command to make a primary partition, and then the <code>w</code> command to write the partition table.
   1.125 +
   1.126 +=== Completing the Installation ===
   1.127 +
   1.128 +With a partition in place (<code>/dev/sdb1</code> in this case), you can now run the following helper script (as <code>root</code> or using <code>sudo</code>):
   1.129 +
   1.130 + qi-emdebian-install rootfs /dev/sdb1 --mkfs
   1.131 +
   1.132 +This will make a filesystem in the partition and copy the root filesystem to the card.
   1.133 +
   1.134 +=== Booting into the New System ===
   1.135 +
   1.136 +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 <code>"/boot/uImage" from mmc device</code>. 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.
   1.137 +
   1.138 +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...
   1.139 +
   1.140 + (none) login:
   1.141 +
   1.142 +This indicates that the system is now ready to allow you to log in. You should be able to do so as <code>root</code> without providing a password. It is then your responsibility to set a password using the <code>passwd</code> command.
   1.143 +
   1.144 +== Further Work ==
   1.145 +
   1.146 +Things to be added include...
   1.147 +
   1.148 +* A selection of sample configuration files plus other files like hostname, group, and so on
   1.149 +* Network configuration
   1.150 +* A proper way of getting a kernel and modules (perhaps using Debian-centric methods)
   1.151 +* Information about essential packages already provided by the existing [[OpenWrt Software Image|software image]]
   1.152 +* Package fixes, such as the use of integer-only libraries for Vorbis decoding, for example
   1.153 +
   1.154 +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.
   1.155 +
   1.156 +=== Initial Root Filesystems ===
   1.157 +
   1.158 +Use of a separate [http://www.kernel.org/doc/Documentation/initrd.txt initial root filesystem] has been suggested. [http://www.mobileread.com/forums/showthread.php?t=99021 Installing a "normal" Debian ARMEL Linux on the Kindle] provides one recipe for making such a filesystem. There is also a Debian package - [http://packages.debian.org/squeeze/initramfs-tools initramfs-tools] - which might be of interest, although it seems to be limited to copying files around for the same architecture. There is also [http://wiki.debian.org/InitrdReplacementOptions a comparison] between initramfs-tools and [http://packages.debian.org/sid/yaird yaird]. Another related tool is [http://packages.debian.org/squeeze/debirf debirf].
   1.159 +
   1.160 +=== Related Documents ===
   1.161 +
   1.162 +A document somewhat similar to this one, but employing debootstrap is [http://foxg20old.acmesystems.it/doku.php?id=debian:how_to_cross_compile_a_kernel_and_create_the_debian_root_file_store How to Cross Compile a Kernel and Create the Debian Root File Store]. Another similar document describing an initial root filesystem is [http://whiteboard.ping.se/Android/Debian How to run Debian or Ubuntu GNU/Linux on your Android]. And [http://cblfs.cross-lfs.org/index.php/Creating_an_Initramfs Creating an Initramfs] also provides some useful hints.
   1.163 +
   1.164 +[[Category:Ben NanoNote]]