CN104461589A - Single-chip microcomputer updating method and system - Google Patents
Single-chip microcomputer updating method and system Download PDFInfo
- Publication number
- CN104461589A CN104461589A CN201310423785.9A CN201310423785A CN104461589A CN 104461589 A CN104461589 A CN 104461589A CN 201310423785 A CN201310423785 A CN 201310423785A CN 104461589 A CN104461589 A CN 104461589A
- Authority
- CN
- China
- Prior art keywords
- chip microcomputer
- upgrade
- network module
- network
- program
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Landscapes
- Stored Programmes (AREA)
- Information Transfer Between Computers (AREA)
Abstract
Description
技术领域 technical field
本发明涉及软件升级技术,具体地说,是涉及单片机升级方法及升级系统。 The invention relates to software upgrading technology, in particular to a single-chip microcomputer upgrading method and an upgrading system.
背景技术 Background technique
随着超大规模集成电路的迅速发展,芯片的处理速度和处理能力不断提高。单片机凭借其体积小、质量轻、性价比高的优点,在工业控制、网络通讯、航空航天等领域得到越来越广泛的应用。由于单片机通常需要根据实际应用写入执行特定功能的用户程序,且这些用户程序会随着实际情况的不同或者应用的不断推广需要进行更新,因此,需要经常对单片机中的用户程序进行升级,重新加载更新后的用户程序,使得系统能够按照最新的程序进行处理。 With the rapid development of VLSI, the processing speed and processing capacity of chips have been continuously improved. With its advantages of small size, light weight, and high cost performance, single-chip microcomputers are more and more widely used in industrial control, network communication, aerospace and other fields. Because the single-chip microcomputer usually needs to write user programs that perform specific functions according to the actual application, and these user programs will need to be updated with the actual situation or the continuous promotion of the application, therefore, it is necessary to frequently upgrade the user programs in the single-chip microcomputer. Load the updated user program so that the system can process according to the latest program.
单片机升级时,运行加载程序,将升级后的新用户程序写入到单片机的flash中,替换原用户程序。然后,单片机重启,运行flash中的新用户程序。为保证单片机正常升级,加载程序均存储在单片机的flash中,使用时从flash中调入内存运行。由于加载程序仅在单片机升级时使用,但由于其一直保存在flash中,占用flash存储空间,这对于flash极其有限的单片机来说,造成资源的严重浪费。 When the single-chip microcomputer is upgraded, run the loading program to write the upgraded new user program into the flash of the single-chip microcomputer to replace the original user program. Then, the MCU restarts and runs the new user program in the flash. In order to ensure the normal upgrade of the single-chip microcomputer, the loading program is stored in the flash of the single-chip microcomputer, and is transferred from the flash to the memory for operation when used. Because the loader is only used when the single-chip microcomputer is upgraded, but because it is always stored in the flash, it takes up the storage space of the flash, which causes a serious waste of resources for the single-chip microcomputer with extremely limited flash.
发明内容 Contents of the invention
本发明的目的是提供一种单片机升级方法及升级系统,以解决现有技术中升级用加载程序一直存储在flash中、占用flash存储空间的问题。 The object of the present invention is to provide a single-chip microcomputer upgrading method and upgrading system to solve the problem in the prior art that the loading program for upgrading is always stored in the flash and occupies the storage space of the flash.
为实现上述发明目的,本发明提供的升级方法采用下述技术方案予以实现: In order to achieve the purpose of the above invention, the upgrading method provided by the present invention is realized by the following technical solutions:
一种单片机升级方法,所述方法包括下述步骤: A method for upgrading a single-chip microcomputer, said method comprising the steps of:
a、将包括用户程序和加载程序的升级数据存入与单片机相连接的网络模块; a. Store the upgrade data including the user program and the loading program into the network module connected with the single-chip microcomputer;
b、将所述网络模块中的所述加载程序传输至单片机内存中; b. transferring the loading program in the network module to the memory of the single-chip microcomputer;
c、运行内存中的所述加载程序,将所述网络模块中的用户程序写入至单片机flash中。 c. Run the loading program in the memory, and write the user program in the network module into the flash of the single-chip microcomputer.
如上所述的升级方法,为方便升级数据的获取,在所述步骤a中,所述网络模块通过网络从升级数据写入模块中下载并保存所述升级数据。 In the upgrade method described above, in order to facilitate the acquisition of upgrade data, in the step a, the network module downloads and saves the upgrade data from the upgrade data writing module through the network.
如上所述的升级方法,所述步骤b具体包括: As described above in the upgrade method, the step b specifically includes:
所述网络模块下载完所述升级数据后,对所述升级数据进行校验, 在检验正确后,向单片机发送升级命令; After the network module has downloaded the upgrade data, it verifies the upgrade data, and after the verification is correct, sends an upgrade command to the single-chip microcomputer;
所述网络模块在接收到单片机对升级命令的应答后,将所述加载程序传输至单片机内存中。 The network module transmits the loading program to the memory of the single-chip microcomputer after receiving the response of the single-chip microcomputer to the upgrade command.
所述步骤c具体包括: Described step c specifically comprises:
单片机运行内存中的所述加载程序,向所述网络模块发送用户程序传输命令; The single-chip microcomputer runs the loading program in the memory, and sends a user program transmission command to the network module;
所述网络模块接收到上述用户程序传输命令后,向单片机发送所述用户程序; After the network module receives the user program transmission command, it sends the user program to the single-chip microcomputer;
单片机对所述用户程序进行校验,若校验正确,将所述用户程序写入单片机的flash中若校验不正确,则请求所述网络模块重新发送所述用户程序。 The single-chip microcomputer verifies the user program, and if the verification is correct, writes the user program into the flash of the single-chip microcomputer; if the verification is incorrect, then requests the network module to resend the user program.
如上所述的升级方法,为节省空间,在所述步骤c之后还包括步骤d:在所述用户程序全部正确写入至单片机flash中之后,删除所述网络模块中的所述升级数据。 The upgrade method described above, in order to save space, further includes step d after the step c: delete the upgrade data in the network module after all the user programs are correctly written into the flash of the single-chip microcomputer.
为实现前述发明目的,本发明提供的升级系统采用下述技术方案来实现: In order to achieve the aforementioned object of the invention, the upgrade system provided by the present invention adopts the following technical solutions:
一种单片机升级系统,包括单片机,其特征在于,还包括网络模块和升级数据写入模块,所述网络模块与所述单片机和所述升级数据写入模块相连接,用于存储并向所述单片机传输包括用户程序和加载程序的升级数据,所述升级数据写入模块用于将所述升级数据写入至所述网络模块。 A single-chip microcomputer upgrade system, comprising a single-chip microcomputer, is characterized in that it also includes a network module and an upgrade data writing module, and the network module is connected with the single-chip microcomputer and the upgrading data writing module for storing and writing to the The single-chip microcomputer transmits upgrade data including user programs and loading programs, and the upgrade data writing module is used to write the upgrade data into the network module.
优选的,所述网络模块与所述单片机采用串口相连接,所述网络模块包括升级控制单元及与该升级控制单元相连接的存储单元和网络通信单元;所述升级数据写入模块为网络服务器,所述网络模块通过所述网络通信单元从所述网络服务器下载所述升级数据。 Preferably, the network module is connected to the single-chip microcomputer through a serial port, and the network module includes an upgrade control unit, a storage unit and a network communication unit connected to the upgrade control unit; the upgrade data writing module is a network server , the network module downloads the upgrade data from the network server through the network communication unit.
更优选的,为对数据进行校验,所述网络模块还包括校验单元,该校验单元分别与所述升级控制单元、所述网络通信单元及所述存储单元相连接,用于对所述网络通信单元下载的所述升级数据进行校验。 More preferably, in order to verify the data, the network module further includes a verification unit, which is respectively connected to the upgrade control unit, the network communication unit and the storage unit, and is used to verify the The upgrade data downloaded by the network communication unit is verified.
与现有技术相比,本发明的优点和积极效果是:本发明将仅在升级过程中使用的加载程序作为升级数据的一部分,在升级时与要升级的用户程序一同传输至单片机,且仅将加载程序写入至单片机内存中直接运行,能确保在单片机flash中不存储加载程序时也能够实现单片机的正常升级,因而无需在单片机flash中额外存储加载程序,节省了单片机的flash存储空间。而且,通过网络模块下载并暂存升级数据实现对单片机的升级,使得使用单片机的家电等产品能通过互联网等网络实现程序升级,提高了家电的可靠性,并能为已售出的产品提供新的功能。 Compared with the prior art, the advantages and positive effects of the present invention are: the present invention uses the loading program used only in the upgrading process as a part of the upgrading data, and transmits it to the single-chip microcomputer together with the user program to be upgraded when upgrading, and only Writing the loading program into the memory of the single-chip microcomputer to run directly can ensure that the normal upgrade of the single-chip microcomputer can be realized even when the loading program is not stored in the flash of the single-chip microcomputer, so there is no need to additionally store the loading program in the flash of the single-chip microcomputer, which saves the flash storage space of the single-chip microcomputer. Moreover, the upgrade of the single-chip microcomputer is realized by downloading and temporarily storing the upgrade data through the network module, so that products such as home appliances using the single-chip microcomputer can realize program upgrades through networks such as the Internet, improve the reliability of home appliances, and provide new products for sold products. function.
结合附图阅读本发明的具体实施方式后,本发明的其他特点和优点将变得更加清楚。 Other characteristics and advantages of the present invention will become clearer after reading the detailed description of the present invention in conjunction with the accompanying drawings.
附图说明 Description of drawings
图1是本发明单片机升级系统一个实施例的结构框图; Fig. 1 is the structural block diagram of an embodiment of the single-chip microcomputer upgrade system of the present invention;
图2是本发明单片机升级方法第一个实施例的流程图; Fig. 2 is the flowchart of the first embodiment of the single-chip microcomputer upgrading method of the present invention;
图3至图5是本发明单片机升级方法第二个实施例的流程图。 3 to 5 are flow charts of the second embodiment of the single-chip microcomputer upgrading method of the present invention.
具体实施方式 Detailed ways
下面结合附图和具体实施方式对本发明的技术方案作进一步详细的说明。 The technical solutions of the present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments.
首先,对本发明的技术思路作一简单介绍:单片机升级时,需要运行加载程序,以便将要升级的用户程序下载并写入到单片机的flash中。加载程序是单片机升级时必不可少的程序,且其仅在单片机升级时使用。如果能将这部分加载程序不固定存放在单片机的flash中,而是仅在使用时能够获取并运行,则可以节省flash存储空间,这样对于flash资源极其有限的单片机来说,将能显著提高其使用性能。 First, a brief introduction to the technical idea of the present invention is given: when the single-chip microcomputer is upgraded, a loading program needs to be run, so as to download and write the user program to be upgraded into the flash of the single-chip microcomputer. The loader is an essential program when the MCU is upgraded, and it is only used when the MCU is upgraded. If this part of the loading program can not be fixedly stored in the flash of the single-chip microcomputer, but can be obtained and run only when in use, the flash storage space can be saved, and the single-chip microcomputer with extremely limited flash resources will be able to significantly improve its performance. Use performance.
请参考图1,该图所示为本发明单片机升级系统一个实施例的结构框图。 Please refer to FIG. 1 , which is a structural block diagram of an embodiment of the single-chip microcomputer upgrading system of the present invention.
如图1所示,该实施例对单片机进行升级的升级系统包括待升级的单片机13,还包括有升级数据写入单元11和网络模块12。其中,升级数据写入模块11与网络模块12相连接,用于将升级数据写入至网络模块12。网络模块12除与升级数据写入模块11相连接之外,还与单片机13相连接,用来暂存包括加载程序和用户程序的升级数据,并能向单片机13传输该升级数据,实现单片机13的升级。而且,升级数据写入模块11与网络模块12之间的网络连接,可以是有线网络连接,也可以是无线网络连接。 As shown in FIG. 1 , the upgrading system for upgrading single-chip microcomputers in this embodiment includes a single-chip microcomputer 13 to be upgraded, and also includes an upgrading data writing unit 11 and a network module 12 . Wherein, the upgrade data writing module 11 is connected with the network module 12 for writing the upgrade data into the network module 12 . Network module 12 is also connected with single-chip microcomputer 13 except being connected with upgrade data writing module 11, is used for temporarily storing the upgrade data comprising loading program and user program, and can transmit this upgrade data to single-chip microcomputer 13, realizes single-chip microcomputer 13 upgrade. Moreover, the network connection between the upgrade data writing module 11 and the network module 12 may be a wired network connection or a wireless network connection.
具体来说,网络模块12包括有升级控制单元121、网络通信单元122和存储单元124,网络通信单元122用于和升级数据写入模块11进行通信连接,以便从升级数据写入模块11下载升级数据,而存储单元124用来暂存所下载的升级数据。升级控制单元121作为升级过程中网络模块的主控单元,分别与网络通信单元122及存储单元124相连接,用来控制网络通信单元的通信与下载,以及控制将存储单元124中的升级数据传输至单片机13中。 Specifically, the network module 12 includes an upgrade control unit 121, a network communication unit 122, and a storage unit 124. The network communication unit 122 is used to communicate with the upgrade data writing module 11 so as to download the upgrade from the upgrade data writing module 11. data, and the storage unit 124 is used to temporarily store the downloaded upgrade data. The upgrade control unit 121, as the main control unit of the network module in the upgrade process, is connected to the network communication unit 122 and the storage unit 124 respectively, and is used to control the communication and download of the network communication unit, and to control the transmission of the upgrade data in the storage unit 124. To the single-chip microcomputer 13.
此外,为对下载的升级数据进行正确性校验,该实施例的升级系统中,网络模块12还包括有校验单元123,该校验单元123分别与网络通信单元122、存储单元124及升级控制单元121相连接,在升级控制单元121的控制下,对网络通信单元下载的升级数据进行校验,并在校验正确后再存入存储单元124中。 In addition, in order to check the correctness of the downloaded upgrade data, in the upgrade system of this embodiment, the network module 12 also includes a check unit 123, which communicates with the network communication unit 122, the storage unit 124 and the update unit 123 respectively. The control unit 121 is connected to each other, and under the control of the upgrade control unit 121, the upgrade data downloaded by the network communication unit is verified and stored in the storage unit 124 after the verification is correct.
该实施例的升级系统实现对单片机13的升级的具体实现,可参考下面两个升级方法流程的描述。 The upgrade system of this embodiment realizes the specific implementation of the upgrade of the single-chip microcomputer 13, and reference may be made to the description of the following two upgrade method flows.
图2示出了本发明单片机升级方法第一个实施例的流程图。该实施例的流程基于图1的升级系统,其实现单片机升级的过程如下: Fig. 2 shows a flow chart of the first embodiment of the single-chip microcomputer upgrading method of the present invention. The flow process of this embodiment is based on the upgrading system of Fig. 1, and its process of realizing single-chip microcomputer upgrading is as follows:
步骤21:流程开始。 Step 21: The process starts.
步骤22:将包括用户程序和加载程序的升级数据写入网络模块。 Step 22: Write the upgrade data including the user program and the loading program into the network module.
该实施例中,升级数据不仅包括有待更新的用户程序,还包括有控制单片机加载及写入用户程序的加载程序。包括用户程序和加载程序的升级数据通过升级数据写入模块编写并写入到网络模块内暂存。 In this embodiment, the upgrade data includes not only the user program to be updated, but also a loading program that controls the single-chip microcomputer to load and write the user program. The upgrade data including the user program and the loading program are written through the upgrade data writing module and written into the network module for temporary storage.
步骤23:将网络模块中的加载程序传输至单片机内存。 Step 23: Transfer the loader in the network module to the memory of the microcontroller.
首先控制网络模块,将其内暂存的加载程序传输至单片机内存中。 Firstly, the network module is controlled, and the loading program temporarily stored in it is transferred to the memory of the single-chip microcomputer.
步骤24:运行内存中的加载程序,将网络模块中的用户程序写入单片机flash。 Step 24: Run the loading program in the memory, and write the user program in the network module into the flash of the single-chip microcomputer.
单片机内存中写入加载程序之后,在内存中运行该加载程序,加载程序将执行升级的控制,从网络模块中读取用户程序,并写入到单片机flash中。 After writing the loading program in the memory of the single-chip microcomputer, run the loading program in the memory, the loading program will execute the control of the upgrade, read the user program from the network module, and write it into the flash of the single-chip microcomputer.
步骤25:流程结束。 Step 25: The process ends.
在该实施例中,由于作为升级控制程序的加载程序是在升级过程中作为升级数据由升级数据写入模块写入到网络模块中,并由网络模块直接传输至单片机内存中运行,因此,单片机flash中无需存储加载程序也能实现单片机的正常升级,使得加载程序不再占用单片机flash,节省了存储空间。 In this embodiment, because the loading program as the upgrade control program is written into the network module by the upgrade data writing module as upgrade data during the upgrade process, and is directly transmitted to the memory of the single-chip microcomputer by the network module to run, therefore, the single-chip The normal upgrade of the single-chip microcomputer can be realized without storing the loading program in the flash, so that the loading program no longer occupies the flash of the single-chip microcomputer, saving storage space.
请参考图3至图5,图3至图5示出了本发明单片机升级方法第二个实施例的流程图。其中,图3所示是整个流程的第一部分,图4所示是整个流程的第二部分,图5所示则是整个流程的第三部分。该实施例的升级方法也基于图1的升级系统。 Please refer to FIG. 3 to FIG. 5 . FIG. 3 to FIG. 5 show a flow chart of a second embodiment of the single-chip microcomputer upgrading method of the present invention. Wherein, Fig. 3 shows the first part of the whole process, Fig. 4 shows the second part of the whole process, and Fig. 5 shows the third part of the whole process. The upgrade method in this embodiment is also based on the upgrade system in FIG. 1 .
如图3至图5所示,该第二个实施例实现单片机升级的过程如下: As shown in Fig. 3 to Fig. 5, this second embodiment realizes the process of single-chip microcomputer upgrading as follows:
首先,执行图3第一部分的各步骤。该图3是实现升级数据下载至网络模块的过程,具体实现步骤如下: First, execute the steps in the first part of FIG. 3 . Figure 3 is the process of downloading the upgrade data to the network module, and the specific implementation steps are as follows:
步骤311:升级开始。 Step 311: The upgrade starts.
步骤312:网络模块从网络服务器下载升级数据。 Step 312: The network module downloads the upgrade data from the network server.
如图2第一个实施例所述,升级数据包括有作为升级控制程序的加载程序和待升级更新的用户程序,这部分数据预先存放在网络服务器中。如果要对单片机升级,可以采用网络服务器主动向网络模块发送升级数据的方式,也可以采用网络模块发现网络服务器存在升级数据时主动从网络服务器下载升级数据的方式。不管采用哪种方式,在需要对单片机升级时,网络模块将从网络服务器下载而获得升级数据。 As shown in the first embodiment in FIG. 2 , the upgrade data includes a loading program as an upgrade control program and a user program to be updated, and this part of data is pre-stored in the network server. If the single-chip microcomputer is to be upgraded, the network server can actively send the upgrade data to the network module, or the network module can actively download the upgrade data from the network server when the network module finds that the network server has upgrade data. No matter which method is adopted, when the single-chip microcomputer needs to be upgraded, the network module will download the upgrade data from the network server.
该实施例中,网络模块通过网络、如互联网下载升级数据,数据获取简单、方便,升级速度快。 In this embodiment, the network module downloads the upgrade data through the network, such as the Internet, and the data acquisition is simple and convenient, and the upgrade speed is fast.
步骤313:判断下载是否完成。若是,执行步骤314,否则,转至步骤312,继续下载。 Step 313: Determine whether the download is complete. If yes, execute step 314; otherwise, go to step 312 to continue downloading.
步骤314:判断升级数据是否校验正确。若正确,执行后续流程A、也即图4所示的第二部分的流程;否则,转至步骤312,继续重新下载。 Step 314: Determine whether the upgrade data is verified correctly. If it is correct, execute the follow-up process A, that is, the second part of the process shown in FIG. 4; otherwise, go to step 312 and continue to re-download.
下载完成后,对下载的升级数据进行校验,校验包括升级数据版本的校验、数据正确性校验等。校验方式可以采用现有技术中的方式,如CRC32校验等。如果校验正确,则执行后续流程A;否则,需要从网络服务器重新下载升级数据。 After the download is completed, the downloaded upgrade data is verified, and the verification includes the verification of the version of the upgraded data, the verification of the correctness of the data, and the like. The verification method may adopt a method in the prior art, such as CRC32 verification and the like. If the verification is correct, execute subsequent process A; otherwise, it is necessary to re-download the upgrade data from the network server.
在网络模块下载了正确、完整的升级数据之后,执行图4第二部分的各步骤。该图4是实现加载程序写入至单片机内存的过程,具体实现步骤如下: After the network module downloads correct and complete upgrade data, execute the steps in the second part of FIG. 4 . Figure 4 is the process of writing the loading program to the memory of the single-chip microcomputer, and the specific implementation steps are as follows:
步骤321:在网络模块对下载的升级数据校验正确后,将向单片机发送升级命令,并获得单片机应答。 Step 321: After the network module verifies that the downloaded upgrade data is correct, it will send an upgrade command to the single-chip microcomputer and obtain a response from the single-chip microcomputer.
步骤322:在获得单片机应答之后,网络模块向单片机传输加载程序。 Step 322: After obtaining the response from the single-chip computer, the network module transmits the loading program to the single-chip computer.
网络模块可以通过串口、分批将加载程序传输至单片机。 The network module can transmit the loading program to the single-chip microcomputer in batches through the serial port.
步骤323:单片机对加载程序进行校验。 Step 323: The single-chip microcomputer verifies the loading program.
单片机在接收到加载程序后,将对加载程序进行正确性校验。校验方法可以采用现有方法,在此不作具体阐述。 After receiving the loading program, the MCU will check the correctness of the loading program. The verification method may adopt an existing method, which will not be described in detail here.
步骤324:判断校验是否正确。若正确,执行步骤326;否则,执行步骤325。 Step 324: Determine whether the verification is correct. If correct, go to step 326; otherwise, go to step 325.
步骤325:若加载程序校验错误,则请求网络模块重传加载程序。然后,执行步骤322,网络模块向单片机重新传输加载程序。 Step 325: If the loader check is wrong, request the network module to retransmit the loader. Then, step 322 is executed, and the network module retransmits the loading program to the single-chip microcomputer.
步骤326:若加载程序校验正确,则单片机中的原有用户程序将控制加载程序写入单片机内存中。 Step 326: If the verification of the loading program is correct, the original user program in the single-chip microcomputer writes the control loading program into the memory of the single-chip microcomputer.
步骤327:判断加载程序是否全部写入。若是,执行步骤328;否则,转至步骤322,由网络模块继续向单片机传输加载程序。 Step 327: Determine whether all the loading programs are written. If yes, execute step 328; otherwise, go to step 322, and the network module continues to transmit the loading program to the single-chip microcomputer.
步骤328:在加载程序全部写入到单片机内存中之后,运行内存中的加载程序。然后,执行后续流程B、也即图5示出的第三部分的流程。 Step 328: After all the loading programs are written into the memory of the single-chip microcomputer, run the loading program in the memory. Then, the subsequent process B, that is, the process of the third part shown in FIG. 5 is executed.
在将加载程序下载并写入到单片机内存中时,由于单片机中还存在有原用户程序,因此,可以通过原用户程序的控制来实现。 When the loading program is downloaded and written into the memory of the single-chip microcomputer, since the original user program still exists in the single-chip microcomputer, it can be realized through the control of the original user program.
在单片机内存中运行加载程序之后,加载程序获得单片机运行的控制权,然后,将执行单片机的最后升级过程,也即执行图5第三部分的各步骤,以将新的用户程序写入至单片机flash中。具体实现过程如下: After running the loading program in the memory of the single-chip microcomputer, the loading program obtains the control right of the operation of the single-chip microcomputer, and then executes the final upgrade process of the single-chip microcomputer, that is, executes the steps in the third part of Figure 5 to write the new user program to the single-chip microcomputer in flash. The specific implementation process is as follows:
步骤331:擦除全部flash存储空间,并向网络模块发送用户程序传输命令。 Step 331: Erase all flash storage space, and send a user program transmission command to the network module.
由于单片机中无需存储加载程序,因此,可以在其flash中仅存储用户程序。在升级时,用户程序要进行更新,所以,内存中运行的加载程序将擦除全部flash存储空间,也即擦除整块flash。在擦除完全部flash存储空间之后,加载程序将向网络模块发送用户程序传输命令。 Because there is no need to store the loading program in the microcontroller, only the user program can be stored in its flash. When upgrading, the user program needs to be updated, so the loading program running in the memory will erase all flash storage space, that is, erase the entire flash. After erasing all the flash memory space, the loader will send user program transfer command to the network module.
步骤332:网络模块在接收到用户程序传输命令后,将分批相单片机发送用户程序,单片机将对读取到的用户程序进行校验。 Step 332: After receiving the user program transmission command, the network module will send the user program to the single-chip microcomputer in batches, and the single-chip microcomputer will verify the read user program.
步骤333:判断所读取到的用户程序校验是否正确。若正确,执行步骤335;否则,转至步骤334。 Step 333: Determine whether the read user program verification is correct. If correct, go to step 335; otherwise, go to step 334.
步骤334:若用户程序校验错误,则请求网络模块重传用户程序。然后,转至步骤332,重新发送用户程序。 Step 334: If the verification of the user program is wrong, request the network module to retransmit the user program. Then, go to step 332 to resend the user program.
步骤335:若用户程序校验正确,则将用户程序写入单片机flash。 Step 335: If the verification of the user program is correct, write the user program into the flash of the single-chip microcomputer.
步骤336:判断用户程序是否全部写入。若是,执行步骤337;否则,转至步骤332,继续从网络模块读取剩余的用户程序。 Step 336: Determine whether all user programs are written. If yes, go to step 337; otherwise, go to step 332 and continue to read the remaining user programs from the network module.
步骤337:在全部用户程序写入到单片机flash中之后,删除网络模块的升级数据,以释放网络模块的存储空间,方便后续升级使用。 Step 337: After all the user programs are written into the flash of the single-chip microcomputer, delete the upgrade data of the network module, so as to release the storage space of the network module, which is convenient for subsequent upgrade.
步骤338:升级结束。 Step 338: The upgrade ends.
升级完成,在单片机重启后,将运行flash中的新用户程序。 After the upgrade is completed, the new user program in the flash will run after the MCU restarts.
如果在升级过程中单片机断电,升级数据仍存在于网络模块中,网络模块可以重新将加载程序写入至单片机内存中,再次执行单片机的升级。 If the single-chip microcomputer is powered off during the upgrade process, the upgrade data still exists in the network module, and the network module can rewrite the loading program into the memory of the single-chip microcomputer to perform the upgrade of the single-chip microcomputer again.
与图2第一个实施例类似,该第二个实施例也可以节省单片机flash存储空间。而且,在整个升级过程中层层对数据进行校验,防止数据在传输过程中出错,充分保证了单片机的正确升级。此外,网络模块通过网络从网络服务器下载升级数据,升级方便、快捷,适合单片机所应用产品的售后升级。 Similar to the first embodiment in Fig. 2, this second embodiment can also save the flash storage space of the single-chip microcomputer. Moreover, the data is verified layer by layer during the entire upgrade process to prevent data errors during transmission and fully ensure the correct upgrade of the single-chip microcomputer. In addition, the network module downloads the upgrade data from the network server through the network, which is convenient and fast to upgrade, and is suitable for after-sales upgrade of products applied by the single-chip microcomputer.
以上实施例仅用以说明本发明的技术方案,而非对其进行限制;尽管参照前述实施例对本发明进行了详细的说明,对于本领域的普通技术人员来说,依然可以对前述实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或替换,并不使相应技术方案的本质脱离本发明所要求保护的技术方案的精神和范围。 The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art can still understand the foregoing embodiments. Modifications are made to the technical solutions described, or equivalent replacements are made to some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions claimed in the present invention.
Claims (8)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201310423785.9A CN104461589A (en) | 2013-09-17 | 2013-09-17 | Single-chip microcomputer updating method and system |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201310423785.9A CN104461589A (en) | 2013-09-17 | 2013-09-17 | Single-chip microcomputer updating method and system |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN104461589A true CN104461589A (en) | 2015-03-25 |
Family
ID=52907700
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201310423785.9A Pending CN104461589A (en) | 2013-09-17 | 2013-09-17 | Single-chip microcomputer updating method and system |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN104461589A (en) |
Cited By (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN105808298A (en) * | 2016-03-08 | 2016-07-27 | 大连楼兰科技股份有限公司 | A Dynamic Loading Method of Modules Under Single Chip Microcomputer |
| CN107301068A (en) * | 2017-06-12 | 2017-10-27 | 合肥众志行云科技有限公司 | One-to-many wireless program upgrade-system and method on a kind of single-chip microcomputer |
| CN107894936A (en) * | 2017-11-13 | 2018-04-10 | 重庆首亨软件有限公司 | A kind of single-chip microcomputer test software |
| CN109284116A (en) * | 2018-09-11 | 2019-01-29 | 陕西千山航空电子有限责任公司 | A kind of data managing method of the comprehensive number pipe of polymorphic type big data quantity |
| CN110727448A (en) * | 2019-09-29 | 2020-01-24 | 重庆国翰能源发展有限公司 | OTA (over the air) upgrading method for charging pile |
| CN113553087A (en) * | 2021-07-16 | 2021-10-26 | 湖北三江航天红峰控制有限公司 | Singlechip program online upgrading method and device |
Citations (10)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20010046230A1 (en) * | 2000-03-14 | 2001-11-29 | Rojas Michael J. | Method and programmable device for telecommunications applications |
| CN1545363A (en) * | 2003-11-14 | 2004-11-10 | 中兴通讯股份有限公司 | A method for client to download software from server in distributed system |
| CN1564131A (en) * | 2004-03-29 | 2005-01-12 | 中兴通讯股份有限公司 | Method and device of realizing uppdating of single processor software |
| US20090113196A1 (en) * | 2007-10-27 | 2009-04-30 | Hsun-Yao Jan | Method and systems for advanced reprogrammable boot codes and in-application programming of embedded microprocessor systems |
| CN102004651A (en) * | 2009-09-01 | 2011-04-06 | 上海祥昶实业有限公司 | System and method for starting embedded device from T card |
| CN102073515A (en) * | 2009-11-23 | 2011-05-25 | 天津中兴软件有限责任公司 | RFID (Radio Frequency Identification Device) active tag and method and system for upgrading software thereof |
| CN102279757A (en) * | 2010-06-11 | 2011-12-14 | 无锡中星微电子有限公司 | Method and device for starting system program |
| CN102298526A (en) * | 2011-06-08 | 2011-12-28 | 厦门雅迅网络股份有限公司 | Mechanism for upgrading programs of peripheral equipment based on single chips without external extended memories |
| CN102567253A (en) * | 2010-12-13 | 2012-07-11 | 深圳市硅格半导体有限公司 | DMA (direct memory access)-based SPI (serial peripheral interface) data transmission method and DMA-based SPI data transmission device |
| CN102945174A (en) * | 2012-11-08 | 2013-02-27 | 大连捷成实业发展有限公司 | The Method of Upgrading the Program of Single-chip Microcomputer by Attaching the External Flash |
-
2013
- 2013-09-17 CN CN201310423785.9A patent/CN104461589A/en active Pending
Patent Citations (10)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20010046230A1 (en) * | 2000-03-14 | 2001-11-29 | Rojas Michael J. | Method and programmable device for telecommunications applications |
| CN1545363A (en) * | 2003-11-14 | 2004-11-10 | 中兴通讯股份有限公司 | A method for client to download software from server in distributed system |
| CN1564131A (en) * | 2004-03-29 | 2005-01-12 | 中兴通讯股份有限公司 | Method and device of realizing uppdating of single processor software |
| US20090113196A1 (en) * | 2007-10-27 | 2009-04-30 | Hsun-Yao Jan | Method and systems for advanced reprogrammable boot codes and in-application programming of embedded microprocessor systems |
| CN102004651A (en) * | 2009-09-01 | 2011-04-06 | 上海祥昶实业有限公司 | System and method for starting embedded device from T card |
| CN102073515A (en) * | 2009-11-23 | 2011-05-25 | 天津中兴软件有限责任公司 | RFID (Radio Frequency Identification Device) active tag and method and system for upgrading software thereof |
| CN102279757A (en) * | 2010-06-11 | 2011-12-14 | 无锡中星微电子有限公司 | Method and device for starting system program |
| CN102567253A (en) * | 2010-12-13 | 2012-07-11 | 深圳市硅格半导体有限公司 | DMA (direct memory access)-based SPI (serial peripheral interface) data transmission method and DMA-based SPI data transmission device |
| CN102298526A (en) * | 2011-06-08 | 2011-12-28 | 厦门雅迅网络股份有限公司 | Mechanism for upgrading programs of peripheral equipment based on single chips without external extended memories |
| CN102945174A (en) * | 2012-11-08 | 2013-02-27 | 大连捷成实业发展有限公司 | The Method of Upgrading the Program of Single-chip Microcomputer by Attaching the External Flash |
Cited By (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN105808298A (en) * | 2016-03-08 | 2016-07-27 | 大连楼兰科技股份有限公司 | A Dynamic Loading Method of Modules Under Single Chip Microcomputer |
| CN105808298B (en) * | 2016-03-08 | 2019-02-12 | 大连楼兰科技股份有限公司 | A method of dynamic loading of modules under a single chip microcomputer |
| CN107301068A (en) * | 2017-06-12 | 2017-10-27 | 合肥众志行云科技有限公司 | One-to-many wireless program upgrade-system and method on a kind of single-chip microcomputer |
| CN107894936A (en) * | 2017-11-13 | 2018-04-10 | 重庆首亨软件有限公司 | A kind of single-chip microcomputer test software |
| CN109284116A (en) * | 2018-09-11 | 2019-01-29 | 陕西千山航空电子有限责任公司 | A kind of data managing method of the comprehensive number pipe of polymorphic type big data quantity |
| CN109284116B (en) * | 2018-09-11 | 2022-03-08 | 陕西千山航空电子有限责任公司 | Data management method for multi-type large-data-volume comprehensive data management |
| CN110727448A (en) * | 2019-09-29 | 2020-01-24 | 重庆国翰能源发展有限公司 | OTA (over the air) upgrading method for charging pile |
| CN113553087A (en) * | 2021-07-16 | 2021-10-26 | 湖北三江航天红峰控制有限公司 | Singlechip program online upgrading method and device |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN103246536B (en) | The wireless firmware upgrade method of thing connection positioning system | |
| CN104461589A (en) | Single-chip microcomputer updating method and system | |
| US20150261521A1 (en) | Mobile system including firmware verification function and firmware update method thereof | |
| US20100241838A1 (en) | Method and system for firmware updates | |
| CN110083374A (en) | A kind of upgrading rollback method, system and terminal device | |
| CN101689116A (en) | System and method for updating device drivers | |
| CN112424747B (en) | Method, processing system and storage medium for generating binary target file | |
| CN101815988A (en) | Firmware image update and management | |
| CN106406935A (en) | OTA upgrading method for Bluetooth chip and Bluetooth chip | |
| CN113672270B (en) | Upgrading method, computer system and remote upgrading device | |
| CN106547574A (en) | The outside download system and method for a kind of DSP programs and FPGA programs | |
| CN106790247A (en) | A kind of method and apparatus of android system upgrading | |
| CN104035793A (en) | In-application wireless programming method based on single-chip microcomputer | |
| CN106126293A (en) | Electronic cigarette firmware upgrade method and system | |
| CN105786542A (en) | Intelligent device and system update method of the intelligent device | |
| CN106886436A (en) | A kind of method and apparatus of android system upgrading | |
| CN106020875A (en) | Firmware updating management method and device of embedded terminal | |
| CN111309363A (en) | Online upgrade method and device based on Contiki operating system | |
| CN117648109A (en) | Differential upgrading method, system and medium based on Flash page alignment mode | |
| TW202324072A (en) | Method for managing memory, system for managing functions, and non-transitory computer-readable medium | |
| CN104182256B (en) | A kind of embedded device method for updating program | |
| CN102711095B (en) | A kind of method of the node in wireless sensor network being carried out to radio upgrade | |
| CN101667133B (en) | Firmware update method and chips using the method to update firmware | |
| CN110457058A (en) | Control node online upgrade method, device, host computer, system and electronic equipment | |
| CN103631611A (en) | Method and equipment for updating optical transmitter and receiver |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| C06 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| RJ01 | Rejection of invention patent application after publication |
Application publication date: 20150325 |
|
| RJ01 | Rejection of invention patent application after publication |