CN112947978A - Method for upgrading firmware based on chip usbhid, terminal device and computer readable storage medium - Google Patents
Method for upgrading firmware based on chip usbhid, terminal device and computer readable storage medium Download PDFInfo
- Publication number
- CN112947978A CN112947978A CN202110356558.3A CN202110356558A CN112947978A CN 112947978 A CN112947978 A CN 112947978A CN 202110356558 A CN202110356558 A CN 202110356558A CN 112947978 A CN112947978 A CN 112947978A
- Authority
- CN
- China
- Prior art keywords
- chip
- firmware
- usb
- upgrading
- 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.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 37
- 238000012795 verification Methods 0.000 claims description 12
- 230000008569 process Effects 0.000 claims description 11
- 230000004044 response Effects 0.000 claims description 10
- 238000004891 communication Methods 0.000 claims description 9
- 238000004590 computer program Methods 0.000 claims description 6
- 230000009191 jumping Effects 0.000 claims description 5
- 125000004122 cyclic group Chemical group 0.000 claims description 4
- 238000012423 maintenance Methods 0.000 abstract description 2
- 238000010586 diagram Methods 0.000 description 5
- 230000006870 function Effects 0.000 description 5
- 238000012545 processing Methods 0.000 description 2
- 241000282414 Homo sapiens Species 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000011160 research Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/65—Updates
- G06F8/654—Updates using techniques specially adapted for alterable solid state memories, e.g. for EEPROM or flash memories
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/08—Error detection or correction by redundancy in data representation, e.g. by using checking codes
- G06F11/10—Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
- G06F11/1004—Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's to protect a block of data words, e.g. CRC or checksum
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/71—Version control; Configuration management
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Computer Security & Cryptography (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Quality & Reliability (AREA)
- Stored Programmes (AREA)
Abstract
The invention discloses a method for upgrading firmware based on a chip usbhid, a terminal device and a computer readable storage medium, wherein the method comprises the following steps: reading the original firmware version number of the chip through a USB; sending a chip reset instruction to the chip through the USB, and enabling the chip to respond to the instruction, automatically resetting and restarting, running a boot program of a first storage area of the chip and waiting for receiving a firmware data packet; sending a firmware data packet to the chip through the USB; judging whether the firmware data packet contains new firmware data by a boot program in the chip; if so, the new firmware data is temporarily stored in the RAM area of the chip, after temporary storage, the firmware data is simulated and burned to the second storage area in a FLASH writing mode, the user program is written in and operated, and the chip is enabled to update the upgraded firmware version number. The invention realizes the convenience of firmware upgrading, does not need to install a driver, saves the maintenance cost, can upgrade again after upgrading fails and ensures the safety.
Description
Technical Field
The present invention relates to embedded programming, and in particular, to a method for upgrading firmware based on a Universal Serial Bus-Human Interface Device (usb-Human Interface Device), a terminal Device, and a computer-readable storage medium.
Background
Generally, in a chip of firmware to be upgraded, such as a single chip microcomputer chip, and more specifically, such as a stm32 chip, firmware upgrade of these chips requires burning firmware through a burner or a downloader in a development stage, and if a product is delivered to a customer, the product needs to carry a corresponding burner or downloader; some devices also need to disassemble the device shell to update the firmware, which is very inconvenient.
The above background disclosure is only for the purpose of assisting understanding of the concept and technical solution of the present invention and does not necessarily belong to the prior art of the present patent application, and should not be used for evaluating the novelty and inventive step of the present application in the case that there is no clear evidence that the above content is disclosed at the filing date of the present patent application.
Disclosure of Invention
In order to solve the problem of inconvenience in firmware upgrading in the prior art, the invention provides a method for upgrading firmware based on a chip usbhid, a terminal device and a computer-readable storage medium.
The technical problem of the invention is solved by the following technical scheme:
the invention provides a method for upgrading firmware based on a chip usbhid, which comprises the following steps: s1: reading the original firmware version number of the chip through the USB, and judging whether a new version needing to be upgraded exists or not if the reading is successful; s2: if yes, sending a chip reset instruction to the chip through the USB, and enabling the chip to respond to the instruction, automatically resetting and restarting, operating a bootstrap program of a first storage area of the chip, and waiting for receiving a firmware data packet; s3: sending a firmware data packet to the chip through the USB; judging whether the firmware data packet contains new firmware data by a boot program in the chip; if so, temporarily storing the new firmware data in an RAM area of the chip, after temporarily storing, simulating and burning the firmware data in a second storage area in a FLASH writing mode, after writing in the running user program, and enabling the chip to update the upgraded firmware version number; if not, jumping to the second storage area to run the user program.
In some embodiments, in the step S3, the number of segments for receiving and writing the firmware data packet into the new firmware data is set according to the storage space of the RAM area.
In some embodiments, in the step S3, before sending the firmware data packet, a handshake instruction is sent to the chip, where the handshake instruction includes a start address of the second storage area, a size of the new firmware data to be upgraded, a size of the data written in each segment, and a CRC check; after the chip is prompted to receive a handshake instruction, the bootstrap program is instructed to judge whether a write-in initial address, the size of new firmware data to be upgraded, the size of data written in each segment and CRC (cyclic redundancy check) are correct or not; if the handshake fails, resending the handshake instruction until the chip is prompted to check correctly or the upgrade exits after overtime; and if the handshake is successful, sending a firmware data packet to the chip through the USB.
In some embodiments, the step S3, the sending the firmware data packet includes: sending data of an upgrading process in frames each time, wherein each frame of data is subjected to CRC; if the chip is not verified correctly, receiving a response signal of failed verification returned by the chip, and repeatedly sending the current frame data until the verification is correct or the verification is overtime, and quitting the upgrading; if the chip is verified correctly, receiving a response signal of successful verification returned by the chip, and temporarily storing the received data in the RAM; and receiving the response signal successfully verified, and then sending the next frame of data.
In some embodiments, in the step S3, after receiving the new firmware data or receiving the new firmware data to reach the size of the data written each time in the segment specified by the handshake instruction, the new firmware data temporarily stored in the chip RAM area is written into the second storage area; the starting address written in the second storage area is the starting address corresponding to the handshake instruction.
In some embodiments, in the step S3, when the boot program determines whether the firmware data packet contains new firmware data, if the boot program does not receive the new firmware data within the predetermined time, the boot program exits from the upgrade and jumps to the second storage area to run the user program.
In some embodiments, in the step S3, if the chip receives the firmware upgrading signal while running the user program, a reset instruction is sent, which means that the chip is reset and restarted after successfully receiving the reset instruction, and the operation is started from the boot program; if the reset fails, detecting whether VID and PID are correctly set, detecting whether the USB line is well connected, and prompting a user to correctly set VID and PID again or connect the USB line.
In some embodiments, in the step S3, when the user program is running and before the USB program is initialized, the USB software is reset to prevent the USB communication from failing; the USB software reset comprises the step of simulating the USB plugging, namely, the D + pin of the USB is firstly pulled down and then pulled up through software.
The invention also provides a terminal device for upgrading firmware based on a chip usbhid, which comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein the processor implements the steps of any one of the methods when executing the computer program.
The invention also proposes a computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of the above.
Compared with the prior art, the invention has the advantages that: the invention simulates firmware burning by writing in FLASH, can operate and update the firmware of a user only by connecting a PC and a chip through a USB without configuring a burner or a downloader which is used by research personnel; particularly for some devices, the chip originally interacts information with the computer through the USB, so that firmware upgrading can be conveniently carried out only by operating a firmware upgrading interface on the PC, and maintenance cost is saved; the invention uses the usbhid, can be used by being plugged into a PC without installing a drive, and is very convenient; secondly, the boot program and the user firmware to be upgraded are not stored in one area, and the boot program cannot be erased in the upgrading process, so that the boot program can be upgraded again after the upgrading fails, and the safety is ensured.
Drawings
FIG. 1 is a flowchart of a method for upgrading firmware based on a chip usb flash according to an embodiment of the present invention;
FIG. 2 is a storage upgrade diagram of a method for upgrading firmware based on a chip usb flash according to an embodiment of the present invention;
fig. 3 is a flowchart of an upgrade operation of a method for upgrading firmware based on a chip usbhid according to an embodiment of the present invention;
FIG. 4 is a flowchart of a boot program process of a method for upgrading firmware based on a chip usb flash according to an embodiment of the present invention;
FIG. 5 is a PC operation interface diagram of the method for upgrading firmware based on the chip usbhid according to the embodiment of the present invention;
fig. 6 is a handshake process diagram of a method for upgrading firmware based on a chip usbhid according to an embodiment of the present invention;
fig. 7 is a process diagram of receiving firmware data and burning according to the method for upgrading firmware based on a chip usbhid in the embodiment of the present invention.
Detailed Description
The invention will be further described with reference to the accompanying drawings and preferred embodiments. It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict.
The embodiment of the invention comprises three parts: the time sequence relations of the three parts are as follows, as shown in fig. 1:
the HID is a device directly interacting with human beings, and the usbhid is an abbreviation of universal serial bus-human interface device, such as a keyboard, a mouse, a joystick and the like, and can interact without installing a driver. The PC adopts the usbhid protocol for communicating with the chip (such as the stm32 single chip) of the firmware to be upgraded.
The PC terminal program sends instructions or data to the bootstrap program and the user program through the USB, and the bootstrap program and the user program can respond through the USB after receiving the instructions sent by the PC terminal.
The boot program is used for upgrading the user firmware, and the judgment condition in the boot program meets the requirement and automatically jumps to the user program for operation through a jump instruction.
The user program mainly realizes functions required by clients, and some functions are added for matching with firmware upgrading. When the user program is operated, the firmware to be upgraded needs to be returned to the bootstrap program, except for the power-off and restarting of the chip, the PC terminal can send a lower computer reset instruction to reset the chip and then enter the bootstrap program.
The PC program reads the original firmware version number of the chip through the USB, and if the reading is successful, whether a new version needing to be upgraded exists is judged; if the reading fails, whether VID (Vendor ID, supplier ID) and PID (Product ID ) are correctly set and whether the USB line is well connected are detected, and the user is prompted to correctly set VID and PID again or connect the USB line.
Sending a chip reset instruction to the chip through the USB, and enabling the chip to respond to the instruction, automatically resetting and restarting, running a boot program of a first storage area of the chip and waiting for receiving a firmware data packet; opening a firmware data packet; sending a firmware data packet to the chip through the USB; judging whether the firmware data packet contains new firmware data by a boot program in the chip; if so, temporarily storing the new firmware data in an RAM area of the chip, after temporarily storing, simulating and burning the firmware data in a second storage area in a FLASH writing mode, after writing in the running user program, and enabling the chip to update the upgraded firmware version number; if not, jumping to the second storage area to run the user program.
Preferably, the number of sections for receiving and writing the new firmware data in the firmware data packet is set according to the storage space of the RAM area; if the storage space of the RAM area is smaller than the new firmware data, the size of the data received and written each time (smaller than the size of the RAM) is set, the data is written in a segmented mode, and the last written address of each time is recorded. And writing the received next block of data into the last written address of the previous block of data, and repeating the receiving and the writing until the data is completely written.
Preferably, writing to the second storage area comprises: the received data is temporarily stored in the RAM and then written into the second storage area, see fig. 5; the sm32 chip communicates with the computer through USB, the sm32 chip receives the firmware to be upgraded and temporarily stores the firmware in the RAM area, then reads the firmware from the RAM area and writes the firmware into the flash block after 0x80004000, the 64k flash comprises a first storage area in which a boot program is stored in 16k and a second storage area in which a user program is stored in 48k (the specific memory allocation can be adjusted according to the size of the chip, the size of the boot program and the size of the user firmware, and the memory allocation is not limited to the memory allocation listed here).
Preferably, before sending the firmware data packet, sending a handshake instruction to the chip, where the handshake instruction includes an initial address of the second storage area, a size of new firmware data to be upgraded, a size of data written in each segment, and CRC check; after the chip is prompted to receive a handshake instruction, the bootstrap program is instructed to judge whether a write-in initial address, the size of new firmware data to be upgraded, the size of data written in each segment and CRC (cyclic redundancy check) are correct or not; if the handshake fails, resending the handshake instruction until the chip is prompted to check correctly or the upgrade exits after overtime; and if the handshake is successful, sending a firmware data packet to the chip through the USB. The handshake process is as shown in fig. 6, and determining whether the handshake is correct includes: judging whether the CRC is correct, judging whether the burning address is correct, judging whether a new firmware data packet is overlarge, and judging whether the RAM internal memory can store data to be burned at a time.
Preferably, sending the firmware data packet comprises: sending data of an upgrading process in frames each time, wherein each frame of data is subjected to CRC; if the chip is not verified correctly, receiving a response signal of failed verification returned by the chip, and repeatedly sending the current frame data until the verification is correct or the verification is overtime, and quitting the upgrading; if the chip is verified correctly, receiving a response signal of successful verification returned by the chip, and temporarily storing the received data in the RAM; and receiving the response signal successfully verified, and then sending the next frame of data.
Further, after receiving the new firmware data or the new firmware data reaches the size of the data written in each segment specified by the handshake instruction, the new firmware data temporarily stored in the chip RAM area is written into the second storage area; the starting address written in the second storage area is the starting address corresponding to the handshake instruction.
Preferably, when the boot program determines whether the firmware data packet contains new firmware data, if the boot program does not receive the new firmware data within a self-defined preset time (for example, the preset time is 5s), the boot program quits upgrading and jumps to the second storage area to run the user program.
Preferably, if the chip receives a firmware upgrading signal when the user program is operated, a reset instruction is sent, the chip is reset and restarted after successfully receiving the reset instruction, and the operation is started from the boot program; if the reset fails, detecting whether VID and PID are correctly set, detecting whether the USB line is well connected, and prompting a user to correctly set VID and PID again or connect the USB line.
Preferably, when the user program runs and before the USB is initialized, the USB software is reset to prevent the USB communication from failing; the USB software reset comprises the step of simulating the USB plugging, namely, the D + pin of the USB is firstly pulled down and then pulled up through software.
The upgrade operation flow diagram is shown in fig. 3. Running a user program, clicking a 'firmware version', reading a user firmware version number, displaying the current user firmware version number if the reading is successful, and detecting whether VID and PID of a USB connection line and a USB are correctly set if the reading is failed; clicking the 'open file', selecting and opening the firmware to be upgraded; clicking 'lower computer reset', entering a bootstrap program if the reset is successful, and detecting whether VID and PID of a USB connection line and a USB are correctly set if the reset is failed; and clicking to start upgrading, firstly sending a handshake signal, and sending the opened firmware data packet to the chip after receiving a correct response signal, namely, successfully handshaking.
Specifically, the method comprises the following steps:
1. boot program
The boot program needs to be factory written to the chip.
This program is allocated to a memory area (part of a flash area) of a chip (e.g., stm 32). The process includes:
(1) a usbhid communication part;
(2) processing and receiving data sent by a PC (judging whether effective user firmware is received or not, temporarily storing the received data in an RAM if the effective user firmware is received, waiting for a few seconds if the effective user firmware is not received, and jumping to a user program to run after timeout);
(3) writing the received user firmware data packet into a corresponding flash area;
(4) and jumping to a flash area for storing the user program to run.
The boot process flow is shown in fig. 4. The chip can run a bootstrap program after reset, whether the USB receives data is judged within 5s (the waiting time can be defined by the chip), whether the USB receives the data is valid firmware data is detected if the USB receives the data, the data is received and written into the flash, a new program is jumped to run after the upgrade is successful, and an original program is jumped to run if the upgrade is failed.
2. User program
The program is the realization of the client function, and in order to cooperate with the USB upgrading, corresponding processing is required to be carried out:
(1) the false block stored by the user program needs to be configured not to overlap with the flash block stored by the bootstrap program;
(2) the user program also needs a usbhid communication part;
(3) and adding a USB software reset function. When the user program executes the USB software reset code before initializing the USB flash, the USB is reset first to ensure that the USB communication is normal. Because the user program and the bootstrap program both use the usbhid protocol, after the bootstrap program jumps to the user program, the USB host needs to be unplugged and plugged to allow the USB host to re-enumerate the connection control card, otherwise the USB communication may not be available when the user program is run. However, sometimes the control card and the PC end USB are connected and sealed in the equipment, so that the plugging and unplugging are inconvenient, the plugging and unplugging can be simulated, namely the USB software is reset, and the USB software can be realized by pulling down the D + pin of the USB firstly and then pulling up the D + pin;
(4) and adding a chip software reset function. The reset of the chip is because the upgrade needs to be carried out in the operation of the bootstrap program, generally, the chip jumps to the user program to operate after the operation of the bootstrap program is finished, and if the USB upgrade needs to be carried out in the user program, the chip needs to be returned to the bootstrap program to operate. After the chip is electrified and restarted, the chip can enter a bootstrap program to operate, but the chip has limitation or inconvenience, so the chip needs to be reset;
(5) and the current firmware version number is added, so that the identification is convenient.
PC terminal program
This program is used to operate to select the user firmware package to be upgraded to open, and when stm32 is running the boot program, the selected firmware data package is sent to stm32 via USB, and the PC operation interface is as shown in fig. 5. The process includes:
(1) an "open file" operation; clicking an 'open file' (A), opening the firmware to be upgraded, and displaying a firmware path on an interface after the firmware path is opened (see 1);
(2) "start upgrade" operation; after the firmware to be upgraded is selected by opening the file, VID and PID are set (at D), and then the firmware version is clicked to determine that the upgrading is needed, the 'lower computer reset' is clicked (at C). Immediately clicking to start upgrading (at B) after the reset is successfully displayed (see 2, which indicates that the chip restarts to run the boot program) (the upgrading cannot be performed after the chip cannot wait too long or the boot program is skipped due to overtime); then displaying a handshake signal waiting for sending (see 3), then sending firmware data (see 4, displaying how much data is sent currently), prompting whether writing is successful or not after writing is finished (see 5), and finally skipping to run a user program (see 6), wherein 7 and 8 in fig. 5 prompt how long time is spent for writing and how much data is written, and 9 displays the current firmware version information; at this time, clicking the firmware version (F position) displays the upgraded firmware version number; displaying a progress bar at the position H;
(3) controlling stm32 to reset; clicking the lower computer to reset (C), and controlling the chip to reset and restart the running bootstrap program;
(4) inquiring the firmware version number; clicking the firmware version number (F) can read the firmware number of the board card communicating with the current time.
The PC operation interface further comprises:
(1) VID and PID configuration; one computer can simultaneously carry out USB communication with a plurality of board cards, and the VID and the PID corresponding to the board cards need to be modified (position D) when the board cards are upgraded;
(2) adjusting the size of the segments; sometimes, the RAM is insufficient, and the firmware data packet cannot be stored at one time, the segment size (G position) needs to be set; if 8192 is set, the program writes to flash first after receiving 8192byte, and then receives the byte, if 40000 byte exists in the program, 5 times of writing is required (40000/8192 equals 4.8, 8192byte is written in the first four times, and 40000 minus 8192 equals 7232byte is written in the last time);
(3) the operation of 'screen clearing'; clicking to clear the screen (at E), the current screen information may be cleared.
The key points of the idea provided by the invention are as follows:
(1) the bootstrap program and the user program are stored in different flash blocks, and the user program can be restored again when the user program fails to be upgraded, so that risks are avoided;
(2) CRC (cyclic redundancy check) check and retransmission mechanisms are added to data received every time, so that upgrading failure caused by unstable communication is reduced;
(3) resetting USB software to prevent the USB from being plugged;
(4) the PC sends an instruction to control the chip to reset through the USB, so that the condition that the power is required to be re-electrified and restarted is avoided;
(5) the RAM temporarily stores a data packet for upgrading the firmware, and supports segmented receiving and writing if the RAM is insufficient;
(6) if a plurality of USB devices are connected, the appointed devices can be selected and upgraded by setting VID and PID through a computer operation interface, and the operation is convenient.
If the firmware needs to be upgraded when the user program is operated, and the chip receives a firmware upgrading signal when the user program is operated, a reset instruction is sent first, the chip is reset and restarted after successfully receiving the reset instruction, and then the operation is started from the bootstrap program; if the reset fails, detecting whether the VID and the PID of the USB are correctly set and whether the USB line is plugged, and prompting a user to correctly set the VID and the PID again or connect the USB line. Because the firmware needs to be upgraded in the boot program first, the chip is generally powered on again in the general operation, but some device control cards and computers share a power supply, the power on again is troublesome, and the boot program design generally runs for several seconds and jumps to the user firmware to run when a firmware data packet is not received, so that after the power on again, the PC is not started up yet, the chip runs the boot program too late to send the firmware data packet to the chip, and the upgrade is failed. The USB sends an instruction to restart the chip, and the boot program can be entered without power-off restart.
The foregoing is a more detailed description of the invention in connection with specific preferred embodiments and it is not intended that the invention be limited to these specific details. For those skilled in the art to which the invention pertains, several equivalent substitutions or obvious modifications can be made without departing from the spirit of the invention, and all the properties or uses are considered to be within the scope of the invention.
Claims (10)
1. A method for upgrading firmware based on a chip usb chip is used for upgrading the firmware in a single chip of the firmware to be upgraded, and is characterized by comprising the following steps:
s1: reading the original firmware version number of the chip through the USB, and judging whether a new version needing to be upgraded exists or not if the reading is successful;
s2: if yes, sending a chip reset instruction to the chip through the USB, and enabling the chip to respond to the instruction, automatically resetting and restarting, operating a bootstrap program of a first storage area of the chip, and waiting for receiving a firmware data packet;
s3: sending a firmware data packet to the chip through the USB; judging whether the firmware data packet contains new firmware data by a boot program in the chip;
if so, temporarily storing the new firmware data in an RAM area of the chip, after temporarily storing, simulating and burning the firmware data in a second storage area in a FLASH writing mode, after writing in the running user program, and enabling the chip to update the upgraded firmware version number;
if not, jumping to the second storage area to run the user program.
2. The method for upgrading firmware based on a chip usb flash of claim 1, wherein in the step S3, the number of sections for receiving and writing the firmware data packet into the firmware is set according to the storage space of the RAM area.
3. The method for upgrading firmware based on a chip usb chip according to claim 2, wherein in the step S3, before sending the firmware data packet, a handshake command is sent to the chip, including a start address of the second storage area, a size of new firmware data to be upgraded, a size of data written each time in a segment, and a CRC check;
after the chip is prompted to receive a handshake instruction, the bootstrap program is instructed to judge whether a write-in initial address, the size of new firmware data to be upgraded, the size of data written in each segment and CRC (cyclic redundancy check) are correct or not;
if the handshake fails, resending the handshake instruction until the chip is prompted to check correctly or the upgrade exits after overtime;
and if the handshake is successful, sending a firmware data packet to the chip through the USB.
4. The method for upgrading firmware based on a chip usb, according to claim 2, wherein the step of S3, sending the firmware data packet includes: sending data of an upgrading process in frames each time, wherein each frame of data is subjected to CRC;
if the chip is not verified correctly, receiving a response signal of failed verification returned by the chip, and repeatedly sending the current frame data until the verification is correct or the verification is overtime, and quitting the upgrading;
if the chip is verified correctly, receiving a response signal that the chip returns that the verification is successful, and temporarily storing the received new firmware data in an RAM area of the chip;
and receiving the response signal successfully verified, and then sending the next frame of data.
5. The method for upgrading firmware based on a chip usb flash memory according to claim 4, wherein in step S3, after receiving the new firmware data or the new firmware data reaching the size of the segment write-in data each time specified by the handshake command, the new firmware data temporarily stored in the RAM area of the chip is written into the second storage area; the starting address written in the second storage area is the starting address corresponding to the handshake instruction.
6. The method for upgrading firmware based on a chip usb flash as claimed in claim 1, wherein in step S3, when the boot program determines whether the firmware data packet contains new firmware data, if the boot program does not receive the new firmware data within the predefined time, the boot program exits from upgrading and jumps to the second storage area to run the user program.
7. The method for upgrading firmware based on a chip usbhid according to claim 1, wherein in the step S3, if the chip receives a firmware upgrading signal while running the user program, a reset instruction is sent to enable the chip to reset and restart after successfully receiving the reset instruction, and the operation is started from the boot program;
if the reset fails, detecting whether VID and PID are correctly set, detecting whether the USB line is well connected, and prompting a user to correctly set VID and PID again or connect the USB line.
8. The method for upgrading firmware based on chip USB flash as claimed in claim 1, wherein in step S3, when the user program is running and before the USB flash is initialized, the USB software is reset to prevent USB communication failure;
the USB software reset comprises the step of simulating the USB plug, and the D + pin of the USB is firstly pulled down and then pulled up through software.
9. A terminal device for upgrading firmware based on a chip usbhid, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any of claims 1-8 when executing the computer program.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110356558.3A CN112947978A (en) | 2021-04-01 | 2021-04-01 | Method for upgrading firmware based on chip usbhid, terminal device and computer readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110356558.3A CN112947978A (en) | 2021-04-01 | 2021-04-01 | Method for upgrading firmware based on chip usbhid, terminal device and computer readable storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112947978A true CN112947978A (en) | 2021-06-11 |
Family
ID=76232081
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110356558.3A Pending CN112947978A (en) | 2021-04-01 | 2021-04-01 | Method for upgrading firmware based on chip usbhid, terminal device and computer readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112947978A (en) |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113377389A (en) * | 2021-06-30 | 2021-09-10 | 西安诺瓦星云科技股份有限公司 | Data processing method and device, computer readable storage medium and processor |
CN113377409A (en) * | 2021-06-21 | 2021-09-10 | 西安超越申泰信息科技有限公司 | Method, equipment and storage medium for stabilizing BIOS update |
CN113590143A (en) * | 2021-08-03 | 2021-11-02 | 北京宇系航通科技有限公司 | MCU program downloading method based on USB, electronic equipment and storage medium |
CN113626065A (en) * | 2021-08-12 | 2021-11-09 | 深圳市蝶通视讯有限公司 | Embedded firmware redundancy method and device |
CN113641367A (en) * | 2021-08-06 | 2021-11-12 | 瑞芯微电子股份有限公司 | Firmware batch burning method and terminal |
CN113848853A (en) * | 2021-09-27 | 2021-12-28 | 一飞智控(天津)科技有限公司 | Flight controller upgrading flow processing method, system, terminal, medium and application |
CN118012471A (en) * | 2024-01-24 | 2024-05-10 | 安易行(常州)新能源科技有限公司 | Charging program upgrading method based on charging control board of new energy automobile battery exchange station |
Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
KR20030073824A (en) * | 2002-03-13 | 2003-09-19 | 주식회사 레인콤 | A method and apparatus for upgrading a system firmware by using an universal serial bus |
CN106406967A (en) * | 2016-11-15 | 2017-02-15 | 恒鸿达信息技术有限公司 | STM32-based USB online upgrade method and system |
CN106598668A (en) * | 2016-12-13 | 2017-04-26 | 西安航天精密机电研究所 | Method for carrying out remote upgrade on AGV (Automatic Guided Vehicle) logistic transportation system on basis of dispatching system |
CN107562493A (en) * | 2017-10-24 | 2018-01-09 | 厦门市福工动力技术有限公司 | Chip online upgrading method and computer-readable recording medium |
CN107634859A (en) * | 2017-09-30 | 2018-01-26 | 飞天诚信科技股份有限公司 | A kind of firmware upgrade method and device |
CN108572847A (en) * | 2018-05-18 | 2018-09-25 | 深圳国人通信股份有限公司 | A method of scm software version is upgraded by USB port |
CN109189434A (en) * | 2018-09-20 | 2019-01-11 | 安徽南瑞中天电力电子有限公司 | A kind of online upgrading method of electric energy meter |
CN109857434A (en) * | 2019-01-15 | 2019-06-07 | 厦门亿联网络技术股份有限公司 | Method for upgrading software based on USB |
CN110727454A (en) * | 2019-10-24 | 2020-01-24 | 北京云迹科技有限公司 | Updating method and device of intelligent equipment, electronic equipment and storage medium |
-
2021
- 2021-04-01 CN CN202110356558.3A patent/CN112947978A/en active Pending
Patent Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
KR20030073824A (en) * | 2002-03-13 | 2003-09-19 | 주식회사 레인콤 | A method and apparatus for upgrading a system firmware by using an universal serial bus |
CN106406967A (en) * | 2016-11-15 | 2017-02-15 | 恒鸿达信息技术有限公司 | STM32-based USB online upgrade method and system |
CN106598668A (en) * | 2016-12-13 | 2017-04-26 | 西安航天精密机电研究所 | Method for carrying out remote upgrade on AGV (Automatic Guided Vehicle) logistic transportation system on basis of dispatching system |
CN107634859A (en) * | 2017-09-30 | 2018-01-26 | 飞天诚信科技股份有限公司 | A kind of firmware upgrade method and device |
CN107562493A (en) * | 2017-10-24 | 2018-01-09 | 厦门市福工动力技术有限公司 | Chip online upgrading method and computer-readable recording medium |
CN108572847A (en) * | 2018-05-18 | 2018-09-25 | 深圳国人通信股份有限公司 | A method of scm software version is upgraded by USB port |
CN109189434A (en) * | 2018-09-20 | 2019-01-11 | 安徽南瑞中天电力电子有限公司 | A kind of online upgrading method of electric energy meter |
CN109857434A (en) * | 2019-01-15 | 2019-06-07 | 厦门亿联网络技术股份有限公司 | Method for upgrading software based on USB |
CN110727454A (en) * | 2019-10-24 | 2020-01-24 | 北京云迹科技有限公司 | Updating method and device of intelligent equipment, electronic equipment and storage medium |
Cited By (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113377409A (en) * | 2021-06-21 | 2021-09-10 | 西安超越申泰信息科技有限公司 | Method, equipment and storage medium for stabilizing BIOS update |
CN113377409B (en) * | 2021-06-21 | 2024-03-01 | 超越科技股份有限公司 | Method, equipment and storage medium for stabilizing BIOS updating |
CN113377389A (en) * | 2021-06-30 | 2021-09-10 | 西安诺瓦星云科技股份有限公司 | Data processing method and device, computer readable storage medium and processor |
CN113590143A (en) * | 2021-08-03 | 2021-11-02 | 北京宇系航通科技有限公司 | MCU program downloading method based on USB, electronic equipment and storage medium |
CN113590143B (en) * | 2021-08-03 | 2023-11-17 | 北京北航天宇长鹰无人机科技有限公司 | MCU program downloading method based on USB, electronic equipment and storage medium |
CN113641367A (en) * | 2021-08-06 | 2021-11-12 | 瑞芯微电子股份有限公司 | Firmware batch burning method and terminal |
CN113626065A (en) * | 2021-08-12 | 2021-11-09 | 深圳市蝶通视讯有限公司 | Embedded firmware redundancy method and device |
CN113626065B (en) * | 2021-08-12 | 2024-04-19 | 深圳市蝶通视讯有限公司 | Embedded firmware redundancy method and device |
CN113848853A (en) * | 2021-09-27 | 2021-12-28 | 一飞智控(天津)科技有限公司 | Flight controller upgrading flow processing method, system, terminal, medium and application |
CN118012471A (en) * | 2024-01-24 | 2024-05-10 | 安易行(常州)新能源科技有限公司 | Charging program upgrading method based on charging control board of new energy automobile battery exchange station |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112947978A (en) | Method for upgrading firmware based on chip usbhid, terminal device and computer readable storage medium | |
CN109189445B (en) | Method for upgrading program of equipment of Internet of things | |
CN107179909B (en) | Software upgrading method and device and computer readable storage medium | |
CN101557583B (en) | Remote-updating and version-switching method of repeater equipment embedded software | |
WO2020062887A1 (en) | Firmware upgrading method and system based on flash micro-controller, and flash micro-controller | |
CN112947977B (en) | Online software upgrading method and system | |
EP3879399B1 (en) | Method and apparatus for upgrading vehicle-mounted tbox, device, and storage medium | |
CN110045968B (en) | STM32 cross-singlechip program burning method | |
CN112152846B (en) | Metering instrument remote upgrading method based on Internet of things | |
CN105760191A (en) | Embedded system equipment programming mass production method | |
CN113900693B (en) | Firmware upgrading method, device and system, electronic equipment and storage medium | |
CN108345464A (en) | A kind of the startup method and Android vehicle device of Android system | |
CN111240753A (en) | Loading method of bootstrap program, storage medium and embedded terminal | |
CN111897560A (en) | NB-IoT module-based program upgrading system, method, device and storage medium | |
CN109634781A (en) | One kind is based on embedded program two-region Backup Images system and starting method | |
CN114138295A (en) | Method, device and system for upgrading application program firmware of electronic equipment | |
CN110908733B (en) | Working mode determining method and device, and control method and device | |
CN116755749A (en) | On-board MCU upgrading method, on-board MCU, board card and information processing system | |
CN211427090U (en) | Micro control unit device | |
CN110737483B (en) | Signaling and data transmission method based on Windows USB MassStorage class | |
JP2002175193A (en) | Device and method for rewriting program | |
JP2021089643A (en) | Electronic control apparatus and electronic control method | |
CN112667267A (en) | Washing machine firmware upgrading method and washing machine | |
CN113467842B (en) | Method for starting embedded device suitable for industrial application scene, embedded device and computer readable storage medium | |
CN110308939A (en) | Information processing method and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |