stm32 串口 iap在线升级 bootloader keil c源码 手机APP

内容分享2小时前发布
0 1 0

1. 下位机基于STM32F103C8T6芯片编写。

2. 下位机程序可运行与STM32F10X系列芯片。并可移植到其他芯片。

3. 下位机采用Keil编译环境,C语言编写,代码注释详细,易上手。

4. 上位机采用C#语言编写,注释详细,代码简洁、易懂。

5. 上位机采用VS2010/VS2012编译环境(免费提供)。

6. 上位机/下位机程序完全开源。

7. 如有任何问题,可提供技术支持。

1. 本源码为店主多次修改测试,并实际应用的程序。

2. 串口接收采用环形队列接收机,在数据大量发送,或延时情况下不丢包。

可运用于TTL,232,485,网口转串口等。

3. 源码将升级文件拆分成1K单位,加上报头、包尾,每次发送1K字节数据,

下位机接收校验无误后,将数据写入FLASH,程序文件大小,不受RAM大小限制。

4. 数据传输采用CRC16校验,出错的数据包自动重传,保证数据传输的可靠性。

5. IAP程序升级空间为8KB(0x8000 000 ~ 0x8001 fff),FLASH大小为8-512KB,

用户程序最大为(512-8=504KB),既从0x8001 fff ~ 0x8080 000。

6. 通信协议完全公开、程序注释完善 方便移植。

包含资源

APP

IAP-Bootloader-UART

上位机

无有效文本。

上位机 – Microsoft Visual Studio

文件(F) 编辑(E) 视图(V) 重构(R) 项目(P) 生成(B) 调试(D) 团队(T) 数据(A) 工具(I) 测试(S) 分析(N) 窗口(W) 帮助(H)

对该解决方案

Program.cs Form1.cs Form1.cs [设计]

上位机Form1

public partial class Form1 : Form

// IAP协议定义

public const byte Begin = 0xFA;//开始标志

public const byte Cmd = 0xB0;//命令字

public const byte Data = 0xB1;//数据帧

public const byte BootLoader = 0xA0;//进入BootLoader指令

public const byte DownLoad = 0xA1;//开始下载指令

public const byte Confirm = 0xA2;//数据传输确认指令

public const byte Error = 0xA3;//数据传输错误指令

public const byte Length = 0xA4;//数据包长度

public const byte App = 0xA5;//升级文件类型

public const byte Failure = 0xA6;//升级失败

byte[] BootLoader_CMD = new byte[] { Begin, Cmd, BootLoader, 0x00, 0x00, 0x00, End };

byte[] Confirm_CMD = new byte[] { Begin, Cmd, Confirm, 0x00, 0x00, 0x00, End };

byte[] Error_CMD = new byte[] { Begin, Cmd, Error, 0x00, 0x00, 0x00, End };

byte[] App_CMD = new byte[] { Begin, Cmd, App, 0x00, 0x00, 0x00, End };

byte[] datatosend = new byte[1024];

byte[] datarec = new byte[1024];

上位机 – Microsoft Visual Studio

文件(F) 编辑(E) 视图(V) 重构(R) 项目(P) 生成(B) 调试(D) 团队(T) 数据(A) 工具(I) 测试(S) 分析(N) 窗口(W) 帮助(H)

对该解决方案

Program.cs Form1.cs Form1.cs [设计]

if (datarec[0] == Begin && datarec[1] == Cmd && datarec[2] == Error && datarec[4] == 0x00 && datarec[5] == End)

{//升级失败

str = “升级失败”;

textBox1.AppendText(str);

}

else if (datarec[0] == Begin && datarec[1] == Cmd && datarec[2] == Confirm && datarec[4] == 0x00 && datarec[5] == End)

{//升级确认

packet_send++;

str = “已发送” + packet_send.ToString() + “/” + packet_theng;

textBox1.AppendText(str);//显示已发送数据包个数

if (packet_send < packet_theng)

{//继续发送数据包

}

stm32 串口 iap在线升级 bootloader keil c源码 手机APP

stm32 串口 iap在线升级 bootloader keil c源码 手机APP

stm32 串口 iap在线升级 bootloader keil c源码 手机APPstm32 串口 iap在线升级 bootloader keil c源码 手机APP

stm32 串口 iap在线升级 bootloader keil c源码 手机APP

stm32 串口 iap在线升级 bootloader keil c源码 手机APP

stm32 串口 iap在线升级 bootloader keil c源码 手机APPstm32 串口 iap在线升级 bootloader keil c源码 手机APP

© 版权声明

相关文章

1 条评论

none
暂无评论...