SWUpdate Guide: Difference between revisions
Line 99: | Line 99: | ||
= Yocto Integration = | = Yocto Integration = | ||
Currently Variscite supports only Dual-copy approach. | |||
== Dual-copy approach == | |||
== Dual-copy | |||
Before you begin, get familiar with Varicite guide for building {{Varlink2|Yocto Release|{{#var:RELEASE_LINK}}}}. | Before you begin, get familiar with Varicite guide for building {{Varlink2|Yocto Release|{{#var:RELEASE_LINK}}}}. | ||
Line 121: | Line 113: | ||
[[File:Swupdate_layout.png]] | [[File:Swupdate_layout.png]] | ||
== Create SWUpdate-ready Image == | === Create SWUpdate-ready Image === | ||
* Follow steps 1-3 of the {{Varlink2|Yocto Build Release|{{#var:RELEASE_LINK}}}} page. | * Follow steps 1-3 of the {{Varlink2|Yocto Build Release|{{#var:RELEASE_LINK}}}} page. | ||
$ cd {{#var:BUILD_FOLDER}} | $ cd {{#var:BUILD_FOLDER}} | ||
Line 135: | Line 127: | ||
* Either use the installation icons on the desktop, or use the install_yocto.sh script manually, with the "-u" parameter. | * Either use the installation icons on the desktop, or use the install_yocto.sh script manually, with the "-u" parameter. | ||
== Generate Field Update file == | === Generate Field Update file === | ||
* Make and test changes in {{#var:BUILD_FOLDER}} | * Make and test changes in {{#var:BUILD_FOLDER}} | ||
* Edit sw-description file | * Edit sw-description file | ||
Line 141: | Line 133: | ||
$ bitbake var-swu-image | $ bitbake var-swu-image | ||
== Test SWUpdate == | === Test SWUpdate === | ||
* copy result from tmp/deploy/images/{{#var:MACHINE_NAME}}/var- | * copy result from tmp/deploy/images/{{#var:MACHINE_NAME}}/var- | ||
* check IP via ifconfig | * check IP via ifconfig | ||
* upload via web-server | * upload via web-server |
Revision as of 12:44, 19 September 2017
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.
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.
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.
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
Yocto Integration
Currently Variscite supports only Dual-copy approach.
Dual-copy approach
Before you begin, get familiar with Varicite guide for building Yocto Release. The following will focus on customizing Variscite evaluation image to support SWUpdate functionality.
The most notable changes are:
- 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
See the recommended internal storage layout for dual-copy approach:
Create SWUpdate-ready Image
- Follow steps 1-3 of the Yocto Build Release page.
$ cd ~/var-fslc-yocto $ MACHINE=var-som-mx6 DISTRO=fslc-x11 . setup-environment build_x11
$ bitbake fsl-image-gui (for the recovery SD card) $ bitbake var-image-swupdate (this recipe builds only a tar.gz rootfs type)
$ sudo MACHINE=var-som-mx6 ../sources/meta-variscite-fslc/scripts/var_mk_yocto_sdcard/var-create-yocto-sdcard.sh -r tmp/deploy/images/var-som-mx6/var-image-swupdate-var-som-mx6 /dev/sdX (Replace /dev/sdX with your actual device)
- Boot the board using the created SD card
- Either use the installation icons on the desktop, or use the install_yocto.sh script manually, with the "-u" parameter.
Generate Field Update file
- Make and test changes in ~/var-fslc-yocto
- Edit sw-description file
- Generate .swu file
$ bitbake var-swu-image
Test SWUpdate
- copy result from tmp/deploy/images/var-som-mx6/var-
- check IP via ifconfig
- upload via web-server