Adding a Single Debian Package and a Single File to the Linux File System

This example shows the steps to add a file, a Debian package, and build the Linux file system using the file system tools Build-FS and CopyTarget. At the completion of this example, you will complete the following tasks:
  • Customize your Linux file system.
  • Flash your customized Linux file system image onto the NVIDIA DRIVE® platform.
  • Boot up the target platform with your customized Linux file system.
  • Verify the added package and the added file on the target.
  1. In this example, we have chosen to use the file ${NV_WORKSPACE}/drive-linux/filesystem/content/samples/hello_world.txt that is part of the NVIDIA DRIVE® OS samples to add to the Linux file system.

  2. You are, otherwise, welcome to use any other file you want, but the rest of this example will refer to hello_world.txt.

  3. Create the CopyTarget Manifest ${NV_WORKSPACE}/drive-linux/filesystem/copytarget/manifest/copytarget-hello.yaml and add entry to ${NV_WORKSPACE}/drive-linux/filesystem/content/samples/hello_world.txt as shown below. A list of file metadata (perm, owner, group) must be specified to provide detail to describe the file.

  4. To customize the standard Linux file system, specify the file system variant that the file hello_world.txt is part of. Importantly, you must provide the source location (pdk_sdk_installed_path) and the destination that the file hello_world.txt should reside in the customized Linux file system.

  5. As per steps 2 and 3, an example that describes hello_world.txt is provided in the code block below. Copy this excerpt into ${NV_WORKSPACE}/drive-linux/filesystem/copytarget/manifest/copytarget-hello.yaml.
    fileList:
        - destination: /hello_world.txt
          source:
              pdk_sdk_installed_path: ${NV_WORKSPACE}/drive-linux/filesystem/content/samples/hello_world.txt
          perm: 644
          owner: root
          group: root
  6. Further, in this example, we demonstrate adding a Linux Debian package to the file system using the Build-FS config. To add a package, an entry must be added to the DebianPackages block of the config file.
  7. Update the /opt/nvidia/driveos/common/filesystems/build-fs/17/configs/driveos-example-hello_world-rfs.CONFIG.json Build-FS config to add the CopyTarget YAML created above in the "CopyTargets" block and the parted Debian package in the DebianPackages block of the config file.
    {
        "OS": "linux",
        "Output": "driveos-example-hello_world-rfs",
        "Base": "${BASE_DIR}/targetfs.img",
        "Mirrors": [
            {
                "Type": "local_debian_folder",
                "Path": "${MIRROR_DIR}"
            }
        ],
        "CopyTargets": [
            "${COPYTARGETYAML_DIR}/copytarget-hello.yaml"
        ],
        "DebianPackages": [
            "bsdmainutils"
        ]
    }
  8. Run the build-fs tool using the following commands to create a file system with preceding customizations. The created file system shall be at path ${NV_WORKSPACE}/drive-linux/filesystem/targetfs-images/driveos-example-hello_world-rfs.img because of the output name specified in /opt/nvidia/driveos/common/filesystems/build-fs/17/configs/driveos-example-hello_world-rfs.CONFIG.json. Copy the rebuilt file system to replace the starting file system at ${NV_WORKSPACE}/drive-linux/filesystem/targetfs.img.
    $ sudo -E /usr/bin/python3 -B /opt/nvidia/driveos/common/filesystems/build-fs/17/bin/build_fs.py -w ${NV_WORKSPACE}/ -i /opt/nvidia/driveos/common/filesystems/build-fs/17/configs/driveos-linux-example-hello_world-rfs.CONFIG.json -o ${NV_WORKSPACE}/drive-linux/filesystem/targetfs-images/
    $ sudo rm -f ${NV_WORKSPACE}/drive-linux/filesystem/targetfs.img
    $ sudo ln -s ${NV_WORKSPACE}/drive-linux/filesystem/targetfs-images/driveos-example-hello_world-rfs.img ${NV_WORKSPACE}/drive-linux/filesystem/targetfs.img
  9. The NVIDIA DRIVE OS flashing tool bootburn.py PCT picks up the file system by default at path ${NV_WORKSPACE}/drive-linux/filesystem/targetfs.img.
  10. Use bootburn.py to flash the file system.
  11. Reboot the target.
  12. The target should have rebooted with your customized Linux file system.
  13. Verify that intended customizations are present:
    1. Check ls at / path to verify /hello-world.txt exists:
      1. $ ls /hello-world.txt
    2. Use the following hexdump command to confirm the bsdmainutils package is installed:
      1. $ hexdump -C /hello-world.txt