Note : here is the previous version of this page, for Debian Jessie

Note : instead of the following steps of cross-deboostrap, Debian Stretch can also be installed via this installer and an HDMI display and an USB keyboard.

My little ARM board from Olimex :

A20-OLinuXino-LIME2 Rev C. (no NAND, no eMMC)
CPU: Allwinner A20 dual core CORTEX-A7
RAM: 1 Go, eth 1 Gb/s

a20-olinuxino-lime2.jpg

Olimex provides nice ready-to-use Debian images for this board. They even provides howtos for rebuilding these images. But for various reasons I ended up installing instead a pristine Debian Jessie (8.6) on it. Even if this board is supported by Debian, the installation wasn't so easy, since I didn't manage to get the HDMI output to work with Jessie. After reading the Debian wiki, this was rather expected, and not a big issue for my use of this board (lightweight server). But a blind installation is another story : I lack any suitable serial cable (such as this one), and my attempt at a remote Debian install over ssh failed miserably (bad preseed.cfg ?). In case it might help others, here comes the steps I finally followed for this installation, now updated to Debian Stretch (9.6).

Disclaimer

The steps worked for me, but as usual with this kind of tutorial, your mileage may vary. Since we'll install to a micro-SD card (and hence reformat it!), any data on this card will be lost, so be sure to have backups before proceeding. Now, the good news : if something goes wrong it's quite easy to put this SD card on another machine and restore what you want on it (official image, previous backup, etc).

Reference

Prerequisite

  • a micro-SD card of at least 1Gb, with no valuable data on it. Beware! any data on it will be lost during formatting!.
  • a Debian Stretch machine with a SD-card reader. No need for an ARM machine, amd64 or i386 is fine since we'll finalize the debootstrap phase via qemu. Let's call this machine the “host”. Most of the steps below will have to be performed as root.

Steps

  1. On the host machine, we'll need a static version of qemu:
    apt-get install binfmt-support qemu-user-static
  2. On the host machine, insert the SD card, and create two partitions on it, one for /boot (about 100Mb), the other for / (all the remaining space). For instance, here's what fdisk /dev/mmcblk0 tells me after this step:
    Device         Boot  Start      End  Sectors  Size Id Type
    /dev/mmcblk0p1 *      2048   239615   237568  116M 83 Linux
    /dev/mmcblk0p2      239616 15523839 15284224  7,3G 83 Linux
  3. Refresh the partition table and format these new partitions:
    partprobe /dev/mmcblk0  # cf. the 'parted' package 
    mkfs.ext3 /dev/mmcblk0p1
    mkfs.ext4 /dev/mmcblk0p2
  4. Mount these partitions somewhere on the host. Here, we'll use /mnt and hence /mnt/boot:
    mount /dev/mmcblk0p2 /mnt
    mkdir /mnt/boot
    mount /dev/mmcblk0p1 /mnt/boot
  5. Debootstrap, part 1 (pick a convenient mirror):
    MIRROR=http://ftp.fr.debian.org/debian/
    debootstrap --arch=armhf --foreign stretch /mnt $MIRROR
  6. Debootstrap, part 2, via chroot and qemu:
    export DEBIAN_FRONTEND=noninteractive
    export DEBCONF_NONINTERACTIVE_SEEN=true
    export LC_ALL=C
    cp /usr/bin/qemu-arm-static /mnt/usr/bin
    chroot /mnt /debootstrap/debootstrap --second-stage
    chroot /mnt dpkg --configure -a
  7. Let's add some more packages:
    chroot /mnt apt install -y ssh flash-kernel u-boot-tools u-boot-sunxi
  8. A bit of sysadmin:
    chroot /mnt passwd  ##your olimex's root password
    nano /mnt/etc/hostname  ##your olimex's hostname
    mkdir /mnt/root/.ssh
    nano /mnt/root/.ssh/authorized_keys ##some ssh public key allowed to log as root
  9. Edit /mnt/etc/network/interfaces with something like:
    auto eth0
    allow-hotplug eth0
    iface eth0 inet dhcp
    iface eth0 inet6 auto
  10. Edit /mnt/etc/fstab:
    /dev/mmcblk0p2 /     ext4 defaults 0 1
    /dev/mmcblk0p1 /boot ext3 defaults 0 2
    proc /proc proc defaults 0 0
  11. To avoid errors during the final build of the initrd, we need to hack a bit with device nodes:
    mknod /mnt/dev/mmcblk0 b 179 0
    mknod /mnt/dev/mmcblk0p1 b 179 1
    mknod /mnt/dev/mmcblk0p2 b 179 2
  12. Set the machine kind for the flash-kernel tool, and add a console=tty1 to the kernel command-line:
    echo "Olimex A20-OLinuXino-LIME2" > /mnt/etc/flash-kernel/machine
    sed -i -e "s/quiet/quiet console=tty1/" /mnt/etc/default/flash-kernel
  13. Install the u-boot loader:
    dd if=/mnt/usr/lib/u-boot/A20-OLinuXino-Lime2/u-boot-sunxi-with-spl.bin of=/dev/mmcblk0 bs=1k seek=8
  14. Install a kernel and populate the boot directory:
    chroot /mnt apt-get install -y linux-image-armmp
  15. Check that the previous step has created files such as /mnt/boot/boot.scr and /mnt/boot/dtb. If not, you can try manually a chroot /mnt flash-kernel.
  16. Unmount /mnt/boot and /mnt, eject your SD-card from the host machine.
  17. Boot your Olimex Lime2 with this SD-card, cross your fingers, locate its IP and try to log via something like ssh root@192.168.X.Y.
  • The Mac address is generated at each boot, you might want to fix it by some startup script.