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!

Last posts

Useful commands, one-liners, etc.

I decided to record here useful bash fragments, commands, etc. I kept using and forgetting from time to time... I will enrich it as needed. There is no particular order nor specific explanation. Some might be useful to others. Maybe. Who knows.

Arbitrary file binary dump into C array

To …

Using Docker as chroot-on-steroids

chroot for programming

I use chroot environments quite a lot as a light way to develop/test/integrate software for different Linux distributions or even platforms (eg. Ubuntu 18.04 on ARM vs Debian 10 on x86), thanks to the Linux kernel stable ABI and qemu emulation.

However, it was …

Decompressing sparse files

When decompressing a sparse file with gzip, the file is not sparsed anymore. In order to decompress it as sparse, we can use dd:

~# zcat <sparsefile.bin.gz> | dd conv=sparse of=<sparsefile.bin>

Note that this is not specific to gzip. Also note that some utilities such as xz …

Updating Thinkpad X61 BIOS


WARNING 1: the update is done at your own risk and may brick your computer.

WARNING 2: this will wipe all data on the target USB device.

WARNING 3: do not use SYSLINUX MEMDISK driver to boot it directly with eg. Grub. The Lenovo BIOS updater use the …

128-bits multiply with NumPy

128-bits multiply

For another on-going project, I needed to do 64-bits x 64-bits to 128-bits multiply, and I needed it in Python. When doing numerical work with Python, I always use NumPy which is a really awesome library. Unfortunately NumPy is heavily biased towards hardware native types, which makes sense …