Easy Installer custom u-boot environment configuration

Hi.

I want to use the Easy Installer to flash our Yocto based image in production.
We configured our u-boot with redundante environment variables. So here is my /etc/fw_env.config:

# Block device name	Device offset	Env. size
/dev/mmcblk0boot0        -0x4200		0x2000
/dev/mmcblk0boot0        -0x2200		0x2000

I can’t use the Easy Installer “u_boot_env” property as it uses the configuration from the tezi image.
So i tried to extend the wrapup script with the command:

fw_setenv --config /run/media/src/fw_env.config --script /run/media/src/bootenv.txt

When I execute the wrapup.sh script manual in the tezi image, it works as expected.
When installing the image through Easy Installer with the same wrapup.sh script. I see this warning in the log file:

Warning: Bad CRC, using default environment

In u-boot i see just the variables description in the bootenv.txt file. The rest of the default Environment is removed.

What is the difference by executing the script manual or within the installer?

Is there another (better) way to write the u-boot Environment variables with a different configuration (/etc/fw_env.config)?

Best Regards

Martin

And you removed the U-Boot environment part from the regular image json file? Or could it be that this interferes with your wrap-up script?

Yes I removed them. Here is my image.json file:

{
        "config_format": 2,
        "autoinstall": false,
        "name": "APS-9000 Application Controller",
        "description": "APS-9000 Linux Image for the Application Controller",
        "version": "0.0.1",
        "release_date": "20201217",
        "prepare_script": "prepare.sh",
        "wrapup_script": "wrapup.sh",
        "icon": "g+m.png",
        "supported_product_ids": [
            "0014",
            "0015",
            "0016",
            "0017"
        ],
        "blockdevs": [
            {
                  .....
            },
            {
                "name": "mmcblk0boot0",
                "erase": true,
                "content": {
                    "filesystem_type": "raw",
                    "rawfiles": [
                        {
                            "filename": "SPL",
                            "dd_options": "seek=2"
                        },
                        {
                            "filename": "u-boot.imx",
                            "dd_options": "seek=138"
                        }
                    ]
                }
            }
        ]
    }

Hi @mm@gm,

There are several reasons why this warning is printed on the screen.
It can be that you are trying to access an uninitialized on-disk u-boot environment, which is expected and shall not occur after a saveenv, for example.

And… Have you checked that at the end of the installation, you have everything set for your redundant environment variables?

Could be that it’s printing that message because the environment is not set, then you set it, and it’s OK.

If that does not help:

  • Can you check if configblock is correctly set?
  • Can you generate and use a given uboot.env file, as it contains CRC checksum?

Best regards,
André Curvello

Hi @andrecurvello.tx

You are right the environment is not initialized. I checked it with hexdump and both environments are blank. After a saveenv in the u-boot, my environment variables can be correctly set.

So this works for development:

  • Install image.json with Toradex easy Installer
  • execute saveenv in u-boot
  • Set u-Boot environment by hand from the tezi image.
  • Boot my own image

But in production i want to install all together with one click. This is the reason why i choose the Easy Installer. So how can i set the default environment in the wrapup script before set my bootenv.txt?

Hi @mm@gm,

Any news on this topic?

Best regards,
André Curvello

Hi @andrecurvello.tx
I think my last comment go lost. So here again:

You are right. The u-boot environment is not initialized. I checked it with hexdump and see both blocks are empty. After switch back to u-boot and saveenv both are initialized and can be set within the tezi image.

How can I initialize the environment inside the tezi image wrapup script?
I want to install all together without typing in another command in u-boot.

My workaround would be to include the default environment in the bootenv.txt file.

In u-boot i see just the variables description in the bootenv.txt file. The rest of the default Environment is removed.

Bootenv importing is supposed to only add resp. alter whatever stuff that is contained within it, not? And as the module likely starts off without any of your redundant environment that is the expected behaviour, not? I believe what you are looking for would involve two separate imports. First a bootenv file with what you describe as default environment and then whatever else you seem to want to import. Makes sense?

Hi @marcel.tx

Yes, this is what I was looking for. My mistake was, I thought the default environment from the U-Boot is already in the eMMC and I use my bootenv.txt to extend it.

Good idea to create two files. One for default and one for my customizations.

Best Regards
Martin

You are very welcome and sorry that we did not get to the root of this earlier.

Thanks @marcel.tx for the input!

So, can we consider this issue to be solved, @mm@gm?

Yes this is solved for me

Thanks! Good to know.