Ubuntu Based SoC Filesystem

Overview

When most people think about using Linux for a project, the key features that they are looking to utilize are not part of the the Linux kernel.  The Linux kernel is a collection of hardware device drivers that manage physical resources such as memory, PCIe, interrupts, resource allocation, and a host of other low level resources.

The Linux kernel is a required piece of a Linux based design, but by itself, the Linux kernel is not capable of providing all the software needs of the system.  In fact, without a filesystem, the Linux kernel will end up in a kernel panic (system failure) at the end of its initialization process if a filesystem is not found.  A large portion of the software resources utilized in a Linux based system are provided by what is called the filesystem.  A filesystem is comprised of software packages, (OpenCV, Apache2, MySQL, Python, GCC, etc) that provide specific computational abilities to the system. These packages make use of resources found in the kernel, but are not a part of the Linux kernel itself.

If you’ve every used a Ubuntu, Mint, or CentOS based workstation, most of what you interact with is the filesystem.  The organizations that provide these distributions package a variety of different open source applications and utilities into a single installation package.  Collectively, these software packages provide a wide range abilities to the end user.

Ubuntu Based Distribution

Creating a filesystem from scratch takes a significant amount of time and can be very difficult.  For that reason, it is common to use an already existing filesystem as a starting point.  We are going to use a variation of the Ubuntu 18.04 filesystem to build a filesystem for the Intel SoC.  Ubuntu is a commonly used Linux distribution that will allow you to easily install new programs that add specific features to your design.  The version of Ubuntu that you will download needs to be compiled to run on a ARM based processor, so make sure that you are downloading the correct version of the Ubuntu base filesystem.

Download the Base Filesystem

cd
mkdir Ubuntu_filesystem
cd Ubuntu_filesystem
wget -c http://cdimage.ubuntu.com/ubuntu-base/releases/18.04/release/ubuntu-base-18.04-base-armhf.tar.gz
sudo tar -xvf ubuntu-base-18.04-base-armhf.tar.gz
mv ubuntu-base-18.04-base-armhf.tar.gz ~/Downloads/

Mount the Base FILESYSTEM

The following steps will allow you to access the Ubuntu filesystem so that you can install some additional software packages.

sudo cp /usr/bin/qemu-arm-static usr/bin/
sudo sed -i 's%^# deb %deb %' etc/apt/sources.list
sudo cp /etc/resolv.conf ./etc/resolv.conf
cd ..
wget https://raw.githubusercontent.com/psachin/bash_scripts/master/ch-mount.sh
chmod a+x ch-mount.sh
sudo ./ch-mount.sh -m Ubuntu_filesystem/

Installing Common Software Packages

Now that you have your new filesystem mounted, you should update all the existing software packages that are currently installed.

apt update
apt-get upgrade -y

Now you can install additional software packages.  The list below are some very common software packages used by most Linux based system.

apt install language-pack-en-base sudo ssh net-tools ethtool iputils-ping rsyslog alsa-utils bash-completion htop python-gobject-2 network-manager --no-install-recommends --yes

If you have an application that requires a GUI interface (OpenCV, GTK based apps, etc), then you will need to install the following graphics packages.  If you do not have a need for a graphical interface, DO NOT install them.  Adding graphics support consumes a fair amount of CPU cycles.

apt install lxde xfce4-power-manager xinit xorg lightdm-gtk-greeter xserver-xorg-video-fbdev lightdm lxtask htop --yes

Configuring the Filesystem

In order to use the new filesystem, we will need to add a user, set the devices name, configure networking, and enable the serial input port.

# Adding a user and setting permissions
useradd ece453 -m -s /bin/bash
echo ece453:password | chpasswd
addgroup ece453 adm && addgroup ece453 sudo && addgroup ece453 audio && addgroup ece453 video

# Configuring Network Interface
echo 'intel-soc' > /etc/hostname
echo "127.0.0.1    localhost" >> /etc/hosts
echo "127.0.1.1    intel-soc" >> /etc/hosts

#Configuring Serial Port
mkdir /etc/init/          
touch /etc/init/ttyS0.conf

echo "start on stopped rc or RUNLEVEL=[12345]">> /etc/init/ttyS0.conf
echo "stop on runlevel [!12345]">> /etc/init/ttyS0.conf
echo "respawn">> /etc/init/ttyS0.conf
echo "exec /sbin/getty -L 115200 ttyS0 vt102">> /etc/init/ttyS0.conf
echo "exit">> /etc/init/ttyS0.conf

All that is left now is to exit and unmount the new filesystem.

exit
sudo ./ch-mount.sh -u Ubuntu_filesystem/

You now have a filesystem that can be used with an Intel SoC.  This filesystem will need to be transferred to a MicroSD card that will be used to boot the Intel SoC.  This will be covered in a different post.