CN113380308A - Data storage method for simulating EEPROM (electrically erasable programmable read-Only memory) by using PFLASH (pulse frequency laser absorption spectroscopy) software - Google Patents
Data storage method for simulating EEPROM (electrically erasable programmable read-Only memory) by using PFLASH (pulse frequency laser absorption spectroscopy) software Download PDFInfo
- Publication number
- CN113380308A CN113380308A CN202110690762.9A CN202110690762A CN113380308A CN 113380308 A CN113380308 A CN 113380308A CN 202110690762 A CN202110690762 A CN 202110690762A CN 113380308 A CN113380308 A CN 113380308A
- Authority
- CN
- China
- Prior art keywords
- data
- pflash
- current
- parameter
- page
- 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.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 25
- 238000013500 data storage Methods 0.000 title claims abstract description 13
- 230000015654 memory Effects 0.000 title description 6
- 238000001285 laser absorption spectroscopy Methods 0.000 title description 3
- 230000008859 change Effects 0.000 claims description 6
- 238000012545 processing Methods 0.000 claims description 3
- 230000002159 abnormal effect Effects 0.000 abstract description 9
- 125000004122 cyclic group Chemical group 0.000 abstract 1
- 238000005457 optimization Methods 0.000 description 5
- 230000006870 function Effects 0.000 description 4
- 238000005516 engineering process Methods 0.000 description 3
- 239000002699 waste material Substances 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000004134 energy conservation Methods 0.000 description 1
- 230000004807 localization Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000006855 networking Effects 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 230000008439 repair process Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
- 238000012795 verification Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G11—INFORMATION STORAGE
- G11C—STATIC STORES
- G11C16/00—Erasable programmable read-only memories
- G11C16/02—Erasable programmable read-only memories electrically programmable
- G11C16/06—Auxiliary circuits, e.g. for writing into memory
- G11C16/34—Determination of programming status, e.g. threshold voltage, overprogramming or underprogramming, retention
- G11C16/3436—Arrangements for verifying correct programming or erasure
Abstract
The invention relates to a data storage method for simulating an EEPROM by using PFLASH software, which comprises the following steps: s1, constructing a data structure based on PFLASH software, wherein the data structure stores parameters of two bytes, a serial number of one byte and CRC (cyclic redundancy check) of one byte, and the data stored by the single chip microcomputer is processed to obtain first data; s2, setting a data cache list for storing parameters in the first data and a default value list for storing default values of the parameters in the first data based on PFLASH software; and S3, performing power-on initialization on the single chip microcomputer, judging whether the single chip microcomputer is powered on for the first time and whether data are never stored, and if so, storing the default values of the parameters in the first data in the default value list into the data cache list. The invention can ensure that the abnormal power failure has least data loss as possible, can upwards find the latest data, and effectively utilizes the space resource of PFLASH when writing, storing and page changing.
Description
Technical Field
The invention belongs to the technical field of automobile electronic embedded software, and particularly relates to a data storage method for simulating an EEPROM (electrically erasable programmable read-only memory) by using PFLASH (pulse frequency laser absorption spectroscopy) software.
Background
With the continuous progress of the semiconductor technology (according to Moore's law), more and more logic function peripherals integrated in the MCU and larger memories are provided; on the other hand, the requirements of consumers on energy conservation, comfort, interconnectivity and safety of automobiles are higher and higher, and particularly, the development of automobile electronic technology is greatly accelerated due to the rise of new energy electric vehicles, car networking and automatic driving technology in recent years. The integrated function of an Electronic Control Unit (Electronic Control Unit) of an automobile is increasingly complex, and in order to meet the requirements of software remote (online) function upgrade (adding new functions) and bug repair, the requirement of bootLoader (starting loader) is increasingly increased.
The ECU is composed of a singlechip and various complex circuits, and the NVM of the ECU generally comprises an EEPROM or a Data-Flash integrated in the MCU chip for storing Data, a Code-Flash/Program-Flash for storing Program codes/Data and an off-chip NOR Flash or NAND-Flash extended by the MPU.
An eeprom (electrically Erasable Programmable read only memory) refers to a charged Erasable Programmable read only memory, and is a memory chip with no data loss after power failure.
Program-Flash, or PFLASH, is used to put code or data, which is the main Flash. In the prior art, a plurality of PFLASHs are mainly used, and a fixed storage data length and a corresponding PFLASH address are set during initialization. The main problems are as follows: the data which is effectively stored last time is difficult to find out in abnormal power failure, and when the fixed length is much larger than the length of the actually stored data, PFLASH space is wasted in page changing.
Disclosure of Invention
The invention aims to provide a data storage method for simulating an EEPROM by using PFLASH software, aiming at solving the problems that the last effective stored data is found when abnormal power failure occurs and the next power-on is carried out and the space utilization rate of the FLASH is not high.
The invention realizes the purpose through the following technical scheme:
a data storage method for simulating an EEPROM using PFLASH software, comprising the steps of:
s1, constructing a data structure based on PFLASH software, wherein the data structure stores parameters of two bytes, a serial number of one byte and CRC check of one byte, and is used for processing the stored data of the single chip read by the PFLASH software to obtain first data;
s2, setting a data cache list and a default value list based on PFLASH software, wherein the data cache list is used for storing parameters in the first data, and the default value list is used for storing default values of the parameters in the first data;
s3, the single chip microcomputer is electrified and initialized, whether the single chip microcomputer is electrified for the first time and whether data are never stored is judged, and if yes, the default values of the parameters in the first data in the default value list are stored in the data cache list; if not, finding a PFLASH page stored by the parameter of the current first data, and storing the parameter of the current first data into a data cache list;
and S4, when the current FLASH page is full of page change, writing the value in the current data cache list into the PFLASH page after page change.
As a further optimization scheme of the present invention, in step S2, one data cache list and one default value list are set, and the data cache list and the default value list are respectively lists for storing two byte parameters.
As a further optimized solution of the present invention, in step S3, when the parameter of the current first data is stored in the data cache list, it is determined through CRC check whether it is the same as the latest history parameter cached in the data cache list, if so, the storage is cancelled, and if not, the parameter of the current first data is stored in the data cache list.
As a further optimization scheme of the present invention, a method for finding a recent history parameter corresponding to a parameter in current first data is as follows: and after finding the PFLASH stored in the parameter of the current first data, finding out the latest historical parameter of each first data parameter from back to front according to the sequence number in the current first data.
As a further optimization scheme of the present invention, in step S3, after finding the currently stored PFLASH, each latest parameter is found from the back to the front according to the storage sequence number, and then the parameter values in step S4 are determined.
As a further optimization scheme of the present invention, the method for finding the PFLASH page stored in the parameter of the current first data is as follows: the PFLASH software simulates an EEPROM to set an initial address on a PFLASH page of each single chip microcomputer for storing data, and after the single chip microcomputers are powered on, the PFLASH software reads the initial address data and judges whether the current PFLASH page is the PFLASH page stored by the parameters of the current first data.
As a further optimization scheme of the present invention, in step S4, when the value in the current data cache list is written into the PFLASH page after page replacement, the state of the current PFLASH is updated at the start address.
The invention uses the minimum unit for operating PFLASH writing, and can ensure that the parameter writing fails as few as possible when the power-off is abnormal.
If the single chip microcomputer is abnormally powered off, the last written data can automatically find back the effective value correctly written last time if the last written data is not verified, and therefore the problem that some key data are lost due to abnormal power-off is solved.
When the page is changed by storing the data, the invention does not adopt the fixed length integral transportation, but only writes the current latest data cache list into a new page, all of which are used, and the problem of the waste of the PFLASH space with the fixed length can be solved.
The invention has the beneficial effects that:
1) the invention constructs a data structure by the minimum operation unit of 4 bytes stored in the PFLASH, which can ensure that the parameter write-in fails as few as possible when the power-off is abnormal;
2) the method comprises the steps of electrically reading data of each PFLASH initial address for simulating the EEPROM, judging whether the current PFLASH is the currently stored PFLASH, finding the currently stored PFLASH, and finding the latest data of each parameter from back to front;
3) when the single chip microcomputer is abnormally powered off, if the last written data is not verified, the last correctly written effective value can be automatically found back, so that the problem that some key data are lost due to abnormal power-off is solved;
4) when the page is changed by storing the data, the invention does not adopt the fixed length integral transportation, but only writes the current latest data cache list into a new page, all of which are used, and the problem of the waste of the PFLASH space with the fixed length can be solved.
Detailed Description
The present application is described in further detail below, and it should be noted that the following detailed description is provided for illustrative purposes only, and is not intended to limit the scope of the present application, which is defined by the appended claims.
Example one
A data storage method for simulating an EEPROM using PFLASH software, comprising the steps of:
s1, constructing a data structure based on PFLASH software, wherein the data structure stores parameters of two bytes, a serial number of one byte and CRC check of one byte, and is used for processing the stored data of the single chip read by the PFLASH software to obtain first data;
s2, setting a data cache list and a default value list based on PFLASH software, wherein the data cache list and the default value list are respectively lists for storing two byte parameters, the data cache list is used for storing parameters in the first data, and the default value list is used for storing default values of the parameters in the first data;
s3, the single chip microcomputer is electrified and initialized, and whether the single chip microcomputer is electrified for the first time or not and whether data are never stored or not is judged;
s301, when the single chip microcomputer is powered on for the first time and data are never stored, storing the default values of the parameters in the first data in the default value list into a data cache list;
s302, when the single chip microcomputer is not powered on for the first time and the latest first data is stored, finding out a PFLASH page stored by the parameter of the current first data, and storing the parameter of the current first data into a data cache list;
specifically, when abnormal power failure occurs, the CRC check of the latest parameter is definitely problematic, when the parameter of the current first data is stored in the data cache list, whether the parameter is the same as the latest historical parameter cached in the data cache list is judged through the CRC check, if so, the storage is cancelled, and if not, the parameter of the current first data is stored in the data cache list;
the method for finding the latest historical parameter corresponding to the parameter in the current first data comprises the following steps: after finding out the PFLASH stored in the parameter of the current first data, finding out the latest historical parameter of each first data parameter from back to front according to the sequence number in the current first data;
the method for finding the PFLASH page stored in the parameter of the current first data includes: the PFLASH software simulates an EEPROM to set an initial address on a PFLASH page of each single chip microcomputer for storing data, and after the single chip microcomputers are powered on, the PFLASH software reads the initial address data and judges whether the current PFLASH page is the PFLASH page stored by the parameters of the current first data;
and S4, when the current FLASH page is full of the page change, writing the value in the current data cache list into the PFLASH page after the page change, and updating the state of the current PFLASH at the initial address.
The invention constructs a data structure with serial number, parameter and check information by using the minimum operation unit of 4 bytes stored in PFLASH, can ensure that the data loss caused by abnormal power failure is as little as possible, and can upwards find the latest data; when the current FLASH page is full and needs to be changed, a dynamic data cache list is adopted for writing, and space resources of the PFLASH are effectively utilized. The invention is already used in a high-chip localization BMS platform, and has excellent test and verification performance.
The above-mentioned embodiments only express several embodiments of the present invention, and the description thereof is more specific and detailed, but not construed as limiting the scope of the present invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the inventive concept, which falls within the scope of the present invention.
Claims (6)
1. A data storage method for simulating an EEPROM by using PFLASH software is characterized by comprising the following steps:
s1, constructing a data structure based on PFLASH software, wherein the data structure stores parameters of two bytes, a serial number of one byte and CRC check of one byte, and is used for processing the stored data of the single chip read by the PFLASH software to obtain first data;
s2, setting a data cache list and a default value list based on PFLASH software, wherein the data cache list is used for storing parameters in the first data, and the default value list is used for storing default values of the parameters in the first data;
s3, the single chip microcomputer is electrified and initialized, whether the single chip microcomputer is electrified for the first time and whether data are never stored is judged, and if yes, the default values of the parameters in the first data in the default value list are stored in the data cache list; if not, finding a PFLASH page stored by the parameter of the current first data, and storing the parameter of the current first data into a data cache list;
and S4, when the current FLASH page is full of page change, writing the value in the current data cache list into the PFLASH page after page change.
2. The method of claim 1, wherein the data storage method comprises the following steps: in step S2, one data cache list and one default value list are set, and the data cache list and the default value list are respectively lists for storing two byte parameters.
3. The method of claim 1, wherein the data storage method comprises the following steps: in step S3, when the parameter of the current first data is stored in the data cache list, it is determined whether it is the same as the latest history parameter cached in the data cache list through CRC check, if so, the storage is cancelled, and if not, the parameter of the current first data is stored in the data cache list.
4. The method of claim 3, wherein the data storage method comprises the following steps: the method for finding the latest historical parameter corresponding to the parameter in the current first data comprises the following steps: and after finding the PFLASH stored in the parameter of the current first data, finding out the latest historical parameter of each first data parameter from back to front according to the sequence number in the current first data.
5. The method of claim 1, wherein the data storage method comprises the following steps: the method for finding the PFLASH page stored by the parameter of the current first data comprises the following steps: the PFLASH software simulates an EEPROM to set an initial address on a PFLASH page of each single chip microcomputer for storing data, and after the single chip microcomputers are powered on, the PFLASH software reads the initial address data and judges whether the current PFLASH page is the PFLASH page stored by the parameters of the current first data.
6. The method of claim 5, wherein the data storage method comprises the following steps: in step S4, when the value in the current data cache list is written into the PFLASH page after page replacement, the state of the current PFLASH is updated at the start address.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110690762.9A CN113380308B (en) | 2021-06-22 | 2021-06-22 | Data storage method for simulating EEPROM by using PFLASH software |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110690762.9A CN113380308B (en) | 2021-06-22 | 2021-06-22 | Data storage method for simulating EEPROM by using PFLASH software |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113380308A true CN113380308A (en) | 2021-09-10 |
CN113380308B CN113380308B (en) | 2023-10-27 |
Family
ID=77578211
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110690762.9A Active CN113380308B (en) | 2021-06-22 | 2021-06-22 | Data storage method for simulating EEPROM by using PFLASH software |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113380308B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114756179A (en) * | 2022-06-13 | 2022-07-15 | 武汉杰开科技有限公司 | Data writing, reading and managing method based on simulation eeprom |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102053879A (en) * | 2010-12-16 | 2011-05-11 | 国网电力科学研究院 | Self-recovery real-time file system based on FLASH |
CN103645990A (en) * | 2013-12-24 | 2014-03-19 | 飞天诚信科技股份有限公司 | Data updating method and data reading method based on large page Flash |
CN103914393A (en) * | 2014-04-11 | 2014-07-09 | 四川华拓光通信股份有限公司 | MCU-based (microprogrammed control unit-based) non-loss FLASH storage update method |
CN105260270A (en) * | 2015-11-11 | 2016-01-20 | 恒宝股份有限公司 | Flash storage space dynamic recovery method and device |
CN108108271A (en) * | 2017-12-25 | 2018-06-01 | 飞天诚信科技股份有限公司 | It is a kind of to realize affairs and the method and device of power down protection unified management |
CN112506535A (en) * | 2020-05-22 | 2021-03-16 | 上海擎度汽车科技有限公司 | Method for updating Bootloader software by automobile ECU controller |
-
2021
- 2021-06-22 CN CN202110690762.9A patent/CN113380308B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102053879A (en) * | 2010-12-16 | 2011-05-11 | 国网电力科学研究院 | Self-recovery real-time file system based on FLASH |
CN103645990A (en) * | 2013-12-24 | 2014-03-19 | 飞天诚信科技股份有限公司 | Data updating method and data reading method based on large page Flash |
CN103914393A (en) * | 2014-04-11 | 2014-07-09 | 四川华拓光通信股份有限公司 | MCU-based (microprogrammed control unit-based) non-loss FLASH storage update method |
CN105260270A (en) * | 2015-11-11 | 2016-01-20 | 恒宝股份有限公司 | Flash storage space dynamic recovery method and device |
CN108108271A (en) * | 2017-12-25 | 2018-06-01 | 飞天诚信科技股份有限公司 | It is a kind of to realize affairs and the method and device of power down protection unified management |
CN112506535A (en) * | 2020-05-22 | 2021-03-16 | 上海擎度汽车科技有限公司 | Method for updating Bootloader software by automobile ECU controller |
Non-Patent Citations (2)
Title |
---|
叶树梅;季爱明;俞一彪;: "嵌入式系统中Flash存储管理策略", 科学技术与工程, no. 17, pages 1 - 4 * |
邵龙;: "非易失存储器意外掉电线性累计数据突变的防避方法", 单片机与嵌入式系统应用, no. 12, pages 1 - 3 * |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114756179A (en) * | 2022-06-13 | 2022-07-15 | 武汉杰开科技有限公司 | Data writing, reading and managing method based on simulation eeprom |
CN114756179B (en) * | 2022-06-13 | 2022-09-27 | 武汉杰开科技有限公司 | Data writing, reading and managing method based on simulation eeprom |
Also Published As
Publication number | Publication date |
---|---|
CN113380308B (en) | 2023-10-27 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110231952B (en) | ECU program backup and cyclic upgrade control method and device | |
CN106227680B (en) | A kind of data processing and power fail preventing data guard method | |
CN109189405B (en) | Method and system for verifying Flash data consistency of program | |
CN102890657A (en) | Method for reducing data read-write errors of EEPROM (electrically erasable programmable read-only memory) | |
CN110032405A (en) | System boot code memory management method, memory device and the electronic system using it | |
CN105930236A (en) | Application program version returning method based on BMS Bootloaderupgrade | |
CN101178661A (en) | Realization method and apparatus of FLASH integrate BOOTROM | |
CN105760165B (en) | A kind of method that self backup load of MCU refreshes | |
CN103677869A (en) | Wireless sensor network node remote code updating system and method | |
KR20110094047A (en) | Electronic device and electronic device system | |
CN113380308B (en) | Data storage method for simulating EEPROM by using PFLASH software | |
US20080140920A1 (en) | Microcomputer for flash memory rewriting | |
CN114860279A (en) | Rapid empty-film upgrading method | |
CN102043636B (en) | Method and device for loading field programmable gate array bit file | |
CN101398874A (en) | Method for loading program to internal SRAM of MPU by utilizing hash function and operation method | |
CN115793995B (en) | Pflash-only data storage method for traditional MCU | |
CN116431186A (en) | Upgrading method, device and medium of vehicle-mounted ECU | |
CN112445508B (en) | ARM application program online upgrading method based on CAN bus | |
CN103678182A (en) | Power-down protecting method and system for improving data safety of vehicle terminal system | |
CN110928726A (en) | Embedded system self-recovery method and system based on watchdog and PXE | |
CN111611000B (en) | High-reliability firmware air upgrading method and system | |
CN110888605B (en) | EEPROM data writing method and device and electronic equipment | |
CN103778068A (en) | Flash memory and method for access to same | |
CN111258498A (en) | FLASH memory management method | |
CN112835745B (en) | High-reliability storage method of embedded system |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CP03 | Change of name, title or address | ||
CP03 | Change of name, title or address |
Address after: 264000, Yantai City, Shandong Province, China (Shandong) Pilot Free Trade Zone Yantai Area, Yantai Area, No. 300 Changjiang Road, No.10, Zone 1, 1701 Patentee after: Ligao (Shandong) New Energy Technology Co.,Ltd. Address before: Room 501, No.8, No.300, Changjiang Road, Yantai Economic and Technological Development Zone, Shandong Province 264000 Patentee before: LIGO (Shandong) New Energy Technology Co.,Ltd. |