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 Jessie release:
49
50 <pre>
51 [General]
52 arch=mipsel
53 cleanup=true
54 noauth=false
55 bootstrap=Debian
56 aptsources=Debian
57
58 [Debian]
59 packages=udev busybox-static
60 source=http://ftp.debian.org/debian
61 keyring=debian-archive-keyring
62 suite=jessie
63 </pre>
64
65 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 <code>udev</code> and <code>busybox-static</code> 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 [http://hgweb.boddie.org.uk/qi-emdebian/file qi-emdebian distribution] for guidance.
66
67 === Preparing a Root Filesystem ===
68
69 With a suitable configuration file called, for example, <code>multistrap-jessie-mipsel.conf</code> a root filesystem can be constructed in a location such as <code>rootfs</code> as follows. Note that you must be <code>root</code> or use <code>sudo</code> for this to work properly. Multistrap may ask for elevated privileges.
70
71 multistrap -f multistrap-jessie-mipsel.conf -d rootfs
72
73 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 <code>conf</code> directory in the qi-emdebian distribution.
74
75 === Configuring the Installation ===
76
77 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.
78
79 ==== Conventional Configuration Files ====
80
81 A number of configuration files, missing from the root filesystem, must be defined for the installation:
82
83 * <code>/etc/fstab</code>
84 * <code>/etc/hostname</code>
85 * <code>/etc/network/interfaces</code>
86 * <code>/etc/resolv.conf</code>
87
88 Such files can be placed in a directory called, for example, <code>files</code> while retaining the necessary filesystem structure, so that <code>fstab</code> would reside at <code>files/etc/fstab</code>, and so on. This reflects their typical locations in a real system.
89
90 ==== Pre-Initialisation Files ====
91
92 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. The <code>preinit</code> 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 <code>init</code> program are followed. Thus, if you switch to a different kernel from another project, you may need to change the <code>qi-emdebian-postsetup</code> script to install these files into other locations, potentially giving them different names.
93
94 ==== Running the Script ====
95
96 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:
97
98 qi-emdebian-postsetup rootfs openwrt-xburst-qi_lb60-uImage.bin files
99
100 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>files</code> is the directory containing the missing configuration files.
101
102 === Formatting the Boot Medium ===
103
104 Currently, only booting from a microSD card is described in these instructions. Eventually, installation to NAND may also be covered.
105
106 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:
107
108 <pre>
109 [25942.832101] sd 20:0:0:0: [sdb] Attached SCSI removable disk
110 [25942.832148] sd 20:0:0:0: Attached scsi generic sg2 type 0
111 </pre>
112
113 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:
114
115 fdisk -l /dev/sdb
116
117 If the microSD card already has partitions, you should check to see if they have been mounted by the system:
118
119 mount
120
121 If so, you must first unmount the corresponding devices as follows (as <code>root</code> or using <code>sudo</code>):
122
123 umount /dev/sdb1
124
125 To preserve existing partitions, you can copy them from the card to your system as follows (as <code>root</code> or using <code>sudo</code>):
126
127 dd if=/dev/sdb1 of=sdb1.backup
128
129 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. Since <code>fdisk</code> will probably suggest a reasonable start of a partition, perhaps the biggest concern is the size of the partition. Choosing <code>+1024M</code> to indicate a partition of 1024MB or 1GB is not unreasonable for modern microSD cards and current Emdebian installations.
130
131 It is also possible to accept the partition size suggested by <code>fdisk</code> 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).
132
133 ==== Swap Partition ====
134
135 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.
136
137 If you create a swap partition, be sure to edit the <code>files/etc/fstab</code> file and to remove the comment marker for the line describing the <code>swap</code> partition.
138
139 === Completing the Installation ===
140
141 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>):
142
143 qi-emdebian-install rootfs /dev/sdb1 --mkfs
144
145 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):
146
147 eject sdb
148
149 === Booting into the New System ===
150
151 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.
152
153 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...
154
155 nanonote login:
156
157 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.
158
159 === Further Configuration ===
160
161 To set the clock to a UTC time, run the following command:
162
163 date -u -s '2015-06-17 13:08:00'
164
165 To set the time zone, run the following:
166
167 dpkg-reconfigure tzdata
168
169 It may be easier to run this command via a secure shell (ssh) connection to the NanoNote from a computer with a larger screen.
170
171 To set up a default locale or to change the locales and their settings, install the appropriate package and reconfigure it:
172
173 apt-get install locales
174 dpkg-reconfigure locales
175
176 == Further Work ==
177
178 Things to be added include...
179
180 * A selection of sample configuration files plus other files like hostname, group, and so on
181 * Network configuration
182 * A proper way of getting a kernel and modules (perhaps using Debian-centric methods)
183 * Information about essential packages already provided by the existing [[OpenWrt Software Image|software image]]
184 * Package fixes, such as the use of integer-only libraries for Vorbis decoding, for example
185
186 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.
187
188 === Initial Root Filesystems ===
189
190 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/jessie/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/jessie/debirf debirf].
191
192 === Related Documents ===
193
194 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.
195
196 [[Category:Ben NanoNote]]