CN113380308B - Data storage method for simulating EEPROM by using PFLASH software - Google Patents

Data storage method for simulating EEPROM by using PFLASH software Download PDF

Info

Publication number
CN113380308B
CN113380308B CN202110690762.9A CN202110690762A CN113380308B CN 113380308 B CN113380308 B CN 113380308B CN 202110690762 A CN202110690762 A CN 202110690762A CN 113380308 B CN113380308 B CN 113380308B
Authority
CN
China
Prior art keywords
data
pflash
parameters
current
software
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
Application number
CN202110690762.9A
Other languages
Chinese (zh)
Other versions
CN113380308A (en
Inventor
黄军
王翰超
王云
姜明军
孙艳
刘欢
沈永柏
江梓贤
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ligao Shandong New Energy Technology Co ltd
Original Assignee
Ligo Shandong New Energy Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ligo Shandong New Energy Technology Co ltd filed Critical Ligo Shandong New Energy Technology Co ltd
Priority to CN202110690762.9A priority Critical patent/CN113380308B/en
Publication of CN113380308A publication Critical patent/CN113380308A/en
Application granted granted Critical
Publication of CN113380308B publication Critical patent/CN113380308B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G11INFORMATION STORAGE
    • G11CSTATIC STORES
    • G11C16/00Erasable programmable read-only memories
    • G11C16/02Erasable programmable read-only memories electrically programmable
    • G11C16/06Auxiliary circuits, e.g. for writing into memory
    • G11C16/34Determination of programming status, e.g. threshold voltage, overprogramming or underprogramming, retention
    • G11C16/3436Arrangements for verifying correct programming or erasure

Landscapes

  • Techniques For Improving Reliability Of Storages (AREA)

Abstract

The application relates to a data storage method for simulating EEPROM by using PFLASH software, which comprises the following steps: s1, constructing a data structure based on PFLASH software, wherein the data structure stores two bytes of parameters, a byte of sequence number and a byte of CRC, and processes the stored data of the singlechip to obtain first data; s2, setting a data cache list based on PFLASH software and used for storing parameters in the first data and a default value list used for storing default values of the parameters in the first data; and S3, powering up and initializing the singlechip, judging whether the singlechip is powered up for the first time or not and whether the singlechip never stores data, and if so, storing the default value of the parameter in the first data in the default value list into the data cache list. The application can ensure that the data loss caused by abnormal power failure is as little as possible, and can find the latest data upwards, and effectively utilize the space resources of PFLASH when writing, storing and page changing.

Description

Data storage method for simulating EEPROM by using PFLASH software
Technical Field
The application belongs to the technical field of automobile electronic embedded software, and particularly relates to a data storage method for simulating EEPROM (electrically erasable programmable read-Only memory) by using PFLASH software.
Background
With the continuous progress of semiconductor technology (according to moore's law), the logic function peripherals integrated inside the MCU are more and more, and the memory is also larger and larger; on the other hand, the requirements of consumers on energy conservation, comfort, interconnection and safety of automobiles are higher and higher, and particularly, the development of automobile electronic technology is greatly accelerated in the rising of new energy electric vehicles, internet of vehicles and automatic driving technologies in recent years. The functions of the electronic ECU (Electronic Control Unit-electronic control unit) of the automobile are increasingly complex, and in order to cope with the needs of software remote (on-line) function upgrading (adding new functions) and bug repairing, the needs of bootLoader are increasingly more and more.
The ECU consists of a singlechip and various complex circuits, and the NVM of the ECU generally comprises an EEPROM or a Data-Flash integrated in an MCU chip for storing Data, a Code-Flash/Program-Flash for storing Program codes/Data and an off-chip NOR Flash or NAND-Flash expanded by an MPU.
EEPROM (Electrically Erasable Programmable read only memory) is a charged erasable programmable read-only memory, which is a memory chip with no data loss after power failure.
The Program-Flash is PFLASH, which is used for playing codes or data, namely the main Flash. In the prior art, a plurality of PFLASH are mainly used, and a fixed storage data length and a corresponding PFLASH address are set during initialization. The main problems are: abnormal power failure makes it difficult to find data which is effectively stored last time, and PFLASH space is wasted when the fixed length is much longer than the length of the data which is actually stored.
Disclosure of Invention
The application aims to solve the problems of abnormal power failure, how to find the data which are effectively stored last time and low FLASH space utilization rate when the power is on next time, and provides a data storage method for simulating EEPROM by using PFLASH software.
The application realizes the above 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 two bytes of parameters, a byte of sequence number and a byte of CRC (cyclic redundancy check) for processing singlechip storage data 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, powering up and initializing the singlechip, judging whether the singlechip is powered up for the first time and whether the singlechip never stores data, and if so, storing default values of parameters in first data in a default value list into a data cache list; if not, finding a PFLASH page stored by the parameters of the current first data, and storing the parameters of the current first data into a data cache list;
and S4, when the current FLASH page is full of page replacement, writing the value in the current data cache list into the PFLASH page after page replacement.
As a further optimization scheme of the present application, in step S2, one data cache list and one default value list are set, which are lists for storing two byte parameters, respectively.
In step S3, when the parameters of the current first data are stored in the data cache list, whether the parameters are the same as the latest historical parameters cached in the data cache list or not is judged through CRC check, if so, the storage is canceled, and if not, the parameters of the current first data are stored in the data cache list.
As a further optimization scheme of the application, the method for finding the latest historical parameters corresponding to the parameters in the current first data comprises the following steps: after PFLASH of the parameter storage of the current first data is found, the latest historical parameter of each first data parameter is found out from back to front according to the serial number in the current first data.
As a further optimization scheme of the application, in the step S3, after finding the PFLASH stored currently, find each latest parameter from back to front according to the storage sequence number, and then judge the parameter value in the step S4.
As a further optimization scheme of the present application, the method for finding the PFLASH page stored by the parameters of the current first data is as follows: the PFLASH software simulates the EEPROM to set a start address on the PFLASH page of each singlechip for storing data, and after the singlechips are electrified, the PFLASH software reads the start address data and judges whether the current PFLASH page is the PFLASH page of the parameter storage of the current first data.
As a further preferred embodiment of the present application, in step S4, when writing the value in the current data cache list into the PFLASH page after the page change, the state of the current PFLASH is updated at the start address.
The application uses the minimum unit of the PFLASH writing operation, and can ensure that the parameter writing fails as little as possible when the power-down is abnormal.
If the last written data is not checked, the effective value of the last correct written data can be automatically found back, so that the problem that some key data are lost due to abnormal power-down is solved.
When the page is replaced by the stored data, the application does not adopt fixed-length integral transportation, only writes the current latest data cache list into a new page, and the application has no problem of PFLASH space waste with fixed length.
The application has the beneficial effects that:
1) The application constructs a data structure by using the minimum operation unit of 4 bytes stored by PFLASH, so that the failure of parameter writing can be ensured to be as few as possible when power-down is abnormal;
2) The application electrically reads the data of each PFLASH initial address used for simulating the EEPROM, judges whether the current PFLASH is the PFLASH stored currently, finds the PFLASH stored currently, and finds the latest data of each parameter from back to front;
3) When the singlechip is abnormally powered off, if the last written data is not checked, the valid value which is correctly written last time 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 replaced by the stored data, the application does not adopt fixed-length integral transportation, only writes the current latest data cache list into a new page, and the application has no problem of PFLASH space waste with fixed length.
Detailed Description
The following detailed description of the application is provided to illustrate the application and should not be construed as limiting the scope of the application since it is intended that the following detailed description is given for the purpose of illustration only, and that certain non-essential modifications and adaptations of the application may occur to those skilled in the art in light of the foregoing disclosure.
Example 1
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 two bytes of parameters, a byte of sequence number and a byte of CRC (cyclic redundancy check) for processing singlechip storage data 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 used 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, powering up and initializing the singlechip, and judging whether the singlechip is powered up for the first time or not and whether data are never stored;
s301, when the singlechip is powered on for the first time, data are never stored, and default values of parameters in first data in a default value list are stored in a data cache list;
s302, when the singlechip is not powered on for the first time, and when the latest first data is stored, finding a PFLASH page stored by parameters of the current first data, and storing the parameters of the current first data into a data cache list;
specifically, when abnormal power failure occurs, the latest CRC verification of one parameter is certainly 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 or not is judged through CRC verification, if so, the storage is canceled, and if not, the parameter of the current first data is stored in the data cache list;
the method for finding the latest historical parameters corresponding to the parameters in the current first data comprises the following steps: after PFLASH of the parameter storage of the current first data is found, according to the serial number in the current first data, finding out the latest historical parameter of each first data parameter from back to front;
the method for finding the PFLASH page stored by the parameters of the current first data comprises the following steps: the PFLASH software simulates the EEPROM to set a starting address on the PFLASH page of each singlechip for storing data, and after the singlechips are electrified, the PFLASH software reads the starting address data and judges whether the current PFLASH page is the PFLASH page for storing the parameters of the current first data;
and S4, when the current FLASH page is full of page replacement, writing the value in the current data cache list into the PFLASH page after page replacement, and updating the state of the current PFLASH at the starting address.
The application constructs a data structure with the minimum operation unit of 4 bytes stored by PFLASH and with sequence numbers, parameters and verification information, can ensure that the data loss caused by abnormal power failure is as little as possible, and can find the latest data upwards; when the current FLASH page is full and needs to be changed, the dynamic data cache list is adopted for writing, so that the space resources of the PFLASH are effectively utilized. The application is used in the high-power chip domestic BMS platform, and has excellent test verification performance.
The foregoing examples illustrate only a few embodiments of the application and are described in detail herein without thereby limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application.

