Build the BSP

This guide provides you with the tools and know-how to install and develop software using the Linux Board Support Package (BSP) for the phyCORE-AM65x Development Kit.This guide shows you how to do everything from installing the appropriate host tools to building and deploying bootable images.

Please refer to the phyCORE-AM65x Hardware Manual for specific information on board-level features such as jumper configuration, memory mapping and pin layout for the phyCORE-AM65x System on Module (SOM) and carrier board.

Requirements

  • A modern GNU/Linux Operating host system either natively or via a virtual machine:

    1. Ubuntu 18.04 LTS recommended, 64-bit required. Other distributions will likely work, please note that some setup information as well as OS-specific commands and paths may differ.

    2. If using a virtual machine, VMWare Workstation, VMWare Player, and VirtualBox are all viable solutions.

  • Root access to your Linux Host PC. Some commands in the Quickstart will not work if you don’t have sudo access (ex. package installation, formatting SD cards).

  • At least 250GB free on target build partition and at least 8GB of RAM available to the build host.

  • SD card reader operational under Linux.

    #.If you do not have SD card access under Linux then formatting, copying the bootloader, and mounting the root file system on an SD card will not be possible.

  • Active Internet connection

Getting Started With Binary Images

Before proceeding with this BSP development guide, note that you can start evaluating the phyCORE-AM65x Development kit right away just by using pre-built images. Building the BSP in its entirety will be important to do as you start to adapt the development kit for your own design but it is not necessary to do in order to get started with the hardware. To get started with PHYTEC’s pre-built release images, please Create a Bootable SD Card with the release images from Pre-Built Binaries, then configure the board to boot from SD/MMC with the help of the Booting Essentials guide. If needed, you can flash your image to eMMC by following the flashing eMMC guide. From there, head over to the Quickstart to help you power on the hardware and establish a serial connection.

Building Images from Source

This section will show you how to configure your development host to build your own BSP images from source and how to start BSP image builds. Building BSP images from source is useful if you have made changes to the BSP sources and would like to deploy those changes in an easy and reproducible way.

Host Setup

  • Yocto development requires certain packages to be installed. Run the following commands to ensure you have the packages installed:

    Host (Ubuntu)
    sudp apt-get update
    sudo apt-get install git build-essential python diffstat texinfo gawk chrpath dos2unix wget unzip socat doxygen libc6:i386 libncurses5:i386 libstdc++6:i386 libz1:i386 lib32stdc++6 lib32ncurses5 lib32z1 libc6-dev-i386 cpio gcc-multilib
    
  • Verify that the preferred shell for your Host PC is ‘’bash’’ and not ‘’dash’’:

    Host (Ubuntu)
    sudo dpkg-reconfigure dash
    # Respond "No" to the prompt asking "Install dash as /bin/sh?"
    bash
    
  • Download and install the repo tool. This tool is used to obtain Yocto source from Git.

    Host (Ubuntu)
    cd /opt
    sudo mkdir bin
    # /opt/ directory has root permission, change the permissions so your user account can access this folder. In the following replace <user> with your specific username
    sudo chown -R <user>: bin
    
    cd bin
    curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ./repo
    # add directory that contains repo to your path
    chmod a+x repo
    
  • Add the repo directory in your PATH, using export from the command line or permanently by including it in .bashrc:

    Host (Ubuntu)
    export PATH=/opt/bin/:$PATH
    

Git Setup

  • If you have not yet configured your Git environment on this machine, please execute the following commands to set your user name and email address. See here for more information on getting started with Git.

    Host (Ubuntu)
    git config --global user.email "[email protected]"
    git config --global user.name "Your Name"
    git config --global http.sslcainfo /etc/ssl/certs/ca-certificates.crt
    

Setup the BSP Directory

  • Create a directory which will house your BSP development. In this example the BSP directory is /opt/PHYTEC_BSPs/. This is not a requirement and if another location is preferred (ex. ~/PHYTEC_BSPs) feel free to modify. We recommend using /opt over your HOME directory to avoid errors attributed to ~ syntax as well as the sudo requirement for the root filesystem and automation package building. We also recommend creating a package download directory (yocto_dl) separate from the yocto tree (yocto_ti), as it makes resetting the build environment easier and subsequent build times much faster.

    Host (Ubuntu)
     sudo mkdir -p /opt/PHYTEC_BSPs
     cd /opt
    
    
     # /opt directory has root permission, change the permissions so your user account can access this folder. In the following, replace <user> with your username
     sudo chown -R <user>: PHYTEC_BSPs
    
    
     cd PHYTEC_BSPs
     mkdir yocto_ti
     mkdir yocto_dl
     cd yocto_ti
     export YOCTO_DIR=`pwd`
    

    At this point you will now be able to navigate to the Yocto directory using the $YOCTO_DIR environment variable.

Install the ARM Toolchain

  • Run the following commands to install the ARM toolchain:

    Host (Ubuntu)
    wget https://developer.arm.com/-/media/Files/downloads/gnu-a/9.2-2019.12/binrel/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf.tar.xz
    tar -Jxvf gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf.tar.xz -C /opt/PHYTEC_BSPs
    wget https://developer.arm.com/-/media/Files/downloads/gnu-a/9.2-2019.12/binrel/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz
    tar -Jxvf gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz -C /opt/PHYTEC_BSPs
    rm gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf.tar.xz gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz
    

Download the BSP Meta Layers

  • Download the manifest file for the latest BSP:

    Host (Ubuntu)
    cd $YOCTO_DIR
    repo init -u https://stash.phytec.com/scm/pub/manifests-phytec.git -b am65xx -m ALPHA4.xml
    
  • Download the Yocto meta layers specified in the manifest file:

    Host (Ubuntu)
     repo sync
    

Start the Build

  • Run the Yocto build directory setup script. The TEMPLATECONF variable is used to set the source of the local configuration files (conf/bblayers.conf and conf/local.conf), which are located in the meta-phytec layer:

    Host (Ubuntu)
    cd $YOCTO_DIR
    TEMPLATECONF=$YOCTO_DIR/sources/meta-phytec/meta-phytec-ti/conf MACHINE=am65xx-phycore-kit source sources/oe-core/oe-init-build-env build
    
  • Open the build/conf/local.conf file using your preferred editor and make the following modifications:

    1. Modify the download directory to the yocto_dl directory that was created in the previous steps:

      build/conf/local.conf
      DL_DIR ?= "/opt/PHYTEC_BSPs/yocto_dl"
      
    2. Maximize build efficiency by modifying the BB_NUMBER_THREADS variable to suit your host development system. This sets the maximum number of tasks that BitBake should run in parallel. Also set the variable PARALLEL_MAKE to specify the number of threads that make can run. By default, these are already set to 4 in build/conf/local.conf:

      build/conf/local.conf
      # Parallelism options - based on cpu count
      BB_NUMBER_THREADS ?= "4"
      PARALLEL_MAKE ?= "-j 4"
      
    3. Add the following to a new line at the end of the file to set the TOOLCHAIN_BASE variable to point to where you extracted the toolchain:

      build/conf/local.conf
      TOOLCHAIN_BASE = "/opt/PHYTEC_BSPs"
      
    4. Be sure to save your changes to the local.conf file before closing.

The setup is complete and you now have everything ready to start a build. This BSP has been tested with the arago-core-tisdk-bundle and it is suggested that you start with this image before building other images. Alternate images are located in various meta layers at yocto_ti/sources/ meta*/recipes*/images/.bb. They can be found using the command bitbake-layers show-recipes “-image*” in $YOCTO_DIR/build/.

  • The following will start a build from scratch including installation of the toolchain as well as bootloader, Linux kernel, and root filesystem images.

    Host (Ubuntu)
    cd $YOCTO_DIR/build
    MACHINE=am65xx-phycore-kit bitbake -k arago-core-psdkla-bundle
    

Built Images

All images generated by Bitbake are deployed to $YOCTO_DIR/build/arago-tmp-external-arm-glibc/deploy/images/am65xx-phycore-kit:

  • Bootloader: tiboot3.bin, tispl.bin, u-boot.img, and sysfw.itb

  • Kernel: Image

  • Kernel device tree file: k3-am65xx-phycore-kit.dtb

  • Kernel device tree overlays: k3-am65xx-phytec-expansion-sample.dtbo, k3-am65xx-phytec-lcd-018.dtbo, k3-am65xx-phytec-wlan.dtbo

  • Root Filesystem: tisdk-default-image-am65xx-phycore-kit.tar.xz

Source Locations:

  • Kernel: $YOCTO_DIR/build/arago-tmp-external-arm-glibc/work/am65xx_phycore_kit-linux/linux-phytec-ti/5.4.74+git_v5.4.74-phy1-r0a/git/

    1. The device tree file to modify within the linux kernel source is: k3-am65xx-phycore-kit.dts and its included dtsi files.

  • U-Boot: $YOCTO_DIR/build/arago-tmp-external-arm-glibc/work/am65xx_phycore_kit-linux/u-boot-phytec/1_2020.01+git_v2020.01-phy2-r0/git/

Build Time Optimizations

The build time will vary depending on the package selection and Host performance. Beyond the initial build, after making modifications to the BSP, a full build is not required. Use the following as a reference to take advantage of optimized build options and reduce the build time.

  • To rebuild U-Boot:

    Host (Ubuntu)
    bitbake u-boot-phytec u-boot-phytec-k3-r5 -f -c compile && bitbake u-boot-phytec u-boot-phytec-k3-r5
    
  • To rebuild the Linux kernel:

    Host (Ubuntu)
    bitbake linux-phytec-ti -f -c compile && bitbake linux-phytec-ti
    

The Yocto project’s Bitbake User Manual provides useful information regarding build options: http://www.yoctoproject.org/docs/2.6/bitbake-user-manual/bitbake-user-manual.html