Here we will discuss qemu user emulation method and chroot method for and from working and running aarm64 target machine. For sake of simplicity boot-loader and how to booting is not described here.

Method 1 – Qemu user emulation method

Install Below package for chrooting from x86 Ubuntu host to aarm64 target board file system.

user@user:~$ suod apt-get install qemu-user-static

Make directory Ubuntu-18.04

user@user:~$ sudo mkdir ~/Ubuntu-18.04
user@user:~$ cd ~/Ubuntu-18.04

Download Minimal Ubuntu base release from cdimage.ubuntu.com. Here we are choosing Ubuntu 18.04 base release.

user@user:~$ wget http://cdimage.ubuntu.com/ubuntu-base/releases/18.04/release/ubuntu-base-18.04-base-arm64.tar.gz

Extract ubuntu-base-18.04-base-arm64.tar.gz in ~/Ubuntu-18.04

user@user:~$ tar xf ubuntu-base-18.04-base-arm64.tar.gz -C ~/Ubuntu-18.04

Copy Qemu aarm64 static binary to extracted file system.

user@user:~$ cp -rf /usr/bin/qemu-aarch64-static ~/Ubuntu-18.04/usr/bin/

Make packages directory inside Ubuntu-18.04

user@user:~$ mkdir ~/Ubuntu-18.04/packages

Download below Debian packages for arm64 architecture from packages.debian.org for aarm64 architecture, e.g we are downloading rfkill package as below.

user@user:~$ wget http://ftp.cn.debian.org/debian/pool/main/r/rfkill/rfkill_0.5-1_arm64.deb
dbus
libexpat
net-tools
iputils
libidn11
kmod
libkmod2
rfkill
libcap
libnettle6
sudo
libdbus
module-init-tools
sudo
wget
resolv-conf
bash-completion

Switch target fs from x86 host Ubuntu machine to aarm64 Ubuntu minimal fs.

user@user:~$ sudo chroot ~/Ubuntu-18.04/

Now we have switched ourselves from x86 fs to minimal Ubuntu of aarm64 fs which we will make it to complete rich Ubuntu-18.04. command prompt will look like as below.

#/

Execute below command to create desired username and password, give it sudo permission.

# adduser ubuntu (create ubuntu user and set password)
# addgroup ubuntu adm
# addgroup ubuntu sudo
# addgroup ubuntu audio

Now install those downloaded Debian packages and it’s dependent packages.

# dpkg -i /packages/*

if it prompts missing Debian packages, exit out of target fs to x86 command line with keys CTL + D, download dependent packages in ~/Ubuntu-18.04/packages again.

Switch back to target fs with

user@user:~$ sudo chroot ~/Ubuntu-18.04/

Install dependent packages with

# dpkg -i /packages/*

We will follow this until above listed packages get installed in it.

Time to install firnware in minimal Ubutu FS. Install kernel and dependent drivers in minimal Ubuntu.

# copy Image and dtb to ~/Ubuntu-18.04/boot/
# copy Modules to ~/Ubuntu-18.04/lib/modules/

Time to copy minimal Ubuntu to bootable SD card of target. mount sd card in x86 Ubuntu machine and copy minimal Ubuntu in it.

user@user:~$ sudo cp -rf ~/Ubuntu-18.04/* /media/agajjar/Ubuntu-18.04/

Boot minimal Ubuntu on target board (presuming systemd console service and network is working). login to minimal Ubuntu system with credential entered previously.

username: ubuntu
password:  (Enter previosuly set password for ubuntu user)

Change /etc/hostname and /etc/hosts with your target board name. starts and enable basic systemctl services like netowrking, console etc. start networking services, set appropriate nameserver in /etc/resolv.conf. once network service started on board update and install packages.

# sudo apt-get update
# sudo apt-get upgrade
# sudo apt-get install vim

Install lightweight Desktop GUI such as ldxe, xfce etc for target board.

# sudo apt-get install xorg lightdm ldxe

Method: 2 Chroot from working target

Prerequisite – working Linux system on arm64 board, internet connection
to download packages, card reader, ext4 file system formatted SD card.

Boot arm64 board and mount SD card in /media

# mount /dev/sda1 /media

presuming internet service is available to arm64 board.

Download Minimal Ubuntu base release from cdimage.ubuntu.com. Here we are choosing Ubuntu 18.04 release.

# wget http://cdimage.ubuntu.com/ubuntu-base/releases/18.04/release/ubuntu-base-18.04-base-arm64.tar.gz

Extract ubuntu-base-18.04-base-arm64.tar.gz in /media/

# tar xf ubuntu-base-18.04-base-arm64.tar.gz -C /media

Make packages directory inside Ubuntu-18.04

# mkdir /Media/packages

Download below Debian packages for arm64 architecture from packages.debian.org for aarm64 architecture, e.g we are downloading rfkill package as below.

# wget http://ftp.cn.debian.org/debian/pool/main/r/rfkill/rfkill_0.5-1_arm64.deb
dbus
libexpat
net-tools
iputils
libidn11
kmod
libkmod2
rfkill
libcap
libnettle6
sudo
libdbus
module-init-tools
sudo
wget
resolv-conf
bash-completion

Switch file system from working to target fs with command

# chroot /media

now we have switched ourselves from working fs to minimal fs on arm64 target, which we will make it to rich OS to be ported execute below command to create user and give it’s sudo permission.

# adduser ubuntu (enter desired passowrd for ubuntu user)
# addgroup ubuntu adm
# addgroup ubuntu sudo
# addgroup ubuntu audio

Time to switch root fs to extracted Ubuntu minimal fs.

# chroot /media/

Install downloaded Debian packages

# dpkg -i /packages/*

If missing Debian packages is detected, exit out of target fs to working fs with CTL + D command, download dependent packages in /media/packages switch back to target fs with

# chroot /media

Install dependent packages with

# dpkg -i /packages/*

Do this until above listed packages get installed. once we have listed Debian packages are installed, we are ready to boot from target SD card. exit out of target SD card to working SD card install firmware from /boot to /media/boot and install modules from /lib/modules to /media/lib/modules. SD card has Ubuntu minimal fs, boot this SD card (for sake of simplicity how to boot and boot-loader part is not described here).

login to minimal Ubuntu system with credential entered previously

username: ubuntu
password: (enter Ubuntu password set before)

presuming systemd console service and network service is working change /etc/hostname and /etc/hosts with your target board name. set appropriate nameserver in /etc/resolv.conf start and enable basic systemctl services like netowrking, console etc.

Start ethernet connection and update packages

# sudo ifconfig eth0 up
# sudp dhclient -v eth0
# sudo apt-get update
# sudo apt-get upgrade

Install lightweight desktop GUI like ldxe, xfce4

# sudo apt-get install xorg lightdm ldxe
If you are curious in the world of embedded Linux, keep following the blog as we will discuss Linux tips, tricks and guide. don’t forget to comment the links below! Let’s share knowledge and information. Appreciate your time.

Leave a comment