Debian 10 on Cubox

WARNING: this will wipe all data on the target SD card.

To install Debian 10 on the SolidRun CuBox (1st version, Marvell Armada 510 based):

  1. Create 2 partitions on your SD card (eg. using fdisk): the 1st one of type ext4 with size ~200MB for boot and the 2nd of type f2fs for the system (WARNING: this will wipe all data on the target SD card.):

    ~# fdisk /dev/mmcblk0
    ~# mkfs.ext4 /dev/mmcblk0p1
    ~# mkfs.f2fs /dev/mmcblk0p2
  2. Mount the partitions locally:

    ~# mkdir /tmp/cubox
    ~# mount /dev/mmcblk0p2 /tmp/cubox
    ~# mkdir /tmp/cubox/boot
    ~# mount /dev/mmcblk0p1 /tmp/cubox/boot
  3. Install Debian: we need to do it in 2 steps, and we'll use qemu ARM userspace emulator to finalize:

    ~# debootstrap --foreign --arch=armhf buster /mnt/
    ~# cp /usr/bin/qemu-arm-static /tmp/cubox/usr/bin/
    ~# chroot /tmp/cubox
    ~# /debootstrap/debootstrap --second-stage
    ~# apt install linux-image-armmp u-boot-tools
    ~# cat > /etc/initramfs-tools/modules << EOF
    ~# update-initramfs -u
  4. Prepare everything for U-Boot (note: you'll have to do that each time you update your kernel/initrd - it is a good idea to put it in a script you can run after updates):

    ~# TMPFILE="$(mktemp)"
    ~# cat > "$TMPFILE" << EOF
    setenv bootargs console=ttyS0,115200n8 console=tty1,115200 root=/dev/mmcblk0p2 rootfstype=f2fs rootwait video=HDMI-A-1:1920x1080-32@60 debug=vc
    ext4load mmc 0 0x1000000 /uImage
    ext4load mmc 0 0x2000000 /uInitrd
    bootm 0x1000000 0x2000000
    ~# mkimage -A arm -O linux -C none  -T script -n script -d "$TMPFILE" /boot/boot.scr
    ~# cat /vmlinuz /usr/lib/linux-image-$(readlink -f /vmlinuz|cut -d '-' -f 2-)/dove-cubox.dtb > "$TMPFILE"
    ~# mkimage -A arm -O linux -C none  -T kernel -a 0x00008000 -e 0x00008000 -n 'Linux-cubox' -d "$TMPFILE" /boot/uImage
    ~# rm -f "$TMPFILE"
    ~# mkimage -A arm -O linux -C none  -T ramdisk -a 0x1000000 -n 'Initrd-cubox' -d /initrd.img /boot/uInitrd
  5. Finalize the minimal installation:

    ~# systemctl enable getty@ttyS0.service
    ~# cat > /etc/fstab << EOF
    /dev/mmcblk0p2  /       f2fs    defaults        0       1
    /dev/mmcblk0p1  /boot   ext4    defaults        0       2
  6. Exit the chroot and unmount the SD card:

    ~# exit
    ~# umount /tmp/cubox/boot
    ~# umount /tmp/cubox
  7. Boot the CuBox from the SD card and enjoy your new Debian 10 running on CuBox!

Questions? Remarks? Do not hesitated to contact me!