Implementation Scheme of Linux 4.14 OTA Upgrade Based on RAUC for OKMX8MM
by yir65681 in Circuits > Linux
7 Views, 0 Favorites, 0 Comments
Implementation Scheme of Linux 4.14 OTA Upgrade Based on RAUC for OKMX8MM

This document aims to provide an Over-The-Air (OTA) upgrade solution based on RAUC (Robust Auto-Update Controller), which is suitable for embedded Linux systems. RAUC is an open-source OTA framework developed by Pengutronix. It is specifically designed for industrial-grade devices and provides secure, reliable, and atomic firmware update capabilities. It can run on multiple platforms, including Linux, FreeRTOS, and bare-metal environments. OTA is a technology for remotely updating the firmware of embedded devices via wireless networks (such as Wi-Fi, 4G, 5G, etc.). It enables functions such as firmware updates, configuration pushes, and security patches without physically accessing the devices.
In this paper, the RAUC-V0.1 version (the official initial version) is taken as an example for deployment and verification on 8mm-linux4.14.78. Currently, RAUC has been updated to version V1.14. Other platforms can select appropriate versions for transplantation according to the kernel version, glib version, and openssl version. This transplantation only supports manual upgrades and manual partition switching. If necessary, automatic upgrades can be achieved by adding environment variables in U-Boot.
Other OTA upgrade tools: SWupdate
Configuration Requirements
Note: Only the basic RAUC upgrade functions are described here. For example, streaming online updates are only supported in RAUC-v1.7 and above.
1. Kernel Version:
It has been verified that it can run on kernel versions above Linux 4.14. Lower versions have not been verified yet, but theoretically they can also be used. For kernel versions without systemd service, --disable-service needs to be specified when compiling the RAUC source code.
2. File System:
RAUC has no restrictions on the content of the file system. However, since an A/B system is implemented, the flash should have at least twice the capacity of the file system.
Deployment Scheme
1. Install RAUC in the development environment.
2. Install RAUC on the development board.
Note: Copy the json-glib and json-glib-native libraries to the cross-compiler for cross-compilation purposes
3. Key File
Manually generate a key in the development environment and put it in the source code of the file system. RAUC will verify whether the key of the image is consistent with that of the system when upgrading;
Place the generated autobuilder. cert. pem and autobuilder. key. pem key files under the filesystem/etc/rauc/.
4. bundle
Compile the configuration file of the upgrade package
Generate image check code: OK8MM-linux-sdk/images$ sha256sum ./rootfs.ext4de2f256064a0af797747c2b97505dc0b9f3df0de4f489eac731c23ae9ca9cc31
To create a manifest profile:
5. system.conf
The system. conf is the system configuration file of RAUC, which is responsible for configuring the storage, partition, and boot mode; it is the configuration file used in the upgrade process.
The path can be:/etc/rauc/system. conf,/run/rauc/system. conf,/etc/lib/rauc/system. conf; Load in order from the listed directories, using only the first file found.
eg.:
6. Add rauc.service service to the source code
When upgrading rauc, it is necessary to start the service to automatically complete the upgrade operation:
Rauc self-start service: OK8MM-linux-fs$ vim /lib/systemd/system/rauc.service
Create a self starting soft connection:
OK8MM-linux-fs$ ln -s lib/systemd/system/rauc.service \
lib/systemd/system/sysinit.target.wants/rauc.service
Create a rauc configuration file under D-bus:
D-bus explanation: mainly used for implementing atomic update control, status monitoring, and system integration;
After burning the image, check if the rauc service is started:
7. Compile environment variable reading and writing tools
When upgrading to rauc, the fw_ setenv and fw_ printenv tools are needed, mainly to obtain the uboot environment variable from the file system and determine the current mounted partition
Annotate the Makefile line in uboot: There is a problem with the default cross compilation configuration. After commenting it out, execute the environment variables on the command line and compile directly.
Copy fw-printenv to the file system/usr/bin/and make a copy of fw_steenv: cp fw-printenv fw_steenv
8. Create/etc/fw_env.config
The file system reads environment variables by directly reading the emmc address, and the fw-env.config name is fixed and cannot be changed arbitrarily, consistent with the rauc source code.
9. Compile and update packages
eg.:
10. rauc Test
Test premise: The file system partition has been modified, refer to 8mp:
https://forlinx-book.yuque.com/org-wiki-forlinx-book-vclsg5/ibgvyy/fnmsrhfem740p753?singleDoc# OKMX8MP-Linux 5.4.70-OTA Upgrade Using Extended Partition
Manually switch boot partition: enter the uboot command line or use the fw_ setenv tool to modify the boot partition
Problems
1. System time issue
Solutions:
2. fw-print compilation error
Solutions:
3. Env configuration file issue
Cannot parse config file '/etc/fw_env.config': No such file or directoryAug 03 00:08:16 okmx8mm rauc[3189]: Error: environment not initializedAug 03 00:08:16 okmx8mm rauc[3189]: fw_setenv failed: Child process exited with code 1Aug 03 00:08:16 okmx8mm rauc[3189]: failed marking as badAug 03 00:08:17 okmx8mm rauc[3189]: Handler error: Failed marking slot rootfs.1 non-bootableAug 03 00:08:17 okmx8mm rauc[3189]: installing /run/media/sda1/update-2015.04-1.raucb: Handler error: Failed marking slot rootfs.1 non-bootableAug 03 00:08:17 okmx8mm rauc[3189]: installing /run/media/sda1/update-2015.04-1.raucb: finishedAug 03 00:08:17 okmx8mm rauc[3189]: installing `/run/media/sda1/update-2015.04-1.raucb` failed: 1
Solutions:
Refer to Chapter 3-8 of this article
4. The file system cannot read the correct environment variables
There is an issue with the address of the environment variable being read. Simply add the relevant configuration to the uboot source code;
Design List
1. File List
2. Function Description
Related link:
RAUC official website: https://rauc.readthedocs.io/en/latest/index.html
Source code: https://github.com/rauc/rauc