Changes between Initial Version and Version 1 of venice/ubuntu


Ignore:
Timestamp:
10/09/2020 06:37:56 PM (4 years ago)
Author:
Tim Harvey
Comment:

initial page

Legend:

Unmodified
Added
Removed
Modified
  • venice/ubuntu

    v1 v1  
     1[[PageOutline]]
     2
     3= Ubuntu on Venice
     4This page provides details on running Ubuntu on a Gateworks Venice Board.
     5
     6Other references:
     7 * The Gateworks [wiki:venice Venice] software page
     8 * [wiki:/ubuntu Gateworks Ubuntu Page for generic Ubuntu notes not specific to Venice]
     9
     10
     11[=#prebuilt]
     12== Gateworks pre-built Ubuntu based Disk Image for Venice
     13Gateworks provides a pre-built Ubuntu based firmware images for the Venice Family:
     14 * [http://dev.gateworks.com/venice/images/focal-venice.img.gz focal-venice.img.gz] - '''(Recommended)''' Compressed Disk Image containing Firmware, Linux kernel, and Ubuntu 20.04 Focal root filesystem.
     15  * To update the firmware on the eMMC see [wiki:venice/firmware#serial-ethernet]
     16  * To update the firmware on a microSD card see [wiki:linux/blockdev#UsingaDiskImage]
     17 * [http://dev.gateworks.com/venice/kernel/linux-venice.tar.xz linux-venice.tar.xz] - Compressed TAR archive of pre-built Linux kernel
     18 * [http://dev.gateworks.com/ubuntu/focal/focal-venice.tar.xz focal-arm64.tar.xz] - Compressed TAR archive of Ubuntu 20.04 Focal arm64 root filesystem (does not include kernel)([http://dev.gateworks.com/ubuntu/focal/focal-venice.manifest package manifest])
     19
     20'''Login Information (default)'''
     21 * Username: root
     22 * Password: root
     23
     24Features:
     25- Ubuntu aarch64 core (created via debootstrap)
     26- Gateworks Venice Linux kernel
     27- eth0 dhcp with a 10 second timeout
     28- User: root password: root
     29- Packages installed on top of core including:
     30 * Updated modemmanager/libqmi-utils/libmbim-utils (see [wiki:ubuntu#modem ubuntu/modem])
     31 * Misc wireless: wpasupplicant iw
     32 * Misc utils: vim can-utils i2c-tools usbutils pciutils screen watchdog binutils
     33 * Misc network: wget ethtool iperf iperf3 openssh-server iptables
     34 * Linux firmware
     35 * Gateworks [https://raw.githubusercontent.com/Gateworks/meta-gateworks/master/recipes-support/hostapd-conf/hostapd-conf/hostapd-conf hostapd-conf script]
     36 * Filesystem tools: e2fstools parted
     37- first-boot script to grow root filesystem partition and filesystem (useful when putting disk images on removable storage devices)
     38- use ifupdown tools instead of netplan (we find them easier to understand and configure)
     39
     40
     41To install the kernel and root filesystem on a removable block storage device see [#disk-images below].
     42
     43== BSP
     44To build a complete Ubuntu image, including all the boot firmware, start with the [wiki:venice/bsp Venice BSP] page as the easiest option.
     45
     46
     47[=#debootstrap]
     48== Root filesystem ==
     49This is to build the rootfs ONLY. To easily build an entire system image, including the boot firmware and Ubuntu, consider the [wiki:venice/bsp Venice BSP] page.
     50
     51A popular way to create an Ubuntu root filesystem is to use the {{{deboostrap}}} utility on a Debian or Ubuntu host. This tool provides a 2-stage install where the second stage is within a chroot environment using qemu.
     52
     53Gateworks uses a script to do this which you may find at http://github.com/Gateworks/ubuntu-rootfs
     54
     55Requirements:
     56- Linux Ubuntu or Debian System with network connection and sudo permissions
     57
     58Important notes:
     59 * We set and use '''target''' and '''distro''' env variables in step 2 and use those env variables in the remaining steps to make this tutorial more version-agnostic. Please be aware of this and do not deviate from the steps unless or until you completely understand what you are doing.
     60 * These steps are not always exactly what we do in our script but give you an idea of how you would go about doing it yourself if you wanted to customize something
     61
     62Steps:
     631. Install pre-requisites:
     64{{{
     65#!bash
     66sudo apt-get install qemu-user-static debootstrap binfmt-support
     67}}}
     68
     692. Perform first stage install of minimal filesystem for {{{arm64}}} architecture:
     70{{{#!bash
     71distro=focal
     72arch=arm64
     73target=${distro}-${arch}
     74qemu_arch=aarch64
     75sudo debootstrap --arch=$arch --foreign $distro $target
     76# copy qemu binary for the binfmt packages to find it and copy in resolv.conf from host
     77sudo cp /usr/bin/qemu-${qemu_arch}-static $target/usr/bin
     78}}}
     79 * See http://ports.ubuntu.com/ubuntu-ports/dists/ for a list of current Ubuntu releases: oe 20.04=focal (latest LTS)
     80 * this minimal rootfs is still missing some core packages and configuration before it can be booted. These steps are taken care of in a 2nd stage install within a chroot shell
     81 * the chroot shell below will provide network support (inherited from the host)
     82
     833. We now have a minimal Ubuntu rootfs - chroot to it and perform the 2nd stage install:
     84{{{
     85#!bash
     86sudo chroot $target
     87# now we are in the chroot - setup env matching the distro above
     88distro=focal
     89export LANG=C
     90# setup second stage
     91/debootstrap/debootstrap --second-stage
     92}}}
     93 * this is the most minimal rootfs we would recommend
     94
     954. (optional) add additional apt package repos:
     96{{{
     97#!bash
     98cat <<EOT > /etc/apt/sources.list
     99deb http://ports.ubuntu.com/ubuntu-ports $distro main restricted universe multiverse
     100deb http://ports.ubuntu.com/ubuntu-ports $distro-updates main restricted universe multiverse
     101deb http://ports.ubuntu.com/ubuntu-ports $distro-security main restricted universe multiverse
     102EOT
     103}}}
     104 * you may want to customize the above list, depending on your needs. See [#packages below] for more detail on Ubuntu package feeds
     105
     1065. (optional) update package database and setup locales (do not skip this step if you are needing to install any packages for the steps below or otherwise)
     107{{{
     108#!bash
     109apt-get update
     110apt-get -f install # fixup missing package dependencies
     111apt-get install locales dialog
     112dpkg-reconfigure locales
     113}}}
     114
     1156. Set hostname:
     116{{{
     117#!bash
     118echo ${distro}-$(uname -m) > /etc/hostname
     119}}}
     120
     1217. set a root passwd so you can login
     122{{{
     123#!bash
     124passwd
     125}}}
     126 - or consider adding a user via {{{adduser}}}:
     127{{{
     128#!bash
     129adduser myuser
     130usermod -a -G tty myuser # add to tty group for tty access
     131usermod -a -G dialout myuser # add to dialout group for UART access
     132usermod -a -G sudo myuser # add to sudo group for root access
     133}}}
     134
     1358. (optional) configure networking:
     136 - wired ethernet with DHCP on eth0
     137{{{#!bash
     138apt-get install net-tools ifupdown
     139cat <<EOF >> /etc/network/interfaces
     140allow-hotplug eth0
     141auto eth0
     142iface eth0 inet dhcp
     143
     144EOF
     145}}}
     146 - or static IP:
     147{{{#!bash
     148apt-get install net-tools ifupdown
     149cat <<EOF >> /etc/network/interfaces
     150allow-hotplug eth0
     151auto eth0
     152iface eth0 inet static
     153address 192.168.1.1
     154netmask 255.255.255.0
     155gateway 192.168.1.254
     156
     157EOF
     158}}}
     159 - or wireless (requires ~3MB of additional packages):
     160{{{
     161#!bash
     162apt-get install wpasupplicant iw
     163cat << EOF >> /etc/network/interfaces
     164# Wireless interface
     165auto wlan0
     166iface wlan0 inet dhcp
     167        wireless_mode managed
     168        wireless_essid any
     169        wpa-driver nl80211
     170        wpa-conf /etc/wpa_supplicant.conf
     171
     172EOF
     173wpa_passphrase <myssid> <mypass> >> /etc/wpa_supplicant.conf
     174}}}
     175
     1769. (optional) install some useful packages
     177{{{
     178#!bash
     179apt-get install openssh-server # ssh server for remote access
     180apt-get install can-utils i2c-tools usbutils pciutils # cmdline tools for various hardware support
     181}}}
     182 * Note that by default root ssh access is disabled for security. See [wiki:/ubuntu#SSHServer This link] for info on enabling it
     183
     18410. Exit the chroot shell and remove files we no longer need
     185{{{
     186#!bash
     187exit
     188sudo rm $target/usr/bin/qemu-$qemu_arch-static
     189}}}
     190
     191At this point you have a directory containing a root filesystem (without kernel) and likely want to install it onto removable storage or the on-board FLASH of a target board. Some intermediate formats that are useful to keep around would be a tarball, perhaps an ext4 filesystem image, or a compressed disk image suitable for flashing in the U-Boot bootloader.
     192
     193To create a tarball which is the most flexible storage format and can be used for a variety of future installation uses:
     194{{{#!bash
     195sudo tar --keep-directory-symlink -cvJf focal-venice.tar.xz -C rootfs/ .
     196}}}
     197 * '--numeric-owner' is required to store user/group as a number instead of a name, your specific use case may require this switch.
     198 * the '-C rootfs/' is required to eliminate the rootfs directory prefix
     199 * the sudo is needed to be able to read the root owned files
     200 * '--keep-directory-symlink' will preserve symbolic links
     201
     202
     203=== Compressed Disk Image (for flashing onto a board)
     204To create a 'Compressed Disk Image' using this tarball see [wiki:venice/boot#disk-images venice/boot#disk-images] and to install this onto a board's embedded FLASH see [wiki:venice#serial-ethernet here].
     205
     206
     207=== ext4 filesystem ===
     208If desired you can create an ext4 filesystem from the directory or tarball. This requires you choose a size for the filesystem. This size can be increased at runtime using {{{resize2fs}}} as long as the partition table has room for it to grow. The advantage of using an as small as possible size is that the time necessary to flash it onto storage is reduced to a minimum (when flashing you have to write the entire ext4 fs but when formatting or resizing it only has to write periodic markers to FLASH).
     209
     210For a given size (see SIZEMB variable below) you can create a rootfs with:
     211{{{#!bash
     212SIZEMB=1536 # 1.5GB - expandable later with resize2fs
     213OUT=rootfs.ext4
     214# create a file of specific size
     215truncate -s ${SIZEMB}M ${OUT}
     216# format it as an ext4 filesystem
     217mkfs.ext4 -q -F -L rootfs ${OUT}
     218# mount it to a temporary mount point
     219tmp_mnt=$(mktemp -d -p/tmp)
     220mount ${OUT} ${tmp_mnt}
     221# copy files to it
     222cp -rup rootfs/* ${tmp_mnt}
     223# and/or extract files from a tarball
     224tar -C ${tmp_mnt} -xf linux-venice.tar.xz
     225# unmount temporary mount point
     226umount ${tmp_mnt}
     227sync
     228# compress it
     229gzip -k -f ${OUT}
     230}}}
     231
     232Note that the pre-built Gateworks images create a minimal root filesystem as well as a partition table that assumes a specific size (matching the smallest eMMC device used on our boards). There is a script similar to the one above that runs on first-boot which expands the last partition to the extents of the device and grows the partition to fill it. See https://github.com/Gateworks/ubuntu-rootfs/blob/master/ubuntu-rootfs.sh and look for 'growpart' for details.
     233
     234[=#disk-images]
     235== Building a Bootable Disk Image ==
     236You will want to build your own Ubuntu disk image if you want control over any of the following:
     237 * Contents of root filesystem (packages and configuration) (see [#debootstrap debootsrap below)
     238 * Configuration of the Linux kernel (see [wiki:venice/bsp#kernel venice/bsp/kernel])
     239
     240See [wiki:venice/boot#disk-images venice/boot/disk-images] for detailed instructions.