===== Olimex A20-OLinuXino-LIME2 and Debian Stretch ===== **Note** : here is the [[lime2-jessie|previous version of this page, for Debian Jessie]] **Note** : instead of the following steps of cross-deboostrap, Debian Stretch can also be installed via {{https://wiki.debian.org/InstallingDebianOn/Allwinner#Installing_from_an_SD_card_image|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 {{https://www.olimex.com/Products/OLinuXino/A20/A20-OLinuXIno-LIME2/images/thumbs/310x230/A20-OLinuXino-LIME2.jpg}} Olimex provides nice [[https://www.olimex.com/wiki/A20-OLinuXino-LIME2#Official_Images_from_OLIMEX|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 [[https://wiki.debian.org/InstallingDebianOn/Allwinner#Supported_Platforms|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 [[https://www.olimex.com/Products/Components/Cables/USB-Serial-Cable/USB-Serial-Cable-F/|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=== * [[https://wiki.debian.org/InstallingDebianOn/Allwinner|Installing Debian On Allwinner]] * [[https://wiki.debian.org/EmDebian/CrossDebootstrap#QEMU.2Fdebootstrap_approach|CrossDebootstrap]] ===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=== - On the host machine, we'll need a static version of qemu: apt-get install binfmt-support qemu-user-static - 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 - Refresh the partition table and format these new partitions: partprobe /dev/mmcblk0 # cf. the 'parted' package mkfs.ext3 /dev/mmcblk0p1 mkfs.ext4 /dev/mmcblk0p2 - 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 - Debootstrap, part 1 (pick a convenient mirror): MIRROR=http://ftp.fr.debian.org/debian/ debootstrap --arch=armhf --foreign stretch /mnt $MIRROR - 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 - Let's add some more packages: chroot /mnt apt install -y ssh flash-kernel u-boot-tools u-boot-sunxi - 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 - Edit ''/mnt/etc/network/interfaces'' with something like: auto eth0 allow-hotplug eth0 iface eth0 inet dhcp iface eth0 inet6 auto - Edit ''/mnt/etc/fstab'': /dev/mmcblk0p2 / ext4 defaults 0 1 /dev/mmcblk0p1 /boot ext3 defaults 0 2 proc /proc proc defaults 0 0 - 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 - 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 - 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 - Install a kernel and populate the ''boot'' directory: chroot /mnt apt-get install -y linux-image-armmp - 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''. - Unmount ''/mnt/boot'' and ''/mnt'', eject your SD-card from the host machine. - 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''. ==== Notes / Troubleshooting ==== * If you suffer from slow network, see [[https://github.com/OLIMEX/OLINUXINO/issues/31]]. I followed [[https://www.olimex.com/forum/index.php?topic=4615.msg21541#msg21541|these instructions]] with success (v2016.03 tag + 5 cherry-picked commits). * The Mac address is generated at each boot, you might want to fix it by some startup script.