IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 嵌入式 -> YoC RTOS 实战:FOTA系统升级 -> 正文阅读

[嵌入式]YoC RTOS 实战:FOTA系统升级

1. 准备工作

建议在操作前先阅读以下技术文章:
Lichee D1 dock 开发板用户指南
Lichee D1 dock 开发板快速上手教程

2. 示例介绍

本文介绍如何在D1开发板上进行FOTA升级。

FOTA 是 Firmware Over the Air 的缩写,即固件空中升级,最常见的就是手机固件的升级。固件的定义范围比较模糊,windows操作系统升级、手机升级、嵌入式系统、单片机控制程序等都的远程升级可以笼统地称为FOTA。用这种方式,设备厂商可以更加快速地进行系统软件的迭代;能够更加快速地向市场推出具有新功能的设备并以此提高用户对其设备的满意度。

下面我们以fota_demo为例来介绍如何进行FOTA升级。

3. 示例获取

3.1 通过剑池CDK(以下简称CDK)获取
双击打开CDK,点击工具栏最右侧的平头哥图标。点击新建工程按钮。

在搜索栏里输入fota_demo, 在结果里选择fota_demo,点击右侧的创建工程,版本选择v7.5.1。

3.2 通过命令行获取

docker-ubuntu18:~$ mkdir test
docker-ubuntu18:~$ cd test
docker-ubuntu18:~$ yoc init
docker-ubuntu18:~$ yoc install sdk_app_d1 -b v7.5.1
Start to install components...
sdk_app_d1      (v7.5.1), clone https://gitee.com/yocop/sdk_app_d1.git ...
…… (省略) ……
d1_evb          (v7.5.1), clone https://gitee.com/yocop/d1_evb.git ...
chip_d1         (v7.5.1), clone https://gitee.com/yocop/chip_d1.git ...
Download components finish.
docker-ubuntu18:~/test$ ls
boards  components  solutions

4. 示例演示

我们分成3个大的步骤进行介绍:

  • 不同版本固件的生成
  • OCC固件添加,升级策略配置
  • 设备端配置参数,下载固件并进行系统的升级

请注意:以下出现的方案目录指的是solutions/fota_demo这个文件夹下。

4.1 编译生成不同版本固件
4.1.1 基础镜像包1.0.0生成
在示例获取那个章节我们已经把fota_demo工程拉取下来了,接下来我们要编译这个工程并生成相应的镜像包。

如下图所示,点击红色方框处按钮进行编译。

编译结束之后,会在方案目录的generated下生成images.zip包。

如下所示,打开方案目录。将这个images.zip拷贝到上级目录(方案目录)并重命名为images_1.0.0.zip。

4.1.2 镜像包1.1.1版本生成
可以在方案的app/src/app_main.c文件中加个打印保存文件,并重新编译。将生成的generated/images.zip拷贝到方案目录,并重命名为images_1.1.1.zip,作为高版本。

4.2 OCC版本管理
4.2.1 创建产品,获取许可证
注册登陆平头哥芯片开放社区(OCC)后,进入到控制台中

在平头哥芯片开发社区上创建产品,在控制台->我的产品->添加产品,如下图所示,点击提交按钮。

点击编辑按钮

选择许可证, 点击生成按钮,稍等刷新下即可

如下图所示,表示开发许可证已经生成完毕

4.2.2 上传镜像包至OCC服务器,并发布
在我的产品->编辑->FOTA页面选择添加固件

点击提交按钮

点击红色方框

点击发布按钮

返回之后,发布状态就会变成已发布,如果状态未变,可以再次刷新下。

发布1.1.1版本

提交完毕之后,选择1.1.1版本那一行进行发布。发布成功之后,服务器就会生成FOTA固件了。

4.2.3 云端选择升级策略
如右边红色框框,添加标签:

下图中的CID的值后面需要用到,请先记录下来

选择升级策略:

选择刚才写的标签,并提交:

到此为止,云端的配置基本结束了。

4.3 设备检测升级
4.3.1 将发布的镜像包下载到本地
点击红色框图位置下载镜像包到本地

4.3.2 基础版本固件烧录
选择通过CDK或者全志工具进行烧录。

  • 通过CDK烧录
    将下载过来的镜像包解压,并从hex目录取出total_image.hex文件,放到方案目录的generated目录下。

切换到CDK工程,点击红色方框处按钮开始烧录。

烧录过程中。。。

烧录完毕

  • 通过全志工具烧录

比如从OCC上下载过了的压缩包名字为xx_factory.zip。在方案目录下,打开Windows的cmd环境,执行以下命令:packimg_win.bat xx_factory.zip,执行成功之后会有提示:Create yoc_rtos_xx_factory_16M.img in out directory Success!。然后通过全志烧录工具把yoc_rtos_xx_factory_16M.img进行烧录到开发板。

按住FEL按钮,重新上电后,重启后固件开始烧录,直到完成。

如果当前镜像支持xfex模式烧写,直接在串口命令行执行“xfex"命令,再执行"reboot"命令进行重启,重启后固件开始烧录,直到完成。

按复位键启动的打印如下,可以看到当前的版本为1.0.0的版本

###YoC###[Feb 15 2022,11:10:45]
cpu clock is 1008000000Hz
[   0.360]<I>init app_init.c[62]: find 9 partitions
[   0.370]<I>init app_init.c[36]: filesystem init ok.
[   0.380]<D>WIFI l8723ds_devops.c[1595]: Init WLAN enable

[   0.480]<D>WIFI_IO wifi_io.c[255]: __sdio_bus_probe
SD:mmc_card_create card:0x4025dec0 id:1
[ERR] SDC:__mci_irq_handler,879 raw_int:100 err!
[ERR] SDC:SDC err, cmd 8, [ERR] SDC:sdc 663 abnormal status: RespErr
SD:sd1.0 or mmc
SD:***** Try sdio *****
[WRN] SD:card claims to support voltages below the defined range.These will be ignored.
SD:sdio highspeed 
SD:mmc_sdio_init_card bus width type:2
SD:
============= card information ==============
SD:Card Type     : SDIO
SD:Card Spec Ver : 1.0
SD:Card RCA      : 0x0001 
SD:Card OCR      : 0x90ffffff
SD:    vol_window  : 0x00ffffff
SD:    to_1v8_acpt : 1
SD:    high_capac  : 1
SD:Card CSD      :
SD:    speed       : 50000 KHz
SD:    cmd class   : 0x0
SD:    capacity    : 0MB
SD:Card CUR_STA  :
SD:    speed_mode  : DS: 25 MHz
SD:    bus_width   : 2
SD:    speed_class : 0
SD:=============================================
SD:***** sdio init ok *****
[   0.610]<I>app_fota cop_fota.c[165]: ver=============> 1.0.0-20220215.1431-R-d1fota
[   0.620]<I>netmgr netmgr_service.c[316]: start wifi
[   0.620]<I>app_fota cop_fota.c[166]: deviceid========> (null)
[   0.630]<D>WiFiCONF wifi_conf.c[1392]: WIFI is not running
[   0.640]<I>app_fota cop_fota.c[167]: model===========> (null)
[   0.640]<I>netmgr_wifi netmgr_wifi.c[52]: ssid{SSID_Undef}, psk{}

[   0.650]<D>fota fota.c[62]: fota: 0x40277eb8 path:flash://misc
[   0.660]<D>WiFiCONF wifi_conf.c[1392]: WIFI is not running
[   0.680]<D>WiFiCONF wifi_conf.c[1314]: Initializing WIFI ...
[   0.710]<D>WIFI_IO wifi_io.c[143]: sdio_irq_thread enter IRQ routine
[   3.270]<D>WiFiCONF wifi_conf.c[1334]: WIFI initialized

[   3.270]<D>WiFiCONF wifi_conf.c[1373]: a2dp_case_wifi_slot: 35
[   4.610]<E>WIFI l8723ds_devops.c[570]: ERROR: STA Task, wifi connect failed! try another

4.3.3 设备端设置deivce_id/model,接收固件**

我们需要设置一些参数才能联网并且接受新的固件。

  • WiFi设置

通过串口终端输入:

kv set wifi_ssid <your_wifi_ssid>
kv set wifi_psk <your_wifi_password>

your_wifi_ssid:你的wifi名字
your_wifi_password:你的wifi密码

  • 设备信息设置

通过串口终端输入:

kv set device_id <cid>
kv set model d1fota

cid:即4.2.3章节图片中提到的CID的值
model:即4.1章节中的产品型号值

设置完毕之后按开发板上的复位键重启。

4.3.4 设备端完成固件接收,进入系统升级
请确保设备联网成功。

设备检测到新版本的打印:

###YoC###[Feb 15 2022,11:10:45]
cpu clock is 1008000000Hz
[   0.360]<I>init app_init.c[62]: find 9 partitions
[   0.370]<I>init app_init.c[36]: filesystem init ok.
[   0.370]<D>WIFI l8723ds_devops.c[1595]: Init WLAN enable

[   0.480]<D>WIFI_IO wifi_io.c[255]: __sdio_bus_probe
SD:mmc_card_create card:0x4025dec0 id:1
[ERR] SDC:__mci_irq_handler,879 raw_int:100 err!
[ERR] SDC:SDC err, cmd 8, [ERR] SDC:sdc 663 abnormal status: RespErr
SD:sd1.0 or mmc
SD:***** Try sdio *****
[WRN] SD:card claims to support voltages below the defined range.These will be ignored.
SD:sdio highspeed 
SD:mmc_sdio_init_card bus width type:2
SD:
============= card information ==============
SD:Card Type     : SDIO
SD:Card Spec Ver : 1.0
SD:Card RCA      : 0x0001 
SD:Card OCR      : 0x90ffffff
SD:    vol_window  : 0x00ffffff
SD:    to_1v8_acpt : 1
SD:    high_capac  : 1
SD:Card CSD      :
SD:    speed       : 50000 KHz
SD:    cmd class   : 0x0
SD:    capacity    : 0MB
SD:Card CUR_STA  :
SD:    speed_mode  : DS: 25 MHz
SD:    bus_width   : 2
SD:    speed_class : 0
SD:=============================================
SD:***** sdio init ok *****
[   0.610]<I>app_fota cop_fota.c[165]: ver=============> 1.0.0-20220215.1431-R-d1fota
[   0.620]<I>netmgr netmgr_service.c[316]: start wifi
[   0.620]<I>app_fota cop_fota.c[166]: deviceid========> d17dd3720440000030e8aeb4e9b0e3f2
[   0.630]<D>WiFiCONF wifi_conf.c[1392]: WIFI is not running
[   0.640]<I>app_fota cop_fota.c[167]: model===========> d1fota
[   0.640]<I>netmgr_wifi netmgr_wifi.c[52]: ssid{TEST2}, psk{TEST1234}

[   0.650]<D>fota fota.c[62]: fota: 0x40277eb8 path:flash://misc
[   0.660]<D>WiFiCONF wifi_conf.c[1392]: WIFI is not running
[   0.680]<D>WiFiCONF wifi_conf.c[1314]: Initializing WIFI ...
[   0.710]<D>WIFI_IO wifi_io.c[143]: sdio_irq_thread enter IRQ routine
[   3.270]<D>WiFiCONF wifi_conf.c[1334]: WIFI initialized

[   3.270]<D>WiFiCONF wifi_conf.c[1373]: a2dp_case_wifi_slot: 35
[  10.940]<E>WIFI l8723ds_devops.c[570]: ERROR: STA Task, wifi connect failed! try another
[  12.270]<D>WIFI l8723ds_devops.c[1127]: scan done!

