Imx6ul Dart grub integration fw_setenv intermittent error

Hi I am using a varicite Dart-6ul board according to the instructions in the board integrations section . It uses uboot grub integration. When doing file system upgrades occasionally everything runs fine until it trys to enable the new partition for boot. At this point i get an error
“error: fw_setenv returned failure: exit status 2
2022-07-07 14:58:48 +0000 UTC error: transient error: exit status 2”
This error is intermittent but with no particular pattern. I am using a commit_enter script to check before committing and that script does have a 4 minute delay in it to allow the web server on the unit to start up before checking that it is responding ok. I dont know why this would be a problem but I suspect it might be as the delay used to be longer and with the longer delay the problem used to happen much more frequently.

In general exit status 2 refers to not finding the environment location. The location is specified here. Are you sure the /boot/efi partition is mounted before the script runs?

The client service file has data.mount here in order to ensure this for the data partition, but maybe boot-efi.mount should also be there?

The intermittent nature of it would I guess support it being something like the the partition not having been mounted by that point although the by the time this happens the system has booted and been running for about 5 minutes so that would be a little surprising. I can try adding boot-efi.mount to the After clause and see. There is a part of our software which I have just discovered is calling fw_printenv quite frequently so I am also wondering if that is ending up causing a problem with fw_setenv in some unlucky cases

Just to complete this thread. I added the data.mount and boot-efi.mount to the after clause of the systemd service file. I also much reduced the rate at which the app polled the fw_printenv program. These two things appear to have resolved the issue however I now have a different error appearing on some units.

Jul 11 12:19:36 netmaster mender[660]: time=“2022-07-11T12:19:36+01:00” level=error msg=“fw_setenv returned failure: exit status 1”
Jul 11 12:19:36 netmaster mender[660]: time=“2022-07-11T12:19:36+01:00” level=error msg=“Failed to probe the U-Boot environment for which separator to use. Got error: exit status 1”

Again this is intermittent and usually works with a retry