Version 14 (modified by 6 years ago) ( diff ) | ,
---|
Ubuntu on Ventana
While 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 here
This page is dedicated details regarding running Ubuntu on an Gateworks Ventana Board.
See also:
- the Gateworks Ventana third party linux page for more details on how to use other linux distro on Ventana.
- Gateworks Ubuntu Page for general notes
Gateworks pre-built Ubuntu Disk Image
Gateworks provides some pre-built Ubuntu firmware images for the Ventana Family:
Name | Size | Features |
---|---|---|
xenial-ventana | ~600MB1 | console support - Ubuntu kernel/drivers |
trusty-ventana | ~210MB | console support - Gateworks kernel/drivers |
trusty-mm-ventana | ~650MB1 | HW acclerated gstreamer/gstreamer-imx |
trusty-x11-ventana | ~1000MB1 | HW accelerated X11 support with LXDE |
- requires 'large' flash size (2GB) or 1GB and larger of removable storage
For a full Board Support Package providing building a Linux distro from source, please see the OpenWrt, Yocto, or Android BSP from the Ventana BSP page
Ubuntu 16.04 LTS (Xenial Xerus) console image
- * Note *: This is a mainline kernel that does not have Video Hardware Acceleration suppor for gstreamer and a few other Gateworks specific items. For more information, read Gateworks Mainline Linux Support This image is not recommended depending on the requirements.
A pre-built console image created using the debootstrap method for Ubuntu 16.04 (Xenial Xerus) can be downloaded:
- xenial-ventana_20170831_large.ubi - UBI image for 1GB/2GB Flash boards (see wiki:/linux/ubi#BasicMethod for info about flashing UBI images) (sha256sum: e366c22c99353525ce4014ec3cf9d2bdb7e3a8ff4228ad49fc7d383abe3a4753)
- xenial-armhf-ventana_20170831.tar.gz - tarball of rootfs you can use to image onto microSD / mSATA using instructions from linux/blockdev (sha256sum: ad5529c6aaf142ec69034256ad14c7ec3c317f3fe0a2616ff00fc7d8907dada7)
Features:
- Ubuntu 16.04 core (from debootstrap instructions)
- Ubuntu Xenial kernel (Linux 4.11 based) with drivers/firmware
- custom bootscript supporting NAND/UBI, MMC, SATA, USB boot devices and root filesystems
- extra packages: openssh-server can-utils i2c-tools usbutils pciutils
- eth0 dhcp
- user root passwd root
Ubuntu 14.04 LTS (Trusty Tahr) console image
A pre-built console image created using the debootstrap method for Ubuntu 14.04 (Trusty Tahr) can be downloaded:
- trusty-ventana_large.ubi - UBI image for 1GB/2GB Flash boards (see wiki:/linux/ubi#BasicMethod for info about flashing UBI images)
- trusty-ventana_normal.ubi - UBI image for 256MB Flash boards (see wiki:/linux/ubi#BasicMethod for info about flashing UBI images)
- trusty-ventana.tar.gz - tarball of rootfs you can use to image onto microSD / mSATA using instructions from linux/blockdev
Features:
- Ubuntu 14.04 core (from debootstrap instructions)
- Gateworks 3.14 kernel with modules
- ventana bootscript
- extra packages: openssh-server can-utils i2c-tools usbutils pciutils
- eth0 dhcp
- user root passwd root
Ubuntu 14.04 LTS (Trusty Tahr) multimedia image
A pre-built console image created using the debootstrap method for Ubuntu 14.04 (Trusty Tahr) and adding gstreamer-imx for IPU/VPU/GPU hw video acceleration can be downloaded:
- trusty-armhf-ventana_20160112_large.ubi - UBI image for 1GB/2GB Flash boards (see wiki:/linux/ubi#BasicMethod for info about flashing UBI images)
- trusty-armhf-ventana_20160112.tar.gz - tarball of rootfs you can use to image onto microSD / mSATA using instructions from linux/blockdev
Features:
- Ubuntu 14.04 core (from debootstrap instructions)
- Gateworks 3.14 kernel with modules
- ventana bootscript
- extra packages: openssh-server can-utils i2c-tools usbutils pciutils
- eth0 dhcp
- user root passwd root
- gstreamer (gstreamer1.0-x gstreamer1.0-tools gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-alsa)
- fsl vpu firmware
- fsl lib-vpu
- fsl codec library
- fsl libg2d
- dev tools (build-essential autoconf libtool wget python pkg-config git)
- python
- gstreamer/gstreamer-imx/libimxvpuapi
- v4l-utils
For details on Gstreamer and Gstreamer-imx see our page
Ubuntu 14.04 LTS (Trusty Tahr) X11 LXDE image
A pre-built console image created using the debootstrap method for 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:
- http://blog.gateworks.com/?wpdmpro=trusty-x11-ventana_large-ubi - UBI image for 1GB/2GB Flash boards (see wiki:/linux/ubi#BasicMethod for info about flashing UBI images) (sha256sum:fc795f2ec1e302ec5ee746ec4435f090c32584187a875c02582e4dfac5fd1397)
- trusty-x11-ventana.tar.gz - tarball of rootfs you can use to image onto microSD / mSATA / USB using instructions from linux/blockdev (sha256sum:29166d5ebe6fc73c081b171f4f5ad15440b7d9a94c46c1d0111b47ea2fbd0c29)
Features:
- ubuntu 14.04 core (from debootstrap instructions)
- Gateworks 3.14 kernel with modules
- ventana bootscript
- extra packages: openssh-server can-utils i2c-tools usbutils pciutils
- eth0 dhcp
- user root passwd root
- gstreamer (gstreamer1.0-x gstreamer1.0-tools gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-alsa)
- fsl vpu firmware
- fsl lib-vpu
- fsl codec library
- fsl libg2d
- dev tools (build-essential autoconf libtool wget python pkg-config git)
- python
- gstreamer/gstreamer-imx/libimxvpuapi
- v4l-utils
- lxde
Kernel Updates
Ubuntu 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.
For example the latest kernel release available for Ubuntu 16.04 (Xenail) LTS is 4.11 and can be installed with the following:
apt-get update apt-get install linux-image-4.11.0-14-generic # install mkimage apt-get install u-boot-tools # create u-boot image for kernel mkimage -A arm -O linux -T kernel -C none \ -a 0x10008000 -e 0x10008000 -n "linux" \ -d /boot/vmlinuz-4.11.0-14-generic /boot/uImage # install device-tree blobs cp /lib/firmware/4.11.0-14-generic/device-tree/imx6*-gw*.dtb /boot #blacklist imx rtc driver, Gateworks board uses GSC RTC, and does not use imx RTC echo "blacklist rtc_snvs" > /etc/modprobe.d/blacklist-rtc.conf
- use
apt-get search linux-image
to determine what Ubuntu kernel versions are available
Root filesystem Sources
There 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.
Sources:
- build your own via debootstrap (recommended)
- Ubuntu Core - this is a minimal filesystem that you can build off of at runtime by adding packages from various repositories:
- 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.
Ubuntu Core
Ubuntu has supported 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 here, and a Ventana kernel (kernel + device-tree dtbs + modules).
Notes:
- 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
- You can use apt-get to install additional packages
References:
Linaro
The Linaro Developer Platform Team also creates Ubuntu flavored images.
Linaro is a non profit org that manages engineers who work on improving the state of ARM open source software.
They provide 4 different types of rootfs to choose from (unlike the single minimal rootfs choice Ubuntu Core provides):
- Nano - minimum rootfs containing console support and apt package management
- Developer - minimum rootfs containing console support and apt package management and development tools (toolchain, debuggers, profiling, etc)
- 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
- 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.
These rootfs images can be found 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.
For example, you can find the Linaro built Ubuntu 14.04 (trusty) rootfs images at https://releases.linaro.org/14.07/ubuntu/trusty-images
References:
Notes:
- You can use apt-get to install additional packages
Build your own Ubuntu rootfs via debootstrap
The 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.
Requirements:
- Linux Ubuntu or Debian System with network connection and sudo permissions
- 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
- Ventana target board with bootloader
- boot device with 300MB+ of free space (micro-SD, USB mass storage, mSATA, 1GB/2GB NAND flash)
Important notes:
- 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.
Steps:
- Install pre-requisites:
sudo apt-get install qemu-user-static debootstrap binfmt-support
- Perform first stage install of minimal filesystem:
target=rootfs distro=xenial sudo debootstrap --arch=armhf --foreign $distro $target # copy qemu-arm-static binary for the binfmt packages to find it and copy in resolv.conf from host sudo cp /usr/bin/qemu-arm-static $target/usr/bin
- 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).
- 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
- the chroot shell below will provide network support (inherited from the host)
- we now have a minimal Ubuntu rootfs - chroot to it and perform the 2nd stage install:
sudo chroot $target # now we are in the chroot distro=xenial export LANG=C # setup second stage /debootstrap/debootstrap --second-stage
- this is the most minimal rootfs we would recommend
- (optional) add additional apt package repos:
cat <<EOT > /etc/apt/sources.list deb http://ports.ubuntu.com/ubuntu-ports $distro main restricted universe multiverse deb http://ports.ubuntu.com/ubuntu-ports $distro-updates main restricted universe multiverse deb http://ports.ubuntu.com/ubuntu-ports $distro-security main restricted universe multiverse EOT
- you may want to customize the above list, depending on your needs. See below for more detail on Ubuntu package feeds
- (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)
apt-get update apt-get -f install # fixup missing package dependencies apt-get install locales dialog dpkg-reconfigure locales
- set hostname:
echo ${distro}-armhf > /etc/hostname
- create a default fstab:
cat <<EOT > /etc/fstab /dev/root / auto defaults 1 1 EOT
- 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
- /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
- set a root passwd so you can login
passwd
- or consider adding a user via
adduser
:adduser myuser usermod -a -G tty myuser # add to tty group for tty access usermod -a -G dialout myuser # add to dialout group for UART access usermod -a -G sudo myuser # add to sudo group for root access
- or consider adding a user via
- (optional) configure networking:
- wired ethernet with DHCP on eth0
cat <<EOF >> /etc/network/interfaces allow-hotplug eth0 auto eth0 iface eth0 inet dhcp EOF
- or static IP:
cat <<EOF >> /etc/network/interfaces allow-hotplug eth0 auto eth0 iface eth0 inet static address 192.168.1.1 netmask 255.255.255.0 gateway 192.168.1.254 EOF
- or wireless (requires ~3MB of additional packages):
apt-get install wpasupplicant iw cat << EOF >> /etc/network/interfaces # Wireless interface auto wlan0 iface wlan0 inet dhcp wireless_mode managed wireless_essid any wpa-driver nl80211 wpa-conf /etc/wpa_supplicant.conf EOF wpa_passphrase <myssid> <mypass> >> /etc/wpa_supplicant.conf
- wired ethernet with DHCP on eth0
- (optional) install some useful packages
apt-get install openssh-server # ssh server for remote access apt-get install can-utils i2c-tools usbutils pciutils # cmdline tools for various Ventana hardware support
- Note that by default root ssh access is disabled for security. See below for info on enabling it
- install a kernel and kernel support (kernel+dtbs+modules+firmware+initrd). You have several options here:
- Ubuntu Pre-built kernel (includes the most kernel drivers and is built by and supported by Ubuntu):
# disable flash-kernel as its not needed and will otherwise error out echo "FLASH_KERNEL_SKIP=1" >> /etc/environment export FLASH_KERNEL_SKIP=1 # and export it for current operations # install kernel/firmware/headers apt-get install linux-generic # install mkimage apt-get install u-boot-tools # create u-boot image for kernel mkimage -A arm -O linux -T kernel -C none \ -a 0x10008000 -e 0x10008000 -n "linux" \ -d /boot/vmlinuz-*-generic /boot/uImage # install device-tree blobs cp /lib/firmware/*-generic/device-tree/imx6*-gw*.dtb /boot #blacklist imx rtc driver, Gateworks board uses GSC RTC, and does not use imx RTC echo "blacklist rtc_snvs" > /etc/modprobe.d/blacklist-rtc.conf
- 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:
- add NAND/ubifs/usb-storage modules to the initrd:
cat << EOF >> /etc/initramfs-tools/modules # for NAND/ubi gpmi_nand ubi mtd=2 ubifs # for usb-storage ci_hdrc_imx usb-storage EOF update-initramfs -u # press 'Enter' when prompted # create u-boot image for initrd mkimage -A arm -O linux -T ramdisk \ -a 0x0 -e 0x0 -n "initrd" \ -d /boot/initrd.img-*-generic /boot/uramdisk
- 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):
cat << EOF > /tmp/bootscript # if nand|usb dtype use initrd - sata|mmc don't require initrd if itest.s "x\${dtype}" == "xnand" ; then echo "Booting from NAND/ubifs..." setenv bootargs "console=\${console},\${baudrate} root=ubi0:rootfs rootfstype=ubifs rootwait \${video} \${extra}" ubifsload \$fdt_addr boot/\$fdt_file || ubifsload \$fdt_addr boot/\$fdt_file1 || ubifsload \$fdt_addr boot/\$fdt_file2 test -n "\$fixfdt" && run fixfdt ubifsload \$loadaddr boot/uImage ubifsload 16000000 boot/uramdisk ubifsumount bootm \$loadaddr 16000000 \$fdt_addr elif itest.s "x\${dtype}" == "xusb" ; then echo "Booting from usb..." setenv bootargs "console=\${console},\${baudrate} root=/dev/sda1 rootwait \${video} \${extra}" ext4load usb 0:1 \$fdt_addr boot/\$fdt_file || ext4load usb 0:1 \$fdt_addr boot/\$fdt_file1 || ext4load usb 0:1 \$fdt_addr boot/\$fdt_file2 test -n "\$fixfdt" && run fixfdt ext4load usb 0:1 \$loadaddr boot/uImage ext4load usb 0:1 16000000 boot/uramdisk bootm \$loadaddr 16000000 \$fdt_addr fi EOF mkimage -A arm -O linux -T script -n "bootscript" \ -d /tmp/bootscript /boot/6x_bootscript-ventana
- add NAND/ubifs/usb-storage modules to the initrd:
- 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:
- 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
cd / wget http://svn.gateworks.com/ventana/images/gateworks-linux-imx6-3.14.48.tar.gz tar -xvf gateworks-linux-imx6-3.14.48.tar.gz depmod $(ls /lib/modules/) # create module dependencies rm gateworks-linux-imx6-3.14.48.tar.gz
- 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 rundepmod
after the first boot
- the
- Build your own kernel and install it as above with proper bootscript - see linux/kernel 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))
- Ubuntu Pre-built kernel (includes the most kernel drivers and is built by and supported by Ubuntu):
- exit the chroot shell and remove files we no longer need
exit sudo rm $target/usr/bin/qemu-arm-static
- install to bootable media:
- 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:
DEVICE=/dev/sdc # unmount all auto-mounted partitions for this device sudo umount ${DEVICE}? # partition disk - single ext partition printf ",,L,,\n" | sudo sfdisk -uS ${DEVICE} sync sudo mkfs.ext4 -L rootfs ${DEVICE}1 # mount partition (will mount to /media/rootfs/) sudo udisks --mount ${DEVICE}1 # copy the root filesystem sudo cp -rupv $target/* /media/rootfs/ # unmount the disk sudo udisks --unmount ${DEVICE}1
- To create a ubifs suitable for 1GB/2GB NAND flash (large layout) use the following:
mkfs.ubifs -d $target -F -m 4096 -e 248KiB -c 8124 -x zlib -o ${distro}_large.ubifs
- For details on how to flash this onto NAND see linux/ubi
- 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:
version-specific notes
trusty (14.04) LTS
An extra step is needed for serial console configuration:
cat << EOT >> /etc/init/serial.conf start on stopped rc RUNLEVEL=[2345] stop on runlevel [!2345] respawn exec /sbin/getty 115200 ttymxc1 EOT
Adding GStreamer IPU/VPU/GPU support via gstreamer-imx
You 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).
This 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. This procedure has not been proven on versions newer than Trusty.
There are several pre-requisites you will need to install and/or build using the instructions below:
- Gateworks downstream vendor kernel (containing non-upstreamed IPU/VPU/GPU drivers) with kernel headers. See here for instructions on building, or here for a pre-built kernel tarball
- gstreamer and libs
- firmware-imx-3.14.28-1.0.0.bin - Freescale VPU firmware (EULA required)
- 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
- libfslcodec-4.0.3.bin - Freescale Codec Library (EULA required)
- 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
- libimxvpuapi - community based open-source high-level library over the low-level imx-vpu API
- gstreamer-imx - community based open-source GStreamer plugins to utilize hardware accellerated capture, display, transforms, compositing, decode, encode capabilities of the IMX6.
The following instructions can be used on top of the debootstrap created rootfs but should work on other sources of Ubuntu or other Linux distributions root filesystems as well.
- install build deps (~165MB):
apt-get install build-essential autoconf libtool wget python pkg-config git
- install gstreamer1.x (~200MB):
apt-get install gstreamer1.0-x gstreamer1.0-tools # install videoparserbad for video parsers like h264parse, mpegvideoparse and mpeg4videoparse apt-get install gstreamer1.0-plugins-good gstreamer1.0-plugins-bad # install alsa plugin apt-get install gstreamer1.0-alsa
- note that the gstreamer1.0-plugins-bad meta-package is in the multiverse package feed
- 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
- install Freescale VPU firmware (firmware-imx) (EULA required)
wget http://www.freescale.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-3.14.28-1.0.0.bin /bin/sh firmware-imx-*.bin # install firmware mkdir -p /lib/firmware/vpu cp firmware-imx-*/firmware/vpu/vpu_fw_imx6*.bin /lib/firmware/vpu
- build and install Freescale lib_vpu (EULA required)
wget http://www.freescale.com/lgfiles/NMG/MAD/YOCTO/imx-vpu-5.4.31.bin /bin/sh imx-vpu-*.bin cd imx-vpu-* make PLATFORM=IMX6Q all make install # installs vpu_lib.h and vpu_io.h in /usr/include and libvpu.* in /usr/lib cd ..
- (optional) build and install Freescale Codec Library (libfslcodec) (EULA required)
wget http://www.freescale.com/lgfiles/NMG/MAD/YOCTO/libfslcodec-4.0.3.bin /bin/sh libfslcodec-*.bin cd libfslcodec-* ./autogen.sh --prefix=/usr --enable-fhw --enable-vpu make all make install # move the libs where gstreamer plugins will find them mv /usr/lib/imx-mm/video-codec/* /usr/lib mv /usr/lib/imx-mm/audio-codec/* /usr/lib rm -rf /usr/lib/imx-mm/ cd ..
- this is optional and is needed if you want the audio codec support in gstreamer-imx
- Note the Makefile will install the libs into $prefix/lib/imx-mm which is undesirable so we move them after 'make install'
- (optional) install Freescale libg2d (EULA required)
wget http://www.freescale.com/lgfiles/NMG/MAD/YOCTO/imx-gpu-viv-5.0.11.p4.5-hfp.bin /bin/sh imx-gpu-viv-*.bin cd imx-gpu-viv-* # install just the g2d headers/libs cp g2d/usr/include/* /usr/include/ cp -d g2d/usr/lib/* /usr/lib/ # install gpu-core headers/libs cp -d gpu-core/usr/lib/*.so* /usr/lib/ cp -Pr gpu-core/usr/include/* /usr/include/ # optional: install demos cp -r gpu-demos/opt / # optional: install gpu tools cp -axr gpu-tools/gmem-info/usr/bin/* /usr/bin/ cd ..
- 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
- it comes in soft-float (sfp) and hard-float (hfp) - we want the hard-float as we are using an armhf rootfs
- this is not required but needed for the gstreamer-imx g2d transform and sink plugins
- build and install libimxvpuapi library:
- 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.
git clone git://github.com/Freescale/libimxvpuapi.git cd libimxvpuapi ./waf configure --prefix=/usr ./waf ./waf install cd ..
- 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.
- build and install gstreamer-imx:
apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev # +70MB git clone git://github.com/Freescale/gstreamer-imx.git cd gstreamer-imx ln -s /usr/lib/arm-linux-gnueabihf/gstreamer-1.0/ /usr/lib/gstreamer-1.0 ./waf configure --prefix=/usr --kernel-headers=/include ./waf ./waf install cd ..
- 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
- 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
- note g2d lib required to build G2D
- note that linux kernel headers are required to build PxP and IPU
- note that x11 library is required to build EGL sink with Vivante direct textures (only needed for X11 support)
- note that libfslaudiocodec is required to build audio plugins
- After this step you should be able to see several plugins with
gst-inspect-1.0
:# gst-inspect-1.0 | grep imx imxv4l2videosrc: imxv4l2videosrc: V4L2 CSI Video Source imxipu: imxipucompositor: Freescale IPU video compositor imxipu: imxipuvideosink: Freescale IPU video sink imxipu: imxipuvideotransform: Freescale IPU video transform imxpxp: imxpxpvideotransform: Freescale PxP video transform imxpxp: imxpxpvideosink: Freescale PxP video sink imxvpu: imxvpuenc_mjpeg: Freescale VPU motion JPEG video encoder imxvpu: imxvpuenc_mpeg4: Freescale VPU MPEG-4 video encoder imxvpu: imxvpuenc_h264: Freescale VPU h.264 video encoder imxvpu: imxvpuenc_h263: Freescale VPU h.263 video encoder imxvpu: imxvpudec: Freescale VPU video decoder imxg2d: imxg2dcompositor: Freescale G2D video compositor imxg2d: imxg2dvideotransform: Freescale G2D video transform imxg2d: imxg2dvideosink: Freescale G2D video sink
- install a U-Boot bootscript to setup kernel parameters for your display output:
apt-get install u-boot-tools wget https://github.com/Freescale/meta-freescale-3rdparty/raw/master/recipes-bsp/u-boot/u-boot-script-gateworks-imx/6x_bootscript-yocto.txt mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "boot script" -d 6x_bootscript-yocto.txt /boot/6x_bootscript-ventana reboot # reboot to setup bootargs for display
- 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
Now you will be able to use Gstreamer and Gstreamer-imx to tap the full potential of the IMX IPU/VPU/GPU hardware.
Examples:
- show gstreamer-imx plugins:
# gst-inspect-1.0 | grep imx imxvpu: imxvpuenc_mjpeg: Freescale VPU motion JPEG video encoder imxvpu: imxvpuenc_mpeg4: Freescale VPU MPEG-4 video encoder imxvpu: imxvpuenc_h264: Freescale VPU h.264 video encoder imxvpu: imxvpuenc_h263: Freescale VPU h.263 video encoder imxvpu: imxvpudec: Freescale VPU video decoder imxv4l2videosrc: imxv4l2videosrc: V4L2 CSI Video Source imxg2d: imxg2dcompositor: Freescale G2D video compositor imxg2d: imxg2dvideotransform: Freescale G2D video transform imxg2d: imxg2dvideosink: Freescale G2D video sink imxipu: imxipucompositor: Freescale IPU video compositor imxipu: imxipuvideosink: Freescale IPU video sink imxipu: imxipuvideotransform: Freescale IPU video transform imxpxp: imxpxpvideotransform: Freescale PxP video transform imxpxp: imxpxpvideosink: Freescale PxP video sink
- imxipuvideosink:
gst-launch-1.0 videotestsrc ! imxipuvideosink
- imxg2dvideosink:
gst-launch-1.0 videotestsrc ! imxg2dvideosink
See the Gstreamer wiki page for more details.
Adding X11 Support
You 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:
- X11 server - ie Xorg
- Display Manager - this controls the login to the X session
- Window Manager - manages window position, re-sizing, decorations, etc for X clients
A common solution is to install a Desktop Environment such as the 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:
apt-get install lxde xinit # adds ~434MB to a base console image
Notes:
- 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 theautologin
property in thebase
section at the beginning of the config file. - you will need to use a kernel with the vivante GPU driver built as a module or the Xorg server will crash
Hardware GPU Acceleration for X11
To 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:
- libg2d - a documented low-level API to the GPU (used by things like libimxvpuapi for gstreamer-imx and the gpu-core drivers)
- 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.
Procedure:
- Install Freescale Vivante GPU libs (EULA):
wget http://www.freescale.com/lgfiles/NMG/MAD/YOCTO/imx-gpu-viv-5.0.11.p4.5-hfp.bin /bin/sh imx-gpu-viv-*.bin # accept EULA cd imx-gpu-viv-* # install just the g2d headers/libs cp g2d/usr/include/g2d.h /usr/include/ cp -d g2d/usr/lib/libg2d* /usr/lib/ # install gpu-core headers/libs cp -Pr gpu-core/usr/* /usr # install vivante driver for accelerated X11: cp vivante_drv.so /usr/lib/xorg/modules/drivers/ chmod 644 /usr/lib/xorg/modules/drivers/vivante_drv.so # optional: install demos cp -r gpu-demos/opt / # optional: install gpu tools cp -axr gpu-tools/gmem-info/usr/bin/* /usr/bin/ # fix lib collision between fsl/viv gpu-core and libgl1-mesa package rm /usr/lib/arm-linux-gnueabihf/mesa/libGL.so* # fix lib collision between fsl/viv gpu-core and libegl1-mesa package rm /usr/lib/arm-linux-gnueabihf/mesa-egl/libEGL.so* # fix lib collision between fsl/viv gpu-core and libgles1-mesa package #rm /usr/lib/arm-linux-gnueabihf/libGLESv1_CM.so* #rm /usr/lib/arm-linux-gnueabihf/mesa-egl/libGLESv1_CM.so* # fix lib collision between fsl/viv gpu-core and libgles2-mesa package #rm /usr/lib/arm-linux-gnueabihf/libGLESv2.so* # not there rm /usr/lib/arm-linux-gnueabihf/mesa-egl/libGLESv2.so* # fix lib collision between fsl/viv gpu-core and libopenvg1-mesa package rm /usr/lib/arm-linux-gnueabihf/mesa-egl/libOpenVG.so*
- Note: this could be better handled by creating a package and using Ubuntu/Debian 'alternatives' to handle library selection
- switch to gpu-core x11 backend:
backend=x11 ln -sf libEGL-${backend}.so /usr/lib/libEGL.so ln -sf libEGL-${backend}.so /usr/lib/libEGL.so.1 ln -sf libEGL-${backend}.so /usr/lib/libEGL.so.1.0 ln -sf libGAL-${backend}.so /usr/lib/libGAL.so ln -sf libGLESv2-${backend}.so /usr/lib/libGLESv2.so ln -sf libGLESv2-${backend}.so /usr/lib/libGLESv2.so.2 ln -sf libGLESv2-${backend}.so /usr/lib/libGLESv2.so.2.0.0 ln -sf libVIVANTE-${backend}.so /usr/lib/libVIVANTE.so ln -sf libGAL_egl.dri.so /usr/lib/libGAL_egl.so for i in egl glesv1_cm glesv2 vg; do cp /usr/lib/pkgconfig/${i}_${backend}.pc /usr/lib/pkgconfig/${i}.pc done # remove the other backends we no longer need rm /usr/lib/*-dfb.so /usr/lib/*-fb.so /usr/lib/*-wl.so
- make vivante kernel module (GPU kernel driver) load on boot:
echo vivante >> /etc/modules cat << EOT > /etc/udev/rules.d/10-imx.rules KERNEL=="galcore", MODE="0660", GROUP="video" KERNEL=="mxc_asrc", MODE="0666" EOT
- create an xorg.conf configured for the Vivante fbdev driver:
cat << EOT > /etc/X11/xorg.conf Section "Device" Identifier "i.MX Accelerated Framebuffer Device" Driver "vivante" Option "fbdev" "/dev/fb0" Option "vivante_fbdev" "/dev/fb0" Option "HWcursor" "false" EndSection Section "ServerFlags" Option "BlankTime" "0" Option "StandbyTime" "0" Option "SuspendTime" "0" Option "OffTime" "0" EndSection EOT
- Optional: re-build gstreamer-imx (above) if you wish to use gstreamer-imx IPU/VPU/GPU acceleration within an OpenGL window (egl)
- Sync filesystem and reboot
Examples:
- The
imxeglvivsink
allows hardware accelerated display to a window on the X11 host:DISPLAY=:0.0 gst-launch-1.0 videotestsrc ! imxeglvivsink
- See the Gstreamer wiki page for more details.
- The
glxgears
application is a demo of OpenGL that often is used to benchmark rendering performanceDISPLAY=:0.0 glxgears -info # ~300fps on IMX6Q