Installing Debian Stretch on a Cubox-i

I have a Cubox-i and these are my notes to install Debian with the standard u-boot and linux kernel from the Debian archive.

Some requirements on the host:

apt-get install qemu-user-static debootstrap

Assuming the SD-Card is available as /dev/sdb :

# define our target device (mmc card) and the directory we use
export TARGETDEV=/dev/sdb
export MNTDIR=/mnt/tmp

# clean some blocks
dd if=/dev/zero of=$TARGETDEV bs=1M count=4

# create a single partition and ext4 filesystem
echo "n

"|fdisk $TARGETDEV
mkfs.ext4 -L rootfs "$TARGETDEV"1

mkdir -p $MNTDIR
mkdir -p $MNTDIR/etc/{default,flash-kernel}
echo "SolidRun Cubox-i Dual/Quad" >> $MNTDIR/etc/flash-kernel/machine
echo 'LINUX_KERNEL_CMDLINE="root=/dev/mmcblk0p1 rootfstype=ext4 ro rootwait console=ttymxc0,115200 console=tty1"' >> $MNTDIR/etc/default/flash-kernel
echo '/dev/mmcblk0p1 / ext4 defaults,noatime 0 0' >> $MNTDIR/etc/fstab

# get and install packages via debootstrap
qemu-debootstrap --foreign  --include=ntp,ntpdate,less,u-boot,u-boot-tools,flash-kernel,linux-image-armmp,kmod,openssh-server,firmware-linux-free,bash-completion,dialog,fake-hwclock,locales,vim --arch=armhf stretch $MNTDIR

# copy u-boot files to SD-Card (and it's 69, not 42. See cuboxi README from u-boot source tree)
dd if=$MNTDIR/usr/lib/u-boot/mx6cuboxi/SPL of=$TARGETDEV bs=1K seek=1
dd if=$MNTDIR/usr/lib/u-boot/mx6cuboxi/u-boot.img of=$TARGETDEV bs=1K seek=69

# set root password
chroot $MNTDIR passwd root
# serial console
echo 'T0:23:respawn:/sbin/getty -L ttymxc0 115200 vt100' >> $MNTDIR/etc/inittab

# hostname
echo "cubox" >> $MNTDIR/etc/hostname

# network eth0
cat <<eof>> $MNTDIR/etc/network/interfaces.d/eth0
auto eth0
allow-hotplug eth0
iface eth0 inet dhcp

# loopback
cat <<eof>> $MNTDIR/etc/network/interfaces.d/lo
auto lo
iface lo inet loopback

umount $MNTDIR

That’s it. Insert the SD-Card, connect with Putty or minicom and yo should see a booting system and be able to login.


5 thoughts on “Installing Debian Stretch on a Cubox-i

  1. Thanks very much. A succinct post that uses code as documentation 🙂

    `qemu-user-static` suggests `binfmt-support` but does not require it. Install `binfmt-support` before installing `qemu-user-static`. See

    Secondly, I think that should be `u-boot-imx` rather than `u-boot` in the list of packages passed to debootstrap.

    Lastly, I had to insert an extra blank line between 1 and w in the input to fdisk. There are two questions (start and end) after selecting partition number.

  2. Another thing to watch out for is that the SD card may be mounted as a mmc0blk1 rather than mmc0blk0. You can see this in the boot messages and the boot will stop at mounting the rootfs. Update the kernel command line and the entry in /etc/fstab.

  3. I found this documentation through the Debian Wiki, and I’m quite happy with the result! Before I had to rely on images produced by others, and could not get a plain Debian 9. Now, having installed a backports-kernel, and adding I have a well working little Desktop machine (although it does not play video too smooth). I had to change the memory card mount point and root parameter to mmc0blk1 for the target machine, as pointed out by Alok G Singh just before my post. I also added cma=128M to the list of kernel parameters. Thanks a lot for these instructions!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s