How to Install PetaLinux 2020.1

Clean install on a virtual machine

In this post we’re going to install PetaLinux 2020.1 from scratch on a virtual machine running Ubuntu 18.04.4 64-bit. The workstation on which I will be doing this has an Intel Xeon, 64GB RAM and 3TB HDD running Windows 10 64-bit. I’m assuming that your host machine is also running Windows.

Why run PetaLinux on a virtual machine?

Here are the main advantages to using PetaLinux on a virtual machine:

• Easy to keep working setups for multiple versions of PetaLinux. Although you can install multiple versions of PetaLinux side-by-side on the same machine, in time the dependencies can change or be updated, rendering older versions unstable. With VMs you can keep a working setup for each version of PetaLinux that you need to support.
• Practical if you don’t have a spare physical machine to dedicate to the specific requirements of the PetaLinux tools. For one, PetaLinux runs on Linux, and secondly it has a bunch of dependencies that you may not want to install on your main workstation.

Step 1: Create the Virtual Machine

2. Create a new virtual machine using these options:
• Linux
• Ubuntu 64-bit
• 16 GB RAM (8GB minimum according to user guide)
• VirtualBox Disk Image
• Dynamic (resizable) hard disk
• 200 GB size (the resulting VM will have about 113GB free after all of these installs so you can reduce this if you like)

I recommend using the dynamic type of hard disk because the Xilinx tools use up a lot of space, BSPs can take up a couple of GB each, plus PetaLinux projects use up a lot of space typically, so it’s hard to know exactly how much space you will end up needing. If you go with a fixed size HDD, you can’t change it easily with VirtualBox, so I say go with the dynamic.

If VirtualBox doesn’t give you the option to create a 64-bit VM, you may need to enable Hardware Virtualization in your BIOS. You absolutely need to use a 64-bit VM for the PetaLinux install.

Step 2: Install Ubuntu 18.04.4 LTS onto the VM

Before launching the VM, we need to have the Ubuntu installation boot disk (or at least the ISO). According to the PetaLinux 2020.1 reference guide, the latest supported Ubuntu release is 18.04.4 (64-bit), so that’s what we’ll install on our VM.

2. Once the download completes, open up an explorer window at the ISO file location and then double click the .iso file. Windows should automatically mount that ISO file to it’s own drive letter, in my case F:. You will be able to refer to this drive letter to install Ubuntu on the VM.
Alternatively, if your version of Windows doesn’t mount the ISO file to it’s own drive letter, you can burn the image to a DVD. Place a blank writable DVD in your drive, then right click on the ISO file and select “Burn disk image”.
1. Back in VirtualBox, click on the VM we created earlier and click “Start”. You will be asked to select the drive letter of your Ubuntu installation disk. Select either your DVD drive letter, or the ISO file’s drive letter.

2. Ubuntu installer will run. Use these options:

• Install Ubuntu
• Normal installation

As PetaLinux requires Ubuntu 18.04.4 (and doesn’t support 18.04.5), we need to refuse the updates all the way through the install process and on the first boot.

3. After installation, you will be asked to reboot. If you used a DVD, the DVD will be automatically ejected from the drive. If you used the ISO file directly, it will ask you to remove the boot disk. To do this, open Windows Explorer, find the drive for the mounted ISO file, then right click on it and select “Eject”. The ISO will be unmounted and you will be able to continue the Ubuntu boot.

4. When Ubuntu has booted and you are logged in, it will tell you that Ubuntu 2020.04 is available and ask if you want to install it. Be sure to refuse the update.

Sharing files from host to VM

At this point I like to setup the VM so that I can share files from the host machine. The best way to do this is by using VirtualBox Guest Additions, which is software that needs to be installed on the VM after the OS.

1. After logging into Ubunto on the VM, click the menu option “Devices->Insert Guest Additions CD image”.
2. This will mount the Guest Additions installation ISO to Ubuntu and you will be asked if you want to run the installation. Answer yes.
3. Once Guest Additions is installed, you can now go into the “Machine->Settings” and then the “Shared Folders” tab.
4. Click the “Add new shared folders” icon and select a folder on your host machine to share with the VM. It helps to tick the “Auto-mount” option.
5. Since you’ve got Guest Additions installed, it can be useful to enable “Shared Clipboard” and “Drag’n’Drop” from the “General” tab under “Advanced”.

Step 3: Install Vitis

This is a good point to install Vitis 2020.1 on the VM, although it’s not absolutely necessary so you can skip this step if you wont be needing it.

2. By default, the Xilinx_Unified_2020.1_0602_1208.tar.gz file will be in your ~/Downloads directory. Assuming that it is in the ~/Downloads directory, extract the installer and then run it.
tar xvzf ~/Downloads/Xilinx_Unified_2020.1_0602_1208.tar.gz -C ~/Downloads/.
./xsetup

1. During the installation, you will be told that there are newer versions available. Make sure that you refuse these upgrades (2020.1.1 or 2020.2+) unless you actually want those versions. To avoid problems down the line, you’re best to use Vitis 2020.1 with PetaLinux 2020.1.

Step 4: Install PetaLinux dependencies

1. Open a terminal and then run the following command to install all of the PetaLinux 2020.1 dependencies:
sudo apt-get -y install iproute2 \
gcc \
g++ \
net-tools \
libncurses5-dev \
zlib1g:i386 \
libssl-dev \
flex \
bison \
libselinux1 \
xterm \
autoconf \
libtool \
texinfo \
zlib1g-dev \
gcc-multilib \
build-essential \
screen \
pax \
gawk \
python3 \
python3-pexpect \
python3-pip \
python3-git \
python3-jinja2 \
xz-utils \
debianutils \
iputils-ping \
libegl1-mesa \
libsdl1.2-dev \
pylint3 \
cpio


Step 5: Install PetaLinux

1. From the VM, open up Firefox browser and download the PetaLinux 2020.1 Installer from the Xilinx website here. By default, the installer should end up in the ~/Downloads directory and the following commands will assume that it is there.
2. In the terminal, make the installer executable:
chmod +x ~/Downloads/petalinux-v2020.1-final-installer.run

1. Create a directory for the PetaLinux installation and then run the installer:
mkdir -p ~/petalinux/2020.1


Note that I’m installing PetaLinux into the “home” directory. This is because the User Guide specifies that “PetaLinux tools need to be installed as a non-root user”.

1. The first thing that the PetaLinux installer will do is ask you to read and accept the license agreements (Xilinx End User License Agreement, Webtalk Terms and Conditions, Third Party End User License Agreement). For each agreement, use PgUp/PgDn to read through the agreement, then press q to close the agreement, then press y to accept the agreement.

Step 6: Change /bin/sh to bash

PetaLinux tools require that your host system /bin/sh be bash, which in Ubuntu it is dash.

1. In the terminal, run this command: chsh -s /bin/bash.
2. Reboot the VM.
3. Open a terminal and run these commands to make /bin/sh link to /bin/bash:
sudo rm /bin/sh
sudo ln -s /bin/bash /bin/sh


All done!

Now you should be able to run the PetaLinux tools in a terminal with this command: source ~/petalinux/2020.1/settings.sh. If all is good you can go ahead and delete the installers for Vitis and PetaLinux (that will free up about 37.8GB):

rm ~/Downloads/Xilinx_Unified_2020.1_0602_1208.tar.gz