2 Adjustments to the Project
The SDK provides a main "single-button" build script for every specific 'board' / 'hw configuration'.
Each main script runs or includes other scripts, which in turn either set configuration parameters or provide helping shell functions.
BSP.u96v2-2023.2 provides four scripts picked from the SDK (can be found in 'u96v2_sbc_base_2023_2/pre-built/linux/images'):
rebuild_u96v2_sbc_base.sh (modification of the original make_u96v2_sbc_base.sh)
config.boot_method.EXT4.sh
config.boot_method.INITRD.sh
common.sh
Printing substantial part of 'rebuild_u96v2_sbc_base.sh' here:
...
HDL_PROJECT_NAME=base
HDL_BOARD_NAME=u96v2_sbc
ARCH="aarch64"
SOC="zynqMP"
PETALINUX_BOARD_FAMILY=u96v2
PETALINUX_BOARD_NAME=${HDL_BOARD_NAME}
PETALINUX_BOARD_PROJECT=${HDL_PROJECT_NAME}
PETALINUX_PROJECT_ROOT_NAME=${PETALINUX_BOARD_NAME}_${PETALINUX_BOARD_PROJECT}
# Use the PETALINUX_BUILD_IMAGE variable to build a different yocto image than the default petalinux-image-minimal
#PETALINUX_BUILD_IMAGE=avnet-image-full
KEEP_CACHE="true"
KEEP_WORK="false"
DEBUG="no"
#NO_BIT_OPTION can be set to 'yes' to generate a BOOT.BIN without bitstream
NO_BIT_OPTION='yes'
source ${MAIN_SCRIPT_FOLDER}/common.sh
verify_environment
BOOT_METHOD='EXT4'
build_bsp
...
'rebuild_u96v2_sbc_base.sh' script does not provide enough flexibility to adjust the project the way I need. So, instead of changing the SDK workflow in the script I will to use PetaLinux command line utilities directly, which is a nominal way to customize an image.
Also, I made a set of scripts - u96v2-bsp-tweak-kit - that manipulate project parameters. Please find it in GitHub:
https://github.com/malus-brandywine/u96v2-bsp-tweak-kit
2.1 Start
Reminder before the start: PetaLinux utilities and the scripts provided in the tweak kit must be run in the build shell with Vitis/PetaLinux environment set (mentioned in Chapter 1, paragraph 1). We start configuring the PetaLinux project with deploying configuration files. In your working directory in the build shell run the command:
$ petalinux-config -p u96v2_sbc_base_2023_2 --get-hw-description=u96v2_sbc_base_2023_2/hardware/u96v2_sbc_base_2023_2
You will get ncurses-based menu, just exit it for now and let the command do its job - it places configuration files into 'u96v2_sbc_base_2023_2/build/conf/'.
Next, let's create directory 'images/linux' in the project:
$ mkdir -p u96v2_sbc_base_2023_2/images/linux
Also, copy the tweak kit files into your working directory.
2.2 Parameter KEEP_WORK
I need to be able to choose whether I keep components' temporary workspaces (see class 'rm_work' in Yocto Manual) after they have been built.
The rebuild script mentions KEEP_WORK parameter, but it never lets the parameter to give an effect. As mentioned above, I don't want to rearrange the workflow juggling with the SDK functions, so I wrote the script 'keep_work.sh' to switch between "Keep"-ing and "Drop"-ing workspaces.
For example, run the script to set dropping workspaces:
$ ./keep_work.sh u96v2_sbc_base_2023_2 Drop
The change is applied to 'u96v2_sbc_base_2023_2/build/conf/local.conf'
2.3 Parameter BOOT_METHOD
While maintaining images with the two boot methods, I need to be able to switch between the two image boot methods - 'EXT4' (SD card) and 'INITRD' because I use both image versions while I debug my applications. Since we don't use the rebuild script, let's apply changes the other way.
'pre-built/linux/images' directory provides two relevant scripts picked from the SDK:
config.boot_method.EXT4.sh and
config.boot_method.INITRD.sh
Both of them tweak auto-generated project configuration files:
u96v2_sbc_base_2023_2/project-spec/configs/config and
u96v2_sbc_base_2023_2/project-spec/configs/rootfs_config accordingly to the chosen boot method.
Those 'config.boot_method.*.sh' scripts expect to find the config files at the fixed relative path. I modified the scripts so they use a parameter as a path to PetaLinux project.
Besides that, 'config.boot_method.INITRD.sh' has a minor bug in Ultr96V2 board support (in the given version of BSP). I fixed that.
Also, I added two other "run" scripts that compose the proper command line for the two aforementioned scripts. They also require input parameter: the project name.
$ ./run.config.EXT4.sh u96v2_sbc_base_2023_2
or
$ ./run.config.INITRD.sh u96v2_sbc_base_2023_2
Reasoning of using the scripts. Normal way to configure boot method is to run 'petalinux-config' with parameter '-c rootfs'. It offers ncurses-based menu where you set proper parameters. Using the tweak kit scripts is a faster way to update the configuration files.
Last updated