Movatterモバイル変換


[0]ホーム

URL:


CN113407206A - Self-defined upgrading method of single chip microcomputer - Google Patents

Self-defined upgrading method of single chip microcomputer
Download PDF

Info

Publication number
CN113407206A
CN113407206ACN202110636585.6ACN202110636585ACN113407206ACN 113407206 ACN113407206 ACN 113407206ACN 202110636585 ACN202110636585 ACN 202110636585ACN 113407206 ACN113407206 ACN 113407206A
Authority
CN
China
Prior art keywords
firmware
chip microcomputer
frame
single chip
data
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.)
Withdrawn
Application number
CN202110636585.6A
Other languages
Chinese (zh)
Inventor
张延盛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xiamen Meike Iot Technology Co ltd
Original Assignee
Xiamen Meike Iot Technology Co ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Xiamen Meike Iot Technology Co ltdfiledCriticalXiamen Meike Iot Technology Co ltd
Priority to CN202110636585.6ApriorityCriticalpatent/CN113407206A/en
Publication of CN113407206ApublicationCriticalpatent/CN113407206A/en
Withdrawnlegal-statusCriticalCurrent

Links

Images

Classifications

Landscapes

Abstract

The invention relates to a self-defined upgrading method of a singlechip, which comprises the steps that an upper computer starts updating and upgrading; pressing a BOOT key of the single chip microcomputer, and powering on the single chip microcomputer; the upper computer sends the firmware leading frame to the single chip microcomputer, a bootstrap program area of the single chip microcomputer receives and verifies the firmware leading frame, and the firmware leading frame is stored in the memory after being verified correctly; after the single chip microcomputer receives the firmware preamble frame, the upper computer continuously sends the data frame to the single chip microcomputer, a bootstrap program area of the single chip microcomputer continuously receives the data frame and checks the data frame, and the data frame is stored in a buffer area after the data frame is checked to be correct; and after the complete firmware data is received, storing the data frames in the cache region into the memory of the single chip microcomputer, performing IAP programming, and operating the APP region to realize the upgrading of the single chip microcomputer. The invention can be upgraded after the firmware is completely received and the verification is successful, thereby effectively avoiding the occurrence of errors in the upgrading process and improving the safety and stability of the upgrading of the single chip microcomputer.

Description

