《编写适用于STM32的ISP下载器程序.doc》由会员分享,可在线阅读,更多相关《编写适用于STM32的ISP下载器程序.doc(57页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、前一阵公司外购了一些控制器,配合公司的开关一起发给用户。发货前领导认为控制器开机界面会出现我们进货厂家的LOGO不好,应该改成我们公司的名称。于是与控制器厂家协调,让他们把开机欢迎界面改动一下。没几天对方发过来一个ISP下载器,我们用它把控制器的程序升级了一下,就改过来了。闲来无事,感觉这个ISP下载器很有意思。之前我们升级程序,因为还没有着手开发远程自动升级功能,必须到现场去升级。而且用的STM32F103的处理器本身不具备作为主机使用USB的功能,升级的时候使用串口。所以当设备安装在现场的话,就需要带着笔记本,USB转串口线去现场,比较麻烦。而且,笔记本一来体积大,本来出去带着工具什么的东
2、西就很麻烦,再带着本就更头疼;二来在现场也不好用,有转接口不好使的问题,也有其它原因,比如可能需要爬杆,在几米高的杆上抱着本给设备升级是很恐怖的事情。鉴于此,感觉这个ISP下载器还是比较好的一款东西。当然,对方厂家给我们发过来的这款下载器是针对他们用的处理器的,跟我们的不合适。在网上搜索一番,发现还真能找到STM系列的ISP下载器,价格在1200元左右。比起笔记本来说倒是很合算。准备买它几个。当然准备买,那是领导的打算。我觉得应该可以自己做一下,反正我也有不少空闲时间。于是便行动起来。首先,我先在网上找了一款免费的串口监听工具“串口监控精灵”下载安装好。然后将我们的控制器与PC用串口连接好。打
3、开监控精灵,然后打开“串口调试助手”,向终端发送命令。发现监控精灵可以很好的将串口间的上下通信显示出来,并且会给出对串口进行配置的显示。这样,在ISP模式下给控制器上电,在PC上打开STM的flashloader,配置好,下发一个源程序,分析监控精灵的数据:序号 , 时间,进程(PID) , IO类型 , COM口 , 数据长度 , 数据 ,1,14:15:38,hypertrm.exe(3708),IRP_MJ_CREATE,COM3,0,2,14:15:38,hypertrm.exe(3708),IOCTL_SET_QUEUE_SIZE,COM3,8,QueueSize.InSize: 8
4、192, QueueSize.OutSize: 8192,3,14:15:38,hypertrm.exe(3708),IOCTL_SET_BAUD_RATE,COM3,4,115200,4,14:15:38,hypertrm.exe(3708),IOCTL_SET_RTS,COM3,0,5,14:15:38,hypertrm.exe(3708),IOCTL_SET_DTR,COM3,0,6,14:15:38,hypertrm.exe(3708),IOCTL_SET_LINE_CONTROL ,COM3,3,WordLength: 8StopBits: 1Parity:0(None),7,14:
5、15:38,hypertrm.exe(3708),IOCTL_SET_CHARS,COM3,6,Chars Eof: 0, Error: 0, break: 0, Event: 0, Xon: 17, Xoff: 19,8,14:15:38,hypertrm.exe(3708),IOCTL_SET_HANDFLOW,COM3,16,DCB.fAbortOnError=TRUEDCB.fTXContinueOnXoff=TRUEDCB.fRtsControl=RTS_CONTROL_ENABLEDCB.fDtrControl=DTR_CONTROL_ENABLEDCB.fDsrSensitivi
6、ty=FALSEDCB-XonLim: 80DCB-XoffLim: 200,10,14:16:08,hypertrm.exe(3708),IRP_MJ_CLOSE,COM3,0,12,14:16:30,STMicroelectronics flash loader.exe(3872),IOCTL_SET_QUEUE_SIZE,COM3,8,QueueSize.InSize: 2048, QueueSize.OutSize: 2048,13,14:16:30,STMicroelectronics flash loader.exe(3872),IOCTL_SET_BAUD_RATE,COM3,4
7、,115200,14,14:16:30,STMicroelectronics flash loader.exe(3872),IOCTL_CLR_RTS,COM3,0,15,14:16:30,STMicroelectronics flash loader.exe(3872),IOCTL_CLR_DTR,COM3,0,16,14:16:30,STMicroelectronics flash loader.exe(3872),IOCTL_SET_LINE_CONTROL ,COM3,3,WordLength: 8StopBits: 1Parity:0(None),17,14:16:30,STMicr
8、oelectronics flash loader.exe(3872),IOCTL_SET_CHARS,COM3,6,Chars Eof: 0, Error: 0, break: 0, Event: 0, Xon: 17, Xoff: 19,18,14:16:30,STMicroelectronics flash loader.exe(3872),IOCTL_SET_HANDFLOW,COM3,16,DCB.fAbortOnError=TRUEDCB.fTXContinueOnXoff=TRUEDCB.fRtsControl=RTS_CONTROL_DISABLEDCB.fDtrControl
9、=DTR_CONTROL_DISABLEDCB.fDsrSensitivity=FALSEDCB-XonLim: 2048DCB-XoffLim: 512,19,14:16:30,STMicroelectronics flash loader.exe(3872),IRP_MJ_WRITE,COM3,1,7F| ,21,14:16:30,STMicroelectronics flash loader.exe(3872),IRP_MJ_CLOSE,COM3,0,22,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_CREATE,C
10、OM3,0,23,14:17:34,STMicroelectronics flash loader.exe(2848),IOCTL_SET_QUEUE_SIZE,COM3,8,QueueSize.InSize: 2048, QueueSize.OutSize: 2048,24,14:17:34,STMicroelectronics flash loader.exe(2848),IOCTL_SET_BAUD_RATE,COM3,4,115200,25,14:17:34,STMicroelectronics flash loader.exe(2848),IOCTL_CLR_RTS,COM3,0,2
11、6,14:17:34,STMicroelectronics flash loader.exe(2848),IOCTL_CLR_DTR,COM3,0,27,14:17:34,STMicroelectronics flash loader.exe(2848),IOCTL_SET_LINE_CONTROL ,COM3,3,WordLength: 8StopBits: 1Parity:0(None),28,14:17:34,STMicroelectronics flash loader.exe(2848),IOCTL_SET_CHARS,COM3,6,Chars Eof: 0, Error: 0, b
12、reak: 0, Event: 0, Xon: 17, Xoff: 19,29,14:17:34,STMicroelectronics flash loader.exe(2848),IOCTL_SET_HANDFLOW,COM3,16,DCB.fRtsControl=RTS_CONTROL_DISABLEDCB.fDtrControl=DTR_CONTROL_DISABLEDCB.fDsrSensitivity=FALSEDCB-XonLim: 2048DCB-XoffLim: 512,30,14:17:34,STMicroelectronics flash loader.exe(2848),
13、IRP_MJ_WRITE,COM3,1,7F| ,31,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,32,14:17:34,STMicroelectronics flash loader.exe(2848),IOCTL_SET_BAUD_RATE,COM3,4,115200,33,14:17:34,STMicroelectronics flash loader.exe(2848),IOCTL_CLR_RTS,COM3,0,34,14:17:34,STMicroelectronics fl
14、ash loader.exe(2848),IOCTL_CLR_DTR,COM3,0,35,14:17:34,STMicroelectronics flash loader.exe(2848),IOCTL_SET_LINE_CONTROL ,COM3,3,WordLength: 8StopBits: 1Parity:2(E),36,14:17:34,STMicroelectronics flash loader.exe(2848),IOCTL_SET_CHARS,COM3,6,Chars Eof: 0, Error: 0, break: 0, Event: 0, Xon: 17, Xoff: 1
15、9,37,14:17:34,STMicroelectronics flash loader.exe(2848),IOCTL_SET_HANDFLOW,COM3,16,DCB.fRtsControl=RTS_CONTROL_DISABLEDCB.fDtrControl=DTR_CONTROL_DISABLEDCB.fDsrSensitivity=FALSEDCB-XonLim: 2048DCB-XoffLim: 512,38,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,2,00 FF| #0?,39,1
16、4:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,40,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,0B| #11,41,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,22| ,42,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,
17、COM3,11,00 01 02 11 21 31 43 63 73 82 92| #0#1#2#17!1Ccs?,43,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,44,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,2,02 FD| #2y,45,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y
18、,46,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,01| #1,47,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,2,04 14| #4,48,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,49,14:17:34,STMicroelectronics flash loader.exe(2848),IRP
19、_MJ_WRITE,COM3,2,02 FD| #2y,50,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,51,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,01| #1,52,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,2,04 14| #4,53,14:17:34,STMicroelectronics
20、 flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,54,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,2,11 EE| #17?,55,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,56,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,5,1F FF F7 E0
21、F7| ?,57,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,58,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,2,01 FE| #1t,59,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,60,14:17:34,STMicroelectronics flash loader.exe(284
22、8),IRP_MJ_READ,COM3,2,00 02| #0#2,61,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,2,11 EE| #17?,62,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,63,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,5,1F FF F7 E2 F5| ?a?,64,14:1
23、7:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,65,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,2,01 FE| #1t,66,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,67,14:17:34,STMicroelectronics flash loader.exe(2848),IRP_MJ_REA
24、D,COM3,2,FF FF| ?,68,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,2,02 FD| #2y,69,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,70,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,01| #1,71,14:17:40,STMicroelectronics flash l
25、oader.exe(2848),IRP_MJ_READ,COM3,2,04 14| #4,72,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,73,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,2,02 FD| #2y,74,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,75,14:17:40,
26、STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,01| #1,76,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,2,04 14| #4,77,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,78,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM
27、3,2,11 EE| #17?,79,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,80,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,5,1F FF F7 E0 F7| ?,81,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,82,14:17:40,STMicroelectronics fla
28、sh loader.exe(2848),IRP_MJ_WRITE,COM3,2,01 FE| #1t,83,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,84,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,2,00 02| #0#2,85,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,2,11 EE| #17?
29、,86,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,87,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,5,1F FF F7 E2 F5| ?a?,88,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,89,14:17:40,STMicroelectronics flash loader.exe
30、(2848),IRP_MJ_WRITE,COM3,2,01 FE| #1t,90,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,91,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,2,FF FF| ?,92,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,2,00 FF| #0?,93,14:17:40,STMi
31、croelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,94,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,0B| #11,95,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,22| ,96,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,11,00 0
32、1 02 11 21 31 43 63 73 82 92| #0#1#2#17!1Ccs?,97,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,98,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,2,11 EE| #17?,99,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,100,14:17:
33、40,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,5,1F FF F8 08 10| ?#8#16,101,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,102,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,2,03 FC| #3,103,14:17:40,STMicroelectronics flash loader.ex
34、e(2848),IRP_MJ_READ,COM3,1,79| y,104,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,4,FF FF FF FF| ?,105,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,2,11 EE| #17?,106,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,107,14:17:4
35、0,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,5,1F FF F8 0C 14| ?#12,108,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,109,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,2,03 FC| #3,110,14:17:40,STMicroelectronics flash loader.exe(2
36、848),IRP_MJ_READ,COM3,1,79| y,111,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,4,FF FF FF FF| ?,112,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,2,11 EE| #17?,113,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,114,14:17:40,S
37、TMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,5,1F FF F8 00 18| ?#0,115,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,116,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,2,03 FC| #3,117,14:17:40,STMicroelectronics flash loader.exe(2848)
38、,IRP_MJ_READ,COM3,1,79| y,118,14:17:40,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,4,A5 5A FF FF| ¥Z?,119,14:18:20,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,2,43 BC| C?,120,14:18:20,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,121,14:18:20,STMic
39、roelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,2,FF 00| ?#0,122,14:18:20,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,123,14:18:20,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,2,31 CE| 1?,124,14:18:20,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,
40、COM3,1,79| y,125,14:18:20,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,5,08 00 00 00 08| #8#0#0#0#8,126,14:18:20,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,127,14:18:20,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,1,FB| ?,128,14:18:20,STMicroelec
41、tronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,252,80 0D 00 20 FD 1E 00 08 E9 1E 00 08 EB 1E 00 08 ED 1E 00 08 EF 1E 00 08 F1 1E 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F3 1E 00 08 F5 1E 00 08 00 00 00 00 F7 1E 00 08 F9 1E 00 08 3D 1F 00 08 41 1F 00 08 45 1F 00 08 49 1F 00 08 4D 1F 0
42、0 08 51 1F 00 08 55 1F 00 08 59 1F 00 08 5D 1F 00 08 61 1F 00 08 65 1F 00 08 69 1F 00 08 6D 1F 00 08 71 1F 00 08 75 1F 00 08 79 1F 00 08 7D 1F 00 08 81 1F 00 08 85 1F 00 08 89 1F 00 08 8D 1F 00 08 91 1F 00 08 95 1F 00 08 99 1F 00 08 9D 1F 00 08 A1 1F 00 08 A5 1F 00 08 A9 1F 00 08 AD 1F 00 08 B1 1F 0
43、0 08 B5 1F 00 08 B9 1F 00 08 BD 1F 00 08 C1 1F 00 08 C5 1F 00 08 C9 1F 00 08 CD 1F 00 08 D1 1F 00 08 D5 1F 00 08 D9 1F 00 08 DD 1F 00 08 E1 1F 00 08 E5 1F 00 08 E9 1F 00 08 ED 1F 00 08 F1 1F 00 08 F5 1F 00 08| ?#13#0 y#0#8#0#8?#0#8#0#8?#0#8?#0#8#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#8?#0#8#0#0#0#0#0#8#0
44、#8=#0#8A#0#8E#0#8I#0#8M#0#8Q#0#8U#0#8Y#0#8#0#8a#0#8e#0#8i#0#8m#0#8q#0#8u#0#8y#0#8#0#8?#0#8?#0#8?#0#8?#0#8?#0#8?#0#8?#0#8?#0#8?#0#8¥#0#8?#0#8-#0#8#0#8#0#81#0#8?#0#8#0#8?#0#8#0#8#0#8?#0#8?#0#8#0#8Y#0#8#0#8?#0#8#0#8#0#8?#0#8?#0#8,129,14:18:20,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,
45、1,7C| |,130,14:18:20,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,131,14:18:20,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,2,31 CE| 1?,132,14:18:20,STMicroelectronics flash loader.exe(2848),IRP_MJ_READ,COM3,1,79| y,133,14:18:20,STMicroelectronics flash loader.exe(2848),IRP_MJ_WRITE,COM3,5,08 00 00 FC F4| #8#0#0?,134,14:18:20,STMicroelectronics flash loader.exe(2848),IRP_M