Table of Contents

How to build uSomIQ Linux kernel with Device Tree support

This page describes to how deploy the Ubuntu OS and Debian on a uSomIQ COM.

These instructions were adapted from the ones provided by Robert Nelson available here:
http://eewiki.net/display/linuxonarm/BeagleBone+Black

Basic Requirements

GCC Toolchain

wget -c https://releases.linaro.org/14.04/components/toolchain/binaries/gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux.tar.xz
tar xf gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux.tar.xz
export CC=`pwd`/gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux/bin/arm-linux-gnueabihf-

Bootloader

Das U-Boot – the Universal Boot Loader [http://www.denx.de/wiki/U-Boot]

U-Boot Download

Download U-Boot via git:

git clone git://git.denx.de/u-boot.git
cd u-boot/
git checkout v2014.10 -b tmp

U-Boot Patches

wget http://www.mentorel.com/downloads/usomiq/patches/u-boot-usomiq-v2014.10.patch
patch -p1 < u-boot-usomiq-v2014.10.patch

U-Boot Configure and Build

make ARCH=arm CROSS_COMPILE=${CC} distclean
make ARCH=arm CROSS_COMPILE=${CC} am335x_evm_config
make ARCH=arm CROSS_COMPILE=${CC}

If you bought modules with NAND flash 1GB and more then you need to compile a different version of u-boot, because this type of NAND has a different physical structure. The commands should be issued:

make ARCH=arm CROSS_COMPILE=${CC} distclean
make ARCH=arm CROSS_COMPILE=${CC} am335x_nand4k_defconfig
make ARCH=arm CROSS_COMPILE=${CC}

Upgrade distro "device-tree-compiler" package

wget -c https://raw.github.com/RobertCNelson/tools/master/pkgs/dtc.sh
chmod +x dtc.sh
./dtc.sh

Linux Kernel

git clone https://github.com/RobertCNelson/bb-kernel.git
cd bb-kernel/

v3.8.x branch (full cape support)

git checkout origin/am33x-v3.8 -b tmp

Download a patch to enable uSomIQ support in kernel

wget http://www.mentorel.com/downloads/usomiq/patches/add-usomiq-rcn-v3.8.patch
patch -p1 < add-usomiq-rcn-v3.8.patch

v3.18.x branch (SGX and better usb & ethernet)

git checkout origin/am33x-v3.18 -b tmp

Download and apply a patch to add usomiq support in the kernel:

wget http://mentorel.com/downloads/usomiq/patches/add-usomiq-rcn-v3.18.patch
patch -p1 < add-usomiq-rcn-v3.18.patch

If you bought modules with NAND flash 1GB and more then you need to open the file patch.sh, look for this section:

usomiq () {
       git apply "${DIR}/patches/usomiq/0001-add-usomiq-dts.patch"
       #git apply "${DIR}/patches/usomiq/0002-add-usomiq-nand4k.patch"
}

and remove the '#' symbol before the second git command.

Run Build Script:

./build_kernel.sh

The kernel zImage and modules will be under the deploy directory.

Root File System

Debian 8.0.0 (Wheezy) Root File System

This file system is very small and can be installed to the NAND flash on uSomIQ. It is not that small like Angstrom minimal distribution (~20M), but will require around 75M on the flash. However it is a real Debian system with apt-get utility installed.

Default User: debian Password: temppwd

Root User: root Root Password: root

wget -c https://rcn-ee.com/rootfs/eewiki/minfs/debian-8.2-minimal-armhf-2015-09-07.tar.xz

verify the image with:

md5sum debian-8.2-minimal-armhf-2015-09-07.tar.xz
406cd5193f4ba6c2694e053961103d1a  debian-8.2-minimal-armhf-2015-09-07.tar.xz

Extract Image:

tar xf debian-8.2-minimal-armhf-2015-09-07.tar.xz

Now you have a directory with the archived (tar) file system itself and a file with user names/passwords.

Ubuntu 14.04 Root File System

Default User: ubuntu Password: temppwd

wget -c https://rcn-ee.com/rootfs/eewiki/minfs/ubuntu-14.04.3-minimal-armhf-2015-09-07.tar.xz

verify the image with:

md5sum ubuntu-14.04.3-minimal-armhf-2015-09-07.tar.xz
b119ede365e7e7f6d380a5c16592f312  ubuntu-14.04.3-minimal-armhf-2015-09-07.tar.xz

Extract Image:

tar xf ubuntu-14.04.3-minimal-armhf-2015-09-07.tar.xz

Now you have a directory with the archived (tar) file system itself and a file with user names/passwords.

Root File System for NAND

A Root File System around 64Mb in size, for flash applications.

Debian 7 (small flash)

User Password
debian temppwd
root root

Download:

wget -c https://rcn-ee.com/rootfs/eewiki/barefs/debian-8.2-bare-armhf-2015-09-07.tar.xz

Verify:

md5sum debian-8.2-bare-armhf-2015-09-07.tar.xz
033a436bcb13b8c98dd7fa4d3ec37503  debian-8.2-bare-armhf-2015-09-07.tar.xz

Extract:

tar xf debian-8.2-bare-armhf-2015-09-07.tar.xz

Install Ubuntu/Debian

SD card

Setup microSD card

For these instruction, we are assuming: DISK=/dev/mmcblk0, “sudo fdisk \-l” is useful for determining the device id..

export DISK=/dev/mmcblk0

Erase microSD card:

sudo dd if=/dev/zero of=${DISK} bs=1024 count=1024
sudo parted --script ${DISK} mklabel msdos

Setup Boot Partition:

sudo fdisk ${DISK} << __EOF__
n
p
1

+64M
t
e
p
w
__EOF__

Set Boot Flag

sudo parted --script ${DISK} set 1 boot on

Format Boot Partition as vfat:

DISK=/dev/mmcblk0
sudo mkfs.vfat -F 16 ${DISK}p1 -n boot
(or)
DISK=/dev/sdX
sudo mkfs.vfat -F 16 ${DISK}1 -n boot

Setup Root File System Partition:

sudo fdisk ${DISK} << __EOF__
n
p
2


w
__EOF__

Format rootfs as ext4:

DISK=/dev/mmcblk0
sudo mkfs.ext4 ${DISK}p2 -L rootfs
(or)
DISK=/dev/sdX
sudo mkfs.ext4 ${DISK}2 -L rootfs

Mount Partitions

*Note: On most systems these partitions will be auto-mounted…*

sudo mkdir -p /media/boot/
sudo mkdir -p /media/rootfs/

DISK=/dev/mmcblk0
sudo mount ${DISK}p1 /media/boot/
sudo mount ${DISK}p2 /media/rootfs/

(or)

DISK=/dev/sdX
sudo mount ${DISK}1 /media/boot/
sudo mount ${DISK}2 /media/rootfs/

Install Bootloaders

Copy MLO/u-boot.img to the boot partition

sudo cp -v ./u-boot/MLO /media/boot/
sudo cp -v ./u-boot/u-boot.img /media/boot/

uEnv.txt based bootscript

Create “uEnv.txt” boot script: (nano uEnv.txt)

mmcroot=/dev/mmcblk0p2 ro
mmcrootfstype=ext4 rootwait fixrtc
 
loadfdt=load mmc ${bootpart} ${fdtaddr} ${bootdir}/dtbs/${fdtfile}

##Un-comment to enable systemd in Debian Wheezy
#optargs=quiet init=/lib/systemd/systemd

Copy uEnv.txt to the boot partition:

sudo cp -v ./uEnv.txt /media/boot/

Install Kernel and Root File System

To help new users, since the kernel version can change on a daily basis. The kernel building scripts in this git repo will now give you a hint of what kernel version was built.

-----------------------------
Script Complete
eewiki.net: [user@localhost:~$ export kernel_version=3.X.Y-Z]
-----------------------------

Copy and Paste that “export kernel_version=3.X.Y-Z” exactly as shown in your own build/desktop environment:

export kernel_version=3.X.Y-Z

Copy Root File System:

sudo tar xfvp ./*-*-minimal-arm*-*/arm*-rootfs-*.tar -C /media/rootfs/

Copy Kernel zImage:

sudo cp -v ./linux-dev/deploy/${kernel_version}.zImage /media/rootfs/boot/zImage

Kernel Device Tree Binaries:

sudo mkdir -p /media/rootfs/boot/dtbs/
sudo tar xfov ./bb-kernel/deploy/${kernel_version}-dtbs.tar.gz -C /media/rootfs/boot/dtbs/
sudo tar xfv ./bb-kernel/deploy/${kernel_version}-firmware.tar.gz -C /media/rootfs/lib/firmware/

Copy Kernel modules:

sudo tar xfv ./linux-dev/deploy/${kernel_version}-modules.tar.gz -C /media/rootfs/

Setup /etc/fstab:

sudo nano /media/rootfs/etc/fstab

Add:

/dev/mmcblk0p2   /           auto   errors=remount-ro   0   1
/dev/mmcblk0p1   /boot/uboot auto   defaults            0   0

Enable Networking

sudo nano /media/rootfs/etc/network/interfaces

Add:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

Enable Serial Login

Ubuntu:

sudo nano /media/rootfs/etc/init/serial.conf

Add:

start on stopped rc RUNLEVEL=[2345]
stop on runlevel [!2345]

respawn
exec /sbin/getty 115200 ttyO0

Remove microSD card:

sync
sudo umount /media/boot
sudo umount /media/rootfs

Install Debian to NAND

Here you will learn how install Debian to a UBIFS partition on a uSomIQ system on module.

1) Install Ubuntu or Debian to a SD card as described in the previous step

