Building NVIDIA Yocto Project-based Components#
You can build NVIDIA Yocto project-based components by performing the following steps.
Prerequisites#
Users on Ubuntu 24.04 hosts must disable AppArmor restrictions for unprivileged user namespaces to effectively run the
bitbaketool by executing the following as root before continuing with steps below:$ echo 0 > /proc/sys/kernel/apparmor_restrict_unprivileged_userns
For more information, see Ubuntu Release Notes.
Optional: If the system on which the Yocto build is performed is low on system RAM, additional swap space should be allocated to increase system’s virtual memory to avoid out-of-memory failures by running the following commands:
$ sudo dd if=/dev/zero of=/mnt/swapfile bs=1M count=16384
$ sudo chmod 600 /mnt/swapfile
$ sudo mkswap /mnt/swapfile
$ sudo swapon /mnt/swapfile
Procedure#
Because Yocto does not allow launching builds as root, switch to a non-root
useridby running the following command:$ sudo su nvidia
When prompted, use the password
nvidia.Set up the Yocto environment in Docker by using the automated
setup_yocto_env.shscript, which must be executed prior to launching thebitbaketool:Set the
NV_WORKSPACEenvironment variable:$ export NV_WORKSPACE=/drive/
Change to the following directory:
$ cd $NV_WORKSPACE/drive-linux_src/yocto/scripts
Run the script:
$ source setup_yocto_env.sh
Optional: If you are building compute bits like CUDA, CUDNN, and TRT, run the Artifactory Download Tool to setup the toolkits as mentioned in Downloading and Copying Additional DriveOS Packages for Yocto Project Builds.
Set the
IMAGE_TYPE,KERNEL_CONFIG_TYPE, andCOPYTARGET_VARIANTenvironment variables:Note
For a complete set of valid combinations for these environment variables, see Reference.
Select the type of image by setting the
IMAGE_TYPEenvironment variable:$ export IMAGE_TYPE=<type>
Replace
<type>with one of the following:prodRootfs with upstream OSS (baseline Yocto distro) and Tegra software libraries
samplesRootfs with contents of
prodplus NVIDIA DriveOS samples (NVmedia, Gfx, and other samples)debug-utilsRootfs with contents of
prodplus utilities to support debugging and profiling (OSS and NV-proprietary debug utilities)full(default)Superset rootfs with everything in
prod,samples, anddebug-utilspackaged
Select the flavor of kernel to build by setting the
KERNEL_CONFIG_TYPEenvironment variable:$ export KERNEL_CONFIG_TYPE=<type>
Replace
<type>with one of the following:standard(default),production,safety,production_debug, orsafety_debug.Set the
COPYTARGET_VARIANTenvironment variable to eitherrfs(default fortegra-drive-os-av-image) orboot_initramfs(for initramfs builds):$ export COPYTARGET_VARIANT=<rfs|boot_initramfs>
(Optional) To build kernel modules from source (default method is to package prebuilt kernel) with the Yocto build:
$ export K_BUILD_SOURCE=1
Build the component or image, depending on the recipe, by running the following command:
$ bitbake <recipe>
For example, you can replace
<recipe>with one of the following BitBake recipes of interest:tegra-initramfs-bootCold boot initramfs
tegra-prod-initramfs-bootCold boot initramfs with production config
tegra-drive-os-av-imageYocto DRIVE AV rootfs
For kernel security feature configurations, see the following steps:
The default kernel recipe uses prebuilt components to account for signature matching of the base kernel and Tegra kernel modules. To rebuild the base kernel from the source, launch
bitbakeon thelinux-nvidiarecipe manually.SELinux support is enabled in Yocto with default mode as permissive. If you need to begin testing system behavior in enforcing mode, you must modify the
DEFAULT_ENFORCINGtoenforcingin the following file:${NV_WORKSPACE}/drive-linux_yocto/yocto/layers/meta-drive/recipes-security/refpolicy/refpolicy-minimum_%.bbappendTo enable read-only root filesystem and dm-verity kernel security features, see DM-Verity and Read-Only File System Support.
Note
To disable Auto IP Assignment (APIPA) on the target, append
LinkLocalAddressing=noin the[Network]section of the/etc/systemd/networkd.conffile.
Reference#
The following table documents valid combinations for the IMAGE_TYPE, KERNEL_CONFIG_TYPE, COPYTARGET_VARIANT, and PCT environment variables:
|
|
|
|
|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
N/A |
|
|
any |
N/A |
|
|
any |