Files
luban-lite-t3e-pro/doc/topics/sdk/ota/ota_design.html
2025-01-23 16:37:00 +08:00

630 lines
46 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn" lang="zh-cn" data-whc_version="26.0">
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="description" content="OTA 升级包包含下列文件: OTA 升级包配置文件sw-images.cfg OTA 策略描述文件: sw-description OTA 升级包生成工具 swupdate_pack_swu OTA 升级包配置文件: sw-images.cfg Luban 提供 sw-images.cfg 文件 ,用于指示会被打包进 OTA 升级包的文件。 sw-images.cfg 文件路径为 ..."/><meta name="DC.rights.owner" content="(C) 版权 2025"/><meta name="copyright" content="(C) 版权 2025"/><meta name="generator" content="DITA-OT"/><meta name="DC.type" content="topic"/><meta name="DC.contributor" content="yan.wang"/><meta name="DC.date.modified" content="2024-12-25"/><meta name="DC.format" content="HTML5"/><meta name="DC.identifier" content="id"/><title>Luban OTA 升级包制作过程</title><!-- Build number 2023110923. --><meta name="wh-path2root" content="../../../"/><meta name="wh-toc-id" content=""/><meta name="wh-source-relpath" content="topics/sdk/ota/ota_design.dita"/><meta name="wh-out-relpath" content="topics/sdk/ota/ota_design.html"/>
<link rel="stylesheet" type="text/css" href="../../../webhelp/app/commons.css?buildId=2023110923"/>
<link rel="stylesheet" type="text/css" href="../../../webhelp/app/topic.css?buildId=2023110923"/>
<script src="../../../webhelp/app/options/properties.js?buildId=20250121171154"></script>
<script src="../../../webhelp/app/localization/strings.js?buildId=2023110923"></script>
<script src="../../../webhelp/app/search/index/keywords.js?buildId=20250121171154"></script>
<script defer="defer" src="../../../webhelp/app/commons.js?buildId=2023110923"></script>
<script defer="defer" src="../../../webhelp/app/topic.js?buildId=2023110923"></script>
<link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-styles-web.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/notes.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-common.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-images.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/footnote.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-web-watermark.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/topic-body-list.css?buildId=2023110923"/></head>
<body id="id" class="wh_topic_page frmBody">
<a href="#wh_topic_body" class="sr-only sr-only-focusable">
跳转到主要内容
</a>
<header class="navbar navbar-default wh_header">
<div class="container-fluid">
<div class="wh_header_flex_container navbar-nav navbar-expand-md navbar-dark">
<div class="wh_logo_and_publication_title_container">
<div class="wh_logo_and_publication_title">
<a href="http://www.artinchip.com" class=" wh_logo d-none d-sm-block "><img src="../../../company-logo-white.png" alt="RTOS SDK 使用指南SDK 指南文件"/></a>
<div class=" wh_publication_title "><a href="../../../index.html"><span class="booktitle"><span class="ph mainbooktitle">RTOS SDK 使用指南</span><span class="ph booktitlealt">SDK 指南文件</span></span></a></div>
</div>
</div>
<div class="wh_top_menu_and_indexterms_link collapse navbar-collapse" id="wh_top_menu_and_indexterms_link">
</div>
</div>
</div>
</header>
<div class=" wh_search_input navbar-form wh_topic_page_search search " role="form">
<form id="searchForm" method="get" role="search" action="../../../search.html"><div><input type="search" placeholder="搜索 " class="wh_search_textfield" id="textToSearch" name="searchQuery" aria-label="搜索查询" required="required"/><button type="submit" class="wh_search_button" aria-label="搜索"><span class="search_input_text">搜索</span></button></div></form>
</div>
<div class="container-fluid" id="wh_topic_container">
<div class="row">
<nav class="wh_tools d-print-none navbar-expand-md" aria-label="Tools">
<div data-tooltip-position="bottom" class=" wh_breadcrumb "></div>
<div class="wh_right_tools">
<button class="wh_hide_highlight" aria-label="切换搜索突出显示" title="切换搜索突出显示"></button>
<button class="webhelp_expand_collapse_sections" data-next-state="collapsed" aria-label="折叠截面" title="折叠截面"></button>
<div class=" wh_print_link print d-none d-md-inline-block "><button onClick="window.print()" title="打印此页" aria-label="打印此页"></button></div>
</div>
</nav>
</div>
<div class="wh_content_area">
<div class="row">
<div class="col-lg-10 col-md-10 col-sm-10 col-xs-12" id="wh_topic_body">
<button id="wh_close_topic_toc_button" class="close-toc-button d-none" aria-label="Toggle topic table of content" aria-controls="wh_topic_toc" aria-expanded="true">
<span class="close-toc-icon-container">
<span class="close-toc-icon"></span>
</span>
</button>
<div class=" wh_topic_content body "><main role="main"><article class="- topic/topic topic" role="article" aria-labelledby="ariaid-title1"><span class="edit-link" style="font-size:12px; opacity:0.6; text-align:right; vertical-align:middle"><a target="_blank" href="http://172.16.35.88/tasks/jdssno1uvvbf2mltu9kb9v3if05d5gopuakboe8hlud18rma/edit/F:/aicdita/aicdita-cn/topics/sdk/ota/ota_design.dita">Edit online</a></span><h1 class="- topic/title title topictitle1" id="ariaid-title1">Luban OTA 升级包制作过程</h1><div class="date inPage">25 Dec 2024</div><div style="color: gray;">
Read time: 13 minute(s)
</div><div class="- topic/body body"><figure class="- topic/fig fig fignone" data-ofbid="d166364e17__20250121171618"><br/><div class="imagecenter"><img class="- topic/image image imagecenter" src="../../../images/ota/ota_swupdate_tool.png" alt="swu"/></div><br/></figure><div class="- topic/p p" data-ofbid="d166364e21__20250121171618">OTA 升级包包含下列文件:<ul class="- topic/ul ul arabic simple" id="id__ol_ozg_ym5_4dc" data-ofbid="id__ol_ozg_ym5_4dc"><li class="- topic/li li" data-ofbid="d166364e24__20250121171618"><a class="- topic/xref xref" href="ota_design.html#id__ota-sw-images-cfg">OTA 升级包配置文件sw-images.cfg</a>
</li><li class="- topic/li li" data-ofbid="d166364e29__20250121171618"><a class="- topic/xref xref" href="ota_design.html#id__ota-sw-description">OTA 策略描述文件: sw-description</a></li><li class="- topic/li li" data-ofbid="d166364e33__20250121171618"><a class="- topic/xref xref" href="ota_design.html#id__ota-swupdate-pack-swu">OTA 升级包生成工具 swupdate_pack_swu</a></li></ul></div><section class="- topic/section section" id="id__ota-sw-images-cfg" data-ofbid="id__ota-sw-images-cfg"><h2 class="- topic/title title sectiontitle">OTA 升级包配置文件:<span class="+ topic/ph sw-d/filepath ph filepath">sw-images.cfg</span></h2>
<div class="- topic/p p" data-ofbid="d166364e44__20250121171618">Luban 提供 <span class="+ topic/ph sw-d/filepath ph filepath">sw-images.cfg</span> 文件 ,用于指示会被打包进 OTA
升级包的文件。<span class="+ topic/ph sw-d/filepath ph filepath">sw-images.cfg</span> 文件路径为
<span class="+ topic/ph sw-d/filepath ph filepath">${TARGET_BOARD_DIR}/swupdate/sw-images.cfg</span><div class="- topic/div div section" id="id__sw-images-cfg"><strong class="+ topic/ph hi-d/b ph b"><span class="+ topic/ph sw-d/filepath ph filepath">sw-images.cfg</span>
使用说明</strong>
<ul class="- topic/ul ul" id="id__ul_lqm_fn5_4dc" data-ofbid="id__ul_lqm_fn5_4dc"><li class="- topic/li li" data-ofbid="d166364e62__20250121171618">
<p class="- topic/p p" data-ofbid="d166364e64__20250121171618"><span class="+ topic/ph sw-d/filepath ph filepath">sw-images.cfg</span> 文件名称是固定的,如果名称不对,则编译 OTA
升级包时会出错。</p>
</li><li class="- topic/li li" data-ofbid="d166364e69__20250121171618">
<p class="- topic/p p" data-ofbid="d166364e71__20250121171618"><span class="+ topic/ph sw-d/filepath ph filepath">${TARGET_BOARD_DIR}/swupdate</span> 目录下的
<span class="+ topic/ph sw-d/filepath ph filepath">sw-description</span> 文件名称可以指定为其它,但需修改
<span class="+ topic/ph sw-d/filepath ph filepath">sw-images.cfg</span> 中的描述信息。</p>
<p class="- topic/p p" data-ofbid="d166364e82__20250121171618">将最终的文件打包到 OTA 升级包中,重命名为 <span class="+ topic/ph sw-d/filepath ph filepath">sw-description</span>
并放在第一个文件即可。比如将 <span class="+ topic/ph sw-d/filepath ph filepath">sw-description</span> 改为
<span class="+ topic/ph sw-d/filepath ph filepath">sw-description-ubi</span>,则在
<span class="+ topic/ph sw-d/filepath ph filepath">sw-images.cfg</span> 中添加如下信息:</p>
<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_vnv_fn5_4dc" data-ofbid="id__codeblock_vnv_fn5_4dc">${TARGET_BOARD_DIR}/swupdate/sw-description-ubi: sw-description</pre>
</li></ul>
</div><ul class="- topic/ul ul" id="id__ul_b55_cn5_4dc" data-ofbid="id__ul_b55_cn5_4dc"><li class="- topic/li li" data-ofbid="d166364e102__20250121171618">
<div class="- topic/div div section" id="id__spinand-sw-images-cfg"><strong class="+ topic/ph hi-d/b ph b">SPINAND 平台
<span class="+ topic/ph sw-d/filepath ph filepath">sw-images.cfg</span></strong>
<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_fvq_wrw_fdc" data-ofbid="id__codeblock_fvq_wrw_fdc">swota_file_list=(
${TARGET_BOARD_DIR}/swupdate/sw-description: sw-description
${BINARIES_DIR}/recovery.itb:recovery
${BINARIES_DIR}/kernel.itb:kernel
${BINARIES_DIR}/boot_logo.png:logo
${BINARIES_DIR}/rootfs_page_<span class="hl-number">2</span>k_block_<span class="hl-number">128</span>k.ubifs:rootfs
#下面这行给使用 Page 为 <span class="hl-number">4</span>K 的 SPINAND 方案预留, 目前注释掉
#${BINARIES_DIR}/rootfs_page_<span class="hl-number">4</span>k_block_<span class="hl-number">256</span>k.ubifs:rootfs
)</pre><div class="- topic/note note note note_note admonition" id="id__note_sgx_cn5_4dc" data-ofbid="id__note_sgx_cn5_4dc"><span class="note__title">注:</span>
<p class="- topic/p p" data-ofbid="d166364e114__20250121171618">指示打包 SWUpdate 升级包所需的各个文件的位置,这些文件会被拷贝到
<span class="+ topic/ph sw-d/filepath ph filepath">out/images/swupdate</span> 目录后生成 OTA 包。</p>
</div>
</div>
</li><li class="- topic/li li" data-ofbid="d166364e122__20250121171618">
<div class="- topic/div div section" id="id__emmc-sw-images-cfg">
<strong class="+ topic/ph hi-d/b ph b">eMMC 平台 <span class="+ topic/ph sw-d/filepath ph filepath">sw-images.cfg</span></strong>
<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_gqb_xrw_fdc" data-ofbid="id__codeblock_gqb_xrw_fdc">swota_file_list=(
${TARGET_BOARD_DIR}/swupdate/sw-description
${BINARIES_DIR}/recovery.itb:recovery
${BINARIES_DIR}/kernel.itb:kernel
${BINARIES_DIR}/boot_logo.png:logo
${BINARIES_DIR}/rootfs.ext4:rootfs
)</pre>
</div>
</li></ul></div>
</section><section class="- topic/section section" id="id__ota-sw-description" data-ofbid="id__ota-sw-description"><h2 class="- topic/title title sectiontitle">OTA 策略描述文件: <span class="+ topic/ph sw-d/filepath ph filepath">sw-description</span></h2>
<p class="- topic/p p" data-ofbid="d166364e143__20250121171618">OTA 升级包需要包含 <span class="+ topic/ph sw-d/filepath ph filepath">sw-description</span> 文件以及升级使用的其他文件,包括 Kernel 和 RootFS。整个
OTA 升级包是 cpio 格式,且 <span class="+ topic/ph sw-d/filepath ph filepath">sw-description</span> 文件必须放在第一,包名称必须使用
<span class="+ topic/ph sw-d/filepath ph filepath">.swu</span> 后缀才能被 SWUpdate 程序识别到。</p>
<p class="- topic/p p" data-ofbid="d166364e155__20250121171618"><span class="+ topic/ph sw-d/filepath ph filepath">sw-description</span> 文件是 SWUpdate 官方规定的 OTA 策略描述文件,具体语法可以参考 SWUpdate
官方文档,使用 libconfig 格式。</p>
<p class="- topic/p p" data-ofbid="d166364e160__20250121171618">Luban 为 eMMC SPINAND 提供了一个示例,参考 <span class="+ topic/ph sw-d/filepath ph filepath">sw-images.cfg</span>,默认指定路径为
<span class="+ topic/ph sw-d/filepath ph filepath">${TARGET_BOARD_DIR}/swupdate/sw-description:
sw-description</span></p>
<ul class="- topic/ul ul" id="id__ul_cc4_ptw_5dc" data-ofbid="id__ul_cc4_ptw_5dc"><li class="- topic/li li" data-ofbid="d166364e170__20250121171618">
<div class="- topic/div div section" id="id__spinand-sw-description"><strong class="+ topic/ph hi-d/b ph b">SPINAND
<span class="+ topic/ph sw-d/filepath ph filepath">sw-description</span> 文件使用说明</strong>
<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_vhm_xrw_fdc" data-ofbid="id__codeblock_vhm_xrw_fdc">software =
{
<em class="hl-comment">/*版本号和描述符*/</em>
version = <span class="hl-string">"1.0.0.0"</span>;
description = <span class="hl-string">"Firmware update for Luban Project"</span>;
stable = {
<em class="hl-comment">/*
* upgrade_recovery stage:
* Running in main system, and upgrade the "recovery" partition,
* then reboot to the new recovery system
* Step1: Download image and upgrade the "recovery" partition
* Step2: Setup bootenv "swu_entry, boot_partition, boot_os, swu_status"
* Step3: Reboot to the new recovery system to run "upgrade_kernel"
*/</em>
<em class="hl-comment">/*
* 内层 entry, upgrade_recovery,
* 当调用 swupdate xxx -e stable,upgrade_recovery 时, 会匹配到这部分, 执行{}内的动作,
* 可以修改, 调用的时候传入匹配的字符串即可
*/</em>
upgrade_recovery = {
images: (
{
filename = <span class="hl-string">"recovery"</span>; <em class="hl-comment">//烧录文件名称</em>
device = <span class="hl-string">"/dev/mtd8"</span>; <em class="hl-comment">//对应设备节点</em>
type = <span class="hl-string">"flash"</span>; <em class="hl-comment">//操作 mtd 分区</em>
sha256 = <span class="hl-string">"@recovery"</span>; <em class="hl-comment">//自动获取对应镜像的 sha256 值</em>
}
);
<em class="hl-comment">/*
* Some key env variables:
* swu_boardname: The selected board name. Here is "stable"
* swu_entry: The upgrade entry selection. Value can be
* "upgrade_recovery" and "upgrade_kernel"
* boot_os: SPL Falcon mode flag. Should be set to "no"
* during OTA
* swu_status: OTA status flag, Value can be "progress",
* "finish"
* swu_reboot: When this flag is set to "yes", the
* system will be reboot when all works done for current
* stage.
*/</em>
<em class="hl-comment">/*
* image 处理完以后, 需要设置一些标志, 切换状态,
* swu_entry= upgrade_kernel, 下次升级 upgrade_kernel,
* boot_partition= recovery, 下次引导 recovery 里面的内核启动,
* boot_os= no, 临时关闭 Falcon 模式, 请查看后面注释信息,
* swu_status OTA 升级的状态, 备用, Luban 添加,
* swu_reboot=yes,升级 upgrade_recovery 完成, 和外部脚本配合, 指示外部脚本做 reboot 动作
*/</em>
bootenv: (
{
name = <span class="hl-string">"swu_entry"</span>;
value = <span class="hl-string">"upgrade_kernel"</span>;
},
{
name = <span class="hl-string">"boot_partition"</span>;
value = <span class="hl-string">"recovery"</span>;
},
{
name = <span class="hl-string">"boot_os"</span>;
value = <span class="hl-string">"no"</span>;
},
{
name = <span class="hl-string">"swu_status"</span>;
value = <span class="hl-string">"progress"</span>;
},
{
name = <span class="hl-string">"swu_reboot"</span>;
value = <span class="hl-string">"yes"</span>;
}
);
};
<em class="hl-comment">/*
* upgrade_kernel stage:
* Running in Recovery system, it will upgrade some key
* partitions, then reboot to main system.
* Step1: Download and upgrade partitons
* Step2: Setup ENV variables, and mark OTA "finish"
* Step3: Reboot to main system
*/</em>
upgrade_kernel = {
images: (
{
filename = <span class="hl-string">"logo"</span>;
device = <span class="hl-string">"/dev/mtd5"</span>;
type = <span class="hl-string">"flash"</span>;
sha256 = <span class="hl-string">"@logo"</span>;
},
{
filename = <span class="hl-string">"kernel"</span>;
device = <span class="hl-string">"/dev/mtd6"</span>;
type = <span class="hl-string">"flash"</span>;
sha256 = <span class="hl-string">"@kernel"</span>;
},
{
filename = <span class="hl-string">"rootfs"</span>;
volume = <span class="hl-string">"rootfs"</span>; <em class="hl-comment">//ubi 分区名称</em>
installed-directly = true; <em class="hl-comment">//读取升级镜像使用流控方式, 不用先拷贝到本地 flash 上</em>
sha256 = <span class="hl-string">"@rootfs"</span>;
}
);
bootenv: (
{
name = <span class="hl-string">"boot_partition"</span>;
value = <span class="hl-string">"kernel"</span>;
},
{
name = <span class="hl-string">"swu_param"</span>; <em class="hl-comment">//情况环境变量</em>
value = <span class="hl-string">""</span>;
},
{
name = <span class="hl-string">"swu_boardname"</span>;
value = <span class="hl-string">""</span>;
},
{
name = <span class="hl-string">"swu_entry"</span>;
value = <span class="hl-string">""</span>;
},
{
name = <span class="hl-string">"swu_status"</span>;
value = <span class="hl-string">"finish"</span>;
},
{
name = <span class="hl-string">"swu_reboot"</span>;
value = <span class="hl-string">"yes"</span>;
}
);
};
};
}</pre><ol class="- topic/ol ol arabic simple" id="id__ol_ub4_yn5_4dc" data-ofbid="id__ol_ub4_yn5_4dc"><li class="- topic/li li" data-ofbid="d166364e182__20250121171618">
<p class="- topic/p p" data-ofbid="d166364e184__20250121171618">U-Boot 环境变量 <span class="+ topic/keyword pr-d/parmname keyword parmname">boot_partition</span> 用来指导主系统和 Recovery
系统之间切换过程。</p>
</li><li class="- topic/li li" data-ofbid="d166364e190__20250121171618">
<p class="- topic/p p" data-ofbid="d166364e192__20250121171618">当 U-Boot 使能了 Falcon 功能SPL 程序会直接引导内核启动,不会执行 U-Boot 程序,也就不会判断环境变量
<span class="+ topic/keyword pr-d/parmname keyword parmname">boot_partition</span> 进行系统之间的切换,因此需要通过设置
<span class="+ topic/keyword pr-d/parmname keyword parmname">boot_os</span>
<kbd class="+ topic/ph sw-d/userinput ph userinput">no</kbd>,临时关闭 Falcon 功能。</p>
</li></ol>
</div>
</li><li class="- topic/li li" data-ofbid="d166364e206__20250121171618">
<div class="- topic/div div section" id="id__emmc-sw-description"><strong class="+ topic/ph hi-d/b ph b">eMMC sw-description
文件使用说明</strong>
<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_tg1_yrw_fdc" data-ofbid="id__codeblock_tg1_yrw_fdc">software =
{
version = <span class="hl-string">"1.0.0.0"</span>;
description = <span class="hl-string">"Firmware update for Luban Project"</span>;
stable = {
<em class="hl-comment">/*
* upgrade_recovery stage:
* Running in main system, and upgrade the "recovery" partition,
* then reboot to the new recovery system
* Step1: Download image and upgrade the "recovery" partition
* Step2: Setup bootenv "swu_entry, boot_partition, boot_os, swu_status"
* Step3: Reboot to the new recovery system to run "upgrade_kernel"
*/</em>
upgrade_recovery = {
images: (
{
filename = <span class="hl-string">"recovery"</span>;
device = <span class="hl-string">"/dev/mmcblk0p10"</span>;
type = <span class="hl-string">"raw"</span>; <em class="hl-comment">//eMMC 存储介质</em>
sha256 = <span class="hl-string">"@recovery"</span>;
}
);
<em class="hl-comment">/*
* Some key env variables:
* swu_boardname: The selected board name. Here is "stable"
* swu_entry: The upgrade entry selection. Value can be
* "upgrade_recovery" and "upgrade_kernel"
* boot_os: SPL Falcon mode flag. Should be set to "no"
* during OTA
* swu_status: OTA status flag, Value can be "progress",
* "finish"
* swu_reboot: When this flag is set to "yes", the
* system will be reboot when all works done for current
* stage.
*/</em>
bootenv: (
{
name = <span class="hl-string">"swu_entry"</span>;
value = <span class="hl-string">"upgrade_kernel"</span>;
},
{
name = <span class="hl-string">"boot_partition"</span>;
value = <span class="hl-string">"recovery"</span>;
},
{
name = <span class="hl-string">"boot_os"</span>;
value = <span class="hl-string">"no"</span>;
},
{
name = <span class="hl-string">"swu_status"</span>;
value = <span class="hl-string">"progress"</span>;
},
{
name = <span class="hl-string">"swu_reboot"</span>;
value = <span class="hl-string">"yes"</span>;
}
);
};
<em class="hl-comment">/*
* upgrade_recovery stage:
* Running in main system, and upgrade the "recovery" partition,
* then reboot to the new recovery system
* Step1: Download image and upgrade the "recovery" partition
* Step2: Setup bootenv "swu_entry, boot_partition, boot_os, swu_status"
* Step3: Reboot to the new recovery system to run "upgrade_kernel"
*/</em>
upgrade_kernel = {
images: (
{
filename = <span class="hl-string">"logo"</span>;
device = <span class="hl-string">"/dev/mmcblk0p8"</span>;
type = <span class="hl-string">"raw"</span>;
sha256 = <span class="hl-string">"@logo"</span>;
},
{
filename = <span class="hl-string">"kernel"</span>;
device = <span class="hl-string">"/dev/mmcblk0p9"</span>;
type = <span class="hl-string">"raw"</span>;
sha256 = <span class="hl-string">"@kernel"</span>;
},
{
filename = <span class="hl-string">"rootfs"</span>;
device = <span class="hl-string">"/dev/mmcblk0p11"</span>;
type = <span class="hl-string">"raw"</span>;
installed-directly = true; <em class="hl-comment">//使用流控方式</em>
sha256 = <span class="hl-string">"@rootfs"</span>;
}
);
bootenv: (
{
name = <span class="hl-string">"boot_partition"</span>;
value = <span class="hl-string">"kernel"</span>;
},
{
name = <span class="hl-string">"swu_param"</span>;
value = <span class="hl-string">""</span>;
},
{
name = <span class="hl-string">"swu_boardname"</span>;
value = <span class="hl-string">""</span>;
},
{
name = <span class="hl-string">"swu_entry"</span>;
value = <span class="hl-string">""</span>;
},
{
name = <span class="hl-string">"swu_status"</span>;
value = <span class="hl-string">"finish"</span>;
},
{
name = <span class="hl-string">"swu_reboot"</span>;
value = <span class="hl-string">"yes"</span>;
}
);
};
};
}</pre></div>
</li></ul>
</section><section class="- topic/section section" id="id__ota-swupdate-pack-swu" data-ofbid="id__ota-swupdate-pack-swu"><h2 class="- topic/title title sectiontitle">OTA 升级包生成工具 <span class="+ topic/ph sw-d/filepath ph filepath">swupdate_pack_swu</span></h2>
<p class="- topic/p p" data-ofbid="d166364e223__20250121171618">制作 OTA 升级包通过功能命令 <span class="+ topic/keyword sw-d/cmdname keyword cmdname">swupdate_pack_swu</span>,相关文件路径为
<span class="+ topic/ph sw-d/filepath ph filepath">target/d211/common/post-image.sh</span></p>
<p class="- topic/p p" data-ofbid="d166364e232__20250121171618"><span class="+ topic/keyword sw-d/cmdname keyword cmdname">swupdate_pack_swu</span> 调用 <span class="+ topic/keyword sw-d/cmdname keyword cmdname">cpio</span> 命令进行打包。在主系统编译完成后,自动执行
<span class="+ topic/keyword sw-d/cmdname keyword cmdname">swupdate_pack_swu</span> 命令生成
<span class="+ topic/ph sw-d/filepath ph filepath">&lt;board&gt;.swu</span></p>
<p class="- topic/p p" data-ofbid="d166364e246__20250121171618">OTA 包组成:</p>
<figure class="- topic/fig fig fignone" data-ofbid="d166364e249__20250121171618"><br/><div class="imagecenter"><img class="- topic/image image imagecenter" src="../../../images/ota/pack_swu.png" alt="pack_swu"/></div><br/></figure>
<div class="- topic/p p" data-ofbid="d166364e255__20250121171618">使用下列命令可以解压 OTA
包:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_itn_345_4dc" data-ofbid="id__codeblock_itn_345_4dc">cpio -idv &lt; xxx.swu</pre></div>
</section><section class="- topic/section section" id="id__swupdate-cmd-sh" data-ofbid="id__swupdate-cmd-sh"><h2 class="- topic/title title sectiontitle">升级脚本 <span class="+ topic/ph sw-d/filepath ph filepath">swupdate_cmd.sh</span></h2>
<p class="- topic/p p" data-ofbid="d166364e267__20250121171618">OTA 的升级由 SWUpdate 程序完成, 但是如何使用 SWUpdate 完成整个 OTA 流程,
需要一个应用程序对流程进行控制。<span class="+ topic/ph sw-d/filepath ph filepath">swupdate_cmd.sh</span> 脚本就是一个 OTA 流程控制脚本。</p>
<p class="- topic/p p" data-ofbid="d166364e273__20250121171618"><span class="+ topic/ph sw-d/filepath ph filepath">swupdate_cmd.sh</span> 脚本路径为
<span class="+ topic/ph sw-d/filepath ph filepath">package/third-party/swupdate/swupdate_cmd.sh</span>,主要功能如下:</p>
<ol class="- topic/ol ol arabic simple" data-ofbid="d166364e281__20250121171618"><li class="- topic/li li" data-ofbid="d166364e282__20250121171618">
<p class="- topic/p p" data-ofbid="d166364e284__20250121171618">触发和进入 OTA 升级。</p>
</li><li class="- topic/li li" data-ofbid="d166364e287__20250121171618">
<p class="- topic/p p" data-ofbid="d166364e289__20250121171618">生成和传递合适的参数给 SWUpdate 程序。</p>
</li><li class="- topic/li li" data-ofbid="d166364e292__20250121171618">
<p class="- topic/p p" data-ofbid="d166364e294__20250121171618">阶段升级完成后,控制系统重启。</p>
</li></ol>
<p class="- topic/p p" data-ofbid="d166364e298__20250121171618"><span class="+ topic/ph sw-d/filepath ph filepath">swupdate_cmd.sh</span> 功能实现细节如下所示:</p>
<ul class="- topic/ul ul" id="id__ul_jyn_5tw_5dc" data-ofbid="id__ul_jyn_5tw_5dc"><li class="- topic/li li" data-ofbid="d166364e305__20250121171618">
<div class="- topic/div div section" id="id__id2">
<div class="- topic/p p" data-ofbid="d166364e309__20250121171618"><strong class="+ topic/ph hi-d/b ph b">启动升级脚本命令解析</strong><pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_mj4_dsw_fdc" data-ofbid="id__codeblock_mj4_dsw_fdc">swupdate_cmd()
{
<strong class="hl-keyword">while</strong> true
<strong class="hl-keyword">do</strong>
swu_param=$(fw_printenv -n swu_param <span class="hl-number">2</span>&gt;/dev/null)
swu_boardname=$(fw_printenv -n swu_boardname <span class="hl-number">2</span>&gt;/dev/null)
swu_entry=$(fw_printenv -n swu_entry <span class="hl-number">2</span>&gt;/dev/null)
swu_version=$(fw_printenv -n swu_version <span class="hl-number">2</span>&gt;/dev/null) # 从 env 环境变量里面读取 swu 相关环境变量
echo <span class="hl-string">"swu_param: ##$swu_param##"</span>
echo <span class="hl-string">"swu_boardname: ##$swu_boardname##"</span>
echo <span class="hl-string">"swu_entry: ##$swu_entry##"</span>
check_version_para=<span class="hl-string">""</span>
[ x<span class="hl-string">"$swu_version"</span> != x<span class="hl-string">""</span> ] &amp;&amp; { # 解析 swu_version
echo <span class="hl-string">"now version is $swu_version"</span>
check_version_para=<span class="hl-string">"-N $swu_version"</span>
}
[ x<span class="hl-string">"$swu_entry"</span> = x<span class="hl-string">""</span> ] &amp;&amp; { # 如果$swu_entry 为空, 跳出 swupdate_cmd 函数
echo <span class="hl-string">"no swupdate_cmd to run, wait for reboot swupdate"</span>
<strong class="hl-keyword">return</strong>
}
echo <span class="hl-string">"###now do swupdate###"</span>
echo <span class="hl-string">"##swupdate -v$swu_param -e "</span>$swu_boardname,$swu_entry<span class="hl-string">" ##"</span>
swupdate -v$swu_param -e <span class="hl-string">"$swu_boardname,$swu_entry"</span>
# 执行具体的升级过程
swu_reboot=$(fw_printenv -n swu_reboot <span class="hl-number">2</span>&gt;/dev/null)
echo <span class="hl-string">"swu_reboot: ##$swu_reboot##"</span>
<strong class="hl-keyword">if</strong> [ x<span class="hl-string">"$swu_reboot"</span> = <span class="hl-string">"xyes"</span> ]; then # $swu_reboot == yes 强制重启
fw_setenv swu_reboot
reboot -f
fi
sleep <span class="hl-number">1</span>
done
}
# 当$swu_entry 为空, 跳转到此处执行程序
mkdir -p /var/lock
# 读取传递的参数信息,写入到环境变量里面
[ $# -ne <span class="hl-number">0</span> ] &amp;&amp; {
echo <span class="hl-string">"config new swupdate"</span>
swu_input=$*
echo <span class="hl-string">"swu_input: ##$swu_input##"</span>
swu_param=$(echo <span class="hl-string">" $swu_input"</span> | sed -E <span class="hl-string">'s/ -e +[^ ]*//'</span>)
# echo <span class="hl-string">"swu_param: ##$swu_param##"</span>
echo <span class="hl-string">"swu_param=$swu_param"</span> &gt; /tmp/swupdate_param_file
swu_param_e=$(echo <span class="hl-string">" $swu_input"</span> | awk -F <span class="hl-string">' -e '</span> <span class="hl-string">'{print $2}'</span>)
swu_param_e=$(echo <span class="hl-string">"$swu_param_e"</span> | awk -F <span class="hl-string">' '</span> <span class="hl-string">'{print $1}'</span>)
swu_boardname=$(echo <span class="hl-string">"$swu_param_e"</span> | awk -F <span class="hl-string">','</span> <span class="hl-string">'{print $1}'</span>)
# echo <span class="hl-string">"swu_boardname: ##$swu_boardname##"</span>
echo <span class="hl-string">"swu_boardname=$swu_boardname"</span> &gt;&gt; /tmp/swupdate_param_file
swu_entry=$(echo <span class="hl-string">"$swu_param_e"</span> | awk -F <span class="hl-string">','</span> <span class="hl-string">'{print $2}'</span>)
# echo <span class="hl-string">"swu_entry: ##$swu_entry##"</span>
echo <span class="hl-string">"swu_entry=$swu_entry"</span> &gt;&gt; /tmp/swupdate_param_file
fw_setenv -s /tmp/swupdate_param_file
# 一次写入所有的环境变量,延长存储介质寿命
sync
echo <span class="hl-string">"## set swupdate_param done ##"</span>
}
swupdate_cmd
# 跳转到 swupdate_cmd 执行程序</pre></div>
</div>
</li><li class="- topic/li li" data-ofbid="d166364e316__20250121171618">
<div class="- topic/div div section" id="id__id3"><strong class="+ topic/ph hi-d/b ph b">主系统下启动升级命令过程</strong>
<p class="- topic/p p" data-ofbid="d166364e322__20250121171618">当带参调用 <span class="+ topic/ph sw-d/filepath ph filepath">swupdate_cmd.sh</span> 时,脚本取出 “-e xxx,yyy” 部分信息并保存到
<span class="+ topic/keyword pr-d/parmname keyword parmname">swu_boardname</span><span class="+ topic/keyword pr-d/parmname keyword parmname">swu_entry</span>
环境变量,将其余参数原样保存到 <span class="+ topic/keyword pr-d/parmname keyword parmname">swu_param</span> 环境变量。</p><p class="- topic/p p" data-ofbid="d166364e336__20250121171618">SPINAND
主系统下启动升级命令:</p><pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_otq_yrw_fdc" data-ofbid="id__codeblock_otq_yrw_fdc">./usr/lib/swupdate/swupdate_cmd.sh -i /mnt/ota/d211_per2_spinand.swu -e stable,upgrade_recovery</pre><p class="- topic/p p" data-ofbid="d166364e340__20250121171618">自动调用
<code class="+ topic/ph pr-d/codeph ph codeph">swupdate $swu_param -e “$swu_boardname,$
swu_entry”</code>启动升级。</p>
</div>
</li><li class="- topic/li li" data-ofbid="d166364e347__20250121171618">
<div class="- topic/div div section" id="id__recovery"><strong class="+ topic/ph hi-d/b ph b">Recovery 系统下启动升级命令过程</strong>
<p class="- topic/p p" data-ofbid="d166364e353__20250121171618">当不带参调用 <span class="+ topic/ph sw-d/filepath ph filepath">swupdate_cmd.sh</span> 时,脚本从 env 读取
“swu_boardname”、“swu_entry” 和 “swu_param” 环境变量。</p><p class="- topic/p p" data-ofbid="d166364e358__20250121171618">SPINAND Recovery
系统下自动启动升级命令
<code class="+ topic/ph pr-d/codeph ph codeph">./usr/lib/swupdate/swupdate_cmd.sh</code></p><p class="- topic/p p" data-ofbid="d166364e363__20250121171618">自动调用
<code class="+ topic/ph pr-d/codeph ph codeph">swupdate $swu_param -e “$swu_boardname,$ swu_entry”</code>
启动升级。</p>
</div>
</li><li class="- topic/li li" data-ofbid="d166364e370__20250121171618">
<div class="- topic/div div section" id="id__id4"><strong class="+ topic/ph hi-d/b ph b">升级过程中的重启实现</strong>
<p class="- topic/p p" data-ofbid="d166364e376__20250121171618">当主系统或者 Recovery 系统对应的程序升级完成以后,在 <span class="+ topic/ph sw-d/filepath ph filepath">sw-description</span> 文件中设置
swu_reboot =yes。<span class="+ topic/ph sw-d/filepath ph filepath">swupdate_cmd.sh</span>
在检测到该值以后会调用重启命令。</p></div>
</li><li class="- topic/li li" data-ofbid="d166364e385__20250121171618">
<div class="- topic/div div section" id="id__id5"><strong class="+ topic/ph hi-d/b ph b">环境变量其它用法</strong>
<p class="- topic/p p" data-ofbid="d166364e391__20250121171618">如需传递其它信息,比如 WIFI 密码和 IP 地址,可修改 <span class="+ topic/ph sw-d/filepath ph filepath">swupdate_cmd.sh</span> 文件,在
<span class="+ topic/ph sw-d/filepath ph filepath">env.txt </span> 中添加设置对应。</p></div>
</li></ul>
</section></div></article></main></div>
</div>
<nav role="navigation" id="wh_topic_toc" aria-label="On this page" class="col-lg-2 d-none d-lg-block navbar d-print-none">
<div id="wh_topic_toc_content">
<div class=" wh_topic_toc "><div class="wh_topic_label">在本页上</div><ul><li class="section-item"><div class="section-title"><a href="#id__ota-sw-images-cfg" data-tocid="id__ota-sw-images-cfg">OTA 升级包配置文件:<span class="+ topic/ph sw-d/filepath ph filepath">sw-images.cfg</span></a></div></li><li class="section-item"><div class="section-title"><a href="#id__ota-sw-description" data-tocid="id__ota-sw-description">OTA 策略描述文件: <span class="+ topic/ph sw-d/filepath ph filepath">sw-description</span></a></div></li><li class="section-item"><div class="section-title"><a href="#id__ota-swupdate-pack-swu" data-tocid="id__ota-swupdate-pack-swu">OTA 升级包生成工具 <span class="+ topic/ph sw-d/filepath ph filepath">swupdate_pack_swu</span></a></div></li><li class="section-item"><div class="section-title"><a href="#id__swupdate-cmd-sh" data-tocid="id__swupdate-cmd-sh">升级脚本 <span class="+ topic/ph sw-d/filepath ph filepath">swupdate_cmd.sh</span></a></div></li></ul></div>
</div>
</nav>
</div>
</div>
</div>
<footer class="navbar navbar-default wh_footer">
<div class=" footer-container mx-auto ">
<title>footer def</title>
<style><!--
.p1 {
font-family: FangZhengShuSong, Times, serif;
}
.p2 {
font-family: Arial, Helvetica, sans-serif;
}
.p3 {
font-family: "Lucida Console", "Courier New", monospace;
}
--></style>
<div class="webhelp.fragment.footer">
<p class="p1">Copyright © 2019-2024 广东匠芯创科技有限公司. All rights reserved.</p>
</div><div>
<div class="generation_time">
Update Time: 2025-01-21
</div>
</div>
</div>
</footer>
<div id="go2top" class="d-print-none">
<span class="oxy-icon oxy-icon-up"></span>
</div>
<div id="modal_img_large" class="modal">
<span class="close oxy-icon oxy-icon-remove"></span>
<div id="modal_img_container"></div>
<div id="caption"></div>
</div>
<script src="${pd}/publishing/publishing-styles-AIC-template/js/custom.js" defer="defer"></script>
</body>
</html>