.. title: PetaLinux v2019.1 on Ubuntu 18.04 LTS
.. slug: petalinux-v2019-1-ubuntu-18-04
.. date: 2019-07-09 10:05:51 UTC+02:00
.. tags: xilinx, petalinux, ubuntu
.. category: 
.. link: 
.. description: 
.. type: text

Although Xilinx `PetaLinux
<https://www.xilinx.com/products/design-tools/embedded-software/petalinux-sdk.html>`_
officially supports the Ubuntu 18.04 LTS GNU/Linux distribution, there is a small
glitch in the installation procedure.  Following `UG1144
<https://www.xilinx.com/support/documentation/sw_manuals/xilinx2018_2/ug1144-petalinux-tools-reference-guide.pdf>`_
the installation aborts like this:
  
.. code-block:: console

  dzu@zarniwoop:~/Downloads$ bash petalinux-v2019.1-final-installer.run 
  INFO: Checking installation environment requirements...
  awk: read error (Bad address)
  
  Please refer to the PetaLinux Tools Installation Guide.
  
  Check the troubleshooting guide at the end of that manual, and if you are
  unable to resolve the issue please contact customer support with file:
     /home/dzu/Downloads/petalinux_installation_log
  
  petalinux-v2019.1-final-installer.run: line 140: /tmp/tmp.rlFbcgKOQZ/petalinux-env-check: No such file or directory
  ERROR: Failed to extract Petalinux installer...
  dzu@zarniwoop:~/Downloads$

The fix is rather straightforward and easy, but I'll include the
explanation for a better understanding.
  
.. TEASER_END

So the error is thrown by the `awk
<https://en.wikipedia.org/wiki/AWK>`_ tool which first appeared on the
scene 42 years ago in 1977.  It is certainly amazing that tools
of that age are still used for non-legacy things, but why exactly does
it prevent us from installing PetaLinux to our machine?

Searching for the answer leads us into the `Debian alternatives system
<https://wiki.debian.org/DebianAlternatives>`_:
  
.. code-block:: console

  dzu@zarniwoop:~/Downloads$ awk --version
  awk: not an option: --version
  dzu@zarniwoop:~/Downloads$ ls -l /usr/bin/awk 
  lrwxrwxrwx 1 root root 21 May 28 17:17 /usr/bin/awk -> /etc/alternatives/awk
  dzu@zarniwoop:~/Downloads$ ls -l /etc/alternatives/awk
  lrwxrwxrwx 1 root root 13 May 28 17:17 /etc/alternatives/awk -> /usr/bin/mawk
  dzu@zarniwoop:~/Downloads$
  
So the default awk flavor of Ubuntu 18.04 is not the continuously improved
`GNU awk <https://www.gnu.org/software/gawk/manual/>`_ but rather a
minimal POSIX compatible implementation called `mawk
<https://invisible-island.net/mawk/>`_.  Xilinx indeed documents the
requirement of gawk in UG1144 on page 10, but the same document
forgets to mention it in the "Quick Installation of Packages" section
for Ubuntu.

So all in all, fixing the problem is straightforward:
  
.. code-block:: console

  dzu@zarniwoop:~/Downloads$ sudo apt install gawk
  Reading package lists... Done
  Building dependency tree       
  Reading state information... Done
  Suggested packages:
    gawk-doc
  The following NEW packages will be installed:
    gawk
  0 upgraded, 1 newly installed, 0 to remove and 58 not upgraded.
  Need to get 401 kB of archives.
  After this operation, 1552 kB of additional disk space will be used.
  Get:1 http://de.archive.ubuntu.com/ubuntu bionic/main amd64 gawk amd64 1:4.1.4+dfsg-1build1 [401 kB]
  Fetched 401 kB in 0s (1388 kB/s)
  Selecting previously unselected package gawk.
  (Reading database ... 181794 files and directories currently installed.)
  Preparing to unpack .../gawk_1%3a4.1.4+dfsg-1build1_amd64.deb ...
  Unpacking gawk (1:4.1.4+dfsg-1build1) ...
  Setting up gawk (1:4.1.4+dfsg-1build1) ...
  Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
  dzu@zarniwoop:~/Downloads$

  
This automatically takes care of installing gawk as the preferred awk
flavor and is enough for the PetaLinux installer to run correctly:

.. code-block:: console

  dzu@zarniwoop:~/Downloads$ ls -l /etc/alternatives/awk
  lrwxrwxrwx 1 root root 13 Dec 29  2018 /etc/alternatives/awk -> /usr/bin/gawk*
  dzu@zarniwoop:~/Downloads$ bash petalinux-v2019.1-final-installer.run 
  INFO: Checking installation environment requirements...
  INFO: Checking free disk space
  INFO: Checking installed tools
  INFO: Checking installed development libraries
  INFO: Checking network and other services
  WARNING: No tftp server found - please refer to "PetaLinux SDK Installation Guide" for its impact and solution
  INFO: Checking installer checksum...
  INFO: Extracting PetaLinux installer...
  
  LICENSE AGREEMENTS
  
  PetaLinux SDK contains software from a number of sources.  Please review
  the following licenses and indicate your acceptance of each to continue.
  
  You do not have to accept the licenses, however if you do not then you may 
  not use PetaLinux SDK.
  
  Use PgUp/PgDn to navigate the license viewer, and press 'q' to close
  
  Press Enter to display the license agreements
