THIS IS A WORK IN PROGRESS
I picked up a Cubox-i4pro from solid-run and have been having fun testing out different distributions. I have put together the steps I used to get a Debian Jessie install going. This installation uses a Debian u-boot as well as a Debian kernel. There are many tutorials out there you can follow but I haven't found one yet that outlines how to achieve a pure Debian installation. Follow along, test it out, give me feedback. Here we go....
THIS TUTORIAL ASSUMES
- Cubox-i4pro
- 16gb microsd card, class 10
- Host system is a Debian derivative
- Microusb to USB cable for serial connection
PREP THE HOST SYSTEM
- Install necessary software in your host linux system.
apt-get install qemu-user-static debootstrap screen
- Insert your microsd card into your host linux system.
INSTALLATION
- Find out what your device is. Mine is /dev/sdb. Replace sdX with sdb or whatever your device is.
cat /proc/partitions
- Zero out the first few MB of the card to remove any previous U-Boot environment.
dd if=/dev/zero of=/dev/sdX bs=1M count=4
- Create one partition and accept the defaults.
fdisk /dev/sdX
n
- Create the filesystem on the partition.
mkfs.ext4 /dev/sdX1
- Prep for bootstrap. Flash-kernel by default automatically detects the machine, but since we will be chrooted it cannot autodetect the cubox-i4pro. Flash-kernel will match the machine name to the entry for cubox-i in /usr/share/flash-kernel/db/all.db. This entry identifies the needed kernel type,*.dtb, boot.scr path, bootscr template, and required packages. Flash-kernel will build a correct boot.scr using the template in /usr/share/flash-kernel/bootscript/bootscr.cubox-i. The /usr/share/initramfs-tools/hooks/flash_kernel_set_root script reads /etc/fstab to define root. An error "Warning: root device $rootdev does not exist" will be thrown if the fstab entry doesn't exist
# Make a directory to mount your partition.
mkdir /mnt/tmp
# Mount your partition.
mount /dev/sdX1 /mnt/tmp
# Change directory.
cd /mnt/tmp
# Make needed directories for initramfs and flash-kernel.
mkdir -p etc/{default,flash-kernel}
# Define our machine so flash-kernel knows the hardware.
echo "SolidRun Cubox-i Dual/Quad" >> etc/flash-kernel/machine
# Define our linux kernel command line.
# boot.scr will be built with this.
echo 'LINUX_KERNEL_CMDLINE="root=/dev/mmcblk0p1 rootfstype=ext4 ro rootwait console=ttymxc0,115200 console=tty1"' >> etc/default/flash-kernel
# Define root in fstab for initramfs.
echo '/dev/mmcblk0p1 / ext4 defaults,noatime 0 0' >> etc/fstab
- Run bootstrap. It will be a successful installation including flash-kernel and initramfs.
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 --arch=armhf jessie /mnt/tmp http://http.debian.net/debian
- Flash the Debian u-boot SPL and img. Change X to whatever your device is. In my case it was sdb.
dd if=usr/lib/u-boot/mx6_cubox-i/SPL of=/dev/sdX bs=1K seek=1
dd if=usr/lib/u-boot/mx6_cubox-i/u-boot.img of=/dev/sdX bs=1K seek=42
INITIAL CONFIGURATION
- Set a password for root.
chroot /mnt/tmp passwd root
- Allow serial connection
echo 'T0:23:respawn:/sbin/getty -L ttymxc0 115200 vt100' >> /mnt/tmp/etc/inittab
- Set hostname
echo "cubox-i4" >> /mnt/tmp/etc/hostname
nano /mnt/tmp/etc/hosts
127.0.0.1 localhost cubox-i4
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Network interfaces - /etc/network/interfaces reads from /etc/network/interfaces.d/
# Choose either static or dynamic IP entry from below.
# For static IP using router and opendns servers
cat <<eof>> /mnt/tmp/etc/network/interfaces.d/eth0
auto eth0
iface eth0 inet static
address 192.168.1.55
netmask 255.255.255.0
gateway 192.168.1.2
dns-nameservers 192.168.1.2 208.67.222.222 208.67.220.220
eof
# For dynamic IP
cat <<eof>> /mnt/tmp/etc/network/interfaces.d/eth0
auto eth0
allow-hotplug eth0
iface eth0 inet dhcp
eof
# Loopback interface
cat <<eof>> /mnt/tmp/etc/network/interfaces.d/lo
auto lo
iface lo inet loopback
eof
# Manual edit of /etc/resolv.conf is not needed. It is generated by /usr/share/bash-completion/completions/resolvconf
- Edit apt sources.list. Comment out the existing line.
nano /mnt/tmp/etc/apt/sources.list
# deb http://debootstrap.invalid/ jessie main
- Paste the following or modify it to your liking and then paste.
deb http://ftp.us.debian.org/debian/ jessie main contrib non-free
deb-src http://ftp.us.debian.org/debian/ jessie main contrib non-free
deb http://ftp.us.debian.org/debian/ sid main contrib non-free
deb-src http://ftp.us.debian.org/debian/ sid main contrib non-free
deb http://ftp.us.debian.org/debian/ experimental main contrib non-free
deb-src http://ftp.us.debian.org/debian/ experimental main contrib non-free
- Set package priority
cat <<eof>> /mnt/tmp/etc/apt/preferences.d/testing
Package: *
Pin: release o=Debian,a=testing
Pin-Priority: 600
Package: *
Pin: release o=Debian,a=unstable
Pin-Priority: 300
Package: *
Pin: release o=Debian,a=experimental
Pin-Priority: 250
eof
- Mount the chroot environment
chroot /mnt/tmp
- Update your installation
apt-get update
- Exit your chroot environment
exit
- Unmount the partition
umount /mnt/tmp
SERIAL CONNECTION TEST
- Insert the micro sdcard into the cubox-i4pro.
- Connection the microusb-to-usb cable to the cubox-i4pro and then to the host linux system.
- Check that usbserial module is loaded. You should see something like: FTDI USB Serial Device converter now attached to ttyUSB0
dmesg | grep ttyUSB
- Connect to the cubox-i with screen
screen /dev/ttyUSB0 115200
- Power on the cubox-i. You should see output in screen. Hit enter to stop the boot. I get an error:
*** Warning - bad CRC, using default environment
- Correct the above error. Type the following and hit enter:
env default -a
- Save the environment. Type the following and hit enter:
save
- Unplug the cubox-i4pro power and replug it to reboot.
REFERENCES
https://wiki.debian.org/AptPreferences
http://www.denx.de/wiki/view/DULG/UBoot
https://packages.debian.org/jessie/qemu-user-static
https://wiki.debian.org/Debootstrap
http://www.linuxmanpages.com/man1/dd.1.php
http://www.cyberciti.biz/faq/display-show-linux-partitions/
http://www.howtogeek.com/106873/how-to-use-fdisk-to-manage-partitions-on-linux/
http://linux.die.net/man/8/mkfs
https://packages.debian.org/jessie/armhf/flash-kernel/filelist
http://www.solid-run.com/wiki/index.php?title=Building_the_kernel_and_u-boot_for_the_CuBox-i_and_the_HummingBoard#U-Boot_Upstream
http://metadata.ftp-master.debian.org/changelogs/main/f/flash-kernel/unstable_changelog
http://linux-sunxi.org/User_talk:H3ndrik/Mainline_Debian_HowTo
https://www.debian.org/doc/manuals/debian-reference/ch05.en.html
https://wiki.debian.org/NetworkConfiguration
Hello, thank you for this work,
ReplyDeletecan you write what is working and what is not?
Absolutely! Is there anything specifically you are referring to that you want me to check? Would you like to provide examples of what you would like me to check?
DeleteThanks, this helped me a lot.
ReplyDelete