Claims (6)

1. A method of simulating data storage in an EEPROM using PFLASH software, comprising the steps of:
s1, constructing a data structure based on PFLASH software, wherein the data structure stores two bytes of parameters, a byte of sequence number and a byte of CRC (cyclic redundancy check) for processing singlechip storage data 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, powering up and initializing the singlechip, judging whether the singlechip is powered up for the first time and whether the singlechip never stores data, and if so, storing default values of parameters in first data in a default value list into a data cache list; if not, finding a PFLASH page stored by the parameters of the current first data, and storing the parameters of the current first data into a data cache list;
and S4, when the current FLASH page is full of page replacement, writing the value in the current data cache list into the PFLASH page after page replacement.
2. A method of simulating data storage of an EEPROM using PFLASH software as claimed in claim 1, wherein: in step S2, one data cache list and one default list are set, which are lists for storing two byte parameters respectively.
3. A method of simulating data storage of an EEPROM using PFLASH software as claimed in claim 1, wherein: in step S3, when the parameters of the current first data are stored in the data cache list, whether the parameters are the same as the latest historical parameters cached in the data cache list or not is judged through CRC check, if so, the storage is canceled, and if not, the parameters of the current first data are stored in the data cache list.
4. A method of data storage using pflast software to simulate an EEPROM according to claim 3, wherein: the method for finding the latest historical parameters corresponding to the parameters in the current first data comprises the following steps: after PFLASH of the parameter storage of the current first data is found, the latest historical parameter of each first data parameter is found out from back to front according to the serial number in the current first data.
5. A method of simulating data storage of an EEPROM using PFLASH software as claimed in claim 1, wherein: the method for finding the PFLASH page stored by the parameters of the current first data comprises the following steps: the PFLASH software simulates the EEPROM to set a start address on the PFLASH page of each singlechip for storing data, and after the singlechips are electrified, the PFLASH software reads the start address data and judges whether the current PFLASH page is the PFLASH page of the parameter storage of the current first data.
6. A method of simulating data storage of an EEPROM using PFLASH software as claimed in claim 5, wherein: in step S4, when writing the value in the current data cache list into the PFLASH page after page replacement, the state of the current PFLASH is updated at the start address.
CN202110690762.9A 2021-06-22 2021-06-22 Data storage method for simulating EEPROM by using PFLASH software Active CN113380308B (en)

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 CN113380308A (en) 2021-09-10
CN113380308B true 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)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114756179B (en) * 2022-06-13 2022-09-27 武汉杰开科技有限公司 Data writing, reading and managing method based on simulation eeprom

