2015/11/24

Intel Edison; Clone/Copy by 'reboot ota' command

In previous post, I used flashall.sh/bat command to clone a reference image (or restore a backup image) to other Edison board.  If you want to use 'reboot ota' command, it requires some more tweaks.

# reboot ota

If reboot command is given a parameter ("ota"), the parameter is saved in U-Boot environment variable bootargs_mode. And U-Boot runs ota-update.scr at boot up. If you just replace edison-image-edison.ext4 file with a backup image, ota_update.scr fails because it has a hash value of the original ext4 file.

mkimage

If you modify ext4 file's hash value in ota_update.scr (you can edit it with a text editor), then U-Boot fails to load the scr because scr file's CRC check fails. Therefore ota_update.scr file needs to be regenerated with a backup ext4's hash value.

To generate ota_update.scr, it needs mkimage command that is included in U-Boot.
# git clone git://git.denx.de/u-boot.git
It needs not build everything, just needs tools.
make efi-x86_defconfig tools
mkimage tools will be in tools directory.

ota_update.scr

ota_update.scr is basically a script file. It just contains some binary codes at beginning. Strip that binary part off and save a script part into a file, say ota_update.cmd.
Then replace hash value with a reference image's one.
# Start update of edison-image-edison.ext4 on rootfs
setenv ota_image_name edison-image-edison.ext4
setenv u_part_lbl rootfs
setenv sha1_sum_ref cd19f77a22801b21129950a3d5506b55ceeb1888

The following commands generates ota_update.scr from ota_update.cmd.
# mkimage -a 0x10000 -T script -C none -n 'your description' -d ota_update.cmd ota_update.scr

Keep a reference ext4 file and ota_update.scr in pairs. In my case, I create a zip file, for example edison-20150101.zip, and it contains edison-image-edison.ext4 and ota_update.scr. Then I just need unzip a zip file into Edison removable drive and run reboot ota command to restore.

0 件のコメント:

コメントを投稿