How to Use Software Update (SWUpdate) Application
This document demonstrates how SWUpdate updates the software on the SP7350 platforms.
Table of Contents
- 1 Ubuntu MATE 24.04 - eMMC boot
- 1.1 swupdate installation
- 1.2 Apache HTTP Server installation
- 1.3 chromium installation
- 1.4 Generate self-signed certificates
- 1.5 sw-description configuration file
- 1.6 Building a signed SWU image with CMS signature
- 1.7 HW_FILE
- 1.8 Update images
- 1.8.1 Run SWUpdate
- 1.8.2 Web server
- 1.8.2.1 SWUpdate web interface files
- 1.8.2.2 Shell script - swupdate.sh
- 1.8.2.3 Localhost web server
- 1.8.2.4 Another platform's web server
- 2 Buildroot 2024.02 - eMMC boot
- 3 Yocto 4.2.4 - eMMC boot
Ubuntu MATE 24.04 - eMMC boot
When you run “make config” to configure your build environment and after selecting the board, you will be prompted to choose a boot device. Refer to the picture below and Enter “1” to select eMMC.
After selecting eMMC size, you will be prompted to choose a root file system. Refer to the picture below and Enter “7” to select Ubuntu MATE 24.04.1.
After the completion of executing “make config”, execute “make” command to build the images.
swupdate installation
After updating the images to the platform and booting the system, connect to the internet and use the following commands to install swupdate.
sudo apt update
sudo apt-get install swupdate
Apache HTTP Server installation
Use the following command to install apache2.
sudo apt install apache2
chromium installation
Use the following commands to install chromium.
sudo add-apt-repository ppa:xtradeb/apps -y
sudo apt install chromium
Generate self-signed certificates
Use the following command to generate self-signed certificates.
It will create mycert.key.pem containing the private key, and mycert.cert.pem containing the public key and certificate. The default validity period of mycert.cert.pem is 30 days and you can use the following command to check it.
If you want to set the validity period by yourself, you can use the following command to generate self-signed certificates. The command adds a parameter of “-days 365” to set the validity period to 365 days.
sw-description configuration file
The sw-description file created describes the structure and content of the software update (packed in a .swu file) and defines what actions SWUpdate should take when performing the update.
A sw-description file below is an example for updating xboot、uboot and kernel simultaneously for eMMC.
“device” is the partition corresponding to the image. Please refer to Exploring Partitions of All Boot Devices.
“sha256” is the hash of the image. Each image must have the attribute. You can use the following command to get the hash of the image.
Building a signed SWU image with CMS signature
There are two files, sw-description and its signature sw-description.sig. The signature file must always directly follow the description file.
A simple script to create a signed image can be:
After executing the script, sw-description.sig will be produced and the “FILES” in the script will be packed (cpio was chosen for its simplicity and because can be streamed) together to the file of update.swu.
HW_FILE
Create and edit a file (/etc/hwrevision) in the platform if it does not exist. The example of the contents is shown below.
“SP7350” is the hardware board name.
“v1.0” is the hardware revision and it must be the same as “hardware-compatibility” in sw-description.
Update images
The Ubuntu platform can update images (update.swu) via the command or web server.
Run SWUpdate
You can use the following command to update images.
The verbose logging is as shown below. After the update process, the system will reboot.
Web server
The Ubuntu platform can update images via the web server by itself or other Ubuntu platforms.
SWUpdate web interface files
Use the following command to download the SWUpdate GitHub repository.
Make a directory named “swupdate” in /var/www/ of the platform. Copy all the directories and files in /examples/www/v2/ of the SWUpdate repository into /var/www/swupdate/ of the platform.
Shell script - swupdate.sh
Add the parameters of “-k /home/sunplus/my_key/mycert.cert.pem“ for SWUPDATE_ARGS and “-r /var/www/swupdate -p 8080“ for SWUPDATE_WEBSERVER_ARGS in /usr/lib/swupdate/swupdate.sh of the platform shown below. Then reboot the system to activate the web server.
Localhost web server
Open chrominum and connect to the localhost web server with:
The default port of SWUpdate web server is 8080. It can update images for itself via localhost.
Click the blank area and select update.swu packed earlier.
After selecting update.swu, SWUpdate will start to process the received images and then restart the system.
Another platform's web server
You can use chrominum to connect to another platform’s web server to update the images for it which must accomplish the following steps first.
Install swupdate.
Install apache2.
Copy swupdate inferface files into /var/www/swupdate/.
Create and edit /etc/hwrevision.
Copy the public key (mycert.cert.pem) from the platform which packs update.swu.
Make sure the platform system clock is within the validity period of the public key (mycert.cert.pem).
Modify /usr/lib/swupdate/swupdate.sh.
Reboot the system to activate its web server.
Connect to the internet.
After the steps above, you can use the browser to connect to the platform’s SWUpdate web server with:
Therefore, you can update the images for it.
Buildroot 2024.02 - eMMC boot
When you run 'make config' to configure your build environment and after selecting the board, you will be prompted to choose a boot device. Refer to the picture below and Enter “1” to select eMMC.
After selecting eMMC size, you will be prompted to choose a root file system. Refer to the picture below and Enter “11” to select Buildroot 2024.02.
Buildroot Setup
After the completion of executing “make config”, enter the buildroot configuration by running the following command in the top directory of project.
Select submenus for swupdate : Target packages → System tools. Select <*> for swupdate . Save the configuration and exit. Then execute “make” command to build the images.
Generate self-signed certificates
After updating the images to the platform and booting the system of it, it would fail to start SWUpdate daemon as shown below. It lacks a public key to activate the web server.
The procedure to generate self-signed certificates is the same as that in Ubuntu MATE 24.04 - eMMC boot. After generating the public key (mycert.cert.pem) by itself or coping it from other platforms which generate it, pack update.swu and will update the images for this Buildroot platform, add the parameter of SWUPDATE_ARGS=”-k /root/work/my_key/mycert.cert.pem -v” to /usr/lib/swupdate/conf.d/10-mongoose-args of the Buildroot platform and the web server will be activated successfully after reboot.
sw-description configuration file
Reference it in Ubuntu MATE 24.04 - eMMC boot.
Building a signed SWU image with CMS signature
Reference it in Ubuntu MATE 24.04 - eMMC boot.
HW_FILE
Reference it in Ubuntu MATE 24.04 - eMMC boot.
Update images
The Buildroot platform can update images (update.swu) via the command by itself or web server only by other Ubuntu platforms.
Run SWUpdate
Reference it in Ubuntu MATE 24.04 - eMMC boot.
Web server
Besides adding the parameter (the path of the public key) to /usr/lib/swupdate/conf.d/10-mongoose-args for activating the web server, make sure the platform system clock is within the validity period of the public key (mycert.cert.pem) and reference the procedure of updating images by other Ubuntu platforms in Ubuntu MATE 24.04 - eMMC boot.
Yocto 4.2.4 - eMMC boot
When you run “make config” to configure your build environment and after selecting the board, you will be prompted to choose a boot device. Refer to the picture below and Enter “1” to select eMMC.
After selecting eMMC size, you will be prompted to choose a root file system. Refer to the picture below and Enter “12” to select Yocto 4.2.4.
After the execution of “make config”, you can modify linux\rootfs\initramfs\yocto\meta-swupdate\recipes-support\swupdate\swupdate\defconfig according to your requests. An example shown below enables systemd support、checks for hardware / software compatibility、uses environment in RAM as bootloader interface and enables verification of signed images … etc.
Modify linux\rootfs\initramfs\yocto\meta-sunplus\recipes-img\images\img-sp7350.bb to install the webserver of nginx during compilation.
Then execute “make” command to build the images.
Generate self-signed certificates
After updating the images to the platform and boot the system of it, it would fail to start SWUpdate daemon as shown below. It lacks a public key to start SWUpdate daemon.
The procedure to generate self-signed certificates is the same as that in Ubuntu MATE 24.04 - eMMC boot. After generating the public key (mycert.cert.pem) by itself or coping it from other platforms which generate it, pack update.swu and will update the images for this Yocto platform, add the parameters of “-k /home/root/my_key/mycert.cert.pem“ for SWUPDATE_ARGS in /usr/lib/swupdate/swupdate.sh of the platform shown below. Then it will start SWUpdate daemon successfully after rebooting the system.
sw-description configuration file
Reference it in Ubuntu MATE 24.04 - eMMC boot.
Building a signed SWU image with CMS signature
Reference it in Ubuntu MATE 24.04 - eMMC boot.
HW_FILE
Reference it in Ubuntu MATE 24.04 - eMMC boot.
Update images
The Yocto platform can update images (update.swu) via the command by itself or web server only by other Ubuntu platforms.
Run SWUpdate
Reference it in Ubuntu MATE 24.04 - eMMC boot.
Web server
The Yocto system can only update images (update.swu) by other Ubuntu systems. Reference it in Ubuntu MATE 24.04 - eMMC boot.