Building Smart blaze VM Images#
The two mainstream options for embedded linux development are the Debian-based ELBE build system and the industry-standard Yocto Linux. With these systems, you can build an optimized, lean, and reproducible rootfs that can be uploaded to the camera.
The Debian system provided as a default on the Smart blaze camera was chosen as an easy-to-use base where most concepts from typical native Linux development apply. It's built using ELBE. The build process is described under Embedded Linux Build System (ELBE).
The default VM is initially created from the scripts described in the following sections and delivered as part of the pylon Supplementary package for blaze. You can find these scripts below the Samples subfolder of your installation path. On a typical Linux system, this is /opt/pylon/share/pylon/Samples/blaze/smartblaze/vm. If not mentioned otherwise, relative paths referring to scripts and config files in this topic are relative to this directory.
VM Image Structure#
An uploadable VM image is a tar.gz archive containing the following files:
- rootfs image rootfs.{qcow2,img,raw}
- kernel image kernel
- config file config.toml
The archive base name without extension will be used as the VM image name on the camera.
The name debian-arm64-min belongs to the default VM present on the camera. It can be restored using the Factory Reset button in the Smart blaze VM Control web interface.
The vm-image.sh script bundles the individual files into a VM image:
$ ./vm-image.sh --help
Usage: ./vm-image.sh [--rootfs <path>] [--kernel <path>] [--config <path>] [--image <path>]
Build a VM image tar.gz archive containing a rootfs, kernel and optional config toml file.
Defaults:
--rootfs elbe/elbe-build-*/debian-arm64-min.qcow2
--kernel work/_result/blazevm-arm64-kernel
--image work/debian-arm64-min.tar.gz
Rootfs Image#
Supported file names:
- rootfs.qcow2 (QEMU QCOW2 image)
- rootfs.[img|raw] (raw image)
Supported formats:
- Image containing a raw root filesystem
- Image containing a partition table with the root filesystem in the first partition (see ELBE build below)
即: elbe/build-vm.sh script provides an example to build a reproducible rootfs using the description in elbe/blazevm.xml. Results are output in the subdirectory elbe/elbe-build-
Installing ELBE and other required tools is described in elbe/build-vm.sh.
Kernel Image#
There is a simple kernel.sh script that builds a recent kernel. The default arm64-defconfig is used, which isn't optimized for size but includes all necessary drivers for virtio-based paravirtualization.
You can build the kernel by running the script without arguments. Intermediate files are placed in the ./work subdirectory and the completed image is placed in ./work/_result.
The rootfs is started by qemu-system-aarch64 and needs a kernel image including virtio_blk support. The Debian kernel package uses virtio_blk as a module which requires the use of an appropriate initrd. This is not yet supported. Therefore, using the Debian binary kernel, which could be provided by the ELBE build, is not an option. Instead, you need to build your own kernel with static virtio_blk support. Moreover, the Debian binary kernel uses virtio_net as a module, which doesn't work with the way the ip= parameter is provided via kernel cmdline.
Config File#
The configuration file contains options for controlling how the image file is handled when installed on the camera.
# VM Image Configuration for Basler example VMs
# Whether to inject a password in /etc/shadow before first VM image start
# default: ""
# "label-pw" - The password from the label is to be injected.
# "" - No password to inject. Image is responsible for setting a password.
password_rule = "label-pw"
# User whose password is set according to password_rule
# default: "root"
user = "root"
# Whether to manually confirm first VM image start
# default: false
confirm_start = true
If the image uses a fixed password and no startup confirmation is required, the config.toml file can be omitted.
Embedded Linux Build System (ELBE)#
Installing ELBE#
To install ELBE and set everything up for building the VM rootfs using ELBE, follow these steps:
- Install the latest elbe version according to Installing ELBE.
-
Set up the ELBE initvm.
This is a virtual machine on your development computer that is used for building the rootfs inside a controlled environment. -
Prepare SSH access to ELBE initvm.
-
Add your public SSH key (e.g., the content of
~/.ssh/id_rsa.pub) to the initvm with this command: -
Test access with this command:
-
-
Install additional tools needed by the build script:
apt-get intall qemu-utils
Building a Root Filesystem with ELBE#
To build the root filesystem with ELBE, set up ELBE as described above. Then run elbe/build-vm.sh.
Building an SDK with ELBE#
In addition to the VM rootfs, a Yocto-style SDK can be created:
The result is a self-extracting script provided in the subdirectory elbe/elbe-build-
setup-elbe-sdk-aarch64-linux-gnu-BlazeVM-1.2.sh
It provides all packages required to build software for the VM. This includes the gcc cross-compiler for arm64 as well as all -dev development packages corresponding to the packages available in the VM. It provides header files and relevant libraries to build and link against as well as pkgconfig and cmake files for automatically finding these.
Saving Missing Files in ELBE SDK#
Some files of the pylon package and the blaze samples are missing in the SDK target sysroot. After building the ELBE SDK, they have to be copied from the ELBE initvm to a local sysroot directory once.
Make sure you have set up SSH access to your ELBE initvm for this to work.
设置 --project-dir to the ELBE project directory in the initvm (e.g., /var/cache/elbe/
elbe/save-missing-sdk-files.sh --project-dir /var/cache/elbe/XXX --result-dir elbe/elbe-build-YYYYMMDD-HHMMSS
The files are copied to the sysroot subdirectory of the ELBE result directory.
Installing ELBE SDK#
$ LATEST_ELBE_RESULT_DIR=$(ls -dt elbe/elbe-build-* | head -n1)
$ cd ${LATEST_ELBE_RESULT_DIR}
$ chmod +x setup-elbe-sdk-aarch64-linux-gnu-BlazeVM-1.2.sh
$ ./setup-elbe-sdk-aarch64-linux-gnu-BlazeVM-1.2.sh
ELBE BlazeVM 1.2 SDK installer
==============================
Enter target directory for SDK (default: /opt/elbe-sdk-aarch64-linux-gnu-BlazeVM-1.2):
You are about to install the SDK to "/opt/elbe-sdk-aarch64-linux-gnu-BlazeVM-1.2". Proceed[Y/n]?
Extracting SDK............................................................................................done
Setting it up...SKIP /opt/elbe-sdk-aarch64-linux-gnu-BlazeVM-1.2/sysroots/host/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
SDK has been successfully set up and is ready to be used.
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
$ . /opt/elbe-sdk-aarch64-linux-gnu-BlazeVM-1.2/environment-setup-elbe-aarch64-linux-gnu-BlazeVM-1.2
After installing the SDK, the missing files provided in the ELBE result directory must be added manually to the installed SDK.
The default environment setup script is the default name from the section above (/opt/elbe-sdk-aarch64-linux-gnu-BlazeVM-1.2/environment-setup-elbe-aarch64-linux-gnu-BlazeVM-1.2) when installing the SDK in the default path. If you have installed the SDK in a different location, adjust the path accordingly.
Call this script from the corresponding ELBE result directory (adjust the path accordingly):