Bar
SpaceWire UK
Specialist providers of VHDL Intellectual Property & Design Services
BarBarBarBar
Tutorial
Missing Image!
Part 14 - Create bootable SD Card running Ubuntu 20.04.2 (17 February 2021)

Introduction

This tutorial details the steps required to boot Ubuntu 20.4.2 from SD Card on the Zedboard hardware.

Aims

The aims of this tutorial are as follows :-

    Part 1 - Download files & setup project

    1. Download ARM Ubuntu 20.04.2 filesystem
    2. Setup environment
    3. Create project area

    Part 2 - Create PetaLinux project & configure it

    1. Create PetaLinux project
    2. Add Hardware Platform

    Part 3 - Build & package PetaLinux

    1. Build PetaLinux
    2. Package project to produce boot image

    Part 4 - Setup SD Card

    1. Prepare SD Card
    2. Copy files to SD Card

    Part 5 - Hardware Deployment

    1. Setup Zedboard hardware
    2. Launch MiniCom terminal emulator
    3. Check everything is working as expected

    1. Download ARM Ubuntu 20.04.2 filesystem

    Download the following files from RCN-EE into ~/Downloads.
    1. Ubuntu 20.04.2 Minimal ARM 17-Aug-2021 (196 MB)

    2. Setup environment

    Setup Xilinx design environment for the 2021.2 toolset.
    steve@Desktop:~$ xilinx
    Xilinx tools available tools at /opt/Xilinx :-
    1) 2021.2 - Vivado - SDK - Vitis - PetaLinux
    0) Exit
    Please select tools required or exit : 1

    Tools are as follows :-
    vivado @ /opt/Xilinx/Vivado/2021.2/bin/vivado
    vitis @ /opt/Xilinx/Vitis/2021.2/bin/vitis
    petalinux-build @ /opt/Xilinx/PetaLinux/2021.2/tool/tools/common/petalinux/bin/petalinux-build

    3. Create project area

    Create the project directory structure and change the present working directory (pwd) to be inside the OS part.
    steve@Desktop:~$ create_project_structure.sh ~/projects/zedboard_linux
    Creating project directory structure @ ~/projects/zedboard_linux
    steve@Desktop:~$ cd ~/projects/zedboard_linux/os

    4. Create PetaLinux project

    Create a PetaLinux project using the Zynq FPGA template.
    steve@Desktop:~/projects/zedboard_linux/os$ petalinux-create --type project --template zynq --name ubuntu_boot

    5. Add Hardware Platform

    Configure the PetaLinux project to use the exported hardware platform from the zedboard_leds_switches Vivado project.
    steve@Desktop:~/projects/zedboard_linux/os$ cd ubuntu_boot
    steve@Desktop:~/projects/zedboard_linux/os/ubuntu_boot$ petalinux-config --get-hw-description ../../../zedboard_leds_switches/fw/system_wrapper.xsa
    The configuration menu now appears.

    Select Image Packaging Configuration from the main menu. Missing Image! Select Root filesystem type (INITRO) from the sub menu. Missing Image! Set the Root filesystem type to EXT4 (SD/eMMC/SATA/USB) and then choose Select. Missing Image! Choose Exit to exit the sub menu. Missing Image! Choose Exit to exit the main menu. Missing Image! Choose Yes when prompted to save the new configuration. Missing Image!

    6. Build PetaLinux

    Build the PetaLinux project (this takes around 20 minutes, hardware dependent).
    steve@Desktop:~/projects/zedboard_linux/os/ubuntu_boot$ petalinux-build

    7. Package project to produce boot image

    Package the project to produce the boot image BOOT.BIN, this will include the first stage boot loader zynq_fsbl.elf, the programmable logic system.bit, the Linux boot loader u-boot.elf and the device tree blob system.dtb.
    steve@Desktop:~/projects/zedboard_linux/os/ubuntu_boot$ petalinux-package --force --boot --format BIN --fsbl images/linux/zynq_fsbl.elf --fpga images/linux/system.bit --u-boot

    8. Prepare SD Card

    Insert a SD Card into Xubuntu via a slot on the machine or a USB adapter.

    Launch GParted from the Whisper menu and enter the root credentials when prompted.

    Select the SD Card device from the drop box in the top right of the GParted window.

    Unmount all the partions on the SD Card by right clicking on each of them and selecting Unmount from the context menu. Missing Image! Delete all of the existing partitions by right clicking on each of them and selecting Delete from the context menu. Missing Image! Right click on the now unallocated area and select New from the context menu. Missing Image! In the Create new Partition dialog setup the first partition as follows and then click Add :-
    1. Free space preceding (MiB): 4
    2. New size (MiB): 500
    3. Free space following (MiB): (the remaining space on the SD Card) (default)
    4. Align to: MiB (default)
    5. Create as: Primary Partition (default)
    6. Partition name: (default)
    7. Filesystem: fat32
    8. Label: boot
    Missing Image! Right click on the remaining unallocated area and select New from the context menu. Missing Image! In the Create new Partition dialog setup the second partition as follows and then click Add :-
    1. Free space preceding (MiB): 0 (default)
    2. New size (MiB): (the remaining space on the SD Card) (default)
    3. Free space following (MiB): 0 (default)
    4. Align to: MiB (default)
    5. Create as: Primary Partition (default)
    6. Partition name: (default)
    7. Filesystem: ext4
    8. Label: rootfs
    Missing Image! Click on the Apply All Operations to commit the changes. Missing Image! All being well everything should complete successfully. Click Close on the Applying pending operations dialog. Missing Image! Close the GParted application.

    The two new partitions (BOOT & rootfs) should now appear on the desktop, double click on each of them to mount on the system.

    9. Copy files to SD Card

    Copy the previous created PetaLinux files into the BOOT partition.
    steve@Desktop:~/projects/zedboard_linux/os/ubuntu_boot$ cp images/linux/{BOOT.BIN,boot.scr,image.ub} /media/steve/BOOT
    Extract the previously downloaded Ubuntu 20.4.2 archive into the rootfs partition.
    steve@Desktop:~/projects/zedboard_linux/os/ubuntu_boot$ tar xf ~/Downloads/ubuntu-20.04.2-minimal-armhf-2021-08-17.tar.xz -C /tmp
    steve@Desktop:~/projects/zedboard_linux/os/ubuntu_boot$ sudo tar xfvp /tmp/ubuntu-20.04.2-minimal-armhf-2021-08-17/armhf-rootfs-ubuntu-focal.tar -C /media/steve/rootfs
    Once the file copy is finished eject both the mounted volumes by right clicking on one of them on the desktop and selecting Eject Volume from the context menu.

    Remove the SD Card from Xubuntu and insert it in the SD Card slot on the Zedboard.

    10. Setup Zedboard hardware

    Connect up the hardware as follows :-
    1. Xubuntu PC USB ⇄ Zedboard USB JTAG/Debug
    2. Xubuntu PC USB ⇄ Zedboard USB UART
    3. Zedboard Ethernet ⇄ Router
    4. Xubuntu PC Ethenet ⇄ Router
    5. Router ⇄ Internet
    Missing Image! Set the boot mode jumpers on the Zedboard for SD Card. Missing Image! Power on the Zedboard.

    11. Launch MiniCom terminal emulator

    If not already running, open up a new terminal and launch the MiniCom terminal emulator.
    steve@Desktop:~$ minized

    Welcome to minicom 2.7.1

    OPTIONS: I18n
    Compiled on Dec 23 2019, 02:06:26.
    Port /dev/ttyACM0, 06:34:25

    Press CTRL-A Z for help on special keys

    12. Check everything is working as expected

    All being well the following sequence of events should be observed :-
    1. The blue done LED illuminates indicating the Programmable Logic (PL) has been programmed.
    2. LED 7 and 1 illuminate indicating the bitstream from the updated zedboard_leds_switches project is in use.
    3. The first stage boot loader kicks off on the Processor System (PS).
    4. Ubuntu starts to boot and displays its boot log in the terminal emulator.
    5. After a while the login prompt appears (shown below).
    ...

    Ubuntu 20.04 LTS arm ttyPS0

    default username:password is [ubuntu:temppwd]

    arm login:
    The following repeated error (if seen) will be fixed with a system update, so ignore it for now.
    Stopped Advanced IEEE 802.�…1X/WPA/WPA2/EAP Authenticator.  
             Starting Advanced IEEE 802�…/WPA/WPA2/EAP Authenticator...
    [FAILED] Failed to start Advanced I�…1X/WPA/WPA2/EAP Authenticator.
    See 'systemctl status hostapd.service' for details.
    Login using the credentials as shown (username : ubuntu, password : temppwd).

    Check for local area network (LAN) connectivity (ping DHCP server).
    ubuntu@arm:~$ ping 192.168.2.1
    PING 192.168.2.1 (192.168.2.1) 56(84) bytes of data.
    64 bytes from 192.168.2.1: icmp_seq=1 ttl=64 time=6.66 ms

    ...
    Check for wide area network (WAN) connectivity (ping Google).
    ubuntu@arm:~$ ping google.com
    PING google.com (172.217.169.14) 56(84) bytes of data.
    64 bytes from lhr25s26-in-f14.1e100.net (172.217.169.14): icmp_seq=1 ttl=114 time=19.2 ms

    ...
    Find out what IP address the DHCP server issued and also what the MAC number is.
    ubuntu@arm:~$ ifconfig
    eth0: flags=-28605<UP,BROADCAST,RUNNING,MULTICAST,DYNAMIC>  mtu 1500
            inet 192.168.2.87  netmask 255.255.255.0  broadcast 192.168.2.255
            inet6 fe80::20a:35ff:fe00:1e53  prefixlen 64  scopeid 0x20<link>
            ether 00:0a:35:00:1e:53  txqueuelen 1000  (Ethernet)
            RX packets 944  bytes 104433 (104.4 KB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 835  bytes 76679 (76.6 KB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
            device interrupt 34  base 0xb000

    lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
            inet 127.0.0.1  netmask 255.0.0.0
            inet6 ::1  prefixlen 128  scopeid 0x10<host>
            loop  txqueuelen 1000  (Local Loopback)
            RX packets 78  bytes 6890 (6.8 KB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 78  bytes 6890 (6.8 KB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    As with all connected equipment it is highly recommended to assign a fixed IP address to the Zedboard via the DHCP server, in this case 192.168.2.87.

    Do an initial update of the system and reboot to check all is well.
    ubuntu@arm:~$ sudo apt-get update
    ubuntu@arm:~$ sudo apt-get dist-upgrade
    ubuntu@arm:~$ sudo reboot
    Enjoy :-)