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
p
1
w
"|fdisk $TARGETDEV
mkfs.ext4 -L rootfs "$TARGETDEV"1
mkdir -p $MNTDIR
mount "$TARGETDEV"1 $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 http://ftp.de.debian.org/debian/
# 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
eof
# loopback
cat <<eof>> $MNTDIR/etc/network/interfaces.d/lo
auto lo
iface lo inet loopback
eof
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.
I guess there is a mount step missing after the mkfs.ext4
Thanks. Updated!
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 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=866756
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.
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.
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!