Version control

This chapter describes the preferred way to do version control with the TLD, using a GIT repository. This allows for a future update to a new version of the TLD and facilitates support (from TOPIC).

The flow below downloads the BSP file from a remote source. This removes the need to commit the BSP file into the repository.

Note

When ${company_name} is shown below, replace it with your company name, so for exapmle topic. The same goes for ${product_name}.

Follow the steps below to create a new petalinux project from a BSP file.

  1. Create an empty directory with the following name ${company_name}-${product_name}-platform and step into it.
    mkdir ${company_name}-${product_name}-platform
    cd ${company_name}-${product_name}-platform
    
  2. Add the following folders: config, meta-${product_name}, scripts.
    mkdir config meta-${product_name} scripts
    

    Note

    In this example we only create one meta-layer, within the git repo. Meta-layers are often added as git submodules from external sources, like meta-qt5 for example.

  3. Initialize a GIT repository by running:
    git init
    
  4. Add a .gitignore file and as ‘starting point’ fill it with the lines below:
    ${product_name}
    data
    
  5. Create the config for a new meta layer in meta-${product_name}/conf/layer.conf. Again a ‘starting point’ for the content is given below:
    # Add the layer to the ``BBPATH``
    # Prepend (=.) to make sure it looks for .inc files in this layer first
    BBPATH =. "${LAYERDIR}:"
    
    # Add the directories that contain recipes to ``BBFILES``
    BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
            ${LAYERDIR}/recipes-*/*/*.bbappend"
    
    BBFILE_COLLECTIONS += "meta-${product_name}"
    BBFILE_PATTERN_meta-${product_name} = "^${LAYERDIR}/"
    BBFILE_PRIORITY_meta-${product_name} = "7"
    LAYERSERIES_COMPAT_meta-${product_name} = "zeus"
    LAYERDEPENDS_meta-${product_name} = "topic-platform-layer"
    
  6. Create the user config file in meta-${product_name}/recipes-core/images/user-config.inc

    Add packages that need to be installed into the image. See the example below which adds python and enables the autologin feature:

    IMAGE_INSTALL_append = " \
            python3 \
    "
    
    # login by default
    inherit autologin
    
  7. Create a shell script to set up the environment to start the build in.

    Create scripts/setup.sh with the example content below. Update the paths depending on your setup and make sure you add execution permissions to the script (chmod +x scripts/setup.sh).

    #!/bin/sh -e
    DOWNLOAD_DIR='data'
    BSP_NAME="minimal-tdkzu9-default-2021.1-xxxxxxx.bsp"
    REMOTE_BSP_URI="https://topic.nl/downloads/TLD/v2020.2.1/BSP/tdkzu9-default/petalinux/${BSP_NAME}"
    REMOTE_XSA_URI='http://${DATA_SERVER}/downloads/fpga/fpga-image-${company_name}-${product_name}/fpga-image-${company_name}-${product_name}-9dacc9776efe8c0e3ea5114b3157ddbe51a4f30c.tar.xz'
    LOCAL_BSP_PATH="${DOWNLOAD_DIR}/${BSP_NAME}"
    LOCAL_XSA_PATH="${DOWNLOAD_DIR}/rel/${product_name}.xsa"
    PETA_PROJECT_NAME='${product_name}'
    
    note ()
    {
            echo -e "\033[32mNOTE: $1\033[39m"
    }
    
    warning ()
    {
            echo -e "\033[33mWARNING: $1\033[39m"
    }
    
    error ()
    {
            echo -e "\033[31mERROR: $1\033[39m"
    }
    
    if [ ! -e "${LOCAL_BSP_PATH}" ]; then
            warning "Downloading bsp from ${REMOTE_BSP_URI}"
            wget -q -O "${LOCAL_BSP_PATH}" ${REMOTE_BSP_URI}
    fi
    
    if [ ! -e "${LOCAL_XSA_PATH}" ]; then
            warning "Downloading xsa from ${REMOTE_XSA_URI}"
            wget -q -O "/tmp/downloaded.xsa.xz" ${REMOTE_XSA_URI}
            tar -xf "/tmp/downloaded.xsa.xz" --directory=${DOWNLOAD_DIR}
    
    fi
    
    note "Removing old petalinux project if exists in ${PETA_PROJECT_NAME}/"
    rm -rf ${PETA_PROJECT_NAME}
    
    if [ ! -e "${LOCAL_BSP_PATH}" ]; then
            error "BSP doesn't exist ${LOCAL_BSP_PATH}"
            return
    fi
    if [ ! -e "${LOCAL_XSA_PATH}" ]; then
            error "xsa doesn't exist ${LOCAL_XSA_PATH}"
            return
    fi
    
    note "Create petalinux project in ${PETA_PROJECT_NAME}/"
    petalinux-create \
            --type project \
            --name ${PETA_PROJECT_NAME} \
            --source ${LOCAL_BSP_PATH}
    
    cd ${PETA_PROJECT_NAME}
    note "Update with latest XSA file"
    petalinux-config --silentconfig --get-hw-description ../${LOCAL_XSA_PATH}
    
    note "Update with user config"
    if [ -e "../config/config" ]; then
            cp ../config/config project-spec/configs/
    else
            warning "File config/config doesn't exist, will use config from BSP file."
    fi
    
    if [ -e "../config/rootfs_config" ]; then
            cp ../config/rootfs_config project-spec/configs/
    else
            warning "File config/rootfs_config doesn't exist, will use config from BSP file."
    fi
    
    petalinux-config --silentconfig
    note "Setup of petalinux project completed."
    
  8. Create a shell script that will automate the build.

    Create scripts/autobuild.sh and fill it with the example content below. Also make sure to add execution permissions to the script (chmod +X scripts/setup.sh).

    #!/bin/sh -e
    ./scripts/setup.sh
    cd ${product_name}
    petalinux-build -c "petalinux-image-minimal-swu-emmc"
    mkdir -p ../results
    cp build/tmp/deploy/images/*/petalinux-image-minimal-*.wic.xz ../results/.
    cp build/tmp/deploy/images/*/petalinux-image-minimal-swu-emmc-*.swu ../results/.
    
  9. Run the setup script (making sure petalinux is sourced).
    source <petalinux_install_dir>/settings.sh
    ./scripts/setup.sh
    

    This creates the petalinux project. The config files from this project need to be checked in into the GIT repository.

  10. Copy the config files to the GIT repository:

    cp ${product_name}/project-spec/configs/config config/
    cp ${product_name}/project-spec/configs/rootfs_config config/
    
  11. Open config/config and scroll to the end of the file.

    Add the new user (meta) layer to the CONFIG_USER_LAYER_x variables. It should look like the example contents below:

    #
    # User Layers
    #
    CONFIG_USER_LAYER_0="${proot}/../meta-${product_name}"
    CONFIG_USER_LAYER_1="${proot}/project-spec/meta-user"
    CONFIG_USER_LAYER_2="${proot}/project-spec/meta-swupdate"
    CONFIG_USER_LAYER_3="${proot}/project-spec/meta-topic"
    CONFIG_USER_LAYER_4="${proot}/project-spec/meta-topic-platform"
    CONFIG_USER_LAYER_5="${proot}/project-spec/meta-xilinx-standalone"
    CONFIG_USER_LAYER_6="${proot}/project-spec/meta-rust"
    CONFIG_USER_LAYER_7="${proot}/project-spec/meta-dyplo"
    CONFIG_USER_LAYER_8=""
    
  12. Now the project is ready to be built, by running:
    ./scripts/autobuild.sh