Debian on APF
Page under construction... Informations on this page are not guaranteed !!
This page details how to install Debian on an APF27/APF28/APF51.
Contents
Requirements
- an APF board (with corresponding docking board)
- a development PC running linux
- the debootstrap program installed on the development PC
- the qemu-user ARM statically linked on the development PC
- about an hour of free time
Preparing the development PC
- In this tutorial, we have used Ubuntu 11.10 on the development PC. Any other distribution can be used with some adjustments but of course, Debian based distributions are recommended.
- Let's first install all the packages that will be used :
$ sudo apt-get install debootstrap qemu-user-static
- then get in a root shell and prepare a work folder:
$ sudo su # mkdir /root/apf_debian # cd /root/apf_debian
Bootstrapping the Debian filesystem
- The debootstrap command is generating a base debian filesystem by downloading all debian base packages and unpacking them in a folder, in order to build a fresh debian root filesystem.
- Installing deb packages is not only extracting archive files, it also consists in running scripts after unpacking the files. Running these scripts is handled by the script interpreters that have been unpacked in the generated folders. Therefore generating an ARM debian filesystem on an x86 based computer requires to do this in two steps.
- Let's run the first step. That one consists in downloading all the deb packages and unpacking the files, but without running the scripts :
# debootstrap --foreign --arch=armel squeeze rootfs http://ftp.debian.org/debian
- The foreign option makes debootstrap stop right after unpacking. The arch option specifies the architecture we want to make a rootfs for, armel is the name of the ARM port of debian. Then in order we have squeeze, which is the name of the debian version we want to get, currently squeeze is the stable version. Then rootfs is the name of the subfolder where debootstrap will work. Finally the URL of the debian mirror we want to use (you can use another one which sits in your country, to make it faster).
- This process takes a while, it will download all the debian base packages from the mirror and unpack them in the rootfs folder.
- The next step is to run the second stage of debootstrap. That stage consists in finalizing the installation of the package by running the scripts I mentionned. Since these scripts will be executed using the interpreter who is in the new filesystem, and not by the interpreter from your development PC, we are now facing a problem : The interpreter in that new filesystem is an ARM program, and won't run on an x86 system. To overcome this, we will make use of qemu, who allows to run foreign architecture Linux programs by doing emulation.
- First, we need to copy the qemu binary into the new filesystem :
# cp /usr/bin/qemu-arm-static rootfs/usr/bin
- Then we can launch the second stage of debootstrap, qemu will automatically let it run the ARM binaries through qemu :
# DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C chroot rootfs debootstrap/debootstrap --second-stage
- This process also takes a while, it will run the scripts of each package, in order to finalize the packages installation.
Tweaking the filesystem
- After the filesystem has been generated by debootstrap, some adjustments need to be done.
- First, we need to have debian run a getty on the console serial port (ttymxc2 on APF51, ttySMX0 on APF27), otherwise no login prompt will be available on the console port :
# echo 'T0:23:respawn:/sbin/getty -L ttymxc2 115200 vt100' >> rootfs/etc/inittab
- The debian mirror also has to be specified in the APT configuration, in order to install new debian packages later :
# echo 'deb http://ftp.debian.org/debian squeeze main' > rootfs/etc/apt/sources.list
- The hostname of the debian system has to be set properly (here apf51, change it accordingly to your board):
# echo 'apf51' > rootfs/etc/hostname # echo '127.0.1.1 apf51' >> rootfs/etc/hosts
- Remove root password (for first logins):
# sed -i -e 's/root:\*:/root::/' rootfs/etc/shadow
- Finally we can clean the APT cache. We no longer need the deb files, and that will save quite some disk space :
# rm rootfs/var/cache/apt/archives/*.deb
Copying the filesystem on the APF
- Now that the debian filesystem is ready, it must be transferred to the APF.
- This tutorial will describe a method that will allow to keep the original Armadeus system on the board, and that will permit to choose which system to boot very easily. It is not the only way to run Debian on the APF, but it is quite convinient.
- You need to have an APF51 running the Buildroot based original system.
- The first step is to pack the debian filesystem that has been created on the development PC:
# tar cvf debian_arm_rootfs.tar rootfs
- You will end up with a ~150 MBytes tarball
- Then this archive should be transfered to the APF51 board. You can use a USB key or a microSD for example. (or TFTP if you have a lot of free space on your APF NAND; then Pput the file in /root on the APF)
- Now, on the APF, the archive should be extracted (from the media holding it to the APF NAND FLASH). Don't forget the p option of tar, which is required to properly extract permissions on files :
# cd /root # tar xvpf debian_arm_rootfs.tar
- We will boot this distribution using chroot. We need to write a script that will be run by the kernel on startup and that will do the chroot at an early stage of the boot process, so that nothing from the original armadeus system is started when we want to boot debian. To do this, create a file called /debinit that contains the following lines :
#!/bin/sh mount -t proc none /root/rootfs/proc exec chroot /root/rootfs /sbin/init
- This script needs to be executable :
# chmod 755 /debinit
- Kernel modules and firmware files need to be copied from the Armadeus system to the debian filesystem :
# cp -r /lib/modules/* /root/rootfs/lib/modules # cp -r /lib/firmware /root/rootfs/lib/firmware # chroot /root/rootfs /sbin/depmod -a
- Finally, we need to configure U-Boot so it tells the kernel to use that script on bootup. Reboot your board, press a key to interrupt the automatic boot in U-Boot, then do :
BIOS> setenv debboot 'setenv addubifsargs ${addubifsargs} init=/debinit; run ubifsboot' BIOS> saveenv
- That's all. Now you board will keep booting the original system but if you want to boot debian instead, you can interrupt the autoboot of U-Boot and run the command :
BIOS> run debboot
- In case you want the board to boot debian automatically, you can do so by running :
BIOS> setenv bootcmd run debboot BIOS> saveenv
- You can then switch back to the original Armadeus system by running :
BIOS> setenv bootcmd run ubifsboot BIOS> saveenv
First login
Whaoouh ! It booted ! ;-)
Debian GNU/Linux 6.0 apfxx ttySMX0/ttymxc2 apfxx login:
- Login as root with no password
- Update packages:
root@apfxx:~# apt-get update
- Setup system and RTC date:
root@apf51:~# date 012011552010 Wed Jan 20 11:55:00 UTC 2010 root@apf51:~# hwclock -wu
- If you don't have any RTC chip on your development board then it could be a good idea to install ntpdate and use it:
root@apf51:~# apt-get install ntpdate ... root@apf51:~# ntpdate-debian
- Change root password:
root@apfxx:~# passwd
- If you want an X server (requires ~90MBytes of free space):
root@apf51:~# aptitude install xserver-xfbdev
Known issues
APF27
- Xorg won't start. (compatibility problem with framebuffer driver)
APF51
- There's a kernel oops during the boot process. This is related to the SPI driver.
- Booting takes quite some time because udev has an issue with the SPI port and it takes some time before it timeouts and continues the boot.
Console Port Issues
In some cases the boot crashes and errors like these appear
init: Id "T0" respawning too fast: disabled for 5 minutes
It means that the /dev folder haven't been populated with your console serial port.
To fix this, you need to reboot the apf and run armadeus system, then you need to do the following commands :
# cp -r /dev/ttymxc0 /root/rootfs/dev/ttymxc0 (for apf51) # cp -r /dev/ttySMX0 /root/rootfs/dev/ttySMX0 (for apf27)
You also need to check that the file /root/rootfs/etc/securetty contains the console serial port (ttymxc0 for APF51 and ttySMX0 for APF27) if not :
# echo 'ttymxc0' >> /root/rootfs/etc/securetty (for apf51) # echo 'ttySMX0' >> /root/rootfs/etc/securetty (for apf27)
It will allow the root user to login via this serial console.
It could also affects other ports and you will need to do the same procedure for them (ttyX, fbX, input, ttymxcX, ttySMXX, etc.)