Skip to content

Instantly share code, notes, and snippets.

@vervolk
Forked from CrashenX/debian-on-cubox-i.markdown
Created February 23, 2021 18:47
Show Gist options
  • Save vervolk/2c91e7e6a39dc9a7771c9d2868a5bf69 to your computer and use it in GitHub Desktop.
Save vervolk/2c91e7e6a39dc9a7771c9d2868a5bf69 to your computer and use it in GitHub Desktop.
Installing Debian on the CuBox-i

Debian Sid on the CuBox-i

I read http://lifehacker.com/5974087/i-raised-my-kids-on-the-command-lineand-they-love-it, and I was inspired. I order a CuBox-i2Ultra for my son and installed a custom configured Debian Sid rootfs. I've provided the steps I took to get it working.

Setting up your environment

Packages you will probably need:

binutils-arm-linux-gnueabi
cpp-4.4-arm-linux-gnueabi
g++-4.4-arm-linux-gnueabi
gcc-4.4-arm-linux-gnueabi
gcc-4.4-arm-linux-gnueabi-base
gcc-4.4-base-armel-cross
libc-bin-armel-cross
libc-dev-bin-armel-cross
libc6-armel-cross
libc6-dev-armel-cross
libgcc1-armel-cross
libgomp1-armel-cross
libstdc++6-4.4-dev-armel-cross
libstdc++6-armel-cross
linux-libc-dev-armel-cross

Installing Packages

su -l # Become root

echo '# You can delete this file or comment out entries when done
deb http://ftp.us.debian.org/debian squeeze main contrib non-free
deb http://www.emdebian.org/debian squeeze main contrib non-free
' > /etc/apt/sources.list.d/emdebian.list

dpkg --add-architecture armhf
apt-get update
apt-get install g++-4.4-arm-linux-gnueabi
exit # Exit root shell

cd
mkdir CuBox-i
cd CuBox-i

Create uboot and kernel images

mkdir -p uboot
mkdir -p kernel/modules/
mkdir -p src
cd src
git clone https://github.com/rabeeh/u-boot-imx6.git
cd u-boot-imx6

Follow the instructions found here to build uboot images: http://imx.solid-run.com/wiki/index.php?title=Building_the_kernel_and_u-boot_for_the_CuBox-i_and_the_HummingBoard

N.B., You might have to compile with platform specific config: make <config> mx6\_cubox-i{1,2,2ultra,4pro}

cp SPL u-boot.img ../../uboot
cd ..
#git clone https://github.com/SolidRun/linux-imx6.git
#cd linux-imx6
git clone https://github.com/SolidRun/linux-linaro-stable-mx6.git
cd linux-linaro-stable-mx6

Follow the instructions found here to build kernel (i.e. 3.10 LTS): http://imx.solid-run.com/wiki/index.php?title=Building_the_kernel_and_u-boot_for_the_CuBox-i_and_the_HummingBoard

N.B., you might want to modify the config to add netfilter & iptables spport, as well as, TUN support. You can use: ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- make menuconfig. Gentoo has some good resources on what options to select.

N.B., I was unable to get iptables working, but I got TUN working by setting: CONFIG_TUN=y in .config.

#cp arch/arm/boot/uImage ../../kernel/
cp arch/arm/boot/zImage ../../kernel/
cp arch/arm/boot/dts/imx6q-cubox-i.dtb ../../kernel/
ARCH=arm\
  CROSS_COMPILE=/usr/bin/arm-linux-gnueabi-\
  INSTALL_MOD_PATH=../../kernel/modules/\
  make modules_install
cd ../..

Create rootfs

mkdir -p rootfs sources

echo '[General]
unpack=true
debootstrap=Debian
aptsources=Debian
cleanup=true
arch=armhf
directory=rootfs
retainsources=sources

[Debian]
packages=adduser apt base-files base-passwd bash bluez bsdgames bsdutils console-setup coreutils dash debianutils diffutils dpkg e2fsprogs findutils grep gzip hostname ifupdown iproute2 iptables-persistent kbd less libc-bin libterm-readline-gnu-perl locales login logrotate lshw man-db manpages mount ncurses-base ncurses-bin netbase nethack-console screen sed socat resolvconf tar tasksel tcpdump traceroute usbutils util-linux vim wicd-curses
source=http://ftp.us.debian.org/debian keyring=debian-archive-keyring suite=sid' > multistrap.config

su # Become root
multistrap -f multistrap.config

cp /usr/bin/qemu-arm-static rootfs/usr/bin/
DEBIAN_FRONTEND=noninteractive\
  DEBCONF_NONINTERACTIVE_SEEN=true\
  LC_AA=C\
  LANGUAGE=C\
  LANG=C\
  chroot rootfs /var/lib/dpkg/info/dash.preinst install

You might need to run configure again after boot

DEBIAN_FRONTEND=noninteractive\
  DEBCONF_NONINTERACTIVE_SEEN=true\
  LC_AA=C\
  LANGUAGE=C\
  LANG=C\
  chroot rootfs dpkg --configure -a
chroot rootfs passwd <<END
root
root
END

touch rootfs/etc/fstab
echo "my-hostname" > rootfs/etc/hostname
#echo 'bootfile=/boot/uImage' > rootfs/boot/uEnv.txt
echo 'boot_file=/boot/zImage' > rootfs/boot/uEnv.txt
echo "mmcargs=setenv bootargs root=/dev/mmcblk0p1 rootwait video=mxcfb0:dev=hdmi consoleblank=0" >> rootfs/boot/uEnv.txt
ln -s /boot/uEnv.txt rootfs/
#cp kernel/uImage rootfs/boot/
cp kernel/zImage rootfs/boot/
cp kernel/imx6q-cubox-i.dtb rootfs/boot/
#cd src/linux-imx6
cd src/linux-linaro-stable-mx6/
ARCH=arm\
  CROSS_COMPILE=/usr/bin/arm-linux-gnueabi-\
  INSTALL_MOD_PATH=../../rootfs/\
  make modules_install
exit # Exit root shell

Install to your flash drive

N.B., Enure sdX is the flash card you want to wipe

su # Become root
dd if=/dev/zero of=/dev/sdX count=32768 count=64
fdisk /dev/sdX <<END
n
p
1
2048

w
END

Verify dd commands prior to running at: http://imx.solid-run.com/wiki/index.php?title=Building_the_kernel_and_u-boot_for_the_CuBox-i_and_the_HummingBoard

dd if=uboot/SPL of=/dev/sde bs=1K seek=1
dd if=uboot/u-boot.img of=/dev/sde bs=1K seek=42
mkfs.ext4 /dev/sdX1
mount /dev/sdX1 /media/usb/
cp -a rootfs/* /media/usb
sync
umount /media/usb/
exit # Exit root shell

First boot notes

  1. Change your root password
  2. Set the date
  3. Configure any unconfigured packages
  4. Reconfigure any desired packages (tzdata, console-setup, ...)
  5. Add user
  6. Setup iptables # I failed to get this working
  7. Set hostname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment