HOME
  • GM-3568JHF
  • M4-R1
  • M5-R1
  • SC-3568HA
  • M-K1HSE
  • CF-NRS1
  • CF-CRA2
  • 1684XB-32T
  • 1684X-416T
  • C-3568BQ
  • C-3588LQ
  • GC-3568JBAF
  • C-K1BA
Shop
  • English
  • 简体中文
HOME
  • GM-3568JHF
  • M4-R1
  • M5-R1
  • SC-3568HA
  • M-K1HSE
  • CF-NRS1
  • CF-CRA2
  • 1684XB-32T
  • 1684X-416T
  • C-3568BQ
  • C-3588LQ
  • GC-3568JBAF
  • C-K1BA
Shop
  • English
  • 简体中文
  • SC-3568HA

    • Introduction

      • SC-3568HA Overview
    • Quick Start Guide

      • OpenHarmony Overview
      • Image Flashing
      • Setting Up the Development Environment
      • Hello World Application and Deployment
    • Application Development

      • ArkUI

        • Chapter 1 Introduction to ArkTS Language
        • Chapter 2 Introduction to UI Components and Practical Applications (Part 1)
        • Chapter 3 Introduction to UI Components and Practical Applications (Part 2)
        • Chapter 4 Introduction to UI Components and Practical Applications (Part 3)
      • Expand

        • Chapter 1 Getting Started Guide
        • Chapter 2 Referencing and Using Third-Party Libraries
        • Chapter 3: Application Compilation and Deployment
        • Chapter 4: Command-Line Factory Reset
        • Chapter 5: System Debugging -- HDC (Huawei Device Connector) Debugging
        • Chapter 6 APP Stability Testing
        • Chapter 7 Application Testing
    • Device Development

      • Chapter 1 Environment Setup
      • Chapter 2 Download Source Code
      • Chapter 3 Compiling Source Code
    • Peripheral And Iinterface

      • Raspberry Pi interface
      • GPIO Interface
      • I2C Interface
      • SPI communication
      • PWM (Pulse Width Modulation) control
      • Serial port communication
      • TF Card
      • Display Screen
      • Touch
      • Audio
      • RTC
      • Ethernet
      • M.2
      • MINI-PCIE
      • Camera
      • WIFI&BT
      • Raspberry Pi expansion board
    • Frequently Asked Questions

      • Resource Downloads
  • M-K1HSE

    • Introduction

      • M-K1HSE Introduction
    • Quick Start

      • Development environment construction
      • Source code acquisition
      • Compilation Notes
      • Burning Guide
    • Peripherals and interfaces

      • 01 Audio
      • 02 RS485
      • 03 Display
    • System customization development

      • System transplant
      • System customization
      • Driver Development
      • System Debugging
      • OTA Update

OTA Update

Overview

According to the OTA upgrade method, it is divided into:

Local upgrade (supported) Network upgrade (supported) According to the type of OTA package, it is divided into:

Full package upgrade (supported) Differential package upgrade (supported) Variable partition package upgrade (not supported yet) OTA package creation

Preparation

Install Necessary Tools

$ sudo apt update
$ sudo apt upgrade
$ sudo apt install bsdiff
$ sudo pip install xmltodict asn1crypto imgdiff cryptography e2fsdroid

Modify the code

By modifying the code, some differences are added, such as obvious printing, etc., to verify whether the OTA upgrade is successful after the OTA upgrade.

Full package production

Fully compile source code

./build.sh --product-name xxx --ccache --prebuilt-sdk

The content needed is as follows:

The system image file is in out/smt001/packages/phone/images/, as follows:

root@ubuntu:~/WorkSpace/oh5/out/smt001/packages/phone/images$ tree
.
|-- bootfs
|   |-- bianbu.bmp
|   |-- env_k1-x.txt
|   |-- Image.itb
|   `-- k1-x_MUSE-Paper2.dtb
|-- boot.img
|-- chip_prod.img
|-- eng_system.img
|-- env.bin
|-- factory
|   |-- bootinfo_emmc.bin
|   |-- bootinfo_sd.bin
|   |-- bootinfo_spinand.bin
|   |-- bootinfo_spinor.bin
|   `-- FSBL.bin
|-- fastboot.yaml
|-- fw_dynamic.itb
|-- genimage.cfg
|-- partition_universal.json
|-- ramdisk.img
|-- sys_prod.img
|-- system.img
|-- u-boot.itb
|-- updater.img
|-- userdata.img
`-- vendor.img

2 directories, 25 files

Make a full package Enter the OTA packaging tool directory and create target_package, output_package and sign_cert folders. If the folders already exist, you do not need to create them.

$ cd base/update/packaging_tools
$ mkdir target_package output_package sign_cert

Put the public key in the sign_cert folder. The public key comes from

base/update/updater/test/unittest/test_data/src/signing_cert.crt

Put the files to be packaged and generated into the target_packet folder.

Includes: Private key, rsa_private_key2048.pem, from

base/update/updater/test/unittest/test_data/src/rsa_private_key2048.pem

Image file, from the folder out\xxx\packages\phone\images

Binary upgrade file, updater_binary, from out\xxx\packages\phone\system\bin\updater_binary

Upgrade component configuration folder updater_config, which contains:

List of products supported by the upgrade package: BOARD.list,

from device/board/hisilicon/hispark_taurus/linux/updater/config/BOARD.list

The content is as follows:

HI3516
smt001
DEB1
ZT001H
HI3516 必须有,否则 OTA 包校验失败而导致 OTA 升级失败,因为 base/update/updater/utils/utils.cpp 代码匹配 BOARD 时,固定了默认值,如下:


std::string GetLocalBoardId()
{
    return "HI3516";
}

The version range supported by the upgrade package: VERSION.mbn,

from device/board/hisilicon/hispark_taurus/linux/updater/config/VERSION.mbn

VERSION.mbn should be consistent with the set software version.

OpenHarmony 5.0.0.71 component configuration file: updater_specified_config.xml,

from device/board/hisilicon/hispark_taurus/linux/system/updater_specified_config.xml

Change fileVersion to 2 (verification method for 4.0 updates), change softVersion to the current software version, change compType to 0, indicating full version (1 indicating incremental version), change img packaging path, /vendor.img and ./system.img, etc., and the final content is as follows:

<?xml version="1.0"?>
<package>
    <head name="Component header information">
        <info fileVersion="02" prdID="123456" softVersion="OpenHarmony 5.0.0.71" date="2025-02-13" time="14:30">head info</info>
    </head>
    <group name = "Component information">
        <component compAddr="vendor" compId="1" resType="05" compType="0" compVer="0o00">./vendor.img</component>
        <component compAddr="system" compId="2" resType="05" compType="0" compVer="0o00">./system.img</component>
        <component compAddr="boot" compId="3" resType="05" compType="0" compVer="0o00">./boot.img</component>
        <component compAddr="uboot" compId="4" resType="05" compType="0" compVer="0o00">./u-boot.itb</component>
        <component compAddr="fsbl" compId="5" resType="05" compType="0" compVer="0o00">./factory/FSBL.bin</component>
        <component compAddr="env" compId="6" resType="05" compType="0" compVer="0o00">./env.bin</component>
        <component compAddr="opensbi" compId="7" resType="05" compType="0" compVer="0o00">./fw_dynamic.itb</component>
        <component compAddr="ramdisk" compId="8" resType="05" compType="0" compVer="0o00">./ramdisk.img</component>
        <component compAddr="updater" compId="9" resType="05" compType="0" compVer="0o00">./updater.img</component>
        <component compAddr="sys_prod" compId="10" resType="05" compType="0" compVer="0o00">./sys_prod.img</component>
        <component compAddr="chip_prod" compId="11" resType="05" compType="0" compVer="0o00">./chip_prod.img</component>
    </group>
</package>

The complete content of target_packet is as follows:

root@ubuntu:~/WorkSpace/oh5/base/update/packaging_tools/target_package$ tree
.
|-- bootfs
|   |-- bianbu.bmp
|   |-- env_k1-x.txt
|   |-- Image.itb
|   |-- k1-x_MUSE-Paper2.dtb
|   `-- Thumbs.db
|-- boot.img
|-- chip_prod.img
|-- eng_system.img
|-- env.bin
|-- factory
|   |-- bootinfo_emmc.bin
|   |-- bootinfo_sd.bin
|   |-- bootinfo_spinand.bin
|   |-- bootinfo_spinor.bin
|   `-- FSBL.bin
|-- fastboot.yaml
|-- fw_dynamic.itb
|-- genimage.cfg
|-- partition_universal.json
|-- ramdisk.img
|-- rsa_private_key2048.pem
|-- sys_prod.img
|-- system.img
|-- u-boot.itb
|-- updater_binary
|-- updater_config
|   |-- BOARD.list
|   |-- updater_specified_config.xml
|   `-- VERSION.mbn
|-- updater.img
|-- userdata.img
`-- vendor.img

3 directories, 30 files

The full package will be packaged and the updater_full.zip full package will be generated in the base/update/packaging_tools/output_package directory. The command is as follows:

python3 build_update.py ./target_package/ ./output_package/ -pk ./target_package/rsa_private_key2048.pem

The normal log is as follows:

root@ubuntu:~/WorkSpace/oh5/base/update/packaging_tools$ python3 build_update.py ./target_package/ ./output_package/ -pk ./target_package/rsa_private_key2048.pem
2025-02-13 20:56:04 INFO : []
2025-02-13 20:56:04 INFO : VERSION.mbn file parsing complete! path: ./target_package/updater_config/VERSION.mbn
2025-02-13 20:56:04 INFO : BOARD.list file parsing complete! path: ./target_package/updater_config/BOARD.list
2025-02-13 20:56:04 INFO : []
2025-02-13 20:56:04 INFO : XML file parsing completed!
2025-02-13 20:56:04 INFO : []
2025-02-13 20:56:05 INFO : Image vendor full processing completed
2025-02-13 20:56:08 INFO : Image system full processing completed
2025-02-13 20:56:09 INFO : Image boot full processing completed
2025-02-13 20:56:09 INFO : Image u-boot full processing completed
2025-02-13 20:56:09 INFO : Image FSBL full processing completed
2025-02-13 20:56:09 INFO : Image env full processing completed
2025-02-13 20:56:09 INFO : Image fw_dynamic full processing completed
2025-02-13 20:56:09 INFO : Image ramdisk full processing completed
2025-02-13 20:56:09 INFO : Image updater full processing completed
2025-02-13 20:56:09 INFO : Image sys_prod full processing completed
2025-02-13 20:56:09 INFO : Image chip_prod full processing completed
2025-02-13 20:56:09 INFO : All full image processing completed! image count: 11
2025-02-13 20:56:09 INFO : []
2025-02-13 20:56:09 INFO : []
2025-02-13 20:56:09 INFO : []
2025-02-13 20:56:09 INFO : Get hash content success! path: ./target_package/updater_config/VERSION.mbn
2025-02-13 20:56:09 INFO : Get hash content success! path: ./target_package/updater_config/BOARD.list
2025-02-13 20:56:11 INFO : Get hash content success! path: /data/home2/root/WorkSpace/oh5/oh5_r_release/base/update/packaging_tools/target_package/full_imagevendoru8blfa8f
2025-02-13 20:56:22 INFO : Get hash content success! path: /data/home2/root/WorkSpace/oh5/oh5_r_release/base/update/packaging_tools/target_package/full_imagesystem2124936b
2025-02-13 20:56:24 INFO : Get hash content success! path: /data/home2/root/WorkSpace/oh5/oh5_r_release/base/update/packaging_tools/target_package/full_imagebootolvjuuro
2025-02-13 20:56:24 INFO : Get hash content success! path: /data/home2/root/WorkSpace/oh5/oh5_r_release/base/update/packaging_tools/target_package/full_imageu-bootyx5utu44
2025-02-13 20:56:24 INFO : Get hash content success! path: /data/home2/root/WorkSpace/oh5/oh5_r_release/base/update/packaging_tools/target_package/full_imageFSBLgyd5y0tc
2025-02-13 20:56:24 INFO : Get hash content success! path: /data/home2/root/WorkSpace/oh5/oh5_r_release/base/update/packaging_tools/target_package/full_imageenv48uz1h5n
2025-02-13 20:56:24 INFO : Get hash content success! path: /data/home2/root/WorkSpace/oh5/oh5_r_release/base/update/packaging_tools/target_package/full_imagefw_dynamicd_lhhf2r
2025-02-13 20:56:24 INFO : Get hash content success! path: /data/home2/root/WorkSpace/oh5/oh5_r_release/base/update/packaging_tools/target_package/full_imageramdisk_xd3t7d3
2025-02-13 20:56:24 INFO : Get hash content success! path: /data/home2/root/WorkSpace/oh5/oh5_r_release/base/update/packaging_tools/target_package/full_imageupdatertarhn6ph
2025-02-13 20:56:24 INFO : Get hash content success! path: /data/home2/root/WorkSpace/oh5/oh5_r_release/base/update/packaging_tools/target_package/full_imagesys_prodgj47qc31
2025-02-13 20:56:25 INFO : Get hash content success! path: /data/home2/root/WorkSpace/oh5/oh5_r_release/base/update/packaging_tools/target_package/full_imagechip_prod1l3n34w4
2025-02-13 20:56:25 INFO : Write package header complete
2025-02-13 20:56:25 INFO : Add component b'/version_list'
2025-02-13 20:56:25 INFO : component information  StartOffset:180
2025-02-13 20:56:25 INFO : Add component b'/board_list'
2025-02-13 20:56:25 INFO : component information  StartOffset:267
2025-02-13 20:56:25 INFO : Add component b'/vendor'
2025-02-13 20:56:25 INFO : component information  StartOffset:354
2025-02-13 20:56:25 INFO : Add component b'/system'
2025-02-13 20:56:25 INFO : component information  StartOffset:441
2025-02-13 20:56:25 INFO : Add component b'/boot'
2025-02-13 20:56:25 INFO : component information  StartOffset:528
2025-02-13 20:56:25 INFO : Add component b'/uboot'
2025-02-13 20:56:25 INFO : component information  StartOffset:615
2025-02-13 20:56:25 INFO : Add component b'/fsbl'
2025-02-13 20:56:25 INFO : component information  StartOffset:702
2025-02-13 20:56:25 INFO : Add component b'/env'
2025-02-13 20:56:25 INFO : component information  StartOffset:789
2025-02-13 20:56:25 INFO : Add component b'/opensbi'
2025-02-13 20:56:25 INFO : component information  StartOffset:876
2025-02-13 20:56:25 INFO : Add component b'/ramdisk'
2025-02-13 20:56:25 INFO : component information  StartOffset:963
2025-02-13 20:56:25 INFO : Add component b'/updater'
2025-02-13 20:56:25 INFO : component information  StartOffset:1050
2025-02-13 20:56:25 INFO : Add component b'/sys_prod'
2025-02-13 20:56:25 INFO : component information  StartOffset:1137
2025-02-13 20:56:25 INFO : Add component b'/chip_prod'
2025-02-13 20:56:25 INFO : component information  StartOffset:1224
2025-02-13 20:56:25 INFO : Write hashdata sign tlv complete
2025-02-13 20:56:25 INFO : .bin package header signing success! SignOffset: 1589
2025-02-13 20:56:25 INFO : Add component to package  StartOffset:1589
2025-02-13 20:56:25 INFO : Write component complete  ComponentSize:22
2025-02-13 20:56:25 INFO : Add component to package  StartOffset:1611
2025-02-13 20:56:25 INFO : Write component complete  ComponentSize:40
2025-02-13 20:56:25 INFO : Add component to package  StartOffset:1651
2025-02-13 20:56:25 INFO : Write component complete  ComponentSize:268431360
2025-02-13 20:56:25 INFO : Add component to package  StartOffset:268433011
2025-02-13 20:56:29 INFO : Write component complete  ComponentSize:2097152000
2025-02-13 20:56:29 INFO : Add component to package  StartOffset:2365585011
2025-02-13 20:56:29 INFO : Write component complete  ComponentSize:268435456
2025-02-13 20:56:29 INFO : Add component to package  StartOffset:2634020467
2025-02-13 20:56:29 INFO : Write component complete  ComponentSize:1965474
2025-02-13 20:56:29 INFO : Add component to package  StartOffset:2635985941
2025-02-13 20:56:29 INFO : Write component complete  ComponentSize:189728
2025-02-13 20:56:29 INFO : Add component to package  StartOffset:2636175669
2025-02-13 20:56:29 INFO : Write component complete  ComponentSize:16384
2025-02-13 20:56:29 INFO : Add component to package  StartOffset:2636192053
2025-02-13 20:56:29 INFO : Write component complete  ComponentSize:136599
2025-02-13 20:56:29 INFO : Add component to package  StartOffset:2636328652
2025-02-13 20:56:29 INFO : Write component complete  ComponentSize:3035582
2025-02-13 20:56:29 INFO : Add component to package  StartOffset:2639364234
2025-02-13 20:56:29 INFO : Write component complete  ComponentSize:19612459
2025-02-13 20:56:29 INFO : Add component to package  StartOffset:2658976693
2025-02-13 20:56:29 INFO : Write component complete  ComponentSize:52428800
2025-02-13 20:56:29 INFO : Add component to package  StartOffset:2711405493
2025-02-13 20:56:30 INFO : Write component complete  ComponentSize:52428800
2025-02-13 20:56:30 INFO : Write update package complete
2025-02-13 20:56:30 INFO : Create update package .bin complete! path: /data/home2/root/WorkSpace/oh5/oh5_r_release/base/update/packaging_tools/output_package/update_bin-bap8m1xh
2025-02-13 20:56:30 INFO : Verse-script.us generation complete!
2025-02-13 20:56:30 INFO : loadScript.us generation complete!
2025-02-13 20:56:30 INFO : []
2025-02-13 20:56:30 INFO : []
2025-02-13 20:56:30 INFO : []
2025-02-13 20:57:45 INFO : []
2025-02-13 20:57:45 INFO : []
2025-02-13 20:57:51 INFO : Resource cleaning completed!

Differential Packet Production

Fully compile source code

./build.sh --product-name xxx --ccache --prebuilt-sdk

The content needed is as follows:

The system image file is in out\xxx\packages\phone\images, as follows:

root@ubuntu:~/WorkSpace/oh5/out/smt001/packages/phone/images$ tree
.
|-- bootfs
|   |-- bianbu.bmp
|   |-- env_k1-x.txt
|   |-- Image.itb
|   `-- k1-x_MUSE-Paper2.dtb
|-- boot.img
|-- chip_prod.img
|-- eng_system.img
|-- env.bin
|-- factory
|   |-- bootinfo_emmc.bin
|   |-- bootinfo_sd.bin
|   |-- bootinfo_spinand.bin
|   |-- bootinfo_spinor.bin
|   `-- FSBL.bin
|-- fastboot.yaml
|-- fw_dynamic.itb
|-- genimage.cfg
|-- openharmony-spacemit-smt001.zip
|-- partition_universal.json
|-- ramdisk.img
|-- sys_prod.img
|-- system.img
|-- u-boot.itb
|-- updater.img
|-- userdata.img
`-- vendor.img

