Skip to content

Latest commit

 

History

History
369 lines (293 loc) · 12.3 KB

Setup_guide_yocto.md

File metadata and controls

369 lines (293 loc) · 12.3 KB

Setup guide Yocto (bsp)

First you need to decide how you are going to be building for Yocto


Building using a prebuild Yocto SDK

Building using a prebuild Yocto SDK and a prebuild sd-card image. This tend to be the fastest way to get started.

Prerequisites

  • Ubuntu 16.04
  • Python 3.5 (this is standard in Ubuntu 16.04)
  • A prebuild sdk for your board typically called something like toolchain.sh
  • A prebuild sd-card image for your board typically called BoardName.rootfs.sdcard.bz2
  • Git
    sudo apt-get install git

For this guide we will assume you are using a FB image.

  • Download the DemoFramework source using git.

It's also a good idea to read the introduction to the FslBuild toolchain

Preparing a Yocto SDK build

  1. Start a terminal (ctrl+alt t)
  2. Install the sdk:
    ./fsl-imx-internal-xwayland-glibc-x86_64-fsl-image-gui-aarch64-toolchain-4.9.51-mx8-beta.sh
    Chose where to install it, you can use the default location or a location of your choice. For this example, we use "~/sdk/4.9.51-mx8-beta". When the setup is complete it will list the configuration script you need to run to configure the sdk environment. Something like this
    Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
    $ . ~/sdk/4.9.51-mx8-beta/environment-setup-aarch64-poky-linux
  3. Your SDK is now installed.

Yocto SDK environment setup

  1. Start a terminal (ctrl+alt t)
  2. Prepare the yocto build environment by running the config command you got during the sdk install
    . ~/sdk/4.9.51-mx8-beta/environment-setup-aarch64-poky-linux
  3. You should now be ready to build using the demo framework. However, if you experience issues with the prepare.sh script you can help it out by defining the platform name and the location of the root fs
    export FSL_PLATFORM_NAME=Yocto
    export ROOTFS=~/sdk/4.9.51-mx8-beta/sysroots/aarch64-poky-linux
    Another possible error you can encounter is that the FslBuild.py scripts fail to include the 'typing' library. This can happen because the SDK comes with a too old Python3 version or a incomplete Python3.5 version. As a workaround for that you could delete the Python3 binaries from the SDK which will cause it to use the system Python3 version instead.

Ready to build via sdk

You are now ready to start building Yocto apps using the demo framework. Please continue the guide at [Using the demo framework].


Building using a full Yocto build

Building using a full manually build Yocto build. This process provides the most flexible solution but it also takes significantly longer to build the initial Yocto sdcard and toolchain.

BSP Build Prerequisites

For this guide we will assume you are using a FB image.

  • Download the DemoFramework source using git.

It's also a good idea to read the introduction to the FslBuild toolchain

Preparing a Yocto build

Before you build one of these yocto images you need to

  1. Run the yocto build setup (X11 example).

    MACHINE=imx6qpsabresd source fsl-setup-release.sh -b build-x11 -e x11
  2. Bake

    bitbake fsl-image-gui
    bitbake meta-toolchain
    bitbake meta-ide-support

    You can now build one of the images below (or a custom one)

x11 yocto image

Example:

a. Perform step 1 bash MACHINE=imx6qpsabresd source fsl-setup-release.sh -b build-x11 -e x11 b. Perform step 2 bash bitbake fsl-image-gui bitbake meta-toolchain bitbake meta-ide-support

Extracted rootfs

We assume your yocto build dir is located at ~/fsl-release-bsp/build-x11 and that the rootfs will be unpacked to ~/unpacked-rootfs/build-x11 and the image is called fsl-image-gui-imx6qpsabresd.rootfs.tar.bz2 (you will need to locate your image name)

runqemu-extract-sdk ~/fsl-release-bsp/build-x11/tmp/deploy/images/imx6qpsabresd/fsl-image-gui-imx6qpsabresd.rootfs.tar.bz2  ~/unpacked-rootfs/build-x11

FB yocto image

Example:

a. Perform step 1 bash MACHINE=imx6qpsabresd source fsl-setup-release.sh -b build-fb -e fb b. Perform step 2 bash bitbake fsl-image-gui bitbake meta-toolchain bitbake meta-ide-support

Extracted rootfs

We assume your yocto build dir is located at ~/fsl-release-bsp/build-fb and that the rootfs will be unpacked to ~/unpacked-rootfs/build-fb and the image is called fsl-image-gui-imx6qpsabresd.rootfs.tar.bz2 (you will need to locate your image name)

runqemu-extract-sdk ~/fsl-release-bsp/build-fb/tmp/deploy/images/imx6qpsabresd/fsl-image-gui-imx6qpsabresd.rootfs.tar.bz2  ~/unpacked-rootfs/build-fb

Wayland yocto image

Example: a. Perform step 1 bash MACHINE=imx6qpsabresd source fsl-setup-release.sh -b build-wayland -e wayland b. Perform step 2 bash bitbake fsl-image-gui bitbake meta-toolchain bitbake meta-ide-support

Extracted rootfs

We assume your yocto build dir is located at ~/fsl-release-bsp/build-wayland and that the rootfs will be unpacked to ~/unpacked-rootfs/build-wayland and the image is called fsl-image-gui-imx6qpsabresd.rootfs.tar.bz2 (you will need to locate your image name)

runqemu-extract-sdk ~/fsl-release-bsp/build-wayland/tmp/deploy/images/imx6qpsabresd/fsl-image-gui-imx6qpsabresd.rootfs.tar.bz2  ~/unpacked-rootfs/build-wayland

Yocto environment setup

  1. Start a terminal (ctrl+alt t)
  2. Prepare the yocto build environment
    pushd ~/fsl-release-bsp/build-fb/tmp
    source environment-setup-cortexa9hf-neon-poky-linux-gnueabi
    export ROOTFS=~/unpacked-rootfs/build-fb
    export FSL_PLATFORM_NAME=Yocto
    popd

Ready to build using BSP build

You are now ready to start building Yocto apps using the demo framework, please continue the guide at [Using the demo framework].


Using the demo framework

Simple setup

  1. Make sure that you performed the Yocto environment setup for your chosen Yocto environment.
    • SDK build [Yocto SDK environment setup]
    • Custom build [Yocto environment setup].
  2. cd to the demoframework folder
  3. Run the prepare.sh file located in the root of the framework folder to configure the necessary environment variables and paths. Please beware that the prepare.sh file requires the current working directory to be the root of your demoframework folder to function (which is also the folder it resides in).
    source prepare.sh
    Also verify that the script detect that you are doing a Yocto build by outputting
    PlatformName: Yocto
    If it doesn't you can override the platform auto detection by setting the environment variable
    export FSL_PLATFORM_NAME=Yocto
    Before running the prepare.sh script.

To Compile all samples

  1. Make sure that you performed the [simple setup].
  2. Compile everything (a good rule of thumb for '--BuildThreads N' is number of cpu cores * 2)
    FslBuild.py --Variants [WindowSystem=FB] -t sdk --BuildThreads 2
    WindowSystem can be set to either: FB, Wayland or x11

To Compile and run an existing sample application

In this example we will utilize the GLES2.S06_Texturing app.

  1. Make sure that you performed the [simple setup].
  2. Change directory to the sample directory:
    cd DemoApps/GLES2/S06_Texturing
  3. Compile the project (a good rule of thumb for '--BuildThreads N' is number of cpu cores * 2)
    FslBuild.py --Variants [WindowSystem=FB] --BuildThreads 2
    WindowSystem can be set to either: FB, Wayland or x11

To create a new GLES2 demo project named 'CoolNewDemo'

  1. Make sure that you performed the [simple setup]
  2. Change directory to the GLES2 sample directory:
    cd DemoApps/GLES2
  3. Create the project template using the FslBuildNew.py script
    FslBuildNew.py GLES2 CoolNewDemo  
  4. Change directory to the newly created project folder 'CoolNewDemo'
    cd CoolNewDemo
  5. Compile the project (a good rule of thumb for '--BuildThreads N' is number of cpu cores * 2)
    FslBuild.py --Variants [WindowSystem=FB] --BuildThreads 2
    WindowSystem can be set to either: FB, Wayland or x11

Note:

Once a build has been done once you can just invoke the make file directly. However this requires that you didn't change any dependencies or add files.

To do this run bash make -f GNUmakefile_Yocto -j 2 WindowSystem=FB

If you add source files to a project or change the Fsl.gen file then run the FslBuildGen.py script in the project root folder to regenerate the various build files or just make sure you always use the FslBuild.py script as it automatically adds files and regenerate build files as needed.

To see which features a DemoApp requires to be able to build

  1. Make sure that you performed the [simple setup]
  2. Change directory to the GLES2 sample directory:
    cd DemoApps/GLES2
  3. Create the project template using the FslBuildNew.py script
    FslBuild.py --ListFeatures

Copying DemoFramework apps to the sdcard

Basic copy

  1. Mount the SDK card in ubuntu.
  2. Manually copy the build Exectuable and its content directory to the sdcard
  3. Unmount the sdcard

Using install

  1. Mount the SDK card in ubuntu.
  2. Build using
    FslBuild.py -- install
    This will cause the app to install itself and its content to the the demo framework root under a directory called bin. This directory can then be copied manually to the sdcard. Beware that 'install' can be used for all build commands, so you could build all apps and then just copy the bin directory.
  3. Manually copy the build Exectuable and its content directory to the sdcard
  4. Unmount the sdcard

Building Vulkan demo framework apps

To build vulkan demoes you need access to the glslangValidator tool which is used to compile shaders into SPIR-V format. The easiest way to get it is to install the linux vulkan SDK.

  1. Download the vulkan sdk from https://vulkan.lunarg.com/sdk/home
  2. Make the downloaded file executable
    chmod ugo+x vulkansdk-linux-x86_64-1.0.68.0.run
  3. Move the downloaded file to a sdk dir
    mkdir ~/vulkan
    mv vulkansdk-linux-x86_64-1.0.68.0.run ~/vulkan
  4. Run it
    cd ~/vulkan
    ./vulkansdk-linux-x86_64-1.0.68.0.run
  5. Install the necessary packages
     sudo apt-get install libglm-dev graphviz libxcb-dri3-0 libxcb-present0 libpciaccess0 cmake libpng-dev libxcb-dri3-dev libx11-dev
  6. Setup the vulkan environment
      pushd ~/vulkan/VulkanSDK/1.0.68.0
      source setup-env.sh
      popd
  7. Run the normal setup.

Building OpenCV demo framework apps

  1. Edit the <build directory>/conf/local.conf file and add the line:
    CORE_IMAGE_EXTRA_INSTALL += "libopencv-core-dev libopencv-highgui-dev"