|
|
Line 10: |
Line 10: |
| This Introduction was taken from the SWUpdate README.md at: [https://github.com/sbabic/swupdate https://github.com/sbabic/swupdate]<br> | | This Introduction was taken from the SWUpdate README.md at: [https://github.com/sbabic/swupdate https://github.com/sbabic/swupdate]<br> |
| <br> | | <br> |
| Example of using the meta-swupdate layer with Variscite i.MX boards is provided in the meta-variscite-fslc layer.<br>
| |
| This example uses the double-copy approach, using two rootfs partitions on eMMC.<br>
| |
|
| |
| == 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.<br>
| |
| [[File:Double_copy_layout.png]]<br>
| |
| 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. <br>
| |
| [[File:Single_copy_layout.png]]<br>
| |
| 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 .swu image.<br>
| |
| The .swu image may contain multiple images and files. In addition, it must contain a sw-description file with meta information about the image.<br>
| |
| [[File:Image_format.png]]
| |
|
| |
| See the following link for info about the sw-description file syntax: [https://sbabic.github.io/swupdate/sw-description.html https://sbabic.github.io/swupdate/sw-description.html]
| |
|
| |
| == Update methods ==
| |
| === Update via console ===
| |
| To start SWUpdate expecting the image from a file:
| |
| swupdate -H {{#var:MACHINE_NAME}}:1.0 -i <filename.swu>
| |
| The -H option and its parameter is actually optional. The command can be simplified to
| |
| swupdate -i <filename.swu>
| |
| as long as a file named
| |
| /etc/hwrevision
| |
| is present in the rootfs and it's populated with the following content
| |
| {{#var:MACHINE_NAME}} 1.0
| |
| Please note that no multiple instances of swupdate can be running simultaneously: if the roofs contains the service to start the swupdate web-server, the server must be stopped before running swupdate from command line
| |
| /etc/init.d/swupdate stop
| |
| You can schedule an auto update from a removable storage by editing the automount sequence, making it trigger the update command above, each time a removable device is inserted.
| |
|
| |
| === Update via http ===
| |
| OTA update is available via http protocol:
| |
| It is possible to configure the software update agent to include embedded web-server (CONFIG_MONGOOSE). To start SWUpdate with the embedded web-server:
| |
| swupdate -w "--document-root ./www"
| |
|
| |
| The default port of the Web-server is 8080. You can then connect to the target with:
| |
| <nowiki>http://<target_ip>:8080</nowiki>
| |
|
| |
| And upload the .swu file.<br>
| |
| {{#ifeq: {{#var:YOCTO_NAME}} | Pyro |
| |
| [[File:Swupdate-www.png|600px]]
| |
| |
| |
| {{#ifeq: {{#var:YOCTO_NAME}} | Rocko |
| |
| [[File:Swupdate-www.png|600px]]
| |
| |
| |
| <br>The start page:<br>
| |
| [[File:Swupdate-www_sumo2.png|700px]]<br>
| |
| And after a successful update:<br>
| |
| [[File:Swupdate-www_sumo.png|700px]]
| |
| }}}}
| |
| <br><br>
| |
| To see all of the command line parameters of swupdate:
| |
| swupdate -h
| |
|
| |
|
| = Yocto Integration = | | = Yocto Integration = |
|
| |
|
| Variscite provides an example for the double-copy approach, where the rootfs is on eMMC.
| |
| == Recipes == | | == Recipes == |
|
| |
|
| Before you begin, get familiar with the Varicite {{Varlink2|Yocto Build Release|{{#var:RELEASE_LINK}}}} guide.<br> | | Before you begin, get familiar with the Varicite {{Varlink2|Yocto Build Release|{{#var:RELEASE_LINK}}}} guide.<br> |
| <br> | | <br> |
| Variscite provides the following two image recipes: | | Variscite provides the following image recipes: |
| | |
| * '''var-image-swupdate''' - 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 (by including the kernel-image and kernel-devicetree packages), instead of using a BOOT partition
| |
| ** The rootfs is created only as a tar.gz archive (IMAGE_FSTYPES = "tar.gz")
| |
| See the recommended internal storage layout for double-copy approach: <br>
| |
| [[File:Swupdate_layout.png]]
| |
| <br>
| |
| * '''var-image-swu''' - This recipe creates an .swu update image using the var-image-swupdate image
| |
| <br>
| |
| The following is the sw-description file used by the Variscite sample update image recipe (var-image-swu).<br>
| |
| This sample image consists of two components:<br>
| |
| - A root file system (including the kernel), which is created by the var-image-swupdate recipe<br>
| |
| - A bash script that runs before (called with preinst argument) and after (called with postinst argument) the installation of the root file system.<br>
| |
|
| |
|
| software =
| | * '''var-image-docker''' - Based on fsl-image-core with the following differences: |
| {
| | ** xxxxxxxxxxxxxx |
| version = "0.1.0";
| |
|
| |
| {{#var:MACHINE_NAME}} = {
| |
| hardware-compatibility: [ "1.0" ];
| |
|
| |
| files: (
| |
| {
| |
| filename = "var-image-swupdate-{{#var:MACHINE_NAME}}.tar.gz";
| |
| type = "archive";
| |
| compressed = true;
| |
| device = "/dev/update";
| |
| filesystem = "ext4";
| |
| path = "/";
| |
| }
| |
| );
| |
|
| |
| scripts: (
| |
| {
| |
| filename = "update.sh";
| |
| type = "shellscript";
| |
| }
| |
| );
| |
| };
| |
| }
| |
| <br> | | <br> |
| And the following is the aforementioned update.sh bash script: [https://raw.githubusercontent.com/varigit/meta-variscite-fslc/{{#var:YOCTO_BRANCH}}/recipes-support/swupdate/var-image-swu/update.sh update.sh]<br>
| | == Create a Docker-ready Image == |
| This script is being used in order to detect the root device and the U-Boot env. type and location (eMMC vs NAND flash) at runtime.<br>
| |
| | |
| == Create a 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. |
| * Build a recovery SD card and the var-image-swupdate image as the recovery image | | * Build a recovery SD card and the var-image-swupdate image as the recovery image |