humility flash could have an idempotent mode
jclulow opened this issue · 0 comments
As noted in #408, during manufacturing we are doing something suboptimal:
if ! humility flash --check; then
printf 'contents incorrect; programming...\n'
if ! humility flash --verify; then
printf 'programming failed!\n'
exit 1
fi
fi
printf 'ok\n'
In the event that the flash contents are already correct, flash --check
will return success and we drive on.
In the event that the flash contents are not already correct, the check fails and we move on to flash --verify
which then performs the same check again before eventually programming.
The reason we use this sequenced is that (as far as I can tell) flash --verify
, like flash
, will fail execution if the flash contents is already correct and we didn't have to do any work. This strict execution makes sense under some conditions; I can definitely imagine cases where I believed I was replacing the flash contents with something new, but it turns out I was mistaken. For manufacturing, though, what we really want is:
if ! humility flash --idempotent; then
printf 'problems!\n'
exit 1
fi
This would still include all of the checks that --check
and --verify
already perform today (i.e., the flash contents, not just the image ID, are verified) but it would exit successfully after the initial check if the contents are already as they should be.
If we don't want to use --idempotent
, then perhaps a verb like --ensure
would also capture the intent.