Self-defined upgrading method of single chip microcomputer
Technical Field
The invention relates to the technical field of single-chip microcomputers, in particular to a user-defined upgrading method of a single-chip microcomputer.
Background
With the wide application of the single chip microcomputer technology, custom upgrading is more and more important, and generally, MCU manufacturers provide built-in BOOT programs (BOOTLOADER) for us, but the BOOT pins need to be controlled additionally or handshake through serial ports (or other interfaces) when the BOOT pins are powered on, and the BOOT programs enter after the handshake is successful, but the requirements on the timing and operation are strict, which is not beneficial to the operation. Moreover, the upgrading mode of the current manufacturer is that the protocol is received and upgraded at the same time and can not be defined by user, so that the defects that the success rate is not high due to no error in the upgrading process and the upgrading can not be carried out after the integral verification are difficult to avoid.
That is to say, the existing single chip microcomputer upgrading method is easy to make mistakes in the upgrading process, and the upgrading stability and safety are poor.
Disclosure of Invention
Aiming at the problems in the prior art, the invention aims to provide a self-defined upgrading method for a single chip microcomputer, which can effectively improve the stability and safety of upgrading.
In order to achieve the purpose, the invention adopts the technical scheme that:
a self-defined upgrading method of a single chip microcomputer comprises the following steps:
the upper computer starts updating and upgrading;
pressing a BOOT key of the single chip microcomputer, and powering on the single chip microcomputer;
the upper computer sends the firmware leading frame to the single chip microcomputer, a bootstrap program area of the single chip microcomputer receives and verifies the firmware leading frame, and the firmware leading frame is stored in the memory after being verified correctly;
after the single chip microcomputer receives the firmware preamble frame, the upper computer continuously sends the data frame to the single chip microcomputer, a bootstrap program area of the single chip microcomputer continuously receives the data frame and checks the data frame, and the data frame is stored in a buffer area after the data frame is checked to be correct;
and after the firmware data frame is received, storing the data frame in the cache region into the memory of the single chip microcomputer, performing IAP programming, and operating the APP region to realize the upgrading of the single chip microcomputer.
And after the single chip microcomputer completes the reception of the firmware leading frame and the data frame, feeding back the received information to the upper computer.
The data received by the bootstrap area of the single chip microcomputer are specifically as follows:
when the singlechip is checked to receive the data, the data is stored in a buffer area; when a frame ending event is generated at regular time, carrying out data analysis and judging whether the frame is a firmware leading frame or a firmware data frame;
if the firmware is the leading frame, checking is carried out, and the initial address, the length and the check of the firmware are stored in the memory after the check is correct;
if the current frame is the data frame, checking, and storing the base address, the length and the check of the current frame into a memory after the check is correct, and storing the specific data of the current frame into a buffer area; and after all the firmware data frames are received, carrying out integral verification on the firmware data frames, storing the data of the buffer area into the memory after the verification is correct, carrying out IAP programming and operating the APP area.
And when the singlechip receives the firmware leading frame and the data frame, the singlechip collects data sent by the upper computer by adopting an inquiry method.
The firmware preamble frame includes a feature byte and a check byte.
The check bytes of the fixed leading frame comprise firmware and bytes, starting high address bytes, low address bytes, firmware length high address bytes, firmware length low address bytes and exclusive-or check value bytes.
The firmware data frame includes a feature byte, a check byte, and a data byte.
The check bytes of the firmware data frame comprise high address bytes of a base address of the firmware of the frame, low address bytes of the base address of the firmware of the frame, high address bytes of the base address of the firmware of the frame, low address bytes of the firmware of the frame, check sum bytes of the firmware of the frame and exclusive or check value bytes.
After the scheme is adopted, the BOOT key is arranged, the BOOT key is pressed before power-on, then the mainboard is powered on, and the mainboard directly enters a bootstrap program state after detecting the pressed state of the key, so that the time sequence problem between an upper computer and a single chip microcomputer is not required to be considered, and the difficulty of handshaking can be greatly reduced. And when the single chip microcomputer receives the upgrade firmware file, before the firmware file is received, the data bytes of the firmware data frame are stored in the buffer area, and after the firmware file is received, the data in the buffer area is stored in the memory, and the IAP programming is carried out to upgrade the single chip microcomputer, so that errors in the upgrading process are avoided, and the upgrading safety and stability of the single chip microcomputer are improved.
Drawings
FIG. 1 is an overall flow chart of the present invention;
FIG. 2 is a transmission flow chart of the upper computer;
FIG. 3 is a flow chart of the program guide of the single chip microcomputer;
FIG. 4 is a circuit diagram of BOOT keys of the single chip microcomputer.
Detailed Description
As shown in fig. 1-3, the invention discloses a self-defined upgrading method for a single chip microcomputer, which guides handshake between an upper computer and the single chip microcomputer by pressing a BOOT key for a long time, enters an upgrading state, waits for all firmware to be received and is upgraded after verification is successful. The invention specifically comprises the following steps:
andstep 1, connecting serial port lines of the upper computer and the single chip microcomputer, and starting updating.
Andstep 2, pressing a BOOT key of the single chip microcomputer, and powering on the single chip microcomputer. Fig. 4 is a circuit diagram of the BOOT key, in the diagram, the key s1 is the BOOT key, the BOOT key is pressed before the power-on, the main board is powered on, and the main board directly enters the BOOT program state after detecting the pressed state of the key, so that the timing sequence problem between the upper computer and the single chip microcomputer is not required to be considered, and the difficulty of handshaking can be greatly reduced.
And 3, the upper computer sends the firmware preamble frame to the single chip microcomputer, a bootstrap program area of the single chip microcomputer receives and verifies the firmware preamble frame, and the firmware preamble frame is stored in the memory after being verified correctly.
And 4, after the single chip microcomputer finishes receiving the firmware preamble frame, the upper computer continuously sends the data frame to the single chip microcomputer, the boot program area of the single chip microcomputer continuously receives the data frame and checks the data frame, and the data frame is stored in the buffer area after the data frame is checked to be correct.
And 5, after the firmware data frame is received, storing the data frame in the cache region into a memory of the single chip microcomputer, performing IAP programming, and operating an APP region to realize the upgrading of the single chip microcomputer.
In the above step 3 and step 4, the fixed leading frame and the firmware data frame together form a firmware, and the firmware is a file for upgrading the single chip microcomputer. In this embodiment, the firmware is a hex file. And after the singlechip finishes receiving the firmware leading frame and the data frame, feeding back the received information to the upper computer.
The firmware leading frame comprises a characteristic byte and a check byte, the characteristic byte is used for the single chip microcomputer to confirm that the firmware leading frame is a fixed leading frame, and the check byte contains the relevant information of the firmware and is used for the single chip microcomputer to check the received firmware data frame. In this embodiment, the format of the firmware preamble frame is as follows: the bytes 0 to 9 are fixed characteristic bytes, the specific values are 10 bytes in total, i.e., 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88 and 0x99, the 10 byte is a firmware sum, the 11 byte is a start high address of the firmware, the 12 byte is a firmware low address, the 13 byte is a firmware length high address, the 14 byte is a firmware length low address, and the 15 byte is a parity or value of the previous 15 bytes. The 0 th byte to the 9 th byte may be set by themselves, and are not limited to the above-listed values.
The firmware data frame comprises a characteristic byte, a check byte and a data byte, wherein the characteristic byte is used for indicating that the type of the frame data is firmware; the check byte is used for checking whether the data is correct or not; the data bytes are used for upgrading the singlechip. In this embodiment, the format of the firmware data frame is as follows: 7+ N bytes, 7 bytes being fixed bytes, N bytes being specific data. The 0 th byte of the fixed byte of 7 bytes is a characteristic byte fixed to 0x46, and similarly, the value of the 0 th byte may be set by itself, and is not limited to the enumerated values. The 1 st byte is the high address of the base address of the firmware of the frame, the 2 nd byte is the low address of the base address of the firmware of the frame, the 3 rd byte is the high address of the length of the firmware of the frame, the 4 th byte is the low address of the firmware of the frame, the 5 th byte is the checksum of the firmware of the frame, and the 6 th byte is the exclusive or check value of the previous 6 bytes. The length value and the check value of the N-byte firmware data are determined by the corresponding contents of the fixed byte.
As shown in fig. 3, in step 3 and step 4, the bootstrap area of the single chip microcomputer collects data sent by the upper computer by using an inquiry method. The method comprises the following specific steps:
and inquiring a status register of the serial port every 500US, directly storing the data into a buffer area when detecting the change of the status bit, and generating a frame ending event when the MS does not receive the next data by more than 50. And then, carrying out data analysis to judge whether the frame is a firmware leading frame or a firmware data frame. If the firmware is the leading frame, corresponding verification is carried out, and the initial address, the length and the verification of the firmware are stored in the memory after the verification is correct. If the frame is a data frame, the previous 7 bytes of words are checked, the base address, the length and the check of the current firmware frame are stored into the memory after the check is correct, the data of the firmware frame with N bytes are stored into a buffer area, and the buffer area can be composed of an external EEPROM or FLASH. After receiving the complete firmware, the firmware can be integrally verified, and after the firmware is correctly verified, the data in the buffer area is stored in the memory of the single chip microcomputer, and then application programming (IAP programming) is performed. After the IAP programming is finished, the interrupt vector table of the APP area is remapped, if the single chip microcomputer supports the register to set the interrupt vector offset, the interrupt vector table is directly set, and if the register setting can not be supported, the interrupt jump address is remapped, so that the interrupt jump address can jump to the corresponding interrupt inlet of the APP area.
In summary, when the single chip microcomputer receives the upgrade firmware file, before the firmware file is received, the data bytes of the firmware data frame are stored in the buffer area, and after the firmware file is received, the data in the buffer area is stored in the memory, and the IAP programming is performed to upgrade the single chip microcomputer, so that errors are avoided in the upgrading process, and the safety and the stability of upgrading of the single chip microcomputer are improved.
The above description is only exemplary of the present invention and is not intended to limit the technical scope of the present invention, so that any minor modifications, equivalent changes and modifications made to the above exemplary embodiments according to the technical spirit of the present invention are within the technical scope of the present invention.

Claims (8)

CN202110636585.6A2021-06-082021-06-08Self-defined upgrading method of single chip microcomputerWithdrawnCN113407206A (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202110636585.6ACN113407206A (en)2021-06-082021-06-08Self-defined upgrading method of single chip microcomputer

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202110636585.6ACN113407206A (en)2021-06-082021-06-08Self-defined upgrading method of single chip microcomputer

Publications (1)

Publication NumberPublication Date
CN113407206Atrue CN113407206A (en)2021-09-17

Family

ID=77676971

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202110636585.6AWithdrawnCN113407206A (en)2021-06-082021-06-08Self-defined upgrading method of single chip microcomputer

Country Status (1)

CountryLink
CN (1)CN113407206A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CA2382913A1 (en)*2001-05-102002-11-10Ranco Incorporated Of DelawareSystem and method for securely upgrading firmware
CN109240730A (en)*2018-08-292019-01-18武汉光迅科技股份有限公司A kind of single-chip microcontroller online upgrading method and system
CN109901866A (en)*2017-12-072019-06-18航天科工惯性技术有限公司Online upgrading method and rotary steering system for multi-module system
CN112579130A (en)*2020-12-282021-03-30河南城拜检测技术有限公司Interactive IAP (Internet access protocol) upgrading method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CA2382913A1 (en)*2001-05-102002-11-10Ranco Incorporated Of DelawareSystem and method for securely upgrading firmware
CN109901866A (en)*2017-12-072019-06-18航天科工惯性技术有限公司Online upgrading method and rotary steering system for multi-module system
CN109240730A (en)*2018-08-292019-01-18武汉光迅科技股份有限公司A kind of single-chip microcontroller online upgrading method and system
CN112579130A (en)*2020-12-282021-03-30河南城拜检测技术有限公司Interactive IAP (Internet access protocol) upgrading method

Similar Documents

PublicationPublication DateTitle
CN111142919B (en)Method suitable for simultaneous upgrading of multiple groups of MCU unit programs
CN101196823B (en)Method, system and equipment for on-line software upgrade in open application structure
US10691569B2 (en)System and method for testing a data storage device
CN111506333B (en)double-DSP program online upgrading method and system
CN114860279B (en)Rapid empty-chip upgrading method
CN108037931B (en)Method for writing file in storage unit of microprocessor
WO2024168522A1 (en)Smart device and system program switching control method thereof
CN109857433B (en)Single chip microcomputer software upgrading tool and method
CN112181444B (en)DSP multi-core data programming method based on 1553B bus
CN113407206A (en)Self-defined upgrading method of single chip microcomputer
CN108845823A (en)A kind of on-line software updating method based on F2812 chip
CN118672635A (en)System upgrading method and device for embedded equipment under small memory
CN111857785A (en) A kind of MCU startup method, device and terminal equipment
CN117251190A (en)Online upgrading method and system based on 1553B bus
CN100461713C (en) A method for data loading of communication equipment
CN119363729B (en) A DSP online upgrade system and method for error-correctable serial communication
CN117193833B (en)Industrial control application firmware online upgrading method
CN120429036A (en)Ymodel protocol online loading method and system based on FPGA
CN119363729A (en) A DSP online upgrade system and method for error-correctable serial communication
CN115167889B (en) A method and device for upgrading BD board based on PLC
CN116185451A (en)Online programming upgrading system and method for BOOT pin-free singlechip
CN118200138A (en) A type III dedicated transformer terminal and a method for upgrading a cross-purchase module based on the terminal
CN116430771A (en)Singlechip program upgrading method and system based on power line carrier communication
CN118689515B (en) A software upgrade method based on IIC protocol
CN114863662B (en)Resident water meter or gas meter remote upgrading system

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
WW01Invention patent application withdrawn after publication

Application publication date:20210917

WW01Invention patent application withdrawn after publication

[8]ページ先頭

©2009-2025 Movatter.jp