SWUpdate Guide: Difference between revisions

From Variscite Wiki
No edit summary
Line 97: Line 97:
[[File:Swupdate-www.png]]
[[File:Swupdate-www.png]]


= References =
= Yocto Integration =


= Setup and build Yocto =
== Single-copy image==
Follow steps 1-3 of the {{Varlink2|Yocto Build Release|{{#var:RELEASE_LINK}}}} page.
* meta-swupdate is provided: https://github.com/sbabic/meta-swupdate
* Only ’single-copy’ scheme is generated (rescue image)
* MACHINE=<your machine> bitbake swupdate-image
* Images are generated in tmp/deploy/<your machine>/(.ext3.gz.u-boot)
* bitbake bbb-swupate-image: generate an update (.swu)
* meta-swupdate/recipes-extended/images/bbb-swu-image.bb: can be used as an example for your custom’swupdate images’
* swupdate provides a class that can be inherit for your custombuild/images


== Supported image ==
== Dual-copy image==
* Follow steps 1-3 of the {{Varlink2|Yocto Build Release|{{#var:RELEASE_LINK}}}} page.
The following image is provided by Variscite for evaluation purpose:
The following image is provided by Variscite for evaluation purpose:
* '''var-image-swupdate''': This image is based on fsl-image-gui, the Default Variscite demo image with a GUI without any QT content, with the following differences:
* '''var-image-swupdate''': This image is based on fsl-image-gui, the Default Variscite demo image with a GUI without any QT content, with the following differences:
Line 108: Line 115:
- The kernel image and device trees are added to the /boot directory of the rootfs
- The kernel image and device trees are added to the /boot directory of the rootfs
- The rootfs is configured as read-only by default
- The rootfs is configured as read-only by default
This image recipe works on all backends for X11, DirectFB, Frame Buffer and Wayland.
== Supported distros ==
The following distros can be used:
* '''fslc-x11''': Distro for X11 without wayland. This distro include x11 feature and doesn’ has wayland support.
* '''fslc-framebuffer''': Distro for Framebuffer graphical backend. This distro doesn’t include x11 and wayland features.
* '''fslc-wayland''': Distro for Wayland without X11. This distro include wayland feature but doesn’t has x11 support.
* '''fslc-xwayland''': Distro for Wayland with X11. This distro include both wayland and x11 features.
Note: Also [http://www.informit.com/articles/article.aspx?p=2514911&seqNum=4 standard Poky distros] can be used
{{#if:{{#var:GSTREAMER_SUPPORT}}|
== GStreamer support ==
FSL community BSP comes with [https://github.com/Freescale/gstreamer-imx/blob/master/README.md gstreamer-imx], a set of GStreamer1.0 plugins for i.MX platform, which make use of the i.MX multimedia capabilities.<br>
Some of the multimedia plugins do not work well with X11 and Wayland backends.<br>
To get the most from gstreamer-imx, it is recommended to use fslc-framebufer distro with one of the demo images
|}}
== Build X11 GUI demo image ==
$ cd {{#var:BUILD_FOLDER}}
$ MACHINE={{#var:MACHINE_NAME}} DISTRO={{#var:BUILD_DISTRO}} {{#var:BUILD_SCRIPT}} {{#var:BUILD_FOLDER_X11}}
<br>
Optional steps: [[#local.conf customization|local.conf customization]]
launch bitbake:
<pre>
$ bitbake var-image-swupdate
</pre>
{{#if:{{#var:GSTREAMER_SUPPORT}}|
NOTE: Some of the [https://github.com/Freescale/gstreamer-imx/blob/master/docs/blitter-architecture.md blitter-based i.MX GStreamer plugins] do not work with X11 and Wayland backends. To get the most of the i.MX GPU/VPU acceleration, use the fslc-framebuffer backend.
|}}
== local.conf customization ==
=== Change the downloads directory ===
Create a /opt/yocto_downloads directory and set its permissions:
<pre>
$ sudo mkdir /opt/yocto_downloads
$ sudo chmod 777 /opt/yocto_downloads/
</pre>
Direct downloads to it, by replacing 'DL_DIR ?= "${BSPDIR}/downloads/"' with 'DL_DIR = "/opt/yocto_downloads/"' in conf/local.conf:
<pre>
$ sed -i 's/DL_DIR ?= "${BSPDIR}\/downloads/DL_DIR = "\/opt\/yocto_downloads/g' conf/local.conf
</pre>
=== Add Eclipse debug and Qt creator support to your images ===
Append the following to the conf/local.conf file in your Yocto build directory, to add Eclipse debug and Qt creator support to your images:
<pre>
EXTRA_IMAGE_FEATURES = " \
    debug-tweaks \
    tools-debug \
    eclipse-debug \
    "
IMAGE_INSTALL_append = " \
    tcf-agent \
    openssh-sftp-server \
    "
</pre>
=== Use systemd instead of SysV init ===
Append the following to the conf/local.conf file in your Yocto build directory, to use systemd instead of SysV init in your images:
<pre>
DISTRO_FEATURES_append = " systemd"
VIRTUAL-RUNTIME_init_manager = "systemd"
DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"
VIRTUAL-RUNTIME_initscripts = ""
IMX_DEFAULT_DISTRO_FEATURES_append = " systemd"
</pre>
=== Create a read-only root file system ===
Append the following to the conf/local.conf file in your Yocto build directory, to create a read-only rootfs:
<pre>
EXTRA_IMAGE_FEATURES += "read-only-rootfs"
</pre>
== Build Results ==
The resulted images are located in tmp/deploy/images/{{#var:MACHINE_NAME}}.
<section begin=YOCTO_BUILD_RESULTS/>
{| class="wikitable"
|-
! scope="col" | Image Name<br/>
! scope="col" | How to use<br/>
|-
| style="padding: 5px;"| fsl-image-gui-{{#var:MACHINE_NAME}}.sdcard
| style="padding: 5px;"| This image is for SD card boot.<br> It can be flashed as-is on an SD card that can then be used to boot your system,<br> according to the relevant startup-guide of your product<br> (usually requires to press the boot select button, or toggle a DIP switch).<br> For detailed information refer to the [[Yocto_Build_Release#Create_a_bootable_SD_card | Create a bootable SD card]] section below.
|-
| style="padding: 5px;"| fsl-image-gui-{{#var:MACHINE_NAME}}.tar.bz2
| style="padding: 5px;"| Tarball with rootfs files.<br>Can be used to create an NFS root file system on the host.<br> See the  {{Varlink2|Yocto Setup TFTP/NFS|{{#var:RELEASE_LINK}}}} section for more info.<br>Also used to create our extended SD card.<br>See the [[Yocto_Build_Release#Create_a_bootable_SD_card | Create a bootable SD card]] section below.
|-
| style="padding: 5px;"| fsl-image-gui-{{#var:MACHINE_NAME}}.ubi
| style="padding: 5px;"| A complete UBI image containing a UBIFS volume, for writing to NAND flash.
|-
| style="padding: 5px;"| {{#var:KERNEL_IMAGE}}
| style="padding: 5px;"| Linux kernel image, same binary for SD card or NAND flash.
|-
| style="padding: 5px;"| {{#var:U-BOOT_NAND_IMAGE_NAME}}
| style="padding: 5px;"| U-Boot built for NAND flash.
|-
| style="padding: 5px;"| {{#var:U-BOOT_SD_IMAGE_NAME}}
| style="padding: 5px;"| U-Boot built for SD card boot or eMMC boot.
|-
| style="padding: 5px;"| {{#var:SPL_SD_IMAGE_NAME}}
| style="padding: 5px;"| SPL built for SD card boot or eMMC boot.
|-
| style="padding: 5px;"| {{#var:SPL_NAND_IMAGE_NAME}}
| style="padding: 5px;"| SPL built for NAND flash.
|-
|}
<section end=YOCTO_BUILD_RESULTS/>
{{#lst:Yocto_Platform_Customization|{{#var:YOCTO_BUILD_RESULTS_SECTION}}}}

Revision as of 17:46, 18 September 2017

SWUpdate

SWUpdate Introduction

One of the challenges in nowadays embedded systems is field update of the embedded software (e.g. Linux) in the safe and efficient way whether via OTA or removable device. This article presents SWUpdate approach for the embedded system software update that supports local and remote updates, multiple update strategies and it can be well integrated in the Yocto build system by adding the meta-swupdate layer. The SWUpdater is licensed under GPL Version 2.0+ and was developed by Stefano Babic from U-Boot community. The most notable feature are:

  • Install on embedded media (eMMC, NAND, SD)
  • Allow delivery single image for multiple devices
  • Multiple interfaces for getting software
    • local storage
    • integrated web server
    • integrated REST client connector to hawkBit
    • remote server download
  • Software delivered as images, gzipped tarball, etc.
  • Allow custom handlers for installing FPGA firmware, microcontroller firmware via custom protocols.
  • Power-Off safe

There are two typical update strategies supported by SWUpdate

  • Double copy with fall-back
  • Single copy – running as standalone image

Double copy with fall-back

If there is enough space on the storage to save two copies of the whole software, it is possible to guarantee that there is always a working copy even if the software update is interrupted or a power off occurs.

Each copy must contain the kernel, the root file system, and each further component that can be updated. It is required a mechanism to identify which version is running.

SWUpdate should be inserted in the application software, and the application software will trigger it when an update is required. The duty of SWUpdate is to update the stand-by copy, leaving the running copy of the software untouched.

A synergy with the boot loader is often necessary, because the boot loader must decide which copy should be started. Again, it must be possible to switch between the two copies. After a reboot, the boot loader decides which copy should run.
Double copy layout.png
Summary:

  • Requires twice as much space than single copy
  • Guarantees there’s always a working copy!
  • Bootloader is in charge of booting proper image

Single copy – running as standalone image

The software upgrade application consists of kernel (maybe reduced dropping not required drivers) and a small root file system, with the application and its libraries. The whole size is much less than a single copy of the system software (2.5MB-8 MB).The system can be put in “upgrade” mode, simply signaling to the boot loader that the upgrading software must be started (either by using boot loader environment or GPIO).

The boot loader starts “SWUpdate”, booting the SWUpdate kernel and the initrd image as root file system. Because it runs in RAM, it is possible to upgrade the whole storage. Differently as in the double-copy strategy, the systems must reboot to put itself in update mode.

This concept consumes less space in storage as having two copies, but it does not guarantee a fall-back without updating again the software. However, it can be guaranteed that the system goes automatically in upgrade mode when the productivity software is not found or corrupted, as well as when the upgrade process is interrupted for some reason.
Single copy layout.png
Summary:

  • Stand alone image consists of kernel / dt + initrd
  • Much smaller than entire system
  • Bootloader in charge of loading standalone image
  • System must reboot to enter update process

Update image format

The main concept is that the manufacturer delivers a single big image. All single images are packed together with an additional file (sw-description), that contains meta information about each single image.
Image format.png

Attached the sample of image description file suitable for VAR-SOM-MX6 Yocto update. The image consists of two components: new root file system (also includes kernel) and the user-space script that defines the update process.

software =
{
	version = "0.1.0";

	var-som-mx6 = {
		hardware-compatibility: [ "1.0" ];

		images: (
			{
				filename = "var-image-swupdate-var-som-mx6.ext4.gz";
				device = "/dev/update";
				type = "raw";
				compressed = true;
			}
		);

		scripts: (
			{
				filename = "update.sh";
				type = "shellscript";
			}
		);
	};
}

Update methods

  • You can always schedule update from removable storage by running
swupdate -i <file name.swu> 

By editing auto-mount sequence you can trigger the update process each time the removable device is inserted.

  • OTA update is available via http protocol .

It is possible to configure software update agent to include embedded web-server (CONFIG_MONGOOSE). To allow the OTA update via web-server the following command should be executed:

swpdate -w "-document_root ./www"

Then you can then connect to the target with:

http://<target_ip>:8080

And upload the .swu file.
Swupdate-www.png

Yocto Integration

Single-copy image

  • meta-swupdate is provided: https://github.com/sbabic/meta-swupdate
  • Only ’single-copy’ scheme is generated (rescue image)
  • MACHINE=<your machine> bitbake swupdate-image
  • Images are generated in tmp/deploy/<your machine>/(.ext3.gz.u-boot)
  • bitbake bbb-swupate-image: generate an update (.swu)
  • meta-swupdate/recipes-extended/images/bbb-swu-image.bb: can be used as an example for your custom’swupdate images’
  • swupdate provides a class that can be inherit for your custombuild/images

Dual-copy image

The following image is provided by Variscite for evaluation purpose:

  • var-image-swupdate: This image is based on fsl-image-gui, the Default Variscite demo image with a GUI without any QT content, with the following differences:

- swupdate and swupdate-www pacakages are included - The kernel image and device trees are added to the /boot directory of the rootfs - The rootfs is configured as read-only by default