I would like to write OpenOCD script to conditionally flash application binary image. I want to overwrite flash only in case there is different image. Something like this pseudo code:
$IMAGE = "Application.elf";
$already_flashed = verify_image $IMAGE;
if { ! $already_flashed } {
flash write_image erase $IMAGE;
}
Is it possible to do this only by OpenOCD, not using other scripting engine but build-in JimTCL?
Now I use
openocd -c "source [find board/myboard.cfg]; init; reset halt; verify_image Application.elf; shutdown;"
If the return code is 0, verification pass, if the return code is 1, verification failed.