[  13.450]<D>WIFI l8723ds_devops.c[408]: Wait for 4-way handshake

[  13.510]<D>WIFI l8723ds_devops.c[386]: @@@@@@@@@@@@@@ Connection Success @@@@@@@@@@@@@@

[  13.520]<I>netmgr netmgr_service.c[187]: start dhcp
[  13.600]<I>netmgr netmgr_service.c[211]: IP: 172.20.10.3
[  13.610]<I>init app_wifi.c[26]: Got IP
[  13.610]<I>init app_wifi.c[33]: NTP Start
[  13.780]<D>NTP ntp.c[194]: ntp1.aliyun.com
[  13.830]<D>NTP ntp.c[251]: NTP sec: 1644907747 usec: 824016
[  13.840]<D>NTP ntp.c[276]: sync success
[  13.840]<I>init app_wifi.c[41]: NTP Success

开始下载数据:

[15:48:50:777][  36.650]<D>NTP ntp.c[194]: ntp1.aliyun.com
[15:48:50:830][  36.700]<D>NTP ntp.c[251]: NTP sec: 1644911331 usec: 497327
[15:48:50:830][  36.700]<D>NTP ntp.c[276]: sync success
[15:48:50:843][  36.710]<I>init app_wifi.c[41]: NTP Success
[15:48:50:843][  36.710]<D>fota fota.c[373]: fota do check signal........
[15:48:50:854][  36.720]<D>fota fota.c[196]: fota_task start: flash://misc
[15:48:50:854][  36.720]<D>fota fota.c[199]: fota_task FOTA_INIT! wait......
[15:48:50:867][  36.730]<D>app_fota cop_fota.c[61]: FOTA START :1
[15:48:50:879][  36.740]<D>fotacop fota_cop.c[226]: check: {"cid":"d17dd3720440000030e8aeb4e9b0e3f2","model":"d1fota","version":"1.0.0-20220215.1431-R-d1fota"}
[15:48:50:880][  36.750]<D>fotacop fota_cop.c[230]: ota url:http://occ.t-head.cn/api/image/ota/pull
[15:48:50:891][  36.760]<D>fotacop fota_cop.c[237]: http client init start.
[15:48:50:891][  36.760]<D>HTTP_CLIENT http_client.c[779]: ###path:/api/image/ota/pull
[15:48:50:903][  36.770]<D>HTTP_CLIENT http_client.c[788]: New path assign = /api/image/ota/pull
[15:48:50:903][  36.780]<D>fotacop fota_cop.c[244]: http client init ok.
[15:48:50:915][  36.780]<D>HTTP_CLIENT http_client.c[1047]: Begin connect to: http://occ.t-head.cn:80
[15:48:50:963][  36.830]<D>TRANS_TCP transport_tcp.c[83]: [sock=20],connecting to server IP:203.119.214.112,Port:80...
[15:48:51:074][  36.940]<D>fotacop fota_cop.c[68]: HTTP_EVENT_ON_CONNECTED
[15:48:51:086][  36.950]<D>HTTP_CLIENT http_client.c[1159]: Write header[6]: POST /api/image/ota/pull HTTP/1.1
[15:48:51:086]User-Agent: CK HTTP Client/1.0
[15:48:51:086]Host: occ.t-head.cn
[15:48:51:086]Content-Type: application/json
[15:48:51:086]Connection: keep-alive
[15:48:51:096]Cache-Control: no-cache
[15:48:51:096]Content-Length: 100
[15:48:51:096]
[15:48:51:096]
[15:48:51:096][  36.970]<D>fotacop fota_cop.c[71]: HTTP_EVENT_HEADER_SENT
[15:48:51:105][  36.970]<D>fotacop fota_cop.c[169]: write payload ok...
[15:48:51:324][  37.190]<D>HTTP_CLIENT http_client.c[184]: on_message_begin
[15:48:51:336][  37.200]<D>HTTP_CLIENT http_client.c[226]: HEADER=Date:Tue, 15 Feb 2022 07:48:51 GMT
[15:48:51:337][  37.210]<D>HTTP_CLIENT http_client.c[226]: HEADER=Content-Type:application/json;charset=utf-8
[15:48:51:347][  37.210]<D>HTTP_CLIENT http_client.c[226]: HEADER=Content-Length:278
[15:48:51:357][  37.220]<D>HTTP_CLIENT http_client.c[226]: HEADER=Connection:keep-alive
[15:48:51:358][  37.230]<D>HTTP_CLIENT http_client.c[226]: HEADER=Set-Cookie:XSRF-TOKEN=b488eb10-8cda-4c58-8dea-756581a6b074; Path=/
[15:48:51:369][  37.240]<D>HTTP_CLIENT http_client.c[226]: HEADER=X-Content-Type-Options:nosniff
[15:48:51:382][  37.240]<D>HTTP_CLIENT http_client.c[226]: HEADER=X-XSS-Protection:1; mode=block
[15:48:51:392][  37.250]<D>HTTP_CLIENT http_client.c[226]: HEADER=Cache-Control:no-cache, no-store, max-age=0, must-revalidate
[15:48:51:392][  37.260]<D>HTTP_CLIENT http_client.c[226]: HEADER=Pragma:no-cache
[15:48:51:402][  37.270]<D>HTTP_CLIENT http_client.c[226]: HEADER=Expires:0
[15:48:51:403][  37.270]<D>HTTP_CLIENT http_client.c[226]: HEADER=X-Frame-Options:DENY
[15:48:51:413][  37.280]<D>HTTP_CLIENT http_client.c[226]: HEADER=Server:Tengine/Aserver
[15:48:51:424][  37.290]<D>HTTP_CLIENT http_client.c[226]: HEADER=EagleEye-TraceId:0b8879b916449113318991107e26a7
[15:48:51:424][  37.290]<D>HTTP_CLIENT http_client.c[226]: HEADER=Timing-Allow-Origin:*
[15:48:51:435][  37.300]<D>HTTP_CLIENT http_client.c[244]: http_on_headers_complete, status=200, offset=495, nread=495
[15:48:51:447][  37.310]<D>HTTP_CLIENT http_client.c[267]: http_on_message_complete, parser=0x402780c0
[15:48:51:447][  37.320]<D>HTTP_CLIENT http_client.c[1023]: content_length = 278
[15:48:51:457][  37.320]<D>fotacop fota_cop.c[175]: header_ret:278
[15:48:51:457][  37.330]<D>fotacop fota_cop.c[177]: status code:200
[15:48:51:468][  37.330]<D>HTTP_CLIENT http_client.c[873]: is_data_remain=0, is_chunked=0, content_length=278
[15:48:51:480][  37.340]<D>fotacop fota_cop.c[260]: resp: {"result":{"size":840248,"version":"1.1.1-20220215.1435-R-d1fota","url":"https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/image/4014025440049041408/4014028368646844416/20220215143546783_update.imager","timestamp":1644906947},"msg":"","code":0,"requestId":"4014046784811765760"}
[15:48:51:502][  37.370]<D>fotacop fota_cop.c[275]: code: 0
[15:48:51:502][  37.370]<D>fotacop fota_cop.c[294]: version: 1.1.1-20220215.1435-R-d1fota
[15:48:51:514][  37.380]<D>fotacop fota_cop.c[303]: url: https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/image/4014025440049041408/4014028368646844416/20220215143546783_update.imager
[15:48:51:527][  37.400]<I>fotacop fota_cop.c[317]: continue fota :127
[15:48:51:538][  37.400]<D>fotacop fota_cop.c[331]: get url: https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/image/4014025440049041408/4014028368646844416/20220215143546783_update.imager
[15:48:51:549][  37.420]<D>fotacop fota_cop.c[83]: HTTP_EVENT_DISCONNECTED
[15:48:51:560][  37.420]<D>fota fota.c[90]: get image url: https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/image/4014025440049041408/4014028368646844416/20220215143546783_update.imager
[15:48:51:572][  37.440]<D>app_fota cop_fota.c[65]: FOTA VERSION CHECK :1
[15:48:51:572][  37.440]<D>app_fota cop_fota.c[83]: {"code":0,"timestamp":0}
[15:48:51:583][  37.450]<D>fota fota.c[115]: ###fota->from_path:https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/image/4014025440049041408/4014028368646844416/20220215143546783_update.imager, fota->to_path:flash://misc
[15:48:51:604][  37.470]<D>fota netio.c[36]: path:https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/image/4014025440049041408/4014028368646844416/20220215143546783_update.imager delim:://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/image/4014025440049041408/4014028368646844416/20220215143546783_update.imager
[15:48:51:618]
[15:48:51:626][  37.490]<D>fota-httpc httpc.c[266]: http open:https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/image/4014025440049041408/4014028368646844416/20220215143546783_update.imager
[15:48:51:638][  37.510]<D>fota netio.c[56]: open break,http
[15:48:51:638]
[15:48:51:638][  37.510]<D>fota netio.c[36]: path:flash://misc delim:://misc
[15:48:51:638]
[15:48:51:651][  37.520]<D>fota netio.c[56]: open break,flash
[15:48:51:651]
[15:48:51:658][  37.530]<I>fota fota.c[138]: FOTA seek 0
[15:48:51:658][  37.530]<D>fota fota.c[152]: fota prepare ok.
[15:48:51:669][  37.530]<D>fota fota.c[242]: fota_task download! wait......
[15:48:51:680][  37.540]<D>HTTP_CLIENT http_client.c[779]: ###path:/image/4014025440049041408/4014028368646844416/20220215143546783_update.imager
[15:48:51:691][  37.550]<D>HTTP_CLIENT http_client.c[788]: New path assign = /image/4014025440049041408/4014028368646844416/20220215143546783_update.imager
[15:48:51:702][  37.560]<D>fota-httpc httpc.c[178]: http client init ok.[https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/image/4014025440049041408/4014028368646844416/20220215143546783_update.imager]
[15:48:51:714][  37.580]<D>fota-httpc httpc.c[179]: http read connecting........
[15:48:51:714][  37.590]<D>fota-httpc httpc.c[193]: range:bytes=0-
[15:48:51:725][  37.590]<D>HTTP_CLIENT http_client.c[1047]: Begin connect to: https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com:443
[15:48:51:725][  37.600]<D>tls tls.c[362]: tls init...
[15:48:51:738][  37.600]<D>tls tls.c[375]: use_host:occ-oss-prod.oss-cn-hangzhou.aliyuncs.com, port:443
[15:48:51:813][  37.680]<D>tls tls.c[378]: _tls_net connect 0 
[15:48:51:813][  37.690]<D>tls tls.c[397]: tls connecting...
[15:48:51:820][  37.690]<D>tls tls.c[433]: handshake in progress...
[15:48:51:995][  37.860]<D>tls tls.c[477]: open new connection ok
[15:48:51:995][  37.870]<D>fota-httpc httpc.c[29]: HTTP_EVENT_ON_CONNECTED
[15:48:52:006][  37.870]<D>HTTP_CLIENT http_client.c[1159]: Write header[6]: GET /image/4014025440049041408/4014028368646844416/20220215143546783_update.imager HTTP/1.1
[15:48:52:017]User-Agent: CK HTTP Client/1.0
[15:48:52:017]Host: occ-oss-prod.oss-cn-hangzhou.aliyuncs.com
[15:48:52:017]Range: bytes=0-
[15:48:52:028]Connection: keep-alive
[15:48:52:028]Cache-Control: no-cache
[15:48:52:028]Content-Length: 0
[15:48:52:028]
[15:48:52:028]
[15:48:52:028][  37.900]<D>fota-httpc httpc.c[32]: HTTP_EVENT_HEADER_SENT
[15:48:52:038][  37.910]<D>TRANS_SSL transport_ssl.c[159]: ssl read...
[15:48:52:167][  38.040]<D>tls tls.c[81]: tls read...
[15:48:52:229][  38.100]<D>HTTP_CLIENT http_client.c[184]: on_message_begin
[15:48:52:241][  38.100]<D>HTTP_CLIENT http_client.c[226]: HEADER=Server:AliyunOSS
[15:48:52:241][  38.110]<D>HTTP_CLIENT http_client.c[226]: HEADER=Date:Tue, 15 Feb 2022 07:48:52 GMT
[15:48:52:252][  38.120]<D>HTTP_CLIENT http_client.c[226]: HEADER=Content-Type:application/octet-stream
[15:48:52:252][  38.120]<D>HTTP_CLIENT http_client.c[226]: HEADER=Content-Length:840248
[15:48:52:263][  38.130]<D>HTTP_CLIENT http_client.c[226]: HEADER=Connection:keep-alive
[15:48:52:274][  38.140]<D>HTTP_CLIENT http_client.c[226]: HEADER=x-oss-request-id:620B5AE494C77F3432880A98
[15:48:52:274][  38.150]<D>HTTP_CLIENT http_client.c[226]: HEADER=Content-Range:bytes 0-840247/840248
[15:48:52:285][  38.150]<D>HTTP_CLIENT http_client.c[226]: HEADER=Accept-Ranges:bytes
[15:48:52:296][  38.160]<D>HTTP_CLIENT http_client.c[226]: HEADER=ETag:"2D8F0BBB41F7090E7808A48F1152A303"
[15:48:52:307][  38.170]<D>HTTP_CLIENT http_client.c[226]: HEADER=Last-Modified:Tue, 15 Feb 2022 06:35:47 GMT
[15:48:52:307][  38.180]<D>HTTP_CLIENT http_client.c[226]: HEADER=x-oss-object-type:Normal
[15:48:52:319][  38.180]<D>HTTP_CLIENT http_client.c[226]: HEADER=x-oss-hash-crc64ecma:11891437651563570590
[15:48:52:319][  38.190]<D>HTTP_CLIENT http_client.c[226]: HEADER=x-oss-storage-class:Standard
[15:48:52:330][  38.200]<D>HTTP_CLIENT http_client.c[226]: HEADER=Content-MD5:LY8Lu0H3CQ54CKSPEVKjAw==
[15:48:52:340][  38.210]<D>HTTP_CLIENT http_client.c[226]: HEADER=x-oss-server-time:54
[15:48:52:352][  38.210]<D>HTTP_CLIENT http_client.c[244]: http_on_headers_complete, status=206, offset=532, nread=532
[15:48:52:352][  38.220]<D>HTTP_CLIENT http_client.c[1023]: content_length = 840248
[15:48:52:367][  38.230]<D>fota-httpc httpc.c[130]: header_ret:840248
[15:48:52:367][  38.230]<D>fota-httpc httpc.c[132]: status code:206
[15:48:52:367][  38.240]<D>fota-httpc httpc.c[227]: range_len: 840248
[15:48:52:374][  38.240]<D>HTTP_CLIENT http_client.c[873]: is_data_remain=1, is_chunked=0, content_length=840248
[15:48:52:386][  38.250]<D>TRANS_SSL transport_ssl.c[159]: ssl read...
[15:48:52:386][  38.250]<D>tls tls.c[81]: tls read...
[15:48:52:397][  38.260]<D>HTTP_CLIENT http_client.c[883]: need_read=532, byte_to_read=532, rlen=532, ridx=15852
[15:48:52:397][  38.270]<D>fota fota.c[250]: fota_task FOTA_DOWNLOAD! total:840248 offset:0
[15:48:52:405][  38.270]<D>fota fota.c[251]: ##read: 16384
[15:48:52:585][  38.450]<I>fota fota.c[312]: write size: 16384
[15:48:52:585][  38.460]<D>app_fota cop_fota.c[90]: FOTA PROGRESS :2, 16384, 840248
[15:48:52:599][  38.460]<D>app_fota cop_fota.c[131]: {"code":0,"total_size":840248,"cur_size":16384,"percent":1,"speed":0}
[15:48:52:606][  38.470]<D>fota fota.c[242]: fota_task download! wait......
[15:48:52:617][  38.480]<D>HTTP_CLIENT http_client.c[873]: is_data_remain=1, is_chunked=0, content_length=840248
[15:48:52:617][  38.490]<D>TRANS_SSL transport_ssl.c[159]: ssl read...
[15:48:52:628][  38.490]<D>TRANS_SSL transport_ssl.c[91]: remain data in cache, need to read again
[15:48:52:629][  38.500]<D>tls tls.c[81]: tls read...
[15:48:52:639][  38.500]<D>HTTP_CLIENT http_client.c[883]: need_read=16384, byte_to_read=16384, rlen=15852, ridx=0
[15:48:52:651][  38.510]<D>HTTP_CLIENT http_client.c[873]: is_data_remain=1, is_chunked=0, content_length=840248
[15:48:52:652][  38.520]<D>TRANS_SSL transport_ssl.c[159]: ssl read...
[15:48:52:652][  38.520]<D>tls tls.c[81]: tls read...
[15:48:52:667][  38.530]<D>HTTP_CLIENT http_client.c[883]: need_read=532, byte_to_read=532, rlen=532, ridx=15852
[15:48:52:672][  38.540]<D>fota fota.c[250]: fota_task FOTA_DOWNLOAD! total:840248 offset:16384
[15:48:52:672][  38.540]<D>fota fota.c[251]: ##read: 16384
[15:48:52:857][  38.720]<I>fota fota.c[312]: write size: 16384
[15:48:52:857][  38.730]<D>app_fota cop_fota.c[90]: FOTA PROGRESS :2, 32768, 840248
[15:48:52:869][  38.740]<D>app_fota cop_fota.c[116]: interval time: 280 ms
[15:48:52:880][  38.740]<D>app_fota cop_fota.c[131]: {"code":0,"total_size":840248,"cur_size":32768,"percent":3,"speed":57}
[15:48:52:880][  38.750]<D>fota fota.c[242]: fota_task download! wait......
[15:48:52:890][  38.760]<D>HTTP_CLIENT http_client.c[873]: is_data_remain=1, is_chunked=0, content_length=840248
[15:48:52:890][  38.760]<D>TRANS_SSL transport_ssl.c[159]: ssl read...
[15:48:52:901][  38.770]<D>TRANS_SSL transport_ssl.c[91]: remain data in cache, need to read again
[15:48:52:901][  38.780]<D>tls tls.c[81]: tls read...
[15:48:52:913][  38.780]<D>HTTP_CLIENT http_client.c[883]: need_read=16384, byte_to_read=16384, rlen=15852, ridx=0
[15:48:52:923][  38.790]<D>HTTP_CLIENT http_client.c[873]: is_data_remain=1, is_chunked=0, content_length=840248
[15:48:52:923][  38.800]<D>TRANS_SSL transport_ssl.c[159]: ssl read...
[15:48:52:935][  38.800]<D>tls tls.c[81]: tls read...
[15:48:52:946][  38.810]<D>HTTP_CLIENT http_client.c[883]: need_read=532, byte_to_read=532, rlen=532, ridx=15852
[15:48:52:946][  38.820]<D>fota fota.c[250]: fota_task FOTA_DOWNLOAD! total:840248 offset:32768
[15:48:52:952][  38.820]<D>fota fota.c[251]: ##read: 16384
[15:48:53:134][  39.000]<I>fota fota.c[312]: write size: 16384
[15:48:53:134][  39.010]<D>app_fota cop_fota.c[90]: FOTA PROGRESS :2, 49152, 840248
[15:48:53:145][  39.010]<D>app_fota cop_fota.c[116]: interval time: 270 ms
[15:48:53:156][  39.020]<D>app_fota cop_fota.c[131]: {"code":0,"total_size":840248,"cur_size":49152,"percent":5,"speed":59}
[15:48:53:156][  39.030]<D>fota fota.c[242]: fota_task download! wait......
[15:48:53:166][  39.030]<D>HTTP_CLIENT http_client.c[873]: is_data_remain=1, is_chunked=0, content_length=840248
[15:48:53:167][  39.040]<D>TRANS_SSL transport_ssl.c[159]: ssl read...
[15:48:53:178][  39.050]<D>TRANS_SSL transport_ssl.c[91]: remain data in cache, need to read again
[15:48:53:179][  39.050]<D>tls tls.c[81]: tls read...
[15:48:53:189][  39.060]<D>HTTP_CLIENT http_client.c[883]: need_read=16384, byte_to_read=16384, rlen=15852, ridx=0
[15:48:53:200][  39.070]<D>HTTP_CLIENT http_client.c[873]: is_data_remain=1, is_chunked=0, content_length=840248
[15:48:53:200][  39.070]<D>TRANS_SSL transport_ssl.c[159]: ssl read...
[15:48:53:212][  39.080]<D>tls tls.c[81]: tls read...
[15:48:53:223][  39.080]<D>HTTP_CLIENT http_client.c[883]: need_read=532, byte_to_read=532, rlen=532, ridx=15852
[15:48:53:223][  39.090]<D>fota fota.c[250]: fota_task FOTA_DOWNLOAD! total:840248 offset:49152
[15:48:53:229][  39.100]<D>fota fota.c[251]: ##read: 16384
[15:48:53:414][  39.280]<I>fota fota.c[312]: write size: 16384
[15:48:53:414][  39.290]<D>app_fota cop_fota.c[90]: FOTA PROGRESS :2, 65536, 840248
[15:48:53:425][  39.290]<D>app_fota cop_fota.c[116]: interval time: 280 ms
[15:48:53:436][  39.300]<D>app_fota cop_fota.c[131]: {"code":0,"total_size":840248,"cur_size":65536,"percent":7,"speed":57}
[15:48:53:436][  39.310]<D>fota fota.c[242]: fota_task download! wait......

下载检验完毕,设备自动重启进入系统升级:

[15:49:06:789][  52.650]<D>app_fota cop_fota.c[131]: {"code":0,"total_size":840248,"cur_size":840248,"percent":100,"speed":23}
[15:49:06:789][  52.660]<D>fota fota.c[242]: fota_task download! wait......
[15:49:06:799][  52.660]<W>fota-httpc httpc.c[238]: http_read done: offset:840248 tsize:840248
[15:49:06:811][  52.670]<D>fota fota.c[250]: fota_task FOTA_DOWNLOAD! total:840248 offset:840248
[15:49:06:811][  52.680]<D>fota fota.c[251]: ##read: 0
[15:49:06:811][  52.680]<D>fota fota.c[268]: read size 0.
[15:49:06:821][  52.690]<D>app_fota cop_fota.c[141]: FOTA VERIFY :2
[15:49:06:822][  52.690]<D>fotav fota_verify.c[76]: start fota verify...
[15:49:06:832][  52.700]<D>fotav fota_verify.c[128]: image_size:839836
[15:49:06:832][  52.700]<D>fotav fota_verify.c[129]: digest_type:1
[15:49:06:833][  52.710]<D>fotav fota_verify.c[130]: sign_type:1
[15:49:06:844][  52.710]<D>fotav fota_verify.c[131]: hash_len:20
[15:49:06:844][  52.710]<D>fotav fota_verify.c[132]: signature_len:128
[15:49:06:856][  52.720]<D>fotav fota_verify.c[133]: signature_offset:848028
[15:49:06:856][  52.720]<D>fotav fota_verify.c[134]: hash_offset:848284
[15:49:07:002][  52.870]<I>fotav fota_verify.c[189]: ###fota data hash v ok.
[15:49:07:003][  52.880]<D>fota fota.c[174]: fota_release,174
[15:49:07:014][  52.880]<D>fota-httpc httpc.c[144]: httpc cleanup...
[15:49:07:014][  52.890]<D>fota-httpc httpc.c[44]: HTTP_EVENT_DISCONNECTED
[15:49:07:026][  52.890]<D>fota fota.c[289]: fota data verify ok.
[15:49:07:026][  52.900]<D>app_fota cop_fota.c[144]: FOTA FINISH :4
[15:49:08:075][34]HELLO! BOOT0 is starting![Sep 18 2021, 11:27:51]
[15:49:08:075][39]BOOT0 commit : 3b45046
[15:49:08:076][42]set pll start
[15:49:08:087][44]periph0 has been enabled
[15:49:08:087][47]set pll end
[15:49:08:087][48][pmu]: bus read error
[15:49:08:087][50]board init ok
[15:49:08:087][52]enable_jtag
[15:49:08:087][54]DRAM only have internal ZQ!!
[15:49:08:109][57]get_pmu_exist() = -1
[15:49:08:109][59]ddr_efuse_type: 0x0
[15:49:08:109][62][AUTO DEBUG] single rank and full DQ!
[15:49:08:109][66]ddr_efuse_type: 0x0
[15:49:08:112][69][AUTO DEBUG] rank 0 row = 15 
[15:49:08:112][72][AUTO DEBUG] rank 0 bank = 8 
[15:49:08:112][75][AUTO DEBUG] rank 0 page size = 2 KB 
[15:49:08:112][79]DRAM BOOT DRIVE INFO: V0.24
[15:49:08:123][82]DRAM CLK = 792 MHz
[15:49:08:123][84]DRAM Type = 3 (2:DDR2,3:DDR3)
[15:49:08:123][87]DRAMC ZQ value: 0x7b7bfb
[15:49:08:123][90]DRAM ODT value: 0x42.
[15:49:08:137][93]ddr_efuse_type: 0x0
[15:49:08:137][95]DRAM SIZE =512 M
[15:49:08:137][99]DRAM simple test OK.
[15:49:08:137][101]dram size =512
[15:49:08:137][103]spinor id is: ef 40 18, read cmd: 0b
[15:49:08:148][107]Succeed in reading toc file head.
[15:49:08:148][110]The size of toc is cc000.
[15:49:08:283][247]start to copy bootloader.
[15:49:08:322][281]copy bootloader over.
[15:49:08:322][284]Entry_name        = melis-lz4
[15:49:08:322][287]Entry_data_offset = 0x400
[15:49:08:335][290]Entry_data_len    = 0xc9011
[15:49:08:335][293]run_addr          = 0x0
[15:49:08:335][295]image_base        = 0x37cd8189
[15:49:08:335][299]come to LZ4 decompress.
[15:49:08:351][308]LZ4 decompress ok.
[15:49:08:351][310]Jump to second Boot.
[15:49:08:351][313]jump to bootloader,[0x40000000]
[15:49:08:365]
[15:49:08:365]Welcome boot2.0!
[15:49:08:365]build: Feb 15 2022 15:41:15
[15:49:08:366]cpu clock is 1008000000Hz
[15:49:09:054][boot][I] fota data hash verify ok
[15:49:09:055][boot][I] start to upgrade
[15:49:09:180][boot][I] fd:0x40025b20,fd_num:0
[15:49:09:251][boot][I] start FULL update
[15:49:25:111][boot][I] fd:0x40025b20,fd_num:0
[15:49:25:184][boot][I] fd:0x40025b20,fd_num:0
[15:49:25:338][boot][I] suc update ^_^

4.3.5 系统升级完毕,设备重启,正常运行
系统升级完毕之后,设备自动重启,可以看到刚才加的打印信息出来了,版本号也更新了。

[15:49:35:597]###YoC###[Feb 15 2022,11:10:45]
[15:49:35:597]cpu clock is 1008000000Hz
[15:49:35:598][   0.360]<I>init app_init.c[62]: find 9 partitions
[15:49:35:613][   0.370]<I>init app_init.c[36]: filesystem init ok.
[15:49:35:613][   0.370]<D>WIFI l8723ds_devops.c[1595]: Init WLAN enable
[15:49:35:613]
[15:49:35:714][   0.480]<D>WIFI_IO wifi_io.c[255]: __sdio_bus_probe
[15:49:35:714]SD:mmc_card_create card:0x4025dec0 id:1
[15:49:35:774][ERR] SDC:__mci_irq_handler,879 raw_int:100 err!
[15:49:35:774][ERR] SDC:SDC err, cmd 8, [ERR] SDC:sdc 663 abnormal status: RespErr
[15:49:35:787]SD:sd1.0 or mmc
[15:49:35:787]SD:***** Try sdio *****
[15:49:35:787][WRN] SD:card claims to support voltages below the defined range.These will be ignored.
[15:49:35:796]SD:sdio highspeed 
[15:49:35:796]SD:mmc_sdio_init_card bus width type:2
[15:49:35:797]SD:
[15:49:35:797]============= card information ==============
[15:49:35:797]SD:Card Type     : SDIO
[15:49:35:808]SD:Card Spec Ver : 1.0
[15:49:35:808]SD:Card RCA      : 0x0001 
[15:49:35:808]SD:Card OCR      : 0x90ffffff
[15:49:35:808]SD:    vol_window  : 0x00ffffff
[15:49:35:819]SD:    to_1v8_acpt : 1
[15:49:35:819]SD:    high_capac  : 1
[15:49:35:819]SD:Card CSD      :
[15:49:35:820]SD:    speed       : 50000 KHz
[15:49:35:820]SD:    cmd class   : 0x0
[15:49:35:820]SD:    capacity    : 0MB
[15:49:35:830]SD:Card CUR_STA  :
[15:49:35:830]SD:    speed_mode  : DS: 25 MHz
[15:49:35:830]SD:    bus_width   : 2
[15:49:35:830]SD:    speed_class : 0
[15:49:35:845]SD:=============================================
[15:49:35:845]SD:***** sdio init ok *****
[15:49:35:846]I am fota test..mg[   0.610]<I>netmgr netmgr_service.c[316]: start wifi
[15:49:35:857][   0.620]<I>app_fota cop_fota.c[165]: ver=============> 1.1.1-20220215.1435-R-d1fota
[15:49:35:869][   0.620]<D>WiFiCONF wifi_conf.c[1392]: WIFI is not running
[15:49:35:869][   0.630]<I>app_fota cop_fota.c[166]: deviceid========> d17dd3720440000030e8aeb4e9b0e3f2
[15:49:35:888][   0.640]<I>netmgr_wifi netmgr_wifi.c[52]: ssid{TEST2}, psk{TEST1234}
[15:49:35:888]
[15:49:35:888][   0.640]<I>app_fota cop_fota.c[167]: model===========> d1fota
[15:49:35:895][   0.650]<D>WiFiCONF wifi_conf.c[1392]: WIFI is not running
[15:49:35:896][   0.660]<D>fota fota.c[62]: fota: 0x402753f8 path:flash://misc
[15:49:35:914][   0.680]<D>WiFiCONF wifi_conf.c[1314]: Initializing WIFI ...
[15:49:35:948][   0.710]<D>WIFI_IO wifi_io.c[143]: sdio_irq_thread enter IRQ routine
[15:49:38:512][   3.270]<D>WiFiCONF wifi_conf.c[1334]: WIFI initialized
[15:49:38:512]
[15:49:38:512][   3.270]<D>WiFiCONF wifi_conf.c[1373]: a2dp_case_wifi_slot: 35
[15:49:39:216][   3.980]<D>WIFI l8723ds_devops.c[559]: @@@@@@@@@@@@@@ Connection Success @@@@@@@@@@@@@@
[15:49:39:216]
[15:49:39:223][   3.990]<I>netmgr netmgr_service.c[187]: start dhcp
[15:49:39:265][   4.030]<I>netmgr netmgr_service.c[211]: IP: 172.20.10.3
[15:49:39:265][   4.030]<I>init app_wifi.c[26]: Got IP
[15:49:39:273][   4.030]<I>init app_wifi.c[33]: NTP Start
[15:49:39:287][   4.050]<D>NTP ntp.c[194]: ntp1.aliyun.com
[15:49:39:397][   4.160]<D>NTP ntp.c[251]: NTP sec: 1644911380 usec: 91886
[15:49:39:398][   4.160]<D>NTP ntp.c[276]: sync success
[15:49:39:410][   4.170]<I>init app_wifi.c[41]: NTP Success

至此,说明整个FOTA升级已经成功完成了。

5. 注意事项

5.1 分区配置
使用升级功能需要指定升级包的存储区域。 配置文件:configs/config.yaml

mtb_version: 4
chip: d1

diff:
fota_version: 0
ram_buf: 50 #DEC KB ( max ram need)
flash_buf: 16 #DEC KB ( buffer size)
flash_sector: 4096 #DEC byte ( flash sector)
diff_mode: 010 #BIN
double_control: 1
flash:
base_address: 0 # 存储基地址,比如FLASH的基地址
sector: 4096 # Bytes
size: 16777216 # 4096 $(sector count) * sector

partitions:

  • { name: boot0, address: 0x000000, size: 0x00C000 } # don't touch
  • { name: gpt, address: 0x00C000, size: 0x004000 } # don't touch
  • { name: boot, address: 0x010000, size: 0x025000 }
  • { name: imtb, address: 0x035000, size: 0x002000 }
  • { name: prim, address: 0x037000, size: 0x400000, verify: true, update: FULL }
  • { name: lfs, address: 0x437000, size: 0x700000 }
  • { name: misc, address: 0xB37000, size: 0x410000 }
  • { name: kv, address: 0xF47000, size: 0x004000 }
  • { name: kp, address: 0xF4B000, size: 0x001000 }
    对需要升级的分区加上update字段。
  • 分区说明

6. 总结

以上即为整个FOTA升级示例详细的操作说明。有关FOTA升级相关的代码主要是在app/src/cop_fota.c文件中。实际应用过程中需要做好版本的管理。

原贴链接:https://bbs.aw-ol.com/topic/1526/
全志在线开发者交流企鹅群(客服机器人24小时在线解答):498263967
资源获取、问题讨论可以到全志在线开发者社区进行:https://www.aw-ol.com
全志及开发者最新动态可以关注全志在线微信公众号
?

  嵌入式 最新文章
基于高精度单片机开发红外测温仪方案
89C51单片机与DAC0832
基于51单片机宠物自动投料喂食器控制系统仿
《痞子衡嵌入式半月刊》 第 68 期
多思计组实验实验七 简单模型机实验
CSC7720
启明智显分享| ESP32学习笔记参考--PWM(脉冲
STM32初探
STM32 总结
【STM32】CubeMX例程四---定时器中断(附工
上一篇文章      下一篇文章      查看所有文章
加:2022-06-06 17:29:39  更:2022-06-06 17:30:04 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年12日历 -2024/12/29 8:05:34-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码
数据统计