User Tools

Site Tools


subsystem:agl-sota:ostree

This is an old revision of the document!


Using OTA feature

OTA feature is enabled with agl-ota parameter added to agl-setup (see Download and Build AGL Source Code). It allows you to build image that can later be upgraded over TCP/IP conection using OSTree and SOTA client.

OSTree

OSTree is a tool for distributing and deploying filesystem images. It provides atomic upgrades of the whole filesystem tree, while being effective with respect to disk space, i.e. files with the same contents are shared between managed filesystems.

OSTree stores all the data in repositories. They are treated to some degree like git repositories - user can commit data to it checkout commited filesystem tree to some location in the filesystem and pull data from one repository to another. All the data is stored in git-like object database, so that data is not duplicated. Basically there are two types of repositories

  1. archive-z2 repository stores all data in compressed format. When user checks out the data from it, they are just extracted to some location and can be treated independently from the data in repository. This type of repository is intended to be used on servers, from which data is distributed to target devices.
  2. bare repository stores the data in uncompressed form. Checkout from this repository just creates hardlinks to the stored files. This repository type suits best for target devices.

OSTree also provides atomic deployment functionality built on top of the basic features described above. It lets user atomically switch between commited file systems: file system is deployed (checked out) in a dedicated directory and bootloader configuration file is changed to make it boot in a newly deployed rootfs.

You can find more details in OSTree documentation.

SOTA client

Building

To enable OTA feature just add agl-ota to the feature list when setting up your environment.

  source meta-agl/scripts/aglsetup.sh -m qemux86-64 agl-demo agl-netboot agl-appfw-smack agl-sota

You can then edit your local.conf

  vim conf/local.conf

to tune several parameters.

  • OSTREE_REPO sets local OSTree repository, to which your resulting image will be committed.
  • OSTREE_BRANCHNAME is the ref name in your local repository.
  • OSTREE_OSNAME is the OS name in OSTree repository on your target device. See OSTree documentation for the details.

After that just build your desired image e.g.

  bitbake agl-demo-platform

As a result of the building process you will get the following:

  1. The whole root filesystem together with the kernel and initramfs commited to OSTree repository set in OSTREE_REPO on a branch set in OSTREE_BRANCHNAME
  2. Archived exact copy of the commited tree ('*.rootfs.ostree.tar.bz2' file)
  3. Live bootstrap image with the commited tree as the only OSTree deployment ('*.otaimg' file).

To boot into the resulting image, provided you've built it for QEMU run

  ../meta-agl-extra/meta-sota/scripts/runqemu qemuparams="-vga std" tmp/deploy/images/qemux86-64/agl-demo-platform-qemux86-64.otaimg

runqemu script from poky upstream is not able to work with OTA images at the moment.

Non-secure update

OSTree includes its own simple http server. It just exposes the whole OSTree repository to the network so that any remote device can pull data from it to device's local repository. To use OSTree http server you need OSTree installed on your build machine. Alternatively, you could run version built inside Yocto using bitbake's devshell.

To expose your repo run ostree trivial-httpd using any free port.

  ostree trivial-httpd tmp/deploy/images/qemux86-64/ostree_repo -P 57556

You can then run from inside your device or QEMU emulation, provided your network is set up correctly.

  # agl-remote identifies the remote server in your local repo
  ostree remote add --no-gpg-verify agl-remote http://192.168.7.1:57556 agl-ota
  
  # agl-ota is a branch name in the remote repo, set in OSTREE_BRANCHNAME
  ostree pull agl-remote agl-ota
  
  # agl is OS name as set in OSTREE_OSNAME
  ostree admin deploy --os=agl agl-remote:agl-ota

After restart you should boot into the newly deployed OS image.

Secure update

subsystem/agl-sota/ostree.1475756515.txt.gz · Last modified: 2016/10/06 12:21 by oytis