CN111258600A - Mirror image type embedded program firmware upgrading method - Google Patents
Mirror image type embedded program firmware upgrading method Download PDFInfo
- Publication number
- CN111258600A CN111258600A CN201911150250.2A CN201911150250A CN111258600A CN 111258600 A CN111258600 A CN 111258600A CN 201911150250 A CN201911150250 A CN 201911150250A CN 111258600 A CN111258600 A CN 111258600A
- Authority
- CN
- China
- Prior art keywords
- firmware
- upgrading
- value
- electric energy
- energy meter
- 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
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
-
- 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
The invention discloses a method for upgrading mirror image type embedded program firmware, which comprises the following steps: dividing a FALSH virtual memory of a singlechip into a partition A and a partition B; reading the area mark through an EEprom, an EEprom and an EEprom, if the area mark is 0xAA, jumping to an area A, and running the program of the area A; if the zone mark is 0x55, jumping to the zone B and running the program of the zone B; the single chip microcomputer detects whether firmware upgrading is needed, and when the firmware upgrading is needed, firmware package data are stored to carry out firmware upgrading. The invention has the following beneficial effects: the number of the Dataflash chips and the number of the peripheral circuits are reduced, and the cost is reduced; the starting code is simple, the driving is simple, and after the upgrading is successful, the data flash data does not need to be read; the program design is simple, and the framework logic is clear; ensuring the success of upgrading; normal use is not affected in the upgrading process.
Description
Technical Field
The invention relates to the technical field of ammeter estimation upgrading, in particular to a mirror image type embedded program firmware upgrading method which can reduce cost, ensure upgrading success and is simple in program.
Background
The requirement of customers for electric energy meters is that the firmware upgrading function is supported. Currently, if a firmware upgrade is required, the first way: the firmware package needing to be upgraded is issued to the electric energy meter through the GPRS, the electric energy meter firmware package is stored in the DataFlash, and the program is upgraded after the data is received; the second mode is as follows: and sending a command through GPRS or a serial port to enter an upgrading function, and then sending an upgrading packet and upgrading the firmware.
The first method has the following problems: 1. the cost is high, the operation is complex, a Dataflash chip needs to be added, the chip needs to be read and written, and the read-write failure is easy to occur; 2. adding a single chip pin and increasing the PCB space; 3. peripheral circuits are added, and production and welding are complex; the second method has the following problems: 1. upgrading is easy to fail, and a halt occurs, for example, a midway GPRS network is not good; 2. the electric energy meter can not work normally in the upgrading process, the upgrading time of the firmware is long, and the normal use is influenced.
Disclosure of Invention
The invention provides a mirror image type embedded program firmware upgrading method which can reduce the cost, ensure the successful upgrading and has simple program, aiming at overcoming the defects of high production cost and easy failure of firmware upgrading in the prior art.
In order to achieve the purpose, the invention adopts the following technical scheme:
a method for upgrading mirror image type embedded program firmware comprises the following steps:
(1-1) dividing a FALSH virtual memory of a single-chip microcomputer into a partition area A and a partition area B;
(1-2) reading the area mark through an electrified erasable programmable read-only memory (EEprom), if the area mark is 0xAA, skipping to an area A, operating the program of the area A, and turning to the step (1-3); if the parcel mark is 0x55, jumping to parcel B, running the program of parcel B, and going to step (1-3);
(1-3) detecting whether firmware upgrading is needed by the single chip microcomputer, and storing firmware package data for firmware upgrading when the firmware upgrading is needed;
and (1-4) closing the watchdog after the firmware is upgraded, and waiting for resetting.
The method reads the area mark through electrifying the single chip microcomputer, directly skips the area A to check whether firmware upgrading is needed or not if the single chip microcomputer runs in the area A, and directly skips the area B to check whether firmware upgrading is needed or not if the single chip microcomputer runs in the area B; the method has the advantages of simple program design, easy starting and operation, high upgrading success rate and no influence on the normal use of the electric energy meter.
Preferably, when the firmware upgrade is required to be performed in the partition a, a specific method of the firmware upgrade is as follows:
(2-1) firstly loading a firmware upgrade package by the system, and calculating the size M of the firmware upgrade package;
(2-2) comparing the version information of the electric energy meter through a communication protocol, and if the version information of the electric energy meter is correct, turning to the step (2-3); if the version information of the electric energy meter is incorrect, terminating upgrading;
(2-3) calculating the firmware upgrading packet by taking N bytes as frame data to obtainFrame data;
(2-4) sending each frame of data, calculating a cyclic redundancy check CRC32 check value of each frame of data, comparing a cyclic redundancy check CRC32 check value of the electric energy meter with a calculated cyclic redundancy check CRC32 check value, if the cyclic redundancy check CRC32 check value of the electric energy meter is the same as the calculated cyclic redundancy check CRC32 check value, storing the firmware upgrading packet data into a chip area B, and turning to the step (2-5); if the cyclic redundancy check CRC32 check value of the electric energy meter is different from the calculated cyclic redundancy check CRC32 check value, the upgrading is stopped;
(2-5)after the frame data are received, the single chip microcomputer obtains an MD5 value, the obtained MD5 value is compared with an MD5 value of the electric energy meter, and if the obtained MD5 value is the same as the MD5 value of the electric energy meter, the step (2-6) is carried out; if the obtained MD5 value is different from the MD5 value of the electric energy meter, the upgrading is stopped;
(2-6) writing the running zone flag to be 0x55, recording the current firmware upgrading event, stopping feeding the firmware, and resetting the program B;
(2-7) electrifying the single chip microcomputer to read the zone mark, wherein the zone mark is 0x55, and operating the program of the zone B to finish firmware upgrade; and the partition area is upgraded, so that the success rate of firmware upgrading is improved.
Preferably, the memory space of slice a and slice B are equal in size.
Preferably, N has a value of 256.
Preferably, the communication protocol is a device language message specification DLMS.
Preferably, the method also comprises the steps of displaying, metering, communicating, storing, managing power supply, encrypting data and selling electricity of the electric energy meter.
Therefore, the invention has the following beneficial effects: the number of the Dataflash chips and the number of the peripheral circuits are reduced, and the cost is reduced; the production is convenient, the components are reduced, the production flow is simple and the speed is high; the size of the PCB is reduced, and the space can be reasonably utilized; the starting code is simple, the driving is simple, and after the upgrading is successful, the data flash data does not need to be read; the program design is simple, and the framework logic is clear; the upgrading is ensured to be successful, and the next upgrading and normal use are not influenced even if the network is not good; normal use is not affected in the upgrading process.
Drawings
FIG. 1 is a flow chart of the present invention;
FIG. 2 is a specific method of firmware upgrade of the present invention.
Detailed Description
The invention is further described in the following detailed description with reference to the drawings in which:
the embodiment shown in fig. 1 is a method for upgrading firmware of a mirrored embedded program, comprising the following steps:
step 100, dividing a FALSH virtual memory of a single chip microcomputer into a block area A and a block area B with equal memory size;
step 200, reading a slice area mark through an electrified erasable programmable read-only memory EEprom, if the slice area mark is 0xAA, skipping to a slice area A, running a program of the slice area A, and turning to step 300; if the parcel flag is 0x55, jumping to parcel B, running the program of parcel B, and going to step 300;
step 300, the single chip microcomputer detects whether firmware upgrading is needed, and when the firmware upgrading is needed in the area A, firmware package data are stored for firmware upgrading;
as shown in fig. 2, in step 301, the system loads the firmware upgrade package first, and calculates the size M of the firmware upgrade package;
step 302, comparing version information of the electric energy meter through a device language message specification DLMS communication protocol, and if the version information of the electric energy meter is correct, turning to step 303; if the version information of the electric energy meter is incorrect, terminating upgrading;
step 303, calculating the firmware upgrade package by using 256 bytes as frame data to obtainFrame data;
step 304, sending each frame of data, calculating a cyclic redundancy check CRC32 check value of each frame of data, comparing a cyclic redundancy check CRC32 check value of the electric energy meter with a calculated cyclic redundancy check CRC32 check value, if the cyclic redundancy check CRC32 check value of the electric energy meter is the same as the calculated cyclic redundancy check CRC32 check value, storing firmware upgrade packet data into a chip area B, and turning to step 305; if the cyclic redundancy check CRC32 check value of the electric energy meter is different from the calculated cyclic redundancy check CRC32 check value, the upgrading is stopped;
in a step 305 of the method, the step is described,after the frame data is received, the single chip microcomputer obtains an MD5 value, and the obtained MD5 value and the electric energy meter are connectedComparing the MD5 values, and if the obtained MD5 value is the same as the MD5 value of the electric energy meter, turning to step 306; if the obtained MD5 value is different from the MD5 value of the electric energy meter, the upgrading is stopped;
step 306, writing the running zone flag to be 0x55, recording the current firmware upgrading event, stopping feeding the firmware, and resetting the program B;
and 307, electrifying the single chip microcomputer to read the zone mark, wherein the zone mark is 0x55, and operating the program of the zone B to finish firmware upgrade.
And step 400, closing the watchdog after the firmware is upgraded, and waiting for resetting.
And 500, performing display, metering, communication, storage, power management, data encryption and electricity selling of the electric energy meter.
At present, the technology of a single chip microcomputer is more and more mature, a plurality of chips have large-capacity FALSH, and the price and the low-capacity are almost not different from what; the invention adopts Flash with large capacity chip, the cost difference is 0.1 yuan; the cost is increased by at least 1.5 yuan due to the fact that a Dataflash chip is at least 1 yuan, a peripheral circuit is added, the size of a PCB and the power supply power are increased; the electric energy meter calculates according to 1 million sets of shipment, can save 1.5 million costs at least, great reduction cost.
It should be understood that this example is for illustrative purposes only and is not intended to limit the scope of the present invention. Further, it should be understood that various changes or modifications of the present invention may be made by those skilled in the art after reading the teaching of the present invention, and such equivalents may fall within the scope of the present invention as defined in the appended claims.
Claims (6)
1. A method for upgrading mirror image type embedded program firmware is characterized by comprising the following steps:
(1-1) dividing a FALSH virtual memory of a single-chip microcomputer into a partition area A and a partition area B;
(1-2) reading the area mark through an electrified erasable programmable read-only memory (EEprom), if the area mark is 0xAA, skipping to an area A, operating the program of the area A, and turning to the step (1-3); if the parcel mark is 0x55, jumping to parcel B, running the program of parcel B, and going to step (1-3);
(1-3) detecting whether firmware upgrading is needed by the single chip microcomputer, and storing firmware package data for firmware upgrading when the firmware upgrading is needed;
and (1-4) closing the watchdog after the firmware is upgraded, and waiting for resetting.
2. The firmware upgrading method of the mirrored embedded program according to claim 1, wherein when the firmware upgrading is required in the partition a, the specific method of firmware upgrading is as follows:
(2-1) firstly loading a firmware upgrade package by the system, and calculating the size M of the firmware upgrade package;
(2-2) comparing the version information of the electric energy meter through a communication protocol, and if the version information of the electric energy meter is correct, turning to the step (2-3); if the version information of the electric energy meter is incorrect, terminating upgrading;
(2-3) calculating the firmware upgrading packet by taking N bytes as frame data to obtainFrame data;
(2-4) sending each frame of data, calculating a cyclic redundancy check CRC32 check value of each frame of data, comparing a cyclic redundancy check CRC32 check value of the electric energy meter with a calculated cyclic redundancy check CRC32 check value, if the cyclic redundancy check CRC32 check value of the electric energy meter is the same as the calculated cyclic redundancy check CRC32 check value, storing the firmware upgrading packet data into a chip area B, and turning to the step (2-5); if the cyclic redundancy check CRC32 check value of the electric energy meter is different from the calculated cyclic redundancy check CRC32 check value, the upgrading is stopped;
(2-5)after the frame data are received, the single chip microcomputer obtains an MD5 value, the obtained MD5 value is compared with an MD5 value of the electric energy meter, and if the obtained MD5 value is the same as the MD5 value of the electric energy meter, the step (2-6) is carried out; if the obtained MD5 value is not the same as the MD5 value of the electric energy meter, the rising is terminatedA stage;
(2-6) writing the running zone flag to be 0x55, recording the current firmware upgrading event, stopping feeding the firmware, and resetting the program B;
and (2-7) electrifying the singlechip to read the zone mark, wherein the zone mark is 0x55, and operating the program of the zone B to finish firmware upgrade.
3. The method of claim 1, wherein the memory space of partition A and partition B is equal in size.
4. The mirrored embedded program firmware upgrade method according to claim 2, wherein the value of N is 256.
5. The method of claim 2, wherein the communication protocol is a Device Language Message Specification (DLMS).
6. The method for upgrading the mirrored embedded program firmware as claimed in claim 1, 2, 3, 4 or 5, further comprising performing displaying, metering, communication, storage, power management, data encryption and power selling of the electric energy meter.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911150250.2A CN111258600A (en) | 2019-11-21 | 2019-11-21 | Mirror image type embedded program firmware upgrading method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911150250.2A CN111258600A (en) | 2019-11-21 | 2019-11-21 | Mirror image type embedded program firmware upgrading method |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111258600A true CN111258600A (en) | 2020-06-09 |
Family
ID=70953840
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201911150250.2A Pending CN111258600A (en) | 2019-11-21 | 2019-11-21 | Mirror image type embedded program firmware upgrading method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111258600A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112312374A (en) * | 2020-11-06 | 2021-02-02 | 国网江苏省电力有限公司电力科学研究院 | Device and method for upgrading firmware of single chip microcomputer based on NFC |
CN113342383A (en) * | 2021-06-30 | 2021-09-03 | 广州市保伦电子有限公司 | Remote online burning upgrading method for single chip microcomputer |
CN113672271A (en) * | 2021-08-24 | 2021-11-19 | 天津津航计算技术研究所 | Domestic FPGA remote upgrading system and method |
CN114610358A (en) * | 2022-04-19 | 2022-06-10 | 无锡市恒通电器有限公司 | Calibration method for remote upgrade installation package of single-phase electric energy meter |
Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101650662A (en) * | 2009-08-26 | 2010-02-17 | 中兴通讯股份有限公司 | Memory device of embedded system and staring method and upgrading of firmware |
CN102314369A (en) * | 2011-10-09 | 2012-01-11 | 杭州先锋电子技术股份有限公司 | Self-upgrade method for equipment in remote online monitoring system |
CN102662706A (en) * | 2012-04-01 | 2012-09-12 | 西安合众思壮导航技术有限公司 | Method for remotely reliably upgrading XIP (execute in place) chip software |
CN105183501A (en) * | 2015-08-10 | 2015-12-23 | 珠海格力电器股份有限公司 | Method for preventing on-line program programming error |
CN105278998A (en) * | 2015-11-17 | 2016-01-27 | 北京联合众为科技发展有限公司 | Single-chip microcomputer hardware upgrading method |
CN105912356A (en) * | 2016-03-31 | 2016-08-31 | 武汉光迅科技股份有限公司 | Optical module firmware program online upgrade method supporting version fallback |
CN108510727A (en) * | 2018-04-03 | 2018-09-07 | 杭州炬华科技股份有限公司 | The remote upgrade method of bandwidth carrier communication and acquisition module based on DLMS |
CN110134426A (en) * | 2019-04-18 | 2019-08-16 | 深圳市致宸信息科技有限公司 | A kind of embedded system upgrade method, device and terminal device |
CN110231952A (en) * | 2019-06-17 | 2019-09-13 | 合肥巨一动力系统有限公司 | A kind of ECU program backup and circulation upgrade control method and device |
-
2019
- 2019-11-21 CN CN201911150250.2A patent/CN111258600A/en active Pending
Patent Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101650662A (en) * | 2009-08-26 | 2010-02-17 | 中兴通讯股份有限公司 | Memory device of embedded system and staring method and upgrading of firmware |
CN102314369A (en) * | 2011-10-09 | 2012-01-11 | 杭州先锋电子技术股份有限公司 | Self-upgrade method for equipment in remote online monitoring system |
CN102662706A (en) * | 2012-04-01 | 2012-09-12 | 西安合众思壮导航技术有限公司 | Method for remotely reliably upgrading XIP (execute in place) chip software |
CN105183501A (en) * | 2015-08-10 | 2015-12-23 | 珠海格力电器股份有限公司 | Method for preventing on-line program programming error |
CN105278998A (en) * | 2015-11-17 | 2016-01-27 | 北京联合众为科技发展有限公司 | Single-chip microcomputer hardware upgrading method |
CN105912356A (en) * | 2016-03-31 | 2016-08-31 | 武汉光迅科技股份有限公司 | Optical module firmware program online upgrade method supporting version fallback |
CN108510727A (en) * | 2018-04-03 | 2018-09-07 | 杭州炬华科技股份有限公司 | The remote upgrade method of bandwidth carrier communication and acquisition module based on DLMS |
CN110134426A (en) * | 2019-04-18 | 2019-08-16 | 深圳市致宸信息科技有限公司 | A kind of embedded system upgrade method, device and terminal device |
CN110231952A (en) * | 2019-06-17 | 2019-09-13 | 合肥巨一动力系统有限公司 | A kind of ECU program backup and circulation upgrade control method and device |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112312374A (en) * | 2020-11-06 | 2021-02-02 | 国网江苏省电力有限公司电力科学研究院 | Device and method for upgrading firmware of single chip microcomputer based on NFC |
CN112312374B (en) * | 2020-11-06 | 2022-09-06 | 国网江苏省电力有限公司电力科学研究院 | Device and method for upgrading firmware of single chip microcomputer based on NFC |
CN113342383A (en) * | 2021-06-30 | 2021-09-03 | 广州市保伦电子有限公司 | Remote online burning upgrading method for single chip microcomputer |
CN113672271A (en) * | 2021-08-24 | 2021-11-19 | 天津津航计算技术研究所 | Domestic FPGA remote upgrading system and method |
CN114610358A (en) * | 2022-04-19 | 2022-06-10 | 无锡市恒通电器有限公司 | Calibration method for remote upgrade installation package of single-phase electric energy meter |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111258600A (en) | Mirror image type embedded program firmware upgrading method | |
CN102799502B (en) | A kind of spaceborne embedded software maintaining method in-orbit | |
CN102890657B (en) | The method that the reading and writing data of a kind of EEPROM of minimizing is made mistakes | |
CN101281493A (en) | And non flash memory device and management method thereof | |
CN101699402B (en) | Multi-mode startup embedded system | |
CN101963912A (en) | Implementation method for storing and checking hardware configuration information of system | |
CN110096300A (en) | A kind of fpga program file backup management system, operation method and upgrade method | |
CN106569964A (en) | Power-off protection method, power-off protection device, power-off protection system and memory | |
CN110442473A (en) | A kind of non-volatile data storage method, apparatus, electronic equipment and medium | |
CN104090788A (en) | Method and system for configuring and running satellite-borne software on basis of load | |
CN109783390A (en) | PSU firmware promotion and demotion stability test method, apparatus, terminal and storage medium | |
CN109278678A (en) | Vehicle trouble judges system | |
CN108196873A (en) | Electric system embedded software Remote Dynamic upgrade method and system | |
CN103019969A (en) | Flash memory storage device and determination method of bad storage area thereof | |
CN101178660A (en) | Memory data automatic update method | |
CN112270945B (en) | Method, device, storage medium and terminal for recording power failure during erasing | |
CN112214384A (en) | Hard disk serial number management method, system, terminal and storage medium | |
CN112181444A (en) | DSP multi-core data programming method based on 1553B bus | |
CN111291022A (en) | Data storage system based on block chain | |
CN115220968A (en) | VPD data management system and method with redundancy and fault tolerance capability | |
CN112231159B (en) | Memory installation position testing method, system, terminal and storage medium | |
CN115793835A (en) | Method, device, equipment and storage medium for adjusting load line | |
CN112445508B (en) | ARM application program online upgrading method based on CAN bus | |
CN110490581B (en) | Distributed system critical data resource updating method and system | |
CN103559141A (en) | Management method and device for nonvolatile memory (NVM) |
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 | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20200609 |
|
RJ01 | Rejection of invention patent application after publication |