Citations (6)

* Cited by examiner, † Cited by third party
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

Patent Citations (6)

* Cited by examiner, † Cited by third party
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)

* Cited by examiner, † Cited by third party
Title
嵌入式系统中Flash存储管理策略;叶树梅;季爱明;俞一彪;;科学技术与工程(第17期);第1-4节 *
非易失存储器意外掉电线性累计数据突变的防避方法;邵龙;;单片机与嵌入式系统应用(第12期);第1-3节 *

Also Published As

Publication number Publication date
CN113380308A (en) 2021-09-10

Similar Documents

Publication Publication Date Title
CN110069280B (en) Electronic device and firmware updating method thereof
CN109189405B (en) Method and system for verifying Flash data consistency of program
CN106227680B (en) A kind of data processing and power fail preventing data guard method
CN105930236A (en) Application program version returning method based on BMS Bootloaderupgrade
CN110865822B (en) Boot architecture and method for Bootloader brush writing program for whole vehicle controller
CN113380308B (en) Data storage method for simulating EEPROM by using PFLASH software
CN105760165B (en) A kind of method that self backup load of MCU refreshes
CN108874422B (en) Software online upgrading method for refrigerator electric control board, refrigerator electric control board and refrigerator
CN102279757A (en) Method and device for starting system program
US7934050B2 (en) Microcomputer for flash memory rewriting
US6128694A (en) Method of correcting identification data stored in an EEPROM
CN105095101A (en) Method and device for writing data in memorizer and intelligent card
CN109144538A (en) A kind of CAN node Bootloader design method and system based on UDS
CN101398874A (en) Method for loading program to internal SRAM of MPU by utilizing hash function and operation method
CN112835601A (en) Firmware updating method, device, equipment and storage medium
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
CN114816273A (en) Adaptive optimal configuration method, device and medium for Norflash
CN111611000B (en) High-reliability firmware air upgrading method and system
CN103778068A (en) Flash memory and method for access to same
CN113626091A (en) Starting optimization method and device of solid state disk, computer equipment and storage medium
CN111949321A (en) Firmware code execution method, memory storage device and memory control circuit unit
CN111258498A (en) FLASH memory management method
CN112835745B (en) High-reliability storage method of embedded system
CN110281865B (en) Vehicle controller and data storage method

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.

CP03 Change of name, title or address
CP03 Change of name, title or address

Address after: No. 15 Hengyang Road, Guxian Street, Yantai Economic and Technological Development Zone, Shandong Province, China 265503

Patentee after: Ligao (Shandong) New Energy Technology Co.,Ltd.

Country or region after: China

Address before: 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 before: Ligao (Shandong) New Energy Technology Co.,Ltd.

Country or region before: China