Add files to /var/ during Yocto build (OSTree)

Hi there,

I have set up a subsystem (M7 firmware, Verdin i.MX8mp) on a torizon-minimal Yocto build. Since I boot from Uboot, the firmware must be at a non-ostree location, so /var/ for example.
Manually copying the files or also updating with TorizonCloud works, but I now want to also have the firmware files (3 .bins, or 1 .tar) in the TEZI image, so that we can just flash that in production.

How can I add these files to the /var/ directory during my Yocto build? I reckon that I need to add it somehow to the filelist in the image.json, so TEZI can move the files to the /var/, but how can I do that?

I started looking into image_type_tezi.bbclass, but it is still unclear to me how and when I should add my files.

Any input is welcome.

Cheers
Tim

Hi, I’m the Toradex AI Assistant.

I might make mistakes or occasionally get you wrong. Our support team will step in if needed.


Hi Tim,

For adding firmware files to the /var/ directory in your TEZI image during Yocto build, you have a couple of approaches available with TorizonCore Builder.

Approach 1: Using TorizonCore Builder with Filesystem Customization

The most straightforward approach is to use TorizonCore Builder’s filesystem customization feature. You can create a directory structure containing your firmware files and include it in your build configuration(1)(2).

Steps:

  1. Create your project directory structure(1):
.
├── firmware/
│   └── var/
│       └── your-firmware-files.bin
├── tcbuild.yaml
└── torizon-minimal-verdin-imx8mp-Tezi_X.X.X+build.X.tar
  1. Configure your tcbuild.yaml(2):
input:
  easy-installer:
    local: torizon-minimal-verdin-imx8mp-Tezi_X.X.X+build.X.tar

customization:
  filesystem:
    - firmware/

output:
  easy-installer:
    local: custom-torizon-minimal-verdin-imx8mp
    name: "Torizon Minimal with M7 Firmware"
  1. Build the custom image(1):
torizoncore-builder build

Approach 2: Using the Isolate Command

If you have already configured your target device with the firmware files in the correct location, you can capture those changes(2):

  1. Capture configuration changes(2):
torizoncore-builder isolate --remote-host <DEVICE-IP> --remote-username torizon --remote-password torizon --changes-directory firmware-changes
  1. Include in your build configuration(2):
customization:
  filesystem:
    - firmware-changes/

Important Considerations

  • Directory Structure: The filesystem customization feature merges directory trees on top of the base image(2), so ensure your firmware directory structure matches exactly where you want the files placed (e.g., firmware/var/your-files)

  • File Permissions: Make sure your firmware files have the correct permissions before including them in the filesystem customization

  • Build Process: TorizonCore Builder runs inside a Docker container and only has access to files within your project directory(1), so ensure all firmware files are accessible within your working directory

This approach will create a TEZI image that includes your M7 firmware files in the /var/ directory, ready for production flashing.

Best regards,
Toradex AI Assistant.


Did you like my answer? :+1: :-1:

If I answered your question, please tick the “Solution” checkbox.

For follow-up questions to me, please use @ToradexAI in your post.

Greetings @TimSiegrist,

If you want to do this with Yocto, you would need to do the following.

You need to append to this variable somewhere in your Yocto build TEZI_ROOT_FILELIST. The entries in this variable are space separated, and each entry should have the following format:

<name of your file>:<location in  filesystem you want Easy Installer to flash it to>

So for example going with your use-case if you want to install a M7 binary to /var it would look something like this:

my_m7_binary.bin:/ostree/deploy/torizon/var/

You mentioned you also have a *.tar file as well. In that case there would be a third parameter based on whether you want this tar to be unpacked or not. So the following:

my_tarball.tar:/ostree/deploy/torizon/var/:true

Would unpack the provided tar archive to /var in the final booted filesystem.

Once you have TEZI_ROOT_FILELIST properly set, you then need to make sure the actual files themselves are available in ${IMGDEPLOYDIR}, before the TEZI related functions get executed in Yocto. So either create some recipe or bbclass that will make these files available in this location. If you want a reference or example of all of this, you can find one in our meta-layer here: meta-toradex-torizon/classes/torizon_base_image_type.inc at scarthgap-7.x.y · torizon/meta-toradex-torizon · GitHub

This basically adds an optional tarball containing some provisioning data for Torizon Cloud to the Yocto build to be installed by TEZI.

Alternatively, if you end up wanting to do this outside of Yocto you would just basically need to do what is described here: Torizon Core Builder deploy permanent data to EasyInstaller Image - #7 by jeremias.tx

Arguably might be easier/simpler to have a post Yocto script that modifies the TEZI image to add your files rather than doing that part in Yocto. But I’ll leave that discretion up to you.

Best Regards,
Jeremias