CN108958781B - Remote embedded firmware online upgrading method - Google Patents
Remote embedded firmware online upgrading method Download PDFInfo
- Publication number
- CN108958781B CN108958781B CN201810730456.1A CN201810730456A CN108958781B CN 108958781 B CN108958781 B CN 108958781B CN 201810730456 A CN201810730456 A CN 201810730456A CN 108958781 B CN108958781 B CN 108958781B
- Authority
- CN
- China
- Prior art keywords
- firmware
- acquisition controller
- intelligent acquisition
- server
- 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.)
- Active
Links
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
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
A remote embedded firmware online upgrade method comprises an APP program and a Bootload program, wherein the APP program comprises a step S1: setting an offset interrupt vector table; step S2: initializing a clock and peripheral equipment; step S3: establishing communication connection with a server; step S4: receiving and identifying an instruction which is sent by a server and requests for upgrading the firmware; step S5: judging whether to approve upgrading; step S6: marking an upgrading flag bit; step S7: sending out a response signal; the Bootload program includes: step S8: initializing the offset of an APP program, and setting an offset interrupt vector table to zero; step S9: judging whether the upgrading flag bit is a specific mark or not; step S10: receiving and identifying a data packet which contains firmware data and is sent by a server; step S11: judging whether the firmware data is correct or not; step S12, burning the firmware data into the flash memory; and step S13, sending a firmware upgrading feedback signal to the server. Thus, the embedded firmware can be safely and efficiently updated remotely.
Description
Technical Field
The invention relates to a firmware upgrading method, in particular to a remote embedded firmware online upgrading method.
Background
The intelligent acquisition controller can be used for unattended stations. The intelligent acquisition controller can acquire station switching value, analog quantity and equipment running state information and communicates with a remote data center communication server through TCP/IP connection in a 4G communication mode. And the acquired data information is sent to a remote data center for processing. The user can inquire information through the mobile phone APP and the WEB client. The remote data service center sends a control instruction to the intelligent acquisition controller through the mobile phone APP and the WEB client, and the controller analyzes the control instruction and executes control operation to realize remote control. Generally, if the embedded software code of the intelligent acquisition controller needs to be upgraded or the product needs to be modified, the program needs to be rewritten on site. Thus, the time and the cost are large expenses, and the method is very inconvenient and inflexible.
Disclosure of Invention
In view of the above, the present invention provides a remote embedded firmware online upgrade method capable of remotely updating embedded firmware safely and efficiently, so as to solve the above problems.
A remote embedded firmware online upgrading method comprises an APP program and a Bootload program, wherein the APP program comprises:
step S1: setting an offset interrupt vector table;
step S2: initializing a clock and peripheral equipment of the intelligent acquisition controller;
step S3: executing a program set by a user, and establishing communication connection with a server by adopting a TCP/IP protocol;
step S4: the intelligent acquisition controller receives and identifies an instruction which is sent by the server and requests for upgrading the firmware;
step S5: the intelligent acquisition controller judges whether to approve upgrading;
step S6: if the upgrade is agreed, the intelligent acquisition controller marks an upgrade flag bit;
step S7: the intelligent acquisition controller sends out a response signal; then entering a Bootload program;
the Bootload program comprises:
step S8: initializing the offset of an APP program, and setting an offset interrupt vector table to zero;
step S9: the intelligent acquisition controller judges whether the upgrading flag bit is a specific mark, if so, the step S10 is carried out, otherwise, the APP program is returned;
step S10: the intelligent acquisition controller receives and identifies a data packet containing firmware data sent by the server;
step S11: the intelligent acquisition controller judges whether the firmware data is complete and correct, if so, the step S12 is carried out, otherwise, the step S10 is carried out;
step S12, the intelligent acquisition controller writes the firmware data into the flash memory and simultaneously sets the upgrading flag position to zero;
and step S13, the intelligent acquisition controller sends a firmware upgrading feedback signal to the server and then returns to the APP program.
Furthermore, information exchange is performed between the intelligent acquisition controller and the server in a data packet mode, and the data packet comprises a start bit, a data length, a function code, a state code, a sequence number, data, a CRC check and an end bit.
Further, the start bit is a fixed value AAH, and the end bit is a fixed value 55H.
Further, the function code of the instruction issued by the server to request the firmware upgrade is 0x 89.
Further, the function code of the response signal sent by the intelligent acquisition controller is 0x 09.
Further, the state code of the response signal sent by the intelligent acquisition controller is 0x00 to indicate that the upgrade is approved, and the state code is 0x01 to indicate that the upgrade is not approved.
Further, the server sends out a packet containing firmware data when the status code of the received response signal is 0x 00.
Further, the function code of the data packet containing the firmware data issued by the server is 0x 8A.
Further, the function code of the firmware upgrade feedback signal sent by the intelligent acquisition controller is 0x0A, the status code of the firmware upgrade feedback signal is 0x00, which indicates that the upgrade is successful, and the status code is 0x01, which indicates that the parameter is wrong.
Further, the APP program starts from an address of a certain offset after the Bootload program, and a corresponding offset is set in an offset interrupt vector table of the APP program.
Compared with the prior art, the remote embedded firmware online upgrading method comprises an APP program and a Bootload program, wherein the APP program comprises the following steps of S1: setting an offset interrupt vector table; step S2: initializing a clock and peripheral equipment of the intelligent acquisition controller; step S3: executing a program set by a user, and establishing communication connection with a server by adopting a TCP/IP protocol; step S4: the intelligent acquisition controller receives and identifies an instruction which is sent by the server and requests for upgrading the firmware; step S5: the intelligent acquisition controller judges whether to approve upgrading; step S6: if the upgrade is agreed, the intelligent acquisition controller marks an upgrade flag bit; step S7: the intelligent acquisition controller sends out a response signal; then entering a Bootload program; the Bootload program comprises: step S8: initializing the offset of an APP program, and setting an offset interrupt vector table to zero; step S9: the intelligent acquisition controller judges whether the upgrading flag bit is a specific mark, if so, the step S10 is carried out, otherwise, the APP program is returned; step S10: the intelligent acquisition controller receives and identifies a data packet containing firmware data sent by the server; step S11: the intelligent acquisition controller judges whether the firmware data is complete and correct, if so, the step S12 is carried out, otherwise, the step S10 is carried out; step S12, the intelligent acquisition controller writes the firmware data into the flash memory and simultaneously sets the upgrading flag position to zero; and step S13, the intelligent acquisition controller sends a firmware upgrading feedback signal to the server and then returns to the APP program. Thus, the embedded firmware can be safely and efficiently updated remotely.
Drawings
Embodiments of the invention are described below with reference to the accompanying drawings, in which:
fig. 1 is a schematic block diagram of an intelligent acquisition controller in a remote embedded firmware online upgrade method provided by the present invention.
Fig. 2 is a schematic flow diagram of an APP program in the remote embedded firmware online upgrade method provided by the present invention.
Fig. 3 is a schematic flow diagram of a Bootload program in the remote embedded firmware online upgrade method provided by the present invention.
Detailed Description
Specific embodiments of the present invention will be described in further detail below based on the drawings. It should be understood that the description herein of embodiments of the invention is not intended to limit the scope of the invention.
Please refer to fig. 1 and fig. 2, which illustrate an online upgrade method for a remote embedded firmware according to the present invention.
The intelligent acquisition controller 100 comprises a controller STM32F103VCT6, and has an online programmable function (IAP), namely, a USER FLASH memory (USER FLASH) is programmed by using a program of the intelligent acquisition controller in the program running process.
The controller STM32F103VCT6 is connected with the 4G module by a universal asynchronous receiver transmitter (UART 1). The controller STM32F103VCT6 operates the 4G module through AT commands using UART 1. And when the 4G module and the platform communication server establish TCP/IP connection, data transmission is carried out by adopting a transparent transmission mode.
The invention provides a remote embedded firmware online upgrading method, which is used for remotely updating embedded firmware for an intelligent acquisition controller 100, wherein an APP (application) program 110 and a Bootload program 120 are stored in the intelligent acquisition controller 100, and the intelligent acquisition controller 100 executes the following steps through the APP program 110:
step S1: an offset interrupt vector table is set, the offset interrupt vector table refers to the offset and the segment base value of the entry address of the interrupt service program, and one interrupt vector occupies 4 bytes of space. The interrupt vector table is the byte space at the lowest end in the Cortex-M3 system memory, and is used for storing corresponding interrupt vectors according to the order of the interrupt type numbers from small to large, and storing 83 interrupt vectors in total. In the interrupt response process, the MCU calculates the position of the corresponding interrupt vector in the table by the interrupt type number (interrupt vector number) obtained from the interface circuit, and obtains the interrupt vector from the interrupt vector table, and diverts the program flow to the entry address of the interrupt service program.
Step S2: the clocks and peripherals of the intelligent acquisition controller 100 are initialized.
Step S3: and executing a program set by a user, and establishing communication connection with the server by adopting a TCP/IP protocol.
Step S4: the smart acquisition controller 100 receives and identifies an instruction from a server requesting an upgrade of firmware.
Step S5: the intelligent acquisition controller 100 determines whether to approve the upgrade. After receiving the instruction requesting to upgrade the firmware, the intelligent acquisition controller 100 determines whether to approve the upgrade according to its own working state, and if the intelligent acquisition controller 100 is acquiring or transmitting station switching value, analog value and device operating state information and cannot be interrupted, it does not approve the upgrade, and then the process goes to step S7; if the smart acquisition controller 100 is in the idle state or in the interruptible operation and the upgrade is approved, the process proceeds to step S6.
Step S6: the intelligent acquisition controller 100 flags the upgrade flag bit to indicate that the intelligent acquisition controller 100 is ready to upgrade the firmware.
Step S7: the smart acquisition controller 100 sends a response signal.
If the intelligent acquisition controller 100 agrees to upgrade and the response signal sent by step S7 includes a signal agreeing to upgrade, the intelligent acquisition controller 100 executes the following steps through the Bootload program 120:
step S8: initializing the offset of the APP program, and setting the offset interrupt vector table to zero.
Step S9: the smart acquisition controller 100 determines whether the upgrade flag is a specific flag, if yes, step S10 is performed, otherwise, the process returns to the APP program, if no, step S1.
Step S10: the intelligent acquisition controller 100 receives and identifies a data packet containing firmware data sent by the server, and if the response signal sent by the intelligent acquisition controller 100 contains a signal agreeing to upgrade, the server sends the data packet containing firmware data. Therefore, the server sends the data packet containing the firmware data according to the response signal of the intelligent acquisition controller 100, and the situation that the data packet is directly sent by the server when the intelligent acquisition controller 100 cannot be upgraded is avoided, so that the data packet transmission is wasted, the bandwidth is occupied, and the working efficiency is influenced.
Step S11: the smart collection controller 100 determines whether the firmware data is complete and correct, if yes, step S12 is performed, otherwise, step S10 is performed.
In step S12, the smart collection controller 100 writes the firmware data into its flash memory and sets the upgrade flag to zero.
In step S13, the smart collection controller 100 sends a firmware upgrade feedback signal to the server.
Thereafter, the process returns to step S1, and so on.
The intelligent acquisition controller 100 exchanges information with the server in a data packet mode, and each time data is transmitted and received, the following specific frame format is used:
start bit | Data length | Function code | Status code | Serial number | Data of | CRC checking | End bit |
AAH | XXXXH | XXH | XXH | XXXXH | XXXXH | XXXXH | 55H |
The data packet includes start bits, data length, function code, status code, sequence number, data, CRC check, and end bits. Byte encoding uses a network byte order (Big Endian). Wherein:
start bit (HEAD): a fixed value AAH.
Data length: the number of bytes of data.
Function code (OPCODE): and an operation code for indicating the attribute or function of the data packet.
And (3) status code: and an operation status code for representing the response signal.
Sequence number: the sequence number of the frame.
Data: specific data.
CRC checking: cyclic redundancy check, CCITT check value from start bit to end of data, polynomial: x16+ x12+ x5+1(0x 1021).
End bit (TAIL): a fixed value of 55H.
The format of the command frame for firmware upgrade between the server and the smart acquisition controller 100 is as follows:
1. server-issued instructions requesting firmware upgrade
2. Response signal sent by the smart acquisition controller 100:
3. data packet containing firmware data sent by server
4. The firmware upgrade feedback signal sent by the intelligent acquisition controller 100:
in the program memory of the controller STM32F103VCT6, the Bootload program 120 and the APP program 110 are stored in different address ranges of the flash memory. For example, Bootload program 120 is placed at the bottom end of the program memory, and APP program 110 is placed on the Bootload program, which are not overlapped with each other. The APP program 110 starts at an address of a certain offset X of the Bootload program 120, and the offset interrupt vector table of the APP program 110 makes a corresponding movement, where the offset is X.
Compared with the prior art, the remote embedded firmware online upgrading method comprises an APP program and a Bootload program, wherein the APP program comprises the following steps of S1: setting an offset interrupt vector table; step S2: initializing a clock and peripheral equipment of the intelligent acquisition controller; step S3: executing a program set by a user, and establishing communication connection with a server by adopting a TCP/IP protocol; step S4: the intelligent acquisition controller receives and identifies an instruction which is sent by the server and requests for upgrading the firmware; step S5: the intelligent acquisition controller judges whether to approve upgrading; step S6: if the upgrade is agreed, the intelligent acquisition controller marks an upgrade flag bit; step S7: the intelligent acquisition controller sends out a response signal; then entering a Bootload program; the Bootload program comprises: step S8: initializing the offset of an APP program, and setting an offset interrupt vector table to zero; step S9: the intelligent acquisition controller judges whether the upgrading flag bit is a specific mark, if so, the step S10 is carried out, otherwise, the APP program is returned; step S10: the intelligent acquisition controller receives and identifies a data packet containing firmware data sent by the server; step S11: the intelligent acquisition controller judges whether the firmware data is complete and correct, if so, the step S12 is carried out, otherwise, the step S10 is carried out; step S12, the intelligent acquisition controller writes the firmware data into the flash memory and simultaneously sets the upgrading flag position to zero; and step S13, the intelligent acquisition controller sends a firmware upgrading feedback signal to the server and then returns to the APP program. Thus, the embedded firmware can be safely and efficiently updated remotely.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the scope of the present invention, and any modifications, equivalents or improvements that are within the spirit of the present invention are intended to be covered by the following claims.
Claims (10)
1. A remote embedded firmware online upgrade method is characterized in that: the method comprises an APP program and a Bootload program, wherein the APP program comprises:
step S1: setting an offset interrupt vector table;
step S2: initializing a clock and peripheral equipment of the intelligent acquisition controller;
step S3: executing a program set by a user, and establishing communication connection with a server by adopting a TCP/IP protocol;
step S4: the intelligent acquisition controller receives and identifies an instruction which is sent by the server and requests for upgrading the firmware;
step S5: the intelligent acquisition controller judges whether to approve upgrading;
step S6: if the upgrade is agreed, the intelligent acquisition controller marks an upgrade flag bit;
step S7: the intelligent acquisition controller sends out a response signal; then entering a Bootload program;
the Bootload program comprises:
step S8: initializing the offset of an APP program, and setting an offset interrupt vector table to zero;
step S9: the intelligent acquisition controller judges whether the upgrading flag bit is a specific mark, if so, the step S10 is carried out, otherwise, the APP program is returned;
step S10: the intelligent acquisition controller receives and identifies a data packet containing firmware data sent by the server; step S11: the intelligent acquisition controller judges whether the firmware data is complete and correct, if so, the step S12 is carried out, otherwise, the step S10 is carried out;
step S12, the intelligent acquisition controller writes the firmware data into the flash memory and simultaneously sets the upgrading flag position to zero;
and step S13, the intelligent acquisition controller sends a firmware upgrading feedback signal to the server and then returns to the APP program.
2. The remote embedded firmware online upgrade method according to claim 1, wherein: the intelligent acquisition controller and the server exchange information in a data packet mode, wherein the data packet comprises a start bit, a data length, a function code, a state code, a serial number, data, CRC check and an end bit.
3. The remote embedded firmware online upgrade method according to claim 2, wherein: the start bit is a fixed value AAH and the end bit is a fixed value 55H.
4. The remote embedded firmware online upgrade method according to claim 2, wherein: the function code of the instruction issued by the server to request the firmware upgrade is 0x 89.
5. The remote embedded firmware online upgrade method according to claim 2, wherein: the function code of the response signal sent by the intelligent acquisition controller is 0x 09.
6. A remote embedded firmware online upgrade method according to claim 3, characterized by: and when the state code of the response signal sent by the intelligent acquisition controller is 0x00, the upgrade is approved, and when the state code is 0x01, the upgrade is not approved.
7. The remote embedded firmware online upgrade method according to claim 6, wherein: the server sends out a packet containing firmware data when the status code of the received response signal is 0x 00.
8. The remote embedded firmware online upgrade method according to claim 2, wherein: the function code of the data packet containing firmware data sent out by the server is 0x 8A.
9. The remote embedded firmware online upgrade method according to claim 2, wherein: the function code of the firmware upgrading feedback signal sent by the intelligent acquisition controller is 0x0A, the state code of the firmware upgrading feedback signal is 0x00 to indicate that upgrading is successful, and the state code is 0x01 to indicate that parameters are wrong.
10. The remote embedded firmware online upgrade method according to claim 1, wherein: the APP program starts from an address of a certain offset behind the Bootload program, and a corresponding offset is set in an offset interrupt vector table of the APP program.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810730456.1A CN108958781B (en) | 2018-07-05 | 2018-07-05 | Remote embedded firmware online upgrading method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810730456.1A CN108958781B (en) | 2018-07-05 | 2018-07-05 | Remote embedded firmware online upgrading method |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108958781A CN108958781A (en) | 2018-12-07 |
CN108958781B true CN108958781B (en) | 2022-03-01 |
Family
ID=64485911
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810730456.1A Active CN108958781B (en) | 2018-07-05 | 2018-07-05 | Remote embedded firmware online upgrading method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108958781B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111104145B (en) * | 2019-11-29 | 2021-08-31 | 浪潮电子信息产业股份有限公司 | Out-of-band updating method and system for Expander |
CN111800488B (en) * | 2020-06-23 | 2023-01-24 | 翱捷科技股份有限公司 | Data transmission method and system based on UDP (user Datagram protocol) and IPV6 (Internet protocol video protocol) |
CN112910948B (en) * | 2021-01-12 | 2023-05-09 | 拉扎斯网络科技(上海)有限公司 | Protocol upgrading method, device, electronic equipment, storage medium and program product |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101383847A (en) * | 2008-08-25 | 2009-03-11 | 中兴通讯股份有限公司 | Firmware upgrading method and device for wireless data terminal |
CN101916198A (en) * | 2010-07-23 | 2010-12-15 | 深圳创维-Rgb电子有限公司 | Method for updating web TV and managing software version thereof |
CN104122815A (en) * | 2014-06-26 | 2014-10-29 | 南京易周能源科技有限公司 | Hydrological measurement and control terminal based on ARM and remote upgrading method thereof |
CN106647517A (en) * | 2016-12-29 | 2017-05-10 | 金卡高科技股份有限公司 | Internet of Things metering instrument remote firmware upgrading method and metering instrument system |
-
2018
- 2018-07-05 CN CN201810730456.1A patent/CN108958781B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101383847A (en) * | 2008-08-25 | 2009-03-11 | 中兴通讯股份有限公司 | Firmware upgrading method and device for wireless data terminal |
CN101916198A (en) * | 2010-07-23 | 2010-12-15 | 深圳创维-Rgb电子有限公司 | Method for updating web TV and managing software version thereof |
CN104122815A (en) * | 2014-06-26 | 2014-10-29 | 南京易周能源科技有限公司 | Hydrological measurement and control terminal based on ARM and remote upgrading method thereof |
CN106647517A (en) * | 2016-12-29 | 2017-05-10 | 金卡高科技股份有限公司 | Internet of Things metering instrument remote firmware upgrading method and metering instrument system |
Also Published As
Publication number | Publication date |
---|---|
CN108958781A (en) | 2018-12-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108958781B (en) | Remote embedded firmware online upgrading method | |
JP6483696B2 (en) | Application program update processing method and terminal device | |
US7634261B2 (en) | Mobile communications terminal and software updating method for mobile communications terminal | |
WO2016149908A1 (en) | Method for updating terminal system, terminal and system | |
CN111200811B (en) | TWS earphone, upgrading method and device thereof and readable storage medium | |
CN111142905B (en) | OTA upgrading method, OTA server and OTA upgrading system | |
KR101956574B1 (en) | Apparatus and method for identifying operating system of host device in portable terminal | |
EP3291086A1 (en) | Method and device for downloading software version, and storage medium | |
CN108449198A (en) | A kind of method, system and the storage device of OTA upgradings | |
EP2922267A1 (en) | Method for achieving communication based on mbim interface and device therefor | |
CN106453629B (en) | A kind of automobile electronic system remote update system and its method based on mobile network | |
CN106708564A (en) | FOTA update method, device and server | |
US8250223B2 (en) | Portable electronic device and method for downloading a firmware loader from a host computer | |
CN111897560B (en) | Program upgrading system, method, device and storage medium based on NB-IoT module | |
CN104469501A (en) | Set top box automatic set-up method based on serial communication protocol | |
CN104572188A (en) | System updating method and device for mobile equipment | |
CN112035135A (en) | Method, apparatus and storage medium for updating firmware program of slave station apparatus | |
CN110704080B (en) | Method for upgrading Bluetooth module through Wi-Fi module | |
CN112181147B (en) | Small program-based wearable device interaction method and device and electronic device | |
EP2515601B1 (en) | Dial-up connection method and device of mobile data terminal | |
CN112771497A (en) | Method and device for upgrading equipment and storage medium | |
CN107171915B (en) | Communication protocol changing method and device | |
CN210348467U (en) | Modular design structure capable of updating MCU software | |
KR20160011090A (en) | Apparatus and Method for Updating Application Program of Internet of Things | |
CN110851161B (en) | Firmware updating method for intelligent household 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 | ||
TA01 | Transfer of patent application right |
Effective date of registration: 20220119 Address after: No. 58, Zhenhua Road, Weitang street, Jiashan County, Jiaxing City, Zhejiang Province Applicant after: ZHEJIANG EIODMEN ENVIRONMENTAL PROTECTION SCIENCE & TECHNOLOGY CO.,LTD. Address before: 314000 room 222, R & D building, Shanghai Jiaotong University (Jiaxing) science and Technology Park, No. 321, Jiachuang Road, Xiuzhou District, Jiaxing City, Zhejiang Province Applicant before: JIAXING TIANKONG INFORMATION TECHNOLOGY Co.,Ltd. |
|
TA01 | Transfer of patent application right | ||
GR01 | Patent grant | ||
GR01 | Patent grant |