TorizonCore is built with OSTree, a shared library and suite of command line tools that combines a "git-like" model for committing and downloading bootable filesystem trees, along with a layer for deploying them and managing the bootloader configuration". In short, this image has the foundation for OTA (over-the-air) update capabilities.
Torizon Update System reuses what Linux microPlatform and meta-updater are providing. You can find more about the OTA strategy on the foundries.io Blog.
This article complies to the Typographic Conventions for Torizon Documentation.
Here's a quick demo on performing an update using the underlying OSTree technology on the device manually. It helps to understand how things are done, which can then be used for automation.
Whenever you build TorizonCore a directory
ostree_repo gets produced during the build. This directory is git-like containing the meta-data for that build's filesystem. Toradex uploads the nightly build OSTree repository and makes it available at http://feeds.toradex.com/ostree/nightly/apalis-imx6/.
Attention: All device commands must be executed as root, so you have to login as root on the device or, if you are logged-in using the torizon user, prefix the following command lines with "sudo" to execute them as root.
On the board, using OSTree you can add this repository like how one would add a remote git repo:
# ostree remote add --no-gpg-verify toradex-nightly \ http://feeds.toradex.com/ostree/nightly/apalis-imx6/
Check that it was successful:
# ostree remote refs toradex-nightly toradex-nightly:torizon-core-balena toradex-nightly:torizon-core-docker toradex-nightly:torizon-core-lite
Following standard git procedure you'd then perform a pull:
# ostree pull toradex-nightly:torizon-core-docker 172 metadata, 485 content objects fetched; 17704 KiB transferred in 12 seconds
To see which files got updated,
ostree diff can be used:
# ostree diff toradex-nightly:torizon-core-docker M /usr/package.manifest M /usr/etc/manifest.xml ...
Next, you queue the commit for deployment upon next boot:
# ostree admin deploy toradex-nightly:torizon-core-docker Copying /etc changes: 5 modified, 2 removed, 7 added Transaction complete; bootconfig swap: yes; deployment count change: 1
OSTree shows that there is a switch to a new tree pending:
# ostree admin status torizon 0cbeafe2973079d5edb4457839054af3c1bb8ea09678c92bcf022eea2ca92e60.0 (pending) origin refspec: toradex-nightly:torizon-core-docker * torizon 4fc80f14d5ee2160004e3252080226f8f1d6f6ad4d8d7024b4198584c23afaa6.0 origin refspec: 4fc80f14d5ee2160004e3252080226f8f1d6f6ad4d8d7024b4198584c23afaa6
After a quick reboot you can see the new OSTree active:
Finally, you can view your current and previous deployment which you can rollback to if need be:
# ostree admin status * torizon 0cbeafe2973079d5edb4457839054af3c1bb8ea09678c92bcf022eea2ca92e60.0 origin refspec: toradex-nightly:torizon-core-docker torizon 4fc80f14d5ee2160004e3252080226f8f1d6f6ad4d8d7024b4198584c23afaa6.0 (rollback) origin refspec: 4fc80f14d5ee2160004e3252080226f8f1d6f6ad4d8d7024b4198584c23afaa6
If you are building TorizonCore image locally you may provide an ostree repo directly from your PC. If you have Python installed, just move to the ostree_repo folder of your build directory (should be under deploy/images/$MACHINE/ostree_repo) and bring-up the Python built-in simple HTTP server:
$ python -m SimpleHTTPServer 8081
In this way your PC will be sharing the image you just built on port 8081. You can replace http://feeds.toradex.com/ostree/nightly/apalis-imx6/ in the above instructions with
<your PC ip address>:8081 and update your device directly from your build machine.
Please notice that this kind of operation is not secure and such a configuration should be used only for debugging purposes.
If you don't have network connectivity on target board, In that case, keep the OStree repo to the USB thumb drive then connect the USB thumb drive to the target board and then can do the update by following instructions below
If you are building Torizoncore image locally the OSTree files will be in deploy/images/$MACHINE/ostree_repo path.
List the refs
ostree refs --repo=PATH_TO_REPO_DIRCTORY e.g. colibri-imx6-04836481:~# ostree refs --repo=/home/root/pendrive/ostree_repo/ torizon/torizon-core-docker torizon/torizon-core-docker-torizon-core-docker
Pull the repo from USB thumb drive to the target board
ostree pull-local PATH_TO_USB_REPO REFS_NAME e.g ostree pull-local /home/root/pendrive/ostree_repo/ torizon/torizon-core-docker
Deploy the tree for the next boot
ostree admin deploy REFS e.g. ostree admin deploy torizon/torizon-core-docker
OSTree shows that there is a switch to a new tree pending
root@colibri-imx6-04836481:~# ostree admin status torizon 1d98e25015a390556e7ab93c9b94e01e8632d30d800b36bff1ddd54fa9fc7cf4.0 (pending) origin refspec: torizon/torizon-core-docker * torizon d0d53487d305358ad50c37b1b2a94fc78eaea5e770749a33f5607573e2447660.0 origin refspec: d0d53487d305358ad50c37b1b2a94fc78eaea5e770749a33f5607573e2447660
After a quick reboot you can see the new OSTree active
Finally, you can view your current and previous deployment which you can rollback to if need be.
root@colibri-imx6-04836481:~# ostree admin status * torizon 1d98e25015a390556e7ab93c9b94e01e8632d30d800b36bff1ddd54fa9fc7cf4.0 origin refspec: torizon/torizon-core-docker torizon d0d53487d305358ad50c37b1b2a94fc78eaea5e770749a33f5607573e2447660.0 (rollback) origin refspec: d0d53487d305358ad50c37b1b2a94fc78eaea5e770749a33f5607573e2447660