2 directories, 25 files

Binary upgrade file updater_binary,

It is out\xxx\packages\phone\system\bin\updater_binary

Making a differential package

Create a lib folder and put the differential image binary tools in it. If these files already exist, ignore this step.

root@ubuntu:~/WorkSpace/oh5/base/update/packaging_tools$ mkdir lib
root@ubuntu:~/WorkSpace/oh5/base/update/packaging_tools$ cp -rf ../../../out/smt001/clang_x64/updater/updater/diff lib/
root@ubuntu:~/WorkSpace/oh5/base/update/packaging_tools$ cp -rf ../../../out/smt001/clang_x64/thirdparty/e2fsprogs/* lib/

The contents of the lib folder are as follows:

root@ubuntu:~/WorkSpace/oh5base/update/packaging_tools/lib$ tree
.
|-- diff
|-- e2fsck
|-- e2fsdroid
|-- libext2_blkid.so
|-- libext2_com_err.so
|-- libext2_e2p.so
|-- libext2fs.so
|-- libext2_misc.so
|-- libext2_quota.so
|-- libext2_uuid.so
`-- mke2fs

0 directories, 11 files

In the packaging_tools directory, copy the last target_package as the source_package for making the differential package

root@ubuntu:~/WorkSpace/oh5/base/update/packaging_tools$ cp -rf target_package/* source_package/

Update files in the target_package directory

Replace with a new image file Replace with a new binary upgrade file Update softVersion and compType of target_package/updater_config/updater_specified_config.xml. The softVersion must be greater than the current system version; compType is set to 1, indicating an incremental version. The compType of some small img files is still set to 0, using a full upgrade

<?xml version="1.0"?>
<package>
    <head name="Component header information">
        <info fileVersion="02" prdID="123456" softVersion="OpenHarmony 5.0.0.72" date="2025-02-14" time="14:30">head info</info>
    </head>
    <group name = "Component information">
        <component compAddr="vendor" compId="1" resType="05" compType="1" compVer="0o00">./vendor.img</component>
        <component compAddr="system" compId="2" resType="05" compType="1" compVer="0o00">./system.img</component>
        <component compAddr="boot" compId="3" resType="05" compType="0" compVer="0o00">./boot.img</component>
        <component compAddr="uboot" compId="4" resType="05" compType="0" compVer="0o00">./u-boot.itb</component>
        <component compAddr="fsbl" compId="5" resType="05" compType="0" compVer="0o00">./factory/FSBL.bin</component>
        <component compAddr="env" compId="6" resType="05" compType="0" compVer="0o00">./env.bin</component>
        <component compAddr="opensbi" compId="7" resType="05" compType="0" compVer="0o00">./fw_dynamic.itb</component>
        <component compAddr="ramdisk" compId="8" resType="05" compType="0" compVer="0o00">./ramdisk.img</component>
        <component compAddr="updater" compId="9" resType="05" compType="0" compVer="0o00">./updater.img</component>
        <component compAddr="sys_prod" compId="10" resType="05" compType="1" compVer="0o00">./sys_prod.img</component>
        <component compAddr="chip_prod" compId="11" resType="05" compType="1" compVer="0o00">./chip_prod.img</component>
    </group>
</package>

Packaging difference package:

python3 build_update.py ./target_package/ ./output_package/ -s ./source_package/ -pk ./target_package/rsa_private_key2048.pem

Get the differential package base/update/packaging_tools/output_package/updater_diff.zip

OTA Updates

Local OTA upgrade

Put the prepared full package updater_full.zip (or differential package updater_diff.zip) into the device and set the reboot mode

D:\>hdc file send Y:\WorkSpace/oh5/base/update/packaging_tools\output_package\updater_xxx.zip /data/updater/updater.zip
D:\>hdc shell
# write_updater updater /data/updater/updater.zip
# reboot updater

After the upgrade is successful, the device automatically restarts

Edit this page on GitHub
Last Updated:
Contributors: zsl, zwhuang
Prev
System Debugging