1 {{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.}}
2
3 [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.
4
5 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.
6
7 == The Workflow ==
8
9 Making an installable Emdebian system involves the following steps:
10
11 # Obtain the necessary tools.
12 # Obtain a kernel image.
13 # Choose a suitable configuration.
14 # Prepare a root filesystem.
15 # Configure the installation.
16 # Format the boot medium.
17 # Complete the installation.
18 # Boot into the new system.
19
20 === Obtaining the Tools ===
21
22 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:
23
24 apt-get install multistrap
25
26 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...
27
28 apt-get update
29
30 ...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.
31
32 ==== Downloads ====
33
34 The scripts and files related to this activity are provided in the following archive:
35
36 [[File:Qi-emdebian.tar.gz]]
37
38 A [http://hgweb.boddie.org.uk/qi-emdebian repository] also provides the scripts and files in their different versions.
39
40 === Obtaining a Kernel Image ===
41
42 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].
43
44 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.
45
46 === Choosing a Configuration ===
47
48 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:
49
50 <pre>
51 [General]
52 arch=mipsel
53 cleanup=true
54 noauth=false
55 bootstrap=Grip Debian
56 aptsources=Grip Debian
57
58 [Grip]
59 packages=udev busybox-static
60 source=http://www.emdebian.org/grip
61 keyring=emdebian-archive-keyring
62 suite=squeeze
63
64 [Debian]
65 packages=
66 source=http://ftp.debian.org/debian
67 keyring=debian-archive-keyring
68 suite=squeeze
69 </pre>
70
71 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.
72
73 === Preparing a Root Filesystem ===
74
75 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:
76
77 multistrap -f multistrap-squeeze-mipsel.conf -d rootfs
78
79 If this operation fails with errors related to repository public keys, you may need to install a newer version of multistrap as described above.
80
81 === Configuring the Installation ===
82
83 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.
84
85 ==== Conventional Configuration Files ====
86
87 A number of configuration files, missing from the root filesystem, must be defined for the installation:
88
89 * <code>/etc/fstab</code>
90 * <code>/etc/network/interfaces</code>
91
92 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.
93
94 ==== Pre-initialisation Files ====
95
96 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.
97
98 ==== Running the Script ====
99
100 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:
101
102 qi-emdebian-postsetup rootfs openwrt-xburst-qi_lb60-uImage.bin configfiles
103
104 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.
105
106 === Formatting the Boot Medium ===
107
108 Currently, only booting from a microSD card is described in these instructions. Eventually, installation to NAND may also be covered.
109
110 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:
111
112 <pre>
113 [25942.832101] sd 20:0:0:0: [sdb] Attached SCSI removable disk
114 [25942.832148] sd 20:0:0:0: Attached scsi generic sg2 type 0
115 </pre>
116
117 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:
118
119 fdisk -l /dev/sdb
120
121 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.
122
123 === Completing the Installation ===
124
125 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>):
126
127 qi-emdebian-install rootfs /dev/sdb1 --mkfs
128
129 This will make a filesystem in the partition and copy the root filesystem to the card.
130
131 === Booting into the New System ===
132
133 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.
134
135 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...
136
137 (none) login:
138
139 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.
140
141 == Further Work ==
142
143 Things to be added include...
144
145 * A selection of sample configuration files plus other files like hostname, group, and so on
146 * Network configuration
147 * A proper way of getting a kernel and modules (perhaps using Debian-centric methods)
148 * Information about essential packages already provided by the existing [[OpenWrt Software Image|software image]]
149 * Package fixes, such as the use of integer-only libraries for Vorbis decoding, for example
150
151 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.
152
153 === Initial Root Filesystems ===
154
155 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].
156
157 === Related Documents ===
158
159 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.
160
161 [[Category:Ben NanoNote]]