How to Build Ubuntu

This procedure describes how to create Ubuntu image with SD Card for I-Pi SMARC IMX8M Plus with 2G/4G Memory. The version of Ubuntu used is 20.04 (Focal Fossa).

Recommended Hardware

To setup the build environment for Ubuntu image creation, a Linux host with the following configuration is recommended.

  • Intel Core-i7 processor (>= 4 cores)

  • 8 GB RAM

  • 1 TB disk space

  • High speed network connectivity

  • OS: Ubuntu 18.04 LTS/Ubuntu 16.04 LTS

Update apt repositories list on your host machine and install required packages

$ sudo apt update
$ sudo apt install build-essential

Getting Started

The following are the steps required to generate Ubuntu image for I-Pi SMARC IMX8M Plus.

Step 1: Create a Ubuntu 20.04 root file system.
Step 2: Downloading Yocto IMX8MP image.
Step 3: Replacing IMX8MP yocto image rootfs with Ubuntu 20.04 rootfs.

Note: Remember to download yocto image respective to memory. For example, Download 2G image, if you are building Ubuntu image for 2G memory and vice versa.

Step 1: Create a Ubuntu root file system

  1. Create a new working directory and change directory into it**
$ mkdir $HOME/imx8mp
$ cd HOME/imx8mp
  1. Create a rootfs directory**
$ mkdir rootfs
  1. Install deboot strap and its dependencies**
$ sudo apt install debootstrap binfmt-support qemu-user-static
$ sudo debootstrap --arch=arm64 --foreign focal rootfs
  1. Configure the Rootfs, Add host name to /etc/hostname

Here is an example

$ sudo bash -c"echo'adlink'>rootfs/etc/hostname"
  1. Add host entry in /etc/hosts
$ sudo bash -c"printf'\tlocalhost\n127.0.1.1\tadlink\n\n'>rootfs/etc/hosts"
$ sudo bash -c "echo'root::0:0:root:/root:/bin/bash'>rootfs/etc/passwd"
  1. Prepare QEMU
$ sudo wget -O rootfs/usr/bin/qemu-aarch64-static
$ sudo chmod +x rootfs/usr/bin/qemu-aarch64-static
  1. Get your network ready
$ sudo cp /etc/resolv.conf rootfs/etc/
  1. Mount the proc sys dev file systems
$ for f in proc sys dev dev/pts; do sudo mount --bind /$f rootfs/$f; done
  1. Change root
$ sudo chroot rootfs /bin/bash
  1. Add user name
$ /debootstrap/debootstrap --second-stage
$ adduser imx8mp
#(provide new password and name for the user in the prompt)
$ usermod -a -G sudo imx8mp
  1. Add required apt repositories to sources.list
$ printf 'deb focal main restricted\n# deb-src focal main restricted\n\ndeb focal-updates main restricted\n# deb-src focal-updates main restricted\n\ndeb focal universe\n# deb-src focal universe\n\ndeb focal-updates universe\n# deb-src focal-updates universe\n\ndeb focal multiverse\n# deb-src focal multiverse\n\ndeb focal-updates multiverse\n# deb-src focal-updates multiverse\n\ndeb focal-backports main restricted universe multiverse \n# deb-src focal-backports main restricted universe multiverse\n\ndeb focal-security main restricted \n# deb-src focal-security main restricted\n\ndeb focal-security universe\n# deb-src focal-security universe\n\ndeb focal-security multiverse\n# deb-src focal-security multiverse' > /etc/apt/sources.list
  1. Configure locales

You will be prompted through GUI menu to make certain selections such as date/time/region. Please make the appropriate selections and proceed.

$ apt update
$ dpkg-reconfigure locales
  1. Install ubuntu-desktop and necessary packages
$ apt install ubuntu-desktop
$ apt install vim git sudo net-tools ifupdown kmod iputils-ping man wget bash-completion alsa-utils apt-utils usbutils locales i2c-tools tightvncserver lm-sensors usbmount build-essential mesa-utils cmake can-utils sox v4l-utils glmark2
  1. Clean up and exit from chroot
$ rm -rf /var/cache/apt/archives/*.deb
$ sync
$ exit
  1. Unmount the mounted files
$ for f in proc sys dev/pts dev; do sudo umount rootfs/$f; done
  1. Remove emulator and resolv.conf file
$ sudo rm rootfs/usr/bin/qemu-aarch64-static rootfs/etc/resolv.conf
  1. Use netplan to enable configurations in networking on the system

    Create a01-network-manager-all.yaml file under /etc/neplan

$ sudo vim $HOME/imx8mp/rootfs/etc/neplan/01-network-manager-all.yaml
  1. Add the following content, then save it.

    Let NetworkManager manage all devices on this system


version: 2

renderer: NetworkManager

  1. Make the Root File System

Execute the commands below to make the rootfs.img

Notice that you need change the “count” value according to the size of the “rootfs” folder

Below command will create new rootfs.img file of size 4 GB (3 GB)

$ cd
$ dd if=/dev/zero of=rootfs.img count=4096 status=progress && sync
$ sudo mkfs.ext4 rootfs.img
$ mkdir rootfs
$ sudo mount rootfs.img rootfs/
$ sudo cp -rfp $HOME/imx8mp/rootfs/* rootfs/
$ sudo umount rootfs/

Step 2: Downloading Yocto imx8mp image

  1. Download the Yocto IMX8MP image

For 2G image click here

For 4G image click here

Unzip the file and flash the Image into SD card

$ sudo bunzip2 -dk -f filename
$ sudo dd if=filename of=/dev/sdX bs=64M status=progress

(where X will give mounted device id)

Step 3: Replacing IMX8MP yocto image rootfs with Ubuntu 20.04 rootfs

  1. Unmount the mounted partitions
$ sudo umount /dev/sdc*

Note: In our case, /dev/sdb is SD card device name

  1. Run GParted in the command line
$ sudo gparted

Note: GParted is a free partition editor for graphically managing your disk partitions.

  1. Select SD card as highlighted in above corner in below picture


  2. Select the rootfs partition and select resize option above. Partition 2 (/dev/sdc2) is the rootfs partition in below picture.


  3. Size of rootfs before resize as shown below


  1. Increase the rootfs size i.e /dev/sdb2 here and click on resize button.


  1. Save changes and select apply


  1. Close the GParted and eject SD card. Also connect your SD Card to the development Linux Host PC.


  1. Run lsblk command to get the path for mounted rootfs partition.


  1. Remove the existing contents as this filesystem is the default build root file system.
$ sudo rm -rf <mount_path>/*

$ sync

  1. Create a temporary directory and mount the rootfs.img, which is prepared at Step 1, Preparing Ubuntu Root File System
$ mkdir $HOME/sd_temp
$ sudo mountrootfs.img $HOME/sd_temp
  1. Run the following commands to copy the contents of the ubuntu rootfs.img to the SD card.
$ sudo cp -rfp$HOME/sd_temp/* <mount_path>/
$ sync   
$ sudo umount$HOME/sd_temp
  1. Eject the SD card.

    You can directly insert SD card into the target board and boot using the SD card.