Changes between Initial Version and Version 1 of ventana/ubuntu


Ignore:
Timestamp:
10/22/2017 05:28:45 AM (2 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ventana/ubuntu

    v1 v1  
     1[[PageOutline]]
     2
     3
     4= Ubuntu on Ventana =
     5[[Image(trusty-ventana-lxde.png,400px)]]
     6
     7While Gateworks cannot fully support all Linux distros, it is relatively simple to overlay a Gateworks Ventana kernel onto any non-Gateworks third party Linux distro rootfs image. For a full list of Linux BSP's for Ventana see [wiki:ventana#bsp here]
     8
     9See the Gateworks Ventana [wiki:ventana#third_party_linux third party linux] page for more details on how to use other linux distro on Ventana.
     10
     11
     12[=#prebuilt]
     13== Gateworks pre-built Ubuntu Disk Image ==
     14Gateworks provides some pre-built Ubuntu firmware images for the Ventana Family:
     15||= Name              =||= Size =||= Features =||
     16|| xenial-ventana      || ~600MB^^^1^^^ || console support - Ubuntu kernel/drivers ||
     17|| trusty-ventana      || ~210MB  || console support - Gateworks kernel/drivers ||
     18|| trusty-mm-ventana   || ~650MB^^^1^^^ || HW acclerated gstreamer/gstreamer-imx ||
     19|| trusty-x11-ventana  || ~1000MB^^^1^^^ || HW accelerated X11 support with LXDE ||
     20^1. requires 'large' flash size (2GB) or 1GB and larger of removable storage
     21
     22For a full Board Support Package providing building a Linux distro from source, please see the OpenWrt, Yocto, or Android BSP from the [wiki:ventana#bsp Ventana BSP] page
     23
     24
     25=== Ubuntu 16.04 LTS (Xenial Xerus) console image ===
     26A pre-built console image created using the  [#debootstrap debootstrap] method for [http://releases.ubuntu.com/16.04/ Ubuntu 16.04 (Xenial Xerus)] can be downloaded:
     27 * [http://blog.gateworks.com/?wpdmpro=xenial-ventana_large-ubi-2 xenial-ventana_large.ubi] - UBI image for 2GB Flash boards (see wiki:/linux/ubi#BasicMethod for info about flashing UBI images) (sha256sum: e366c22c99353525ce4014ec3cf9d2bdb7e3a8ff4228ad49fc7d383abe3a4753)
     28 * [http://blog.gateworks.com/?wpdmpro=xenial-ventana-tar-gz-2 xenial-ventana.tar.gz] - tarball of rootfs you can use to image onto microSD / mSATA using instructions from [wiki:linux/blockdev linux/blockdev] (sha256sum: ad5529c6aaf142ec69034256ad14c7ec3c317f3fe0a2616ff00fc7d8907dada7)
     29
     30Features:
     31- Ubuntu 16.04 core (from debootstrap instructions)
     32- Ubuntu Xenial kernel (Linux 4.11 based) with drivers/firmware
     33- custom bootscript supporting NAND/UBI, MMC, SATA, USB boot devices and root filesystems
     34- extra packages: openssh-server can-utils i2c-tools usbutils pciutils
     35- eth0 dhcp
     36- user root passwd root
     37- *** Note ***: This is a mainline kernel that does not have Video Hardware Acceleration support for gstreamer and a few other Gateworks specific items. For more information, read [wiki:ventana#MainlineLinuxKernelsupport Gateworks Mainline Linux Support]
     38
     39
     40=== Ubuntu 14.04 LTS (Trusty Tahr) console image ===
     41A pre-built console image created using the  [#debootstrap debootstrap] method for [http://releases.ubuntu.com/14.04/ Ubuntu 14.04 (Trusty Tahr)] can be downloaded:
     42 * [http://dev.gateworks.com/ubuntu/trusty/trusty-ventana_large.ubi trusty-ventana_large.ubi] - UBI image for 2GB Flash boards (see wiki:/linux/ubi#BasicMethod for info about flashing UBI images)
     43 * [http://dev.gateworks.com/ubuntu/trusty/trusty-ventana_normal.ubi trusty-ventana_normal.ubi] - UBI image for 256MB Flash boards (see wiki:/linux/ubi#BasicMethod for info about flashing UBI images)
     44 * [http://dev.gateworks.com/ubuntu/trusty/trusty-ventana.tar.gz trusty-ventana.tar.gz] - tarball of rootfs you can use to image onto microSD / mSATA using instructions from [wiki:linux/blockdev linux/blockdev]
     45
     46Features:
     47- Ubuntu 14.04 core (from debootstrap instructions)
     48- Gateworks 3.14 kernel with modules
     49- ventana bootscript
     50- extra packages: openssh-server can-utils i2c-tools usbutils pciutils
     51- eth0 dhcp
     52- user root passwd root
     53
     54
     55
     56=== Ubuntu 14.04 LTS (Trusty Tahr) multimedia image ===
     57A pre-built console image created using the [#debootstrap debootstrap] method for [http://releases.ubuntu.com/14.04/ Ubuntu 14.04 (Trusty Tahr)] and adding gstreamer-imx for IPU/VPU/GPU hw video acceleration can be downloaded:
     58 * [http://blog.gateworks.com/?wpdmpro=trusty-mm-ventana_large-ubi trusty-mm-ventana_large.ubi] - UBI image for 2GB Flash boards (see wiki:/linux/ubi#BasicMethod for info about flashing UBI images)
     59 * [http://blog.gateworks.com/?wpdmpro=trusty-mm-ventana-tar-gz trusty-mm-ventana.tar.gz] -  tarball of rootfs you can use to image onto microSD / mSATA using instructions from [wiki:linux/blockdev linux/blockdev]
     60
     61
     62Features:
     63- Ubuntu 14.04 core (from debootstrap instructions)
     64- Gateworks 3.14 kernel with modules
     65- ventana bootscript
     66- extra packages: openssh-server can-utils i2c-tools usbutils pciutils
     67- eth0 dhcp
     68- user root passwd root
     69- gstreamer (gstreamer1.0-x gstreamer1.0-tools gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-alsa)
     70- fsl vpu firmware
     71- fsl lib-vpu
     72- fsl codec library
     73- fsl libg2d
     74- dev tools (build-essential autoconf libtool wget python pkg-config git)
     75- python
     76- gstreamer/gstreamer-imx/libimxvpuapi
     77- v4l-utils
     78
     79For details on Gstreamer and Gstreamer-imx see our [wiki:Yocto/gstreamer page]
     80
     81
     82=== Ubuntu 14.04 LTS (Trusty Tahr) X11 LXDE image ===
     83A pre-built console image created using the  [#debootstrap debootstrap] method for [http://releases.ubuntu.com/14.04/ Ubuntu 14.04 (Trusty Tahr)] and adding gstreamer-imx for IPU/VPU/GPU hw video acceleration as well as X11/LXDE with hardware acceleration can be downloaded:
     84 * [http://blog.gateworks.com/?wpdmpro=trusty-x11-ventana_large-ubi-2 trusty-x11-ventana_large.ubi] - UBI image for 2GB Flash boards (see wiki:/linux/ubi#BasicMethod for info about flashing UBI images)
     85 * [http://blog.gateworks.com/?wpdmpro=trusty-x11-ventana-tar-gz trusty-x11-ventana.tar.gz] - tarball of rootfs you can use to image onto microSD / mSATA / USB using instructions from [wiki:linux/blockdev linux/blockdev]
     86
     87
     88Features:
     89- ubuntu 14.04 core (from debootstrap instructions)
     90- Gateworks 3.14 kernel with modules
     91- ventana bootscript
     92- extra packages: openssh-server can-utils i2c-tools usbutils pciutils
     93- eth0 dhcp
     94- user root passwd root
     95- gstreamer (gstreamer1.0-x gstreamer1.0-tools gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-alsa)
     96- fsl vpu firmware
     97- fsl lib-vpu
     98- fsl codec library
     99- fsl libg2d
     100- dev tools (build-essential autoconf libtool wget python pkg-config git)
     101- python
     102- gstreamer/gstreamer-imx/libimxvpuapi
     103- v4l-utils
     104- lxde
     105
     106
     107
     108
     109
     110[=#packages]
     111== Ubuntu Packages ==
     112Ubuntu inherits its package management from Debian Linux using the 'apt' packaging system and 'deb' packages. The list of package feeds is in /etc/apt/sources.list:
     113{{{
     114#!bash
     115# cat rootfs/etc/apt/sources.list
     116deb http://ports.ubuntu.com/ubuntu-ports vivid main
     117deb http://ports.ubuntu.com/ubuntu-ports vivid universe
     118}}}
     119
     120You can search for Ubuntu packages at https://launchpad.net/ubuntu. The search results will show what Ubuntu versions (by name) the package is available in and clicking on the resulting package will show information as to the package feed its contained in.
     121
     122The standard Ubuntu package feeds are located at http://ports.ubuntu.com/ubuntu-ports/ and you will find packages in the dist/<ubuntu-version>/<feed> directories. Ubuntu breaks up feeds into the following:
     123 * Main - Officially supported software.
     124 * Restricted - Supported software that is not available under a completely free license.
     125 * Universe - Community maintained software, i.e. not officially supported software.
     126 * Multiverse - Software that is not free. (meaning licensing)
     127
     128If you are trying to find out what package an application belongs to you have a few choices:
     129 1. Use {{{dpkg -S}}} on your Ubuntu development host. For example to find the package that contains ifconfig:
     130{{{
     131#!bash
     132$ dpkg -S $(which ifconfig)
     133net-tools: /sbin/ifconfig
     134}}}
     135  * ifconfig is in /sbin/ifconfig and is part of the net-tools package
     136  * {{{dpkg -L net-tools}}} will show you everything else contained in that package
     137 2. Use {{{apt-cache search}}}:
     138{{{
     139#!bash
     140$ apt-cache search ifconfig
     141iproute2 - networking and traffic control tools
     142net-tools - The NET-3 networking toolkit
     143gnome-nettool - network information tool for GNOME
     144inetutils-tools - base networking utilities (experimental package)
     145libnet-ifconfig-wrapper-perl - multiplatform Perl wrapper for ifconfig
     146moreutils - additional Unix utilities
     147wmifinfo - Dockapp that shows information for all interfaces
     148}}}
     149 3. Googling the question 'what package contains <xyz>'
     150
     151Personal Package Archives (PPAs) are package feeds that are not part of Ubuntu and can be used by people to distribute their own personally built packages. To use a PPA you need to first add it to your repository list and update your package sources.
     152
     153References:
     154 * [https://help.ubuntu.com/community/Repositories/Ubuntu Ubuntu Software Repositories]
     155 * [http://askubuntu.com/questions/4983/what-are-ppas-and-how-do-i-use-them What are PPAs and how do I use them]
     156
     157
     158[=#kernel]
     159== Kernel Updates ==
     160Ubuntu releases are based on a specific major kernel version. However over time the Ubuntu team releases new major kernel version updates for specific distro versions. An {{{apt-get install linux-image}}} will not change the kernel major version and you have to specifically install a new major version to switch to it.
     161
     162For example the latest kernel release available for Ubuntu 16.04 (Xenail) LTS is 4.11 and can be installed with the following:
     163{{{#!bash
     164apt-get update
     165apt-get install linux-image-4.11.0-14-generic
     166# install mkimage
     167apt-get install u-boot-tools
     168# create u-boot image for kernel
     169mkimage -A arm -O linux -T kernel -C none \
     170  -a 0x10008000 -e 0x10008000 -n "linux" \
     171  -d /boot/vmlinuz-4.11.0-14-generic /boot/uImage
     172# install device-tree blobs
     173cp /lib/firmware/4.11.0-14-generic/device-tree/imx6*-gw*.dtb /boot
     174}}}
     175 - use {{{apt-get search linux-image}}} to determine what Ubuntu kernel versions are available
     176
     177
     178
     179
     180[=#modem]
     181== Modem Support ==
     182Aleksander Morgado (​https://aleksander.es), a key developer behind the !ModemManager, libqmi, and libmbim projects that provide modem support on Ubuntu provides up-to-date Ubuntu PPA's for 14.04 trusty and 16.04 xenial.
     183
     184For Xenial:
     185{{{#!bash
     186apt-get install software-properties-common # contains add-apt-repository
     187add-apt-repository ppa:aleksander-m/modemmanager-xenial
     188apt-get update
     189apt-get install modemmanager libqmi-utils libmbim-utils network-manager
     190}}}
     191
     192See [wiki:wireless/modem modem] for more info on how to use these packages
     193
     194
     195[=#ssh]
     196== ssh server ==
     197The {{{openssh-server}}} package provides an ssh daemon suitable for secure shell (ssh) and secure copy (scp):
     198{{{
     199#!bash
     200apt-get install openssh-server
     201}}}
     202
     203During development it may be useful to enable root ssh capability, which is disabled by default. To do this  edit /etc/ssh/sshd_config, and:
     2041. comment out the following line:
     205{{{
     206#!bash
     207PermitRootLogin without-password
     208}}}
     2092. Just below it, add the following line:
     210{{{
     211#!bash
     212PermitRootLogin yes
     213}}}
     2143. Then reload SSH config:
     215{{{
     216#!bash
     217service ssh reload
     218}}}
     219
     220
     221== Root filesystem Sources ==
     222There are several sources of pre-built root filesystems that are compatible with Ventana. As Ventana uses an i.MX6 SoC, you need to use something that is compatible with an ARMv7 instruction set. Many pre-built distributions will reference 'armhf' which means 'ARM hard-float' which is appropriate for the i.MX6 as it has hardware floating-point.
     223
     224Sources:
     225 * [#debootstrap build your own via debootstrap] '''(recommended)'''
     226 * [#ubuntu-core Ubuntu Core] - this is a minimal filesystem that you can build off of at runtime by adding packages from various repositories:
     227 * [#linaro Linaro] - Linaro has several root filesystems including server, nano, developer, core, and ALIP.  Each root filesystem will have different things installed for different purposes.  Choose carefully which will work for you.
     228
     229
     230[=#ubuntu-core]
     231=== Ubuntu Core ===
     232Ubuntu has supported [http://cdimage.ubuntu.com/ubuntu-core/releases Ubuntu core] builds for the ARMv7 Application Processor family (Cortex A8, A9, and above with hardware float) since the 12.04 (Precise Pangolin) releases. Canocial provides multiple images that contain differing functionality (desktop, server, cloud, etc). Since 12.04 they have been providing a 'core' image (Ubuntu Core) which is a minimal rootfs for the use in the creation of custom images for specific needs. This is a suitable rootfs to start with. To deploy Ubuntu Core you need to use an Ubuntu Core rootfs from [http://cdimage.ubuntu.com/ubuntu-core/releases/ here], and a Ventana kernel (kernel + device-tree dtbs + modules).
     233
     234Notes:
     235 * Ubuntu Core ships with no local users, therefore you will need to add a local user and passwd then add that user to adm and sudo groups manually before booting the image
     236 * You can use apt-get to install additional packages
     237
     238References:
     239 * [https://wiki.ubuntu.com/Core Ubuntu Core Wiki]
     240 * http://cdimage.ubuntu.com/ubuntu-core/releases/
     241
     242
     243[=#linaro]
     244=== Linaro ===
     245The [https://releases.linaro.org/ Linaro] Developer Platform Team also creates Ubuntu flavored images.
     246
     247Linaro is a non profit org that manages engineers who work on improving the state of ARM open source software.
     248
     249They provide 4 different types of rootfs to choose from (unlike the single minimal rootfs choice Ubuntu Core provides):
     250 * '''Nano''' - minimum rootfs containing console support and apt package management
     251 * '''Developer''' - minimum rootfs containing console support and apt package management and development tools (toolchain, debuggers, profiling, etc)
     252 * '''ALIP''' - a small distribution created using upstream Ubuntu packages containing LXDE (Lubuntu) with lightdm, X11 and chromium as the default graphics applications but still with an emphasis on small size
     253 * '''Ubuntu Desktop''' - basically a stock Ubuntu Desktop environment with a few extra packages which should bring the same environment you would find with Unity, Firefox, etc.
     254
     255These rootfs images can be found [https://releases.linaro.org here] within directories based on a year and a month. These directories are not to be confused with Ubuntu versions (also based on a year and a month). '''Note that not all the above rootfs images are available for every monthly build.'''
     256
     257For example, you can find the Linaro built Ubuntu 14.04 (trusty) rootfs images at https://releases.linaro.org/14.07/ubuntu/trusty-images
     258
     259References:
     260 * [https://wiki.linaro.org/Platform/DevPlatform/Rootfs Linaro Rootfs Wiki]
     261 * https://releases.linaro.org/
     262
     263Notes:
     264 * You can use apt-get to install additional packages
     265
     266
     267[=#debootstrap]
     268=== Build your own Ubuntu rootfs via debootstrap ===
     269The preferred way to create a 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-arm.
     270
     271Requirements:
     272- Linux Ubuntu or Debian System with network connection and sudo permissions
     273- Linux Kernel (ie Gateworks latest pre-built 3.14 kernel with full hardware support, Ubuntu pre-built kernel (missing full video in/out support but more up-to-date), or a vanilla mainline kernel (still missing full video in/out support but even more up-to-date), or a kernel of your own) - see below steps for more detail
     274- Ventana target board with bootloader
     275- boot device with 300MB+ of free space (micro-SD, USB mass storage, mSATA, 2GB NAND flash)
     276
     277Important notes:
     278 * 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.
     279
     280Steps:
     2811. Install pre-requisites:
     282{{{
     283#!bash
     284sudo apt-get install qemu-user-static debootstrap binfmt-support
     285}}}
     286
     2872. Perform first stage install of minimal filesystem:
     288{{{
     289#!bash
     290target=rootfs
     291distro=xenial
     292sudo debootstrap --arch=armhf --foreign $distro $target
     293# copy qemu-arm-static binary for the binfmt packages to find it and copy in resolv.conf from host
     294sudo cp /usr/bin/qemu-arm-static $target/usr/bin
     295}}}
     296 * See http://ports.ubuntu.com/ubuntu-ports/dists/ for a list of current Ubuntu releases: 16.10=yakkety (latest), 16.04=xenial (latest LTS), 15.04=vivid, 14.10=utopic (LTS), 14.04=trusty (LTS), 12.04=precise (LTS), 10.04=lucid (LTS).
     297 * this minimal rootfs can be considered about the same as an Ubuntu-core downloaded rootfs however it 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
     298 * the chroot shell below will provide network support (inherited from the host)
     299
     3003. we now have a minimal Ubuntu rootfs - chroot to it and perform the 2nd stage install:
     301{{{
     302#!bash
     303sudo chroot $target
     304# now we are in the chroot
     305distro=xenial
     306export LANG=C
     307# setup second stage
     308/debootstrap/debootstrap --second-stage
     309}}}
     310 * this is the most minimal rootfs we would recommend
     311
     3124. (optional) add additional apt package repos:
     313{{{
     314#!bash
     315cat <<EOT > /etc/apt/sources.list
     316deb http://ports.ubuntu.com/ubuntu-ports $distro main restricted universe multiverse
     317deb http://ports.ubuntu.com/ubuntu-ports $distro-updates main restricted universe multiverse
     318deb http://ports.ubuntu.com/ubuntu-ports $distro-security main restricted universe multiverse
     319EOT
     320}}}
     321 * you may want to customize the above list, depending on your needs. See [#packages below] for more detail on Ubuntu package feeds
     322
     3235. (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)
     324{{{
     325#!bash
     326apt-get update
     327apt-get -f install # fixup missing package dependencies
     328apt-get install locales dialog
     329dpkg-reconfigure locales
     330}}}
     331
     3326. set hostname:
     333{{{
     334#!bash
     335echo ${distro}-armhf > /etc/hostname
     336}}}
     337
     3387. create a default fstab:
     339{{{
     340#!bash
     341cat <<EOT > /etc/fstab
     342/dev/root            /                    auto       defaults              1  1
     343EOT
     344}}}
     345 * Note that this not required if you pass in 'rw' on the kernel cmdline. However while that is the default for the Ventana bootscripts for removeable storage it is not for NAND boot, therefore we will add a default fstab that will re-mount the kernel mounted rootfs as read-write
     346 * /dev/root in /etc/fstab will refer to the rootfs mounted by the kernel, thus the above entry simply re-mounts rootfs as read-write
     347
     3488. set a root passwd so you can login
     349{{{
     350#!bash
     351passwd
     352}}}
     353 - or consider adding a user via {{{adduser}}}:
     354{{{
     355#!bash
     356adduser myuser
     357usermod -a -G tty myuser # add to tty group for tty access
     358usermod -a -G dialout myuser # add to dialout group for UART access
     359usermod -a -G sudo myuser # add to sudo group for root access
     360}}}
     361
     3629. (optional) configure networking:
     363 - wired ethernet with DHCP on eth0
     364{{{
     365#!bash
     366cat <<EOF >> /etc/network/interfaces
     367allow-hotplug eth0
     368auto eth0
     369iface eth0 inet dhcp
     370
     371EOF
     372}}}
     373 - or static IP:
     374{{{
     375#!bash
     376cat <<EOF >> /etc/network/interfaces
     377allow-hotplug eth0
     378auto eth0
     379iface eth0 inet static
     380address 192.168.1.1
     381netmask 255.255.255.0
     382gateway 192.168.1.254
     383
     384EOF
     385}}}
     386 - or wireless (requires ~3MB of additional packages):
     387{{{
     388#!bash
     389apt-get install wpasupplicant iw
     390cat << EOF >> /etc/network/interfaces
     391# Wireless interface
     392auto wlan0
     393iface wlan0 inet dhcp
     394        wireless_mode managed
     395        wireless_essid any
     396        wpa-driver nl80211
     397        wpa-conf /etc/wpa_supplicant.conf
     398
     399EOF
     400wpa_passphrase <myssid> <mypass> >> /etc/wpa_supplicant.conf
     401}}}
     402
     40310. (optional) install some useful packages
     404{{{
     405#!bash
     406apt-get install openssh-server # ssh server for remote access
     407apt-get install can-utils i2c-tools usbutils pciutils # cmdline tools for various Ventana hardware support
     408}}}
     409 * Note that by default root ssh access is disabled for security. See [#ssh below] for info on enabling it
     410
     41111. install a kernel and kernel support (kernel+dtbs+modules+firmware+initrd). You have several options here:
     412 a. Ubuntu Pre-built kernel (includes the most kernel drivers and is built by and supported by Ubuntu):
     413{{{#!bash
     414# disable flash-kernel as its not needed and will otherwise error out
     415echo "FLASH_KERNEL_SKIP=1" >> /etc/environment
     416# install kernel/firmware/headers
     417apt-get install linux-generic
     418# install mkimage
     419apt-get install u-boot-tools
     420# create u-boot image for kernel
     421mkimage -A arm -O linux -T kernel -C none \
     422  -a 0x10008000 -e 0x10008000 -n "linux" \
     423  -d /boot/vmlinuz-*-generic /boot/uImage
     424# install device-tree blobs
     425cp /lib/firmware/*-generic/device-tree/imx6*-gw*.dtb /boot
     426}}}
     427  * The default Ubuntu kernel supports booting a microSD/SATA rootfs directly, but lacks nand/ubifs/ubi/usb-storage support. If you need that (and have a large enough flash to boot from that) you will need to use the Ubuntu initrd:
     428   - add NAND/ubifs/usb-storage modules to the initrd:
     429{{{#!bash
     430cat << EOF >> /etc/initramfs-tools/modules
     431# for NAND/ubi
     432gpmi_nand
     433ubi mtd=2
     434ubifs
     435
     436# for usb-storage
     437ci_hdrc_imx
     438usb-storage
     439EOF
     440update-initramfs -u # press 'Enter' when prompted
     441# create u-boot image for initrd
     442mkimage -A arm -O linux -T ramdisk \
     443  -a 0x0 -e 0x0 -n "initrd" \
     444  -d /boot/initrd.img-*-generic /boot/uramdisk
     445}}}
     446   - create a bootscript that uses the Ubuntu initrd appropriately for NAND/usb-storage (utilizing the 'dtype' var that is set by the default ventana bootscript):
     447{{{#!bash
     448cat << EOF > /tmp/bootscript
     449
     450# if nand|usb dtype use initrd - sata|mmc don't require initrd
     451if itest.s "x\${dtype}" == "xnand" ; then
     452  echo "Booting from NAND/ubifs..."
     453  setenv bootargs "console=\${console},\${baudrate} root=ubi0:rootfs rootfstype=ubifs rootwait \${video} \${extra}"
     454  ubifsload \$fdt_addr boot/\$fdt_file ||
     455  ubifsload \$fdt_addr boot/\$fdt_file1 ||
     456  ubifsload \$fdt_addr boot/\$fdt_file2
     457  test -n "\$fixfdt" && run fixfdt
     458  ubifsload \$loadaddr boot/uImage
     459  ubifsload 16000000 boot/uramdisk
     460  ubifsumount
     461  bootm \$loadaddr 16000000 \$fdt_addr
     462elif itest.s "x\${dtype}" == "xusb" ; then
     463  echo "Booting from usb..."
     464  setenv bootargs "console=\${console},\${baudrate} root=/dev/sda1  rootwait \${video} \${extra}"
     465  ext4load usb 0:1 \$fdt_addr boot/\$fdt_file ||
     466  ext4load usb 0:1 \$fdt_addr boot/\$fdt_file1 ||
     467  ext4load usb 0:1 \$fdt_addr boot/\$fdt_file2
     468  test -n "\$fixfdt" && run fixfdt
     469  ext4load usb 0:1 \$loadaddr boot/uImage
     470  ext4load usb 0:1 16000000 boot/uramdisk
     471  bootm \$loadaddr 16000000 \$fdt_addr
     472fi
     473EOF
     474mkimage -A arm -O linux -T script -n "bootscript" \
     475  -d /tmp/bootscript /boot/6x_bootscript-ventana
     476}}}
     477 a. Gateworks pre-built downstream vendor kernel: 3.14 kernel supporting full video input (which is not currently in upstream Linux) - ** use this if you are going to be using video input **
     478{{{
     479#!bash
     480cd /
     481wget http://svn.gateworks.com/ventana/images/gateworks-linux-imx6-3.14.48.tar.gz
     482tar -xvf gateworks-linux-imx6-3.14.48.tar.gz
     483depmod $(ls /lib/modules/) # create module dependencies
     484rm gateworks-linux-imx6-3.14.48.tar.gz
     485}}}
     486  * the {{{depmod}}} trick above is to run depmod with the exact kernel version (which will be the subdir in /lib/modules). An alternative is to run {{{depmod}}} after the first boot
     487 a. Build your own kernel and install it as above with proper bootscript - see [wiki:linux/kernel#building] for more info (you can do this on a development host with a cross-toolchain or even even install development tools via the '''build-essential''' meta-package and build and install sources such as the kernel below (adds appx 180MB))
     488
     48912. exit the chroot shell and remove files we no longer need
     490{{{
     491#!bash
     492exit
     493sudo rm $target/usr/bin/qemu-arm-static
     494}}}
     495
     49613. install to bootable media:
     497 * For a removable block storage device supported by your board such as a USB Mass Storage device, a microSD, an mSATA SSD the example below will create a single ext4 rootfs partition on a removable block storage device. Ensure you set DEVICE properly for your system. We use the 'udisks' application for mount/unmount so that the mount-point is obvious - if you know what your doing you could use standard mount/unmount as well:
     498{{{
     499#!bash
     500DEVICE=/dev/sdc
     501# unmount all auto-mounted partitions for this device
     502sudo umount ${DEVICE}?
     503# partition disk - single ext partition
     504printf ",,L,,\n" | sudo sfdisk -uS ${DEVICE}
     505sync
     506sudo mkfs.ext4 -L rootfs ${DEVICE}1
     507# mount partition (will mount to /media/rootfs/)
     508sudo udisks --mount ${DEVICE}1
     509# copy the root filesystem
     510sudo cp -rupv $target/*  /media/rootfs/
     511# unmount the disk
     512sudo udisks --unmount ${DEVICE}1
     513}}}
     514 * To create a ubifs suitable for 2GB NAND flash (large layout) use the following:
     515{{{
     516#!bash
     517mkfs.ubifs -d $target -F -m 4096 -e 248KiB -c 8124 -x zlib -o ${distro}_large.ubifs
     518}}}
     519  * For details on how to flash this onto NAND see [wiki:linux/ubi#uboot-ubifs]
     520
     521==== version-specific notes ====
     522===== trusty (14.04) LTS =====
     523An extra step is needed for serial console configuration:
     524{{{
     525#!bash
     526cat << EOT >> /etc/init/serial.conf
     527start on stopped rc RUNLEVEL=[2345]
     528stop on runlevel [!2345]
     529respawn
     530exec /sbin/getty 115200 ttymxc1
     531EOT
     532}}}
     533
     534
     535[=#gstreamer-imx]
     536== Adding GStreamer IPU/VPU/GPU support via gstreamer-imx ==
     537You can easily add IMX6 IPU, VPU, and GPU support via GStreamer and Gstreamer-imx plugins. Many of the pieces needed (firmware and source-code) are from Freescale and not freely redistributable thus must be downloaded from their mirror and extracted from a shell script that forces you to read and agree to their End User License Agreement (EULA).
     538
     539This support requires that you are using the Gateworks downstream vendor kernel as it has the necessary driver support that is not in the mainline Linux kernel.
     540
     541There are several pre-requisites you will need to install and/or build using the instructions below:
     542 - Gateworks downstream vendor kernel (containing non-upstreamed IPU/VPU/GPU drivers) with kernel headers. See [wiki:linux/kernel here] for instructions on building, or [http://svn.gateworks.com/ventana/images/gateworks-linux-imx6-3.14.48.tar.gz here] for a pre-built kernel tarball
     543 - gstreamer and libs
     544 - firmware-imx-3.14.28-1.0.0.bin - Freescale VPU firmware (EULA required)
     545 - imx-vpu-5.4.31.bin - Freescale lib_vpu (EULA required) - this is the low-level documented API that works with the (undocumented) VPU kernel driver API. You can think of this as a kernel driver in userspace
     546 - libfslcodec-4.0.3.bin - Freescale Codec Library (EULA required)
     547 - imx-gpu-viv-5.0.11.p4.5-hfp.bin - Freescale libg2d (EULA required) - this is the low-level documented API that works with the (undocumented) Vivante Galcore GPU kernel driver API. You can think of this as a kernel driver in userspace
     548 - libimxvpuapi - community based open-source high-level library over the low-level imx-vpu API
     549 - gstreamer-imx - community based open-source GStreamer plugins to utilize hardware accellerated capture, display, transforms, compositing, decode, encode capabilities of the IMX6.
     550
     551
     552The following instructions can be used on top of the [#debootstrap debootstrap created rootfs] but should work on other sources of Ubuntu or other Linux distributions root filesystems as well.
     553
     5541. install build deps (~165MB):
     555{{{
     556#!bash
     557apt-get install build-essential autoconf libtool wget python pkg-config git
     558}}}
     559
     5602. install gstreamer1.x (~200MB):
     561{{{
     562#!bash
     563apt-get install gstreamer1.0-x gstreamer1.0-tools
     564# install videoparserbad for video parsers like h264parse, mpegvideoparse and mpeg4videoparse
     565apt-get install gstreamer1.0-plugins-good gstreamer1.0-plugins-bad
     566# install alsa plugin
     567apt-get install gstreamer1.0-alsa
     568}}}
     569 * note that the gstreamer1.0-plugins-bad meta-package is in the multiverse package feed
     570 * at this point you could use 'gst-launch-1.0 videotestsrc ! fbdevsink' but it will not stretch to the display, and will not be hardware accelerated
     571
     5723. install Freescale VPU firmware (firmware-imx) (EULA required)
     573{{{
     574#!bash
     575wget http://www.freescale.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-3.14.28-1.0.0.bin
     576/bin/sh firmware-imx-*.bin
     577# install firmware
     578mkdir -p /lib/firmware/vpu
     579cp firmware-imx-*/firmware/vpu/vpu_fw_imx6*.bin /lib/firmware/vpu
     580}}}
     581
     5824. build and install Freescale lib_vpu (EULA required)
     583{{{
     584#!bash
     585wget http://www.freescale.com/lgfiles/NMG/MAD/YOCTO/imx-vpu-5.4.31.bin
     586/bin/sh imx-vpu-*.bin
     587cd imx-vpu-*
     588make PLATFORM=IMX6Q all
     589make install # installs vpu_lib.h and vpu_io.h in /usr/include and libvpu.* in /usr/lib
     590cd ..
     591}}}
     592
     5935. (optional) build and install Freescale Codec Library (libfslcodec) (EULA required)
     594{{{
     595#!bash
     596wget http://www.freescale.com/lgfiles/NMG/MAD/YOCTO/libfslcodec-4.0.3.bin
     597/bin/sh libfslcodec-*.bin
     598cd libfslcodec-*
     599./autogen.sh --prefix=/usr --enable-fhw --enable-vpu
     600make all
     601make install
     602# move the libs where gstreamer plugins will find them
     603mv /usr/lib/imx-mm/video-codec/* /usr/lib
     604mv /usr/lib/imx-mm/audio-codec/* /usr/lib
     605rm -rf /usr/lib/imx-mm/
     606cd ..
     607}}}
     608 * this is optional and is needed if you want the audio codec support in gstreamer-imx
     609 * Note the Makefile will install the libs into $prefix/lib/imx-mm which is undesirable so we move them after 'make install'
     610
     6116. (optional) install Freescale libg2d (EULA required)
     612{{{
     613#!bash
     614wget http://www.freescale.com/lgfiles/NMG/MAD/YOCTO/imx-gpu-viv-5.0.11.p4.5-hfp.bin
     615/bin/sh imx-gpu-viv-*.bin
     616cd imx-gpu-viv-*
     617# install just the g2d headers/libs
     618cp g2d/usr/include/* /usr/include/
     619cp -d g2d/usr/lib/* /usr/lib/
     620# install gpu-core headers/libs
     621cp -d gpu-core/usr/lib/*.so* /usr/lib/
     622cp -Pr gpu-core/usr/include/* /usr/include/
     623# optional: install demos
     624cp -r gpu-demos/opt /
     625# optional: install gpu tools
     626cp -axr gpu-tools/gmem-info/usr/bin/* /usr/bin/
     627cd ..
     628}}}
     629 * this is part of the Freescale Vivante GPU driver and apps (imx-gpu-viv) package which provides libgl/libgles1/libgles2/wayland-egl/libgal-x11/egl/libopenvg/libg2d
     630 * it comes in soft-float (sfp) and hard-float (hfp) - we want the hard-float as we are using an armhf rootfs
     631 * this is not required but needed for the gstreamer-imx g2d transform and sink plugins
     632
     6337. build and install libimxvpuapi library:
     634 - This library provides a community based open-source API to the Freescale imx-vpu library (the low-level IMX6 VPU interface). It is a replacement for Freescale's closed-development libfslvapwrapper library.
     635{{{
     636#!bash
     637git clone git://github.com/Freescale/libimxvpuapi.git
     638cd libimxvpuapi
     639./waf configure --prefix=/usr
     640./waf
     641./waf install
     642cd ..
     643}}}
     644
     6458. build and install gstreamer-imx:
     646{{{
     647#!bash
     648apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev # +70MB
     649git clone git://github.com/Freescale/gstreamer-imx.git
     650cd gstreamer-imx
     651ln -s /usr/lib/arm-linux-gnueabihf/gstreamer-1.0/ /usr/lib/gstreamer-1.0
     652./waf configure --prefix=/usr --kernel-headers=/include
     653./waf
     654./waf install
     655cd ..
     656}}}
     657 * note './waf install' installs artifacts to its prefix + /lib/gstreamer-1.0 but they need to be installed to /usr/lib/arm-linux-gnueabihf/gstreamer-1.0 which is why we created a symlink above before installing
     658 * note the uniaudio decoder codecs are from Freescale (found in the fsl-mm-codeclib package) and you do not need these unless you want to use FSL's audio codecs instead of the GStreamer ones
     659 * note g2d lib required to build G2D
     660 * note that linux kernel headers are required to build PxP and IPU
     661 * note that x11 library is required to build EGL sink with Vivante direct textures (only needed for X11 support)
     662 * note that libfslaudiocodec is required to build audio plugins
     663 * After this step you should be able to see several plugins with {{{gst-inspect-1.0}}}:
     664{{{
     665#!bash
     666# gst-inspect-1.0 | grep imx
     667imxv4l2videosrc:  imxv4l2videosrc: V4L2 CSI Video Source
     668imxipu:  imxipucompositor: Freescale IPU video compositor
     669imxipu:  imxipuvideosink: Freescale IPU video sink
     670imxipu:  imxipuvideotransform: Freescale IPU video transform
     671imxpxp:  imxpxpvideotransform: Freescale PxP video transform
     672imxpxp:  imxpxpvideosink: Freescale PxP video sink
     673imxvpu:  imxvpuenc_mjpeg: Freescale VPU motion JPEG video encoder
     674imxvpu:  imxvpuenc_mpeg4: Freescale VPU MPEG-4 video encoder
     675imxvpu:  imxvpuenc_h264: Freescale VPU h.264 video encoder
     676imxvpu:  imxvpuenc_h263: Freescale VPU h.263 video encoder
     677imxvpu:  imxvpudec: Freescale VPU video decoder
     678imxg2d:  imxg2dcompositor: Freescale G2D video compositor
     679imxg2d:  imxg2dvideotransform: Freescale G2D video transform
     680imxg2d:  imxg2dvideosink: Freescale G2D video sink
     681}}}
     682
     6839. install a U-Boot bootscript to setup kernel parameters for your display output:
     684{{{
     685#!bash
     686apt-get install u-boot-tools
     687wget https://github.com/Freescale/meta-freescale-3rdparty/raw/master/recipes-bsp/u-boot/u-boot-script-gateworks-imx/6x_bootscript-yocto.txt
     688mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "boot script" -d 6x_bootscript-yocto.txt /boot/6x_bootscript-ventana
     689reboot # reboot to setup bootargs for display
     690}}}
     691 * The Freescale IMX6 display drivers use kernel parameters to configure what display outputs to enable and in what format. What displays, resolutions, and formats affect how much contiguous memory is needed (CMA) as well. The Gateworks Yocto BSP has a bootscript that configures connected displays based on various rules and we will use this here. See http://trac.gateworks.com/wiki/Yocto/Video_Out#DisplaysDevices for more info
     692
     693Now you will be able to use Gstreamer and Gstreamer-imx to tap the full potential of the IMX IPU/VPU/GPU hardware.
     694
     695Examples:
     696 * show gstreamer-imx plugins:
     697{{{
     698#!bash
     699# gst-inspect-1.0 | grep imx
     700imxvpu:  imxvpuenc_mjpeg: Freescale VPU motion JPEG video encoder
     701imxvpu:  imxvpuenc_mpeg4: Freescale VPU MPEG-4 video encoder
     702imxvpu:  imxvpuenc_h264: Freescale VPU h.264 video encoder
     703imxvpu:  imxvpuenc_h263: Freescale VPU h.263 video encoder
     704imxvpu:  imxvpudec: Freescale VPU video decoder
     705imxv4l2videosrc:  imxv4l2videosrc: V4L2 CSI Video Source
     706imxg2d:  imxg2dcompositor: Freescale G2D video compositor
     707imxg2d:  imxg2dvideotransform: Freescale G2D video transform
     708imxg2d:  imxg2dvideosink: Freescale G2D video sink
     709imxipu:  imxipucompositor: Freescale IPU video compositor
     710imxipu:  imxipuvideosink: Freescale IPU video sink
     711imxipu:  imxipuvideotransform: Freescale IPU video transform
     712imxpxp:  imxpxpvideotransform: Freescale PxP video transform
     713imxpxp:  imxpxpvideosink: Freescale PxP video sink
     714}}}
     715 * imxipuvideosink:
     716{{{
     717#!bash
     718gst-launch-1.0 videotestsrc ! imxipuvideosink
     719}}}
     720 * imxg2dvideosink:
     721{{{
     722#!bash
     723gst-launch-1.0 videotestsrc ! imxg2dvideosink
     724}}}
     725
     726See the [wiki:Yocto/gstreamer Gstreamer wiki page] for more details.
     727
     728
     729[=#X11]
     730== Adding X11 Support ==
     731You can easily add X11 support to a base image created with the debootstrap instructions above by adding a few package groups. You will need the following:
     732 * X11 server - ie Xorg
     733 * Display Manager - this controls the login to the X session
     734 * Window Manager - manages window position, re-sizing, decorations, etc for X clients
     735
     736A common solution is to install a Desktop Environment such as the [http://lxde.org/ Lightweight X11 Desktop Environment (LXDE)] that is used for Lubuntu. LXDE includes the Xorg X11 server, the lxdm Display Manager, the openbox Window Manager, and a slew of useful user applications including the Chromium browser:
     737{{{
     738#!bash
     739apt-get install lxde xinit # adds ~434MB to a base console image
     740}}}
     741
     742Notes:
     743 * you will need to add a non-root user with {{{adduser}}} for Chromium browser to work. You may choose to set up auto-login for that user by editing /etc/lxdm/default.conf and setting the {{{autologin}}} property in the {{{base}}} section at the beginning of the config file.
     744 * you will need to use a kernel with the vivante GPU driver built as a module or the Xorg server will crash
     745
     746=== Hardware GPU Acceleration for X11 ===
     747To add hardware GPU acceleration to X11 you need to add some libraries and drivers provided by Freescale from the imx-gpu-viv package. This requires signing Freescales End User License Agreement (EULA). This package provides the following:
     748 - libg2d - a documented low-level API to the GPU (used by things like libimxvpuapi for gstreamer-imx and the gpu-core drivers)
     749 - gpu-core - provides all the various OpenGL libs (libGL, libGLESv1_CM, libGLESv1_CL, libGLESv2, libGLSLC, libCLC, libEGL, libGAL, libOpenCL, libOpenVG) typically provided by the mesa project. Note that several versions of libEGL/libGAL/libGLESv2/libVIVANTE are provided for different backend rendering systems: dfb, fb, wl, x11.
     750
     751Procedure:
     7521. Install Freescale Vivante GPU libs (EULA):
     753{{{
     754#!bash
     755wget http://www.freescale.com/lgfiles/NMG/MAD/YOCTO/imx-gpu-viv-5.0.11.p4.5-hfp.bin
     756/bin/sh imx-gpu-viv-*.bin # accept EULA
     757cd imx-gpu-viv-*
     758# install just the g2d headers/libs
     759cp g2d/usr/include/g2d.h /usr/include/
     760cp -d g2d/usr/lib/libg2d* /usr/lib/
     761# install gpu-core headers/libs
     762cp -Pr gpu-core/usr/* /usr
     763# install vivante driver for accelerated X11:
     764cp vivante_drv.so /usr/lib/xorg/modules/drivers/
     765chmod 644 /usr/lib/xorg/modules/drivers/vivante_drv.so
     766# optional: install demos
     767cp -r gpu-demos/opt /
     768# optional: install gpu tools
     769cp -axr gpu-tools/gmem-info/usr/bin/* /usr/bin/
     770# fix lib collision between fsl/viv gpu-core and libgl1-mesa package
     771rm /usr/lib/arm-linux-gnueabihf/mesa/libGL.so*
     772# fix lib collision between fsl/viv gpu-core and libegl1-mesa package
     773rm /usr/lib/arm-linux-gnueabihf/mesa-egl/libEGL.so*
     774# fix lib collision between fsl/viv gpu-core and libgles1-mesa package
     775#rm /usr/lib/arm-linux-gnueabihf/libGLESv1_CM.so*
     776#rm /usr/lib/arm-linux-gnueabihf/mesa-egl/libGLESv1_CM.so*
     777# fix lib collision between fsl/viv gpu-core and libgles2-mesa package
     778#rm /usr/lib/arm-linux-gnueabihf/libGLESv2.so* # not there
     779rm /usr/lib/arm-linux-gnueabihf/mesa-egl/libGLESv2.so*
     780# fix lib collision between fsl/viv gpu-core and libopenvg1-mesa package
     781rm /usr/lib/arm-linux-gnueabihf/mesa-egl/libOpenVG.so*
     782}}}
     783 * Note: this could be better handled by creating a package and using Ubuntu/Debian 'alternatives' to handle library selection
     784
     7852. switch to gpu-core x11 backend:
     786{{{
     787#!bash
     788backend=x11
     789ln -sf libEGL-${backend}.so /usr/lib/libEGL.so
     790ln -sf libEGL-${backend}.so /usr/lib/libEGL.so.1
     791ln -sf libEGL-${backend}.so /usr/lib/libEGL.so.1.0
     792ln -sf libGAL-${backend}.so /usr/lib/libGAL.so
     793ln -sf libGLESv2-${backend}.so /usr/lib/libGLESv2.so
     794ln -sf libGLESv2-${backend}.so /usr/lib/libGLESv2.so.2
     795ln -sf libGLESv2-${backend}.so /usr/lib/libGLESv2.so.2.0.0
     796ln -sf libVIVANTE-${backend}.so /usr/lib/libVIVANTE.so
     797ln -sf libGAL_egl.dri.so /usr/lib/libGAL_egl.so
     798for i in egl glesv1_cm glesv2 vg; do
     799cp /usr/lib/pkgconfig/${i}_${backend}.pc /usr/lib/pkgconfig/${i}.pc
     800done
     801# remove the other backends we no longer need
     802rm /usr/lib/*-dfb.so /usr/lib/*-fb.so /usr/lib/*-wl.so
     803}}}
     804
     8053. make vivante kernel module (GPU kernel driver) load on boot:
     806{{{
     807#!bash
     808echo vivante >> /etc/modules
     809cat << EOT > /etc/udev/rules.d/10-imx.rules
     810KERNEL=="galcore",  MODE="0660", GROUP="video"
     811KERNEL=="mxc_asrc",  MODE="0666"
     812EOT
     813}}}
     814
     8154. create an xorg.conf configured for the Vivante fbdev driver:
     816{{{
     817#!bash
     818cat << EOT > /etc/X11/xorg.conf
     819Section "Device"
     820    Identifier  "i.MX Accelerated Framebuffer Device"
     821    Driver      "vivante"
     822    Option      "fbdev"     "/dev/fb0"
     823    Option      "vivante_fbdev" "/dev/fb0"
     824    Option      "HWcursor"  "false"
     825EndSection
     826
     827Section "ServerFlags"
     828    Option "BlankTime"  "0"
     829    Option "StandbyTime"  "0"
     830    Option "SuspendTime"  "0"
     831    Option "OffTime"  "0"
     832EndSection
     833EOT
     834}}}
     835
     8365. Optional: re-build gstreamer-imx ([#gstreamer-imx above]) if you wish to use gstreamer-imx IPU/VPU/GPU acceleration within an OpenGL window (egl)
     837
     8386. Sync filesystem and reboot
     839
     840
     841Examples:
     842 * The {{{imxeglvivsink}}} allows hardware accelerated display to a window on the X11 host:
     843{{{
     844#!bash
     845DISPLAY=:0.0 gst-launch-1.0 videotestsrc ! imxeglvivsink
     846}}}
     847  - See the [wiki:Yocto/gstreamer Gstreamer wiki page] for more details.
     848 * The {{{glxgears}}} application is a demo of OpenGL that often is used to benchmark rendering performance
     849{{{
     850#!bash
     851DISPLAY=:0.0 glxgears -info # ~300fps on IMX6Q
     852}}}
     853
     854== Wireless ==
     855
     856Please see [wiki:ventana/ubuntu/wireless here].
     857