Torizon Core Builder deploy permanent data to EasyInstaller Image

Hello everyone,

If some customizations need to be added in a TorizonCoreBuilder project,

Example: To add an M4 binary, the U-Boot variables should be edited to automatically load this binary, run this firmware before Linux starts.

And example:

Add a fan.sh shell script and do a chmod +x that controls a fan.service

I captured the service configuration using the torizoncore-builder isolate command. This works well.

But what is the recommended way to mount a file and run a command after the first boot?

Greetings
Gerald

Greetings @gerko,

But what is the recommended way to mount a file and run a command after the first boot?

If you just want to execute some actions on boot, sounds like you could just create a simple systemd service like what is shown here: Basic Linux Commands | Toradex Developer Center

Then you can capture this service using the isolate command as before.

Best Regards,
Jeremias

Thank you @jeremias.tx ,

OK, that works fine.

Now I need help to deploy my custom M4 Firmware to e.g. /var/fw_m4_1.bin so that I can include it to a custom BSP, that I can use to update other modules / devices.

The U-Boot variables could also be adjusted using a ‘first boot script’ (Is this intended or are there better options?)

Best
Gerald

Now I need help to deploy my custom M4 Firmware to e.g. /var/fw_m4_1.bin so that I can include it to a custom BSP, that I can use to update other modules / devices.

You could add your binary file and use isolate to capture it. That said /var is not a suitable location since it’s not managed by OSTree and therefore will not be “seen” by the TorizonCore Builder tool. Could you put it in another location like /etc?

The U-Boot variables could also be adjusted using a ‘first boot script’ (Is this intended or are there better options?)

This is certainly an option. Unfortunatley, TorizonCore Builder has no capability to affect anything U-Boot related. You could do a Yocto Build to customize U-Boot and the variables though I assume you’re trying to avoid such a thing. We also have the capability to deploy a bootloader update: Bootloader Updates in Torizon OS | Toradex Developer Center

Though this is only relevant if you’re using our Torizon Cloud platform. Also it still requires you to build a custom U-Boot to upload as a package in the first place.

Best Regards,
Jeremias

Hi @jeremias.tx ,

How this may be done? The module just does not boot if the M4 firmware is placed in /etc/

Thanks in advance.

V

If you need to put your M4 firmware in /var then you can also do the following.

In the folder you use to install with Easy Installer there should be a file called image.json, with contents that look something like:

image.json
{
    "config_format": 3,
    "autoinstall": false,
    "name": "Torizon OS Easy Pairing (UPSTREAM)",
    "description": "Torizon OS Linux with Easy Pairing application. Use the code from Torizon Cloud to pair the device.",
    "version": "7.4.0+build.28.modified.container",
    "release_date": "2025-10-22",
    "u_boot_env": "u-boot-initial-env-spl",
    "prepare_script": "prepare.sh",
    "wrapup_script": "wrapup.sh",
    "marketing": "marketing.tar",
    "icon": "toradexlinux.png",
    "license": "LA_OPT_NXP_SW.html",
    "supported_product_ids": [
        "0027",
        "0028",
        "0029",
        "0035",
        "0082",
        "0083",
        "0084",
        "0085"
    ],
    "blockdevs": [
        {
            "name": "mmcblk0",
            "partitions": [
                {
                    "partition_size_nominal": "512",
                    "want_maximised": true,
                    "content": {
                        "label": "otaroot",
                        "filesystem_type": "ext4",
                        "mkfs_options": "-E nodiscard",
                        "filename": "torizon-docker-apalis-imx6.ota.tar.zst",
                        "uncompressed_size": 1120.5171482086182,
                        "filelist": [
                            "docker-compose.yml:/ostree/deploy/torizon/var/sota/storage/docker-compose/",
                            "docker-storage.tar.xz:/ostree/deploy/torizon/var/lib/docker/:true",
                            "target_name:/ostree/deploy/torizon/var/sota/storage/docker-compose/"
                        ]
                    }
                }
            ]
        },
        {
            "name": "mmcblk0boot0",
            "erase": true,
            "content": {
                "filesystem_type": "raw",
                "rawfiles": [
                    {
                        "filename": "SPL",
                        "dd_options": "seek=2"
                    },
                    {
                        "filename": "u-boot.img",
                        "dd_options": "seek=138"
                    }
                ]
            }
        }
    ]
}

First copy your M4 firmware binary to this folder. Then modify the image.json file to install your M4 binary to /var like so (notice the new entry under filelist):

...
    "blockdevs": [
        {
            "name": "mmcblk0",
            "partitions": [
                {
                    "partition_size_nominal": "512",
                    "want_maximised": true,
                    "content": {
                        "label": "otaroot",
                        "filesystem_type": "ext4",
                        "mkfs_options": "-E nodiscard",
                        "filename": "torizon-docker-apalis-imx6.ota.tar.zst",
                        "uncompressed_size": 1120.5171482086182,
                        "filelist": [
                            "docker-compose.yml:/ostree/deploy/torizon/var/sota/storage/docker-compose/",
                            "docker-storage.tar.xz:/ostree/deploy/torizon/var/lib/docker/:true",
                            "target_name:/ostree/deploy/torizon/var/sota/storage/docker-compose/",
                            "hello_world.bin:/ostree/deploy/torizon/var/"
                        ]
                    }
                }
            ]
        },
...

You can then flash this with Toradex Easy Installer and your binary file should be located at /var in the final filesystem. You should then be able to load this binary as documented here: How to Load Compiled Binaries into Cortex-M | Toradex Developer Center

Please keep in mind this is for Torizon OS specifically, if you are not using a Torizon OS based image, then the instructions may be different. In which case please open a new thread with the details on what software you are exactly using.

Best Regards,
Jeremias

Hi, @jeremias.tx ,

Thanks for your prompt reply, but I was asking on /etc/ folder, not /var/.

As you suggest above, I’d like to use torizoncore-builder isolate to capture changes in /etc/. However, I doesn’t seem to work.

Kind regards,

V

As you suggest above, I’d like to use torizoncore-builder isolate to capture changes in /etc/. However, I doesn’t seem to work.

I’m confused you said the module doesn’t boot if the firmware is in /etc. Do you have a reason to prefer the firmware in /etc as opposed to /var? If you’re loading the firmware from U-Boot, it’s a lot simpler to reference the filesystem location if it’s in /var as opposed to /etc.

Also we are going to need more detail other than “doesn’t seem to work”. What are the logs, the exact process you are doing, and other important details.

I also recommend you open a new thread since this thread is quite old and may not be relevant anymore.

Best Regards,
Jeremias

My solution was a service that checks whether the binary is available under /var, and if not, it copies it from a directory in /etc.

Is this an option for you?

Yes, I am going to try that. Thanks @gerko !