GPRS network (Air202 / SIM800) Upgrade STM32: ping-pong test STM32 remote upgrade, based on (GPRS module TCP AT command pass-through mode), the timing to access the upgrade

 

      

Realize the function summary

 

BootLoader program:

   

    Capture the Last update status, if the update status is set to update the status is 0x01 0xFF

    Note: The user program needs to clear the Update status is 0 if the user is running a program error, not cleared, then restart later

    BootLoader program to determine the update status is 0xFF, then do not think the normal operation of the user program,

    Will perform the switching program file, the original file will be loaded.

 

    If you do not update the flag, then attempts to load the user program.

    If an update flag, STM32 control GPRS module with TCP connect Web server, and then send Get protocol file access procedures, after writing Flash, reboot!

    Each write switch Flash Flash writing position, and updating the state detection added, failed update a version of the program is running (rollback)

 

APP user program:

    Get status updates, remove update status

    If the update state switching version number is 0x01

 

    Every 30S, TCP control GPRS module to connect the Web server to get the current version of the program, if the version is inconsistent, writes update flag to restart the MCU!

 

Flash configuration:

 

 

 

Test preparation (default access my server, instead of their own server, see below explanation)

First, download BootLoader program (please to download)

  

 

Second, adjusting the position of the rocker switch, and the STM32 serial communication GPRS

  

 

 

Third, do not forget to insert the phone card, and install the antenna

 

 

 

IV. Prepare two serial module, the RX serial two modules, each connected to the microcontroller PA9 and PA10.

  4.1 Note: This is the STM32 and monitoring data between GPRS, see the update process.

    

 

  4.2 schematic

    

 

start testing

A. Currently only downloaded BootLoader procedures, updated BootLoader program which requires the following operations

  Press PB5 about 4S, waiting lamp flash, release PB5, 3S LEDs shine after writing program update flag, and then restart 

  

 

 

 

 

II. Monitoring data

  

 

 

III. Use a pin practical application control module restart

  3.1 请在每个程序文件的此处修改(注,本人的板子现在未引出复位引脚,下一批板子将跟进)

  

 

 

 

  3.2 如果没有复位可能出现一直发送  AT+CIPSHUT ,模块要等到好久才有反应

  现在测试可人为进行复位!

  

 

 

 

 

四.运行用户程序,每隔30S访问一次云端程序版本

 

  

 

修改为连接自己的服务器

一,修改BootLoader,和两份用户程序连接的Web服务器的IP地址,端口号信息

  

 

 

  

 

 

  

 

 

 

二,Http访问程序文件的路径请自行根据自己的修改,我按照我自己的说明

  2.1 根据单片机程序访问的路径,在Web服务器建立文件夹

  

 

 

 

 

  

 

  

 

  2.2 拷贝记录设备版本的updatainfo.txt文件,和用户程序1文件(Progect.bin),用户程序2文件(Progect2.bin)到服务器

  

 

 

  

 

 

  

 

 

 

  最终效果

  

三,大家设置完自己的,重新按照上面的测试一下,看下可不可以测试通过

  可以自己看看是什么问题,或者告诉我有什么问题.

 

四,修改云端版本

  

 

 

 

  

五,用户程序检测到新版本,写入更新标志,重启,BootLoader更新另一份程序,重启,运行新程序

  

 

 

 

五,测试程序有问题,实现程序回滚(由于底层处理都是一样的,可自行参考上一节测试)

  5.1 我说一下BootLoader里面预防的一个极端问题: 用户程序两份全是有问题的,程序不停的在重启

    5.1.1 在执行BootLoader程序的时候,实际上加载用户程序受控于,按钮(我用的PB5)

    

 

     5.1.2  假设出现极端情况,可让用户长按PB5大约4S,等待指示灯快闪,松开PB5,指示灯闪耀3S以后,程序写入更新标志位,然后重启 

        其实和一开始的一样的操作(这个也可以用来预防极端情况)

 

        

 

 

 

其它

一,可先下载第一份程序到单片机,让单片机默认运行一份程序

  1.1 操作步骤是先现在BootLoader程序(下载进去就可以,不需要任何配置)

  1.2 下载第一份用户程序(程序默认加载第一份用户程序),请按照下面配置下载

  

 

此时单片机启动以后便会加载第一份用户程序运行.

 

Guess you like

Origin www.cnblogs.com/yangfengwu/p/11817373.html
Recommended