2) Download and extract a small Debian file system as described root_file_system_for_nand

You will have an archive debian-7.5-bare-armhf-2014-07-07.tar after extracting. Place this archive to the SD card with OS installed in the previous step.

3) Boot the board with the SD card to u-boot and issue the following commands:

nand erase.chip
mmc rescan
load mmc 0 ${loadaddr} MLO
nand write ${loadaddr} NAND.SPL
nand write ${loadaddr} NAND.SPL.backup1

Load the u-boot image u-boot.img to NAND.

load mmc 0 ${loadaddr} u-boot.img
nand write ${loadaddr} NAND.u-boot

Load the device tree binary

run loadbootenv
run importbootenv
run findfdt
run loadfdt
nand write ${fdtaddr} NAND.u-boot-spl-os

Load the kernel image zImage to NAND.

run loadimage
nand write ${loadaddr} NAND.kernel

4) Boot farther to OS

5) Prepare a UBIFS partition

For more information visit: http://processors.wiki.ti.com/index.php/UBIFS_Support

Preparing NAND partition for modules with 256MB

ubiformat /dev/mtd9 -s 2048 -O 2048
ubiattach /dev/ubi_ctrl -m 9 -O 2048
ubimkvol /dev/ubi0 -s 230MiB -N rootfs
mount -t ubifs ubi0:rootfs /mnt

Preparing NAND partition for modules with 512MB

ubiformat /dev/mtd9 -s 2048 -O 2048
ubiattach /dev/ubi_ctrl -m 9 -O 2048
ubimkvol /dev/ubi0 -s 450MiB -N rootfs
mount -t ubifs ubi0:rootfs /mnt

Preparing NAND partition for modules with 1024MB

ubiformat /dev/mtd9 -s 2048 -O 2048
ubiattach /dev/ubi_ctrl -m 9 -O 2048
ubimkvol /dev/ubi0 -s 950MiB -N rootfs
mount -t ubifs ubi0:rootfs /mnt

6) Install the file system to the UBIFS-partiotion

cd /mnt
tar xf <path to image>/debian-7.5-bare-armhf-2014-07-07.tar
sync

7) Enable the Serial login

Edit the file /mnt/etc/inittab as described for the SD card installation.

8) Enable Network

Edit the file /mnt/etc/network/interfaces as described for the SD card installation.

9) Remove the SD card and reboot the board