Nothing Special   »   [go: up one dir, main page]

WO2016062084A1 - Power-off processing method and apparatus, and electronic device - Google Patents

Power-off processing method and apparatus, and electronic device Download PDF

Info

Publication number
WO2016062084A1
WO2016062084A1 PCT/CN2015/079611 CN2015079611W WO2016062084A1 WO 2016062084 A1 WO2016062084 A1 WO 2016062084A1 CN 2015079611 W CN2015079611 W CN 2015079611W WO 2016062084 A1 WO2016062084 A1 WO 2016062084A1
Authority
WO
WIPO (PCT)
Prior art keywords
memory
electronic device
data
ecc
powered
Prior art date
Application number
PCT/CN2015/079611
Other languages
French (fr)
Chinese (zh)
Inventor
颜志伟
Original Assignee
中兴通讯股份有限公司
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 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2016062084A1 publication Critical patent/WO2016062084A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring

Definitions

  • the present invention relates to the field of communications, and in particular, to a power-down processing method, apparatus, and electronic device.
  • the electronic device When the electronic device is working, there will be a situation in which the system is abnormally powered down. At this time, the user data stored in the memory will be lost. Therefore, it is desirable to have a certain device (such as a battery), and after the electronic device is abnormally powered down, it can continue to be The memory unit of the electronic device is powered to ensure that the data in the memory is not lost. In the process of the next system startup, the valid data stored in the memory is reused, and the implementation of the function is as simple as possible.
  • a certain device such as a battery
  • the memory power-down protection method currently adopted is basically implemented by an external non-volatile storage medium.
  • the data in the memory is transferred to the non-volatile storage medium.
  • the data in the non-volatile storage medium is copied to the memory again.
  • the memory stick with the Error Correcting Code (ECC) function is very common.
  • ECC Error Correcting Code
  • the ECC memory has certain checking and error correction capabilities during normal operation, the ECC does not automatically change when the device is restarted.
  • To verify the existing data in the memory it is obviously not feasible to use the ECC algorithm to verify the data in the memory by simply using the software method.
  • the software can not directly read the existing ECC check value from the ECC memory and compare it with the calculated result. .
  • the embodiment of the invention provides a method, a device, and an electronic device method and device for power-down processing, so as to at least solve the problem that the implementation method for preventing data in the memory from being lost after the abnormal power-off of the electronic device in the prior art is complicated, and ECC does not automatically check for problems with data already in memory at startup.
  • a power down processing method including: detecting that an electronic device is powered down; synchronizing data buffered by the buffer memory in the electronic device into a memory of the electronic device.
  • the electronic device is powered off, and the electronic device is powered off normally, and the electronic device is powered off abnormally.
  • the memory is an error check and correction ECC memory.
  • the flag bit for identifying whether the electronic device is abnormally powered down is set to be abnormally powered down.
  • the method further includes: reading from the non-volatile memory for identifying the A flag indicating whether the electronic device is abnormally powered down; and when the flag indicates an abnormal power failure, the electronic device checks data in the ECC memory.
  • the method includes: performing a check result obtained by performing ECC check on the data in the memory.
  • the ECC check values stored in the memory are compared, and when the comparison result is consistent, it is confirmed that the data in the memory does not change. When the comparison result is inconsistent, it is confirmed that the data in the memory has occurred. Variety.
  • a power down processing apparatus comprising: a detecting module configured to detect that the electronic device is powered down; and a synchronization module configured to buffer data of the buffer memory in the electronic device Synchronized into the memory of the electronic device.
  • the power-off condition of the electronic device detected by the detecting module includes one of the following: the electronic device is powered off normally, and the electronic device is abnormally powered down.
  • the memory is an error check and correction ECC memory.
  • the device further includes: a setting module, configured to set a flag bit for identifying whether the electronic device is abnormally powered down to be abnormally powered down.
  • the apparatus further includes: a reading module configured to read, from the non-volatile memory, a flag bit for identifying whether the electronic device is abnormally powered down; the verification module is configured to be When the flag bit indicates an abnormal power failure, the electronic device checks data in the ECC memory.
  • the device further includes: a comparison module, configured to compare the verification result obtained by performing ECC check on the data in the memory with a pre-stored ECC check value in the memory;
  • the first confirmation module is configured to confirm that the data in the memory does not change if the comparison result is consistent;
  • the second confirmation module is set to confirm that the data in the memory has changed if the comparison result is inconsistent.
  • an electronic device comprising: a microprocessor controller, an ECC memory and a buffer memory; and a microprocessor controller configured to generate a control when the electronic device is detected to be powered down
  • the buffer memory is configured to receive the control instruction and synchronize data buffered by the buffer memory into the ECC memory under the trigger of the control instruction.
  • the electronic device further includes: a non-volatile memory, configured to store a flag bit for identifying whether the electronic device is abnormally powered down.
  • the present invention it is detected that the electronic device is powered down; the data buffered by the buffer memory in the electronic device is synchronized into the memory of the electronic device.
  • the invention solves the problem that the implementation method of the data in the memory is not lost after the abnormal power-off of the electronic device in the prior art, and further, after the abnormal power-off of the electronic device, the operation of not losing the data in the memory is realized, and the memory is guaranteed.
  • the correctness of the data enhances the user experience.
  • FIG. 1 is a flow chart of a power down processing method according to an embodiment of the present invention.
  • FIG. 2 is a block diagram showing the structure of a power-down processing apparatus according to an embodiment of the present invention
  • FIG. 3 is a block diagram 1 of a power-down processing apparatus according to an embodiment of the present invention.
  • FIG. 4 is a block diagram 2 of a power-down processing apparatus according to an embodiment of the present invention.
  • FIG. 5 is a structural block diagram 3 of a power-down processing apparatus according to an embodiment of the present invention.
  • FIG. 6 is a structural block diagram of an electronic device according to an embodiment of the present invention.
  • FIG. 7 is a structural block diagram 1 of an electronic device according to an embodiment of the present invention.
  • FIG. 8 is a block diagram of an apparatus involved in a power down processing method according to an embodiment of the present invention.
  • FIG. 9 is a flowchart 1 of a power down processing method according to an embodiment of the present invention.
  • FIG. 10 is a flowchart of operations when an electronic device is restarted according to an embodiment of the present invention.
  • FIG. 1 is a flowchart of a power-down processing method according to an embodiment of the present invention. As shown in FIG. 1, the process includes the following steps:
  • Step S102 detecting that the electronic device is powered off
  • Step S104 Synchronize data buffered by the buffer memory in the electronic device into the memory of the electronic device.
  • the buffer memory synchronizes its cached data into the memory of the electronic device, and stores it through the non-volatile storage medium after the electronic device is powered down, compared to the prior art.
  • the data is copied into the memory.
  • the above steps solve the problem that the implementation method of the data in the memory is not lost after the electronic device is abnormally powered off, and the data in the memory is not realized after the electronic device is abnormally powered off.
  • the lost operation is simple, ensuring the correctness of the data in the memory and improving the user experience.
  • the electronic device is powered down.
  • the electronic device is powered down, including the normal powering down of the electronic device or the abnormal power failure of the electronic device.
  • the abnormal power-down of the electronic device means that the power is actively powered off due to non-human reasons, such as abnormal voltage and unplugged power.
  • the above memory is error checking and correcting ECC memory.
  • the flag for identifying whether the electronic device is abnormally powered down is set to abnormal power-down.
  • the situation in which the electronic device is powered off is separately identified.
  • a flag for identifying whether the electronic device is abnormally powered down is read from the non-volatile memory, and the buffer memory in the electronic device is used if the flag indicates that the electronic device is abnormally powered down. After the cached data is synchronized into the memory of the electronic device, the electronic device verifies the data in the ECC memory.
  • the verification result obtained by performing ECC check on the data in the memory is performed with the ECC check value pre-stored in the memory. In comparison, if the comparison result is consistent, it is confirmed that the data in the memory has not changed. At this time, after the electronic device is re-powered, the data in the memory is correct and can be used continuously; in the case where the comparison result is inconsistent , to confirm that the data in the memory has changed, in this case, you need to further judge the comparison If the difference is small, the data in the memory can be used continuously. If the difference is large, using the data in the memory will generate an error and cannot be used any more.
  • a power-down processing device is also provided, which is used to implement the above-mentioned embodiments and preferred embodiments, and has not been described again.
  • the term "module” may implement a combination of software and/or hardware of a predetermined function.
  • the apparatus described in the following embodiments is preferably implemented in software, hardware, or a combination of software and hardware, is also possible and contemplated.
  • the apparatus includes: a detecting module 22 configured to detect that the electronic device is powered off; and a synchronization module 24 configured to be in the electronic device.
  • the data buffered by the buffer memory is synchronized into the memory of the electronic device.
  • the power-off condition of the electronic device detected by the detecting module 22 includes one of the following: the electronic device is powered off normally, and the electronic device is abnormally powered down.
  • the memory is an error check and corrects the ECC memory.
  • FIG. 3 is a block diagram showing the structure of a power-down processing apparatus according to an embodiment of the present invention. As shown in FIG. 3, the apparatus further includes: a setting module 26, configured to set a flag for identifying whether the electronic device is abnormally powered down. Power down.
  • a setting module 26 configured to set a flag for identifying whether the electronic device is abnormally powered down. Power down.
  • the apparatus further includes a reading module 28 configured to read from the non-volatile memory for identifying the electronic device. Whether the device is abnormally powered down or not; the verification module 30 is configured to verify the data in the ECC memory when the flag indicates abnormal power failure.
  • FIG. 5 is a structural block diagram 3 of a power-down processing apparatus according to an embodiment of the present invention.
  • the apparatus further includes: a comparison module 32 connected to the verification module 30, configured to perform data in the memory. The verification result obtained by the ECC check is compared with the pre-stored ECC check value in the memory; the first confirmation module 34 is set to confirm that the data in the memory does not change if the comparison result is consistent; the second confirmation module 36. Set to confirm that the data in the memory has changed if the comparison result is inconsistent.
  • the electronic device includes: a microprocessor controller 62, an ECC memory 64, and a buffer memory 66.
  • the microprocessor controller 62 is configured to detect When the electronic device is powered down, a control command is generated; the buffer memory 66 is configured to receive the control command, and the data buffered by the buffer memory 66 is synchronized to the ECC memory 64 under the trigger of the control command.
  • the buffer memory 66 may be part of the microprocessor controller 62, commonly referred to as a refresh cache, and integrated in a central processing unit (CPU).
  • FIG. 7 is a structural block diagram of an electronic device according to an embodiment of the present invention. As shown in FIG. 7, the electronic device further includes: a non-volatile memory 68 configured to store a flag for identifying whether the electronic device is abnormally powered down. .
  • the preferred embodiment provides a memory power down protection method based on ECC memory characteristics.
  • the memory controller unit of the network processing chip used by the communication device can perform ECC check on the data in the memory, the battery that supplies power to the memory after the system is powered off, and the central processing unit (CPU) passes through the CPU bus.
  • CPU central processing unit
  • the communication device uses a memory module with an ECC function.
  • the hardware detects that the main power output voltage is abnormal, the processor chip receives the main power output abnormal interrupt, sends a memory self-refresh command through the memory controller, and sets the corresponding address in the NVRAM, hardware logic. Control turns on the battery and starts to supply power to the memory, after which the main power output fails.
  • the abnormal power-down flag is read from the NVRAM. If the system abnormal power failure occurs before, the data ECC verification process is entered.
  • the method is based on certain hardware conditions, and the memory controller unit of the network processing chip used by the electronic device can perform ECC check on the data in the memory, and the used memory carries the ECC function, and the device block diagram related to the method is shown in FIG. 8 .
  • the CPU is the core of the electronic device, and completes basic functions such as network protocol processing and message distribution.
  • ECC memory which stores programs and data when the electronic device is working properly. After the NVRAM is powered off, it can still maintain a kind of RAM. When the device is powered off abnormally, it will store a flag in the NVRAM. When the device restarts, the corresponding flag is read from the NVRAM to determine whether the last power failure occurred. It is abnormally powered down to distinguish this power-on process. The battery continues to supply power to the memory when the device is powered down, keeping the data in the memory intact.
  • FIG. 9 is a flowchart 1 of the power-down processing method according to the embodiment of the present invention. As shown in FIG. 9, the process includes the following steps:
  • Step S902 the power output is abnormal
  • Step S904 entering an interrupt processing entry
  • Step S906 the NVRAM performs identification, that is, sets the flag bit
  • Step S908 refreshing the cache (cache), that is, refreshing the cache memory, and synchronizing the cached data into the memory;
  • Step S910 starting a memory self-refresh
  • the hardware boot battery is a memory battery.
  • the hardware sends an interrupt signal to the CPU to trigger the device abnormal power-down interrupt.
  • the software enters the interrupt process and triggers the interrupt handler function that is attached by request_irq.
  • the interrupt handler mainly performs two tasks: Setting the corresponding flag bit in NVRAM indicates that the power failure is abnormal power failure of the device, and the device performs ECC check on the data in the memory at the next startup; 2.
  • Refreshing the cache memory (cache) and starting the self-refresh memory Mode refresh the cache is to synchronize the data in the cache to the memory
  • self-refresh Self-Refresh
  • REFS-EN self-refresh command
  • refresh control circuit provides refresh control at certain time intervals
  • Self-Refresh is usually used in power-saving mode, or sleep mode, which can consume less power and refresh cycle The shorter the power consumption is, the longer the refresh cycle is, as long as possible, in order to save power, but the cycle is too long, it is dangerous. Once it is not enough to keep the contents of the DRAM, it will be lost.
  • NVRAM set operation you can directly write the value to the fixed address. You can mount the NVRAM under the local bus of the CPU during design, and then select one byte of its corresponding address space as the flag. The value stored in the section is rewritten to 1. Refreshing the cache can use the way of writing values to the useless memory address.
  • the memory size can directly cover the size of the cache. This is to ensure that the values in the cache are all synchronized to the memory during normal operation. While the software is processing the interrupt, the hardware logic turns on the battery switch and starts to supply power to the memory. After that, the main power fails and the electronic device loses power.
  • the memory Since the memory is always powered by the battery during the power-down of the electronic device, the data in the memory is not lost. However, for software, it is still necessary to ensure the reliability of the data in the memory, or at least to determine whether the data has changed. This mainly depends on some operations performed when the device is powered on again.
  • Step S1002 the flag bit is read in the NVRAM, that is, after entering the process, the software first reads a flag indicating whether the device is abnormally powered down from the NVRAM, and the operation is the same as when the device is powered off, and the address corresponding to the flag bit does not change.
  • One is a write operation and the other is a read operation.
  • Step S1004 determining whether the flag bit is set to 1, if the flag position is 1, indicating that the last power failure is abnormal power failure, the memory is powered by the battery during the power failure process, and the data needs to be verified, if the flag bit is not When set to 1, the process is skipped, and step S1012 is performed. If the flag bit is set to 1, step S1006 is performed.
  • the method of setting the flag position 1 here is only one method for distinguishing whether it is an abnormal power failure, and the manner of judging the flag bit can be additionally selected.
  • the series of operations to be performed after entering the data verification process mainly depend on the hardware characteristics of the CPU.
  • the memory controller unit of the CPU we use here must be able to perform ECC check on the data in the memory.
  • mips architecture CPU as an example to illustrate the process.
  • step S1006 a start address and an end address are determined. Based on the characteristics of the CPU memory controller, first select the required memory space, and use the interval of the start address and the end address to indicate that the address value here is relative to the memory size, for example, the memory size is 2G, and the start address is 0. The end address is 1G, indicating that the first half of the memory is to be verified, not the physical space address 0 ⁇ 1G seen by the CPU.
  • Step S1008 the ECC check process, that is, performing a 64-byte ECC check.
  • a hardware module in the memory controller is used to verify the data.
  • the module can read 64 bytes of data from the ddr3 memory supporting the ECC function, and calculate the ECC school corresponding to the data. The value is checked, and then the value is compared with the existing ECC check value read from the memory. If they are consistent, the data in the memory is considered to have not changed. If not, the value in the memory is changed. Since the module can only process 64 bytes of data at a time, if the size of the checked memory is greater than 64 bytes, it needs to be cycled from the start address to the end address. Each check completes 64 bytes and compares once. If there is a failure, The failure count (errcount) is incremented until all required memory is verified.
  • Step S1010 the errcount is written into the NVRAM, that is, after the verification is completed, the errcount is also written to a corresponding address in the NVRAM, and after the electronic device is completely powered on, the value is read from the NVRAM, and the software verifies the error according to the data. How much to decide whether the data stored in memory can continue to be used. From the process of data verification, we can see that this method mainly relies on the memory ECC check module of the CPU memory controller, especially it can complete the calculation of 64-byte data ECC check value and read the original ECC from the memory. The nature of the check value.
  • the specific implementation of the method is not limited to the above description, for example, if a series of CPUs can complete the ECC check of the data in the memory, but not only can process 64 bytes of data at a time, the implementation of the method will be The corresponding modification, here is only based on the method description of a processor that has been applied.
  • step S1012 the process ends.
  • the method adopted by the embodiment of the present invention saves the process of data movement.
  • the data still exists in the device memory.
  • the correctness of the data during power supply enables the data in the memory to be used normally after the device is restarted, which is also a key to the memory power-down protection function of the present invention.
  • modules or steps of the present invention described above can be implemented by a general-purpose computing device that can be centralized on a single computing device or distributed across a network of multiple computing devices. Alternatively, they may be implemented by program code executable by the computing device such that they may be stored in the storage device by the computing device and, in some cases, may be different from the order herein.
  • the steps shown or described are performed, or they are separately fabricated into individual integrated circuit modules, or a plurality of modules or steps thereof are fabricated as a single integrated circuit module.
  • the invention is not limited to any specific combination of hardware and software.
  • the foregoing technical solution provided by the embodiment of the present invention can be used to detect that the electronic device is powered off during the power failure detection process of the electronic device, and synchronize the data buffered by the buffer memory in the electronic device into the memory of the electronic device.
  • the invention solves the problem that the implementation method of the data in the memory is not lost after the abnormal power-off of the electronic device in the prior art, and further, after the abnormal power-off of the electronic device, the operation of not losing the data in the memory is realized, and the memory is guaranteed.
  • the correctness of the data enhances the user experience.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)

Abstract

Disclosed are a power-off processing method and apparatus, and an electronic device. The method comprises: detecting that an electronic device is powered off; and synchronizing data buffered by a buffer memory in the electronic device into a memory of the electronic device. The present invention solves the problem in the prior art that it is complex to prevent data in a memory from getting lost after an electronic device is powered off abnormally, so that the operation of preventing data in a memory from getting lost after an electronic device is powered off abnormally is simplified, the accuracy of the data in the memory is ensured and the user experience is improved.

Description

掉电处理方法、装置及电子设备Power-down processing method, device and electronic device 技术领域Technical field
本发明涉及通信领域,具体而言,涉及一种掉电处理方法、装置及电子设备。The present invention relates to the field of communications, and in particular, to a power-down processing method, apparatus, and electronic device.
背景技术Background technique
电子设备在工作时,会存在系统异常掉电的情况,这时存储在内存中的用户数据就会丢失,因此希望存在某种设备(比如电池),在电子设备异常掉电后,能够继续为电子设备的内存单元供电,保证内存中数据不丢失,在下次系统启动的过程中,重新利用内存中存储的有效数据,并且尽量使该功能的实现简单。When the electronic device is working, there will be a situation in which the system is abnormally powered down. At this time, the user data stored in the memory will be lost. Therefore, it is desirable to have a certain device (such as a battery), and after the electronic device is abnormally powered down, it can continue to be The memory unit of the electronic device is powered to ensure that the data in the memory is not lost. In the process of the next system startup, the valid data stored in the memory is reused, and the implementation of the function is as simple as possible.
现在采用的内存掉电保护方法基本上是依靠外部非易失性存储介质来实现的,简单的说就是在设备电源即将掉电时,将内存中的数据转移到非易失性存储介质中,在设备下次启动后,再将非易失性存储介质中的数据重新拷贝到内存。The memory power-down protection method currently adopted is basically implemented by an external non-volatile storage medium. In short, when the power of the device is about to be powered down, the data in the memory is transferred to the non-volatile storage medium. After the device is next started, the data in the non-volatile storage medium is copied to the memory again.
目前带有错误检查和纠正(Error Correcting Code,简称为ECC)功能的内存条已经非常普遍,虽然ECC内存在正常工作时具有一定的检查、纠错能力,但是在设备重新启动时ECC不会自动校验内存中已有的数据,单纯依靠软件方法利用ECC算法来校验内存中的数据明显不可行,软件也无法从ECC内存中直接读取已有的ECC校验值与自己计算的结果比较。At present, the memory stick with the Error Correcting Code (ECC) function is very common. Although the ECC memory has certain checking and error correction capabilities during normal operation, the ECC does not automatically change when the device is restarted. To verify the existing data in the memory, it is obviously not feasible to use the ECC algorithm to verify the data in the memory by simply using the software method. The software can not directly read the existing ECC check value from the ECC memory and compare it with the calculated result. .
针对相关技术中,在电子设备异常断电后使内存中数据不丢失的实现方法复杂,并且在设备重新启动时ECC不会自动校验内存中已有的数据的问题,还未提出有效的解决方案。In the related art, the implementation method of making the data in the memory not lost after the electronic device is abnormally powered off is complicated, and the ECC does not automatically verify the existing data in the memory when the device is restarted, and an effective solution has not been proposed yet. Program.
发明内容Summary of the invention
本发明实施例提供了一种掉电处理方法、装置及电子设备方法及装置,以至少解决现有技术中在电子设备异常断电后使内存中数据不丢失的实现方法复杂,并且在设备重新启动时ECC不会自动校验内存中已有的数据的问题。The embodiment of the invention provides a method, a device, and an electronic device method and device for power-down processing, so as to at least solve the problem that the implementation method for preventing data in the memory from being lost after the abnormal power-off of the electronic device in the prior art is complicated, and ECC does not automatically check for problems with data already in memory at startup.
根据本发明的一个实施例,提供了一种掉电处理方法,包括:检测到电子设备掉电;将所述电子设备中的缓冲存储器缓存的数据同步到所述电子设备的内存中。 According to an embodiment of the present invention, a power down processing method is provided, including: detecting that an electronic device is powered down; synchronizing data buffered by the buffer memory in the electronic device into a memory of the electronic device.
在本发明实施例中,所述电子设备掉电的情况包括以下之一:所述电子设备正常掉电、所述电子设备异常掉电。In the embodiment of the present invention, the electronic device is powered off, and the electronic device is powered off normally, and the electronic device is powered off abnormally.
在本发明实施例中,所述内存为错误检查和纠正ECC内存。In the embodiment of the present invention, the memory is an error check and correction ECC memory.
在本发明实施例中,检测到所述电子设备掉电之后包括:将用于标识所述电子设备是否异常掉电的标志位设置为异常掉电。In the embodiment of the present invention, after detecting that the electronic device is powered off, the flag bit for identifying whether the electronic device is abnormally powered down is set to be abnormally powered down.
在本发明实施例中,将所述电子设备中的缓冲存储器缓存的数据同步到所述电子设备的内存中之后,所述方法还包括:从非易失性存储器中读取用于标识所述电子设备是否异常掉电的标志位;在所述标志位指示异常掉电时,所述电子设备对所述ECC内存中的数据进行校验。In the embodiment of the present invention, after synchronizing data of the buffer memory cache in the electronic device into the memory of the electronic device, the method further includes: reading from the non-volatile memory for identifying the A flag indicating whether the electronic device is abnormally powered down; and when the flag indicates an abnormal power failure, the electronic device checks data in the ECC memory.
在本发明实施例中,所述电子设备通过所述ECC内存对所述ECC内存中的数据进行校验之后,包括:将对所述内存中的数据进行ECC校验得到的校验结果与所述内存中预先存储的ECC校验值进行比较,在比较结果为一致的情况下,确认所述内存中的数据没有变化,在比较结果为不一致的情况下,确认所述内存中的数据发生了变化。In the embodiment of the present invention, after the electronic device checks the data in the ECC memory through the ECC memory, the method includes: performing a check result obtained by performing ECC check on the data in the memory. The ECC check values stored in the memory are compared, and when the comparison result is consistent, it is confirmed that the data in the memory does not change. When the comparison result is inconsistent, it is confirmed that the data in the memory has occurred. Variety.
根据本发明的另一个实施例,还提供了一种掉电处理装置,包括:检测模块,设置为检测到电子设备掉电;同步模块,设置为将所述电子设备中的缓冲存储器缓存的数据同步到所述电子设备的内存中。According to another embodiment of the present invention, there is also provided a power down processing apparatus, comprising: a detecting module configured to detect that the electronic device is powered down; and a synchronization module configured to buffer data of the buffer memory in the electronic device Synchronized into the memory of the electronic device.
在本发明实施例中,所述检测模块检测到的所述电子设备掉电情况包括以下之一:所述电子设备正常掉电、所述电子设备异常掉电。In the embodiment of the present invention, the power-off condition of the electronic device detected by the detecting module includes one of the following: the electronic device is powered off normally, and the electronic device is abnormally powered down.
在本发明实施例中,所述内存为错误检查和纠正ECC内存。In the embodiment of the present invention, the memory is an error check and correction ECC memory.
在本发明实施例中,所述装置还包括:设置模块,将用于标识所述电子设备是否异常掉电的标志位设置为异常掉电。In the embodiment of the present invention, the device further includes: a setting module, configured to set a flag bit for identifying whether the electronic device is abnormally powered down to be abnormally powered down.
在本发明实施例中,所述装置还包括:读取模块,设置为从非易失性存储器中读取用于标识所述电子设备是否异常掉电的标志位;校验模块,设置为在所述标志位指示异常掉电时,所述电子设备对所述ECC内存中的数据进行校验。In an embodiment of the present invention, the apparatus further includes: a reading module configured to read, from the non-volatile memory, a flag bit for identifying whether the electronic device is abnormally powered down; the verification module is configured to be When the flag bit indicates an abnormal power failure, the electronic device checks data in the ECC memory.
在本发明实施例中,所述装置还包括:比较模块,设置为将对所述内存中的数据进行ECC校验得到的校验结果与所述内存中预先存储的ECC校验值进行比较;第一确认模块,设置为在比较结果为一致的情况下,确认所述内存中的数据没有变化;第 二确认模块,设置为在比较结果为不一致的情况下,确认所述内存中的数据发生了变化。In the embodiment of the present invention, the device further includes: a comparison module, configured to compare the verification result obtained by performing ECC check on the data in the memory with a pre-stored ECC check value in the memory; The first confirmation module is configured to confirm that the data in the memory does not change if the comparison result is consistent; The second confirmation module is set to confirm that the data in the memory has changed if the comparison result is inconsistent.
根据本发明的另一个实施例,还提供了一种电子设备,包括:微处理控制器、ECC内存和缓冲存储器;微处理控制器,设置为在检测到所述电子设备掉电时,产生控制指令;所述缓冲存储器,设置为接收所述控制指令,并在所述控制指令的触发下,将所述缓冲存储器缓存的数据同步到所述ECC内存中。According to another embodiment of the present invention, there is also provided an electronic device comprising: a microprocessor controller, an ECC memory and a buffer memory; and a microprocessor controller configured to generate a control when the electronic device is detected to be powered down The buffer memory is configured to receive the control instruction and synchronize data buffered by the buffer memory into the ECC memory under the trigger of the control instruction.
在本发明实施例中,所述电子设备还包括:非易失性存储器,设置为存储用于标识所述电子设备是否异常掉电的标志位。In an embodiment of the invention, the electronic device further includes: a non-volatile memory, configured to store a flag bit for identifying whether the electronic device is abnormally powered down.
通过本发明,采用检测到电子设备掉电;将电子设备中的缓冲存储器缓存的数据同步到电子设备的内存中。解决了现有技术中在电子设备异常断电后使内存中数据不丢失的实现方法复杂的问题,进而在电子设备异常断电后,实现了内存中数据不丢失的操作简单,保证了内存中数据的正确性,提升了用户体验。With the present invention, it is detected that the electronic device is powered down; the data buffered by the buffer memory in the electronic device is synchronized into the memory of the electronic device. The invention solves the problem that the implementation method of the data in the memory is not lost after the abnormal power-off of the electronic device in the prior art, and further, after the abnormal power-off of the electronic device, the operation of not losing the data in the memory is realized, and the memory is guaranteed. The correctness of the data enhances the user experience.
附图说明DRAWINGS
此处所说明的附图用来提供对本发明的进一步理解,构成本申请的一部分,本发明的示意性实施例及其说明用于解释本发明,并不构成对本发明的不当限定。在附图中:The drawings described herein are intended to provide a further understanding of the invention, and are intended to be a part of the invention. In the drawing:
图1是根据本发明实施例的掉电处理方法的流程图;1 is a flow chart of a power down processing method according to an embodiment of the present invention;
图2是根据本发明实施例的掉电处理装置的结构框图;2 is a block diagram showing the structure of a power-down processing apparatus according to an embodiment of the present invention;
图3是根据本发明实施例的掉电处理装置的结构框图一;3 is a block diagram 1 of a power-down processing apparatus according to an embodiment of the present invention;
图4是根据本发明实施例的掉电处理装置的结构框图二;4 is a block diagram 2 of a power-down processing apparatus according to an embodiment of the present invention;
图5是根据本发明实施例的掉电处理装置的结构框图三;5 is a structural block diagram 3 of a power-down processing apparatus according to an embodiment of the present invention;
图6是根据本发明实施例的电子设备的结构框图;6 is a structural block diagram of an electronic device according to an embodiment of the present invention;
图7是根据本发明实施例的电子设备的结构框图一;7 is a structural block diagram 1 of an electronic device according to an embodiment of the present invention;
图8是根据本发明实施例的掉电处理方法涉及到的设备框图;8 is a block diagram of an apparatus involved in a power down processing method according to an embodiment of the present invention;
图9是根据本发明实施例的掉电处理方法的流程图一; 9 is a flowchart 1 of a power down processing method according to an embodiment of the present invention;
图10是根据本发明实施例的电子设备重启时的操作流程图。FIG. 10 is a flowchart of operations when an electronic device is restarted according to an embodiment of the present invention.
具体实施方式detailed description
下文中将参考附图并结合实施例来详细说明本发明。需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。The invention will be described in detail below with reference to the drawings in conjunction with the embodiments. It should be noted that the embodiments in the present application and the features in the embodiments may be combined with each other without conflict.
在本实施例中提供了一种掉电处理方法,图1是根据本发明实施例的掉电处理方法的流程图,如图1所示,该流程包括如下步骤:In the embodiment, a power-down processing method is provided. FIG. 1 is a flowchart of a power-down processing method according to an embodiment of the present invention. As shown in FIG. 1, the process includes the following steps:
步骤S102,检测到电子设备掉电;Step S102, detecting that the electronic device is powered off;
步骤S104,将电子设备中的缓冲存储器缓存的数据同步到电子设备的内存中。Step S104: Synchronize data buffered by the buffer memory in the electronic device into the memory of the electronic device.
通过上述步骤,在电子设备掉电时,缓冲存储器将其缓存的数据同步到电子设备的内存中,相比于现有技术中,在电子设备掉电后通过非易失性存储介质将其存储的数据拷贝到内存中,上述步骤解决了现有技术中在电子设备异常断电后使内存中数据不丢失的实现方法复杂的问题,进而在电子设备异常断电后,实现了内存中数据不丢失的操作简单,保证了内存中数据的正确性,提升了用户体验。电子设备出现掉电的情况可以有多种,在一个优选实施例中,电子设备掉电的情况包括电子设备正常掉电或者电子设备异常掉电。其中电子设备异常掉电是指非人为原因主动掉电,比如电压异常、电源被拔掉等。Through the above steps, when the electronic device is powered off, the buffer memory synchronizes its cached data into the memory of the electronic device, and stores it through the non-volatile storage medium after the electronic device is powered down, compared to the prior art. The data is copied into the memory. The above steps solve the problem that the implementation method of the data in the memory is not lost after the electronic device is abnormally powered off, and the data in the memory is not realized after the electronic device is abnormally powered off. The lost operation is simple, ensuring the correctness of the data in the memory and improving the user experience. There may be multiple situations in which the electronic device is powered down. In a preferred embodiment, the electronic device is powered down, including the normal powering down of the electronic device or the abnormal power failure of the electronic device. The abnormal power-down of the electronic device means that the power is actively powered off due to non-human reasons, such as abnormal voltage and unplugged power.
在一个优选实施例中,上述内存为错误检查和纠正ECC内存。In a preferred embodiment, the above memory is error checking and correcting ECC memory.
由于电子设备出现掉电的情况可以有多种,在一个优选实施例中,检测到电子设备掉电之后,将用于标识电子设备是否异常掉电的标志位设置为异常掉电。从而通过对电子设备出现掉电的情况分别予以了标识。在另一个优选实施例中,从非易失性存储器中读取用于标识电子设备是否异常掉电的标志位,在标志位指示电子设备异常掉电的情况下,将电子设备中的缓冲存储器缓存的数据同步到该电子设备的内存中之后,电子设备对ECC内存中的数据进行校验。Since the electronic device may be powered off, there may be various cases. In a preferred embodiment, after detecting that the electronic device is powered off, the flag for identifying whether the electronic device is abnormally powered down is set to abnormal power-down. Thus, the situation in which the electronic device is powered off is separately identified. In another preferred embodiment, a flag for identifying whether the electronic device is abnormally powered down is read from the non-volatile memory, and the buffer memory in the electronic device is used if the flag indicates that the electronic device is abnormally powered down. After the cached data is synchronized into the memory of the electronic device, the electronic device verifies the data in the ECC memory.
在另一个优选实施例中,电子设备通过ECC内存对ECC内存中的数据进行校验之后,将对内存中的数据进行ECC校验得到的校验结果与内存中预先存储的ECC校验值进行比较,在比较结果为一致的情况下,确认内存中的数据没有变化,此时说明对电子设备重新供电后,内存中的数据是正确的,可继续使用的;在比较结果为不一致的情况下,确认内存中的数据发生了变化,在这种情况下,需要进一步判断比较结 果差异的大小,在差异小的情况下,可继续使用该内存中的数据,在差异大的情况下,使用该内存中的数据将会产生错误,不能被继续使用。In another preferred embodiment, after the electronic device checks the data in the ECC memory through the ECC memory, the verification result obtained by performing ECC check on the data in the memory is performed with the ECC check value pre-stored in the memory. In comparison, if the comparison result is consistent, it is confirmed that the data in the memory has not changed. At this time, after the electronic device is re-powered, the data in the memory is correct and can be used continuously; in the case where the comparison result is inconsistent , to confirm that the data in the memory has changed, in this case, you need to further judge the comparison If the difference is small, the data in the memory can be used continuously. If the difference is large, using the data in the memory will generate an error and cannot be used any more.
在本实施例中还提供了一种掉电处理装置,该装置用于实现上述实施例及优选实施方式,已经进行过说明的不再赘述。如以下所使用的,术语“模块”可以实现预定功能的软件和/或硬件的组合。尽管以下实施例所描述的装置较佳地以软件来实现,但是硬件,或者软件和硬件的组合的实现也是可能并被构想的。In the embodiment, a power-down processing device is also provided, which is used to implement the above-mentioned embodiments and preferred embodiments, and has not been described again. As used below, the term "module" may implement a combination of software and/or hardware of a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware, or a combination of software and hardware, is also possible and contemplated.
图2是根据本发明实施例的掉电处理装置的结构框图,如图2所示,该装置包括:检测模块22,设置为检测到电子设备掉电;同步模块24,设置为将电子设备中的缓冲存储器缓存的数据同步到电子设备的内存中。2 is a structural block diagram of a power-down processing apparatus according to an embodiment of the present invention. As shown in FIG. 2, the apparatus includes: a detecting module 22 configured to detect that the electronic device is powered off; and a synchronization module 24 configured to be in the electronic device. The data buffered by the buffer memory is synchronized into the memory of the electronic device.
在本发明实施例中,检测模块22检测到的该电子设备掉电情况包括以下之一:电子设备正常掉电、电子设备异常掉电。In the embodiment of the present invention, the power-off condition of the electronic device detected by the detecting module 22 includes one of the following: the electronic device is powered off normally, and the electronic device is abnormally powered down.
在本发明实施例中,内存为错误检查和纠正ECC内存。In the embodiment of the present invention, the memory is an error check and corrects the ECC memory.
图3是根据本发明实施例的掉电处理装置的结构框图一,如图3所示,该装置还包括:设置模块26,将用于标识该电子设备是否异常掉电的标志位设置为异常掉电。3 is a block diagram showing the structure of a power-down processing apparatus according to an embodiment of the present invention. As shown in FIG. 3, the apparatus further includes: a setting module 26, configured to set a flag for identifying whether the electronic device is abnormally powered down. Power down.
图4是根据本发明实施例的掉电处理装置的结构框图二,如图4所示,该装置还包括:读取模块28,设置为从非易失性存储器中读取用于标识该电子设备是否异常掉电的标志位;校验模块30,设置为在标志位指示异常掉电时,电子设备对该ECC内存中的数据进行校验。4 is a block diagram showing the structure of a power-down processing apparatus according to an embodiment of the present invention. As shown in FIG. 4, the apparatus further includes a reading module 28 configured to read from the non-volatile memory for identifying the electronic device. Whether the device is abnormally powered down or not; the verification module 30 is configured to verify the data in the ECC memory when the flag indicates abnormal power failure.
图5是根据本发明实施例的掉电处理装置的结构框图三,如图5所示,该装置还包括:比较模块32,连接至校验模块30,设置为将对该内存中的数据进行ECC校验得到的校验结果与内存中预先存储的ECC校验值进行比较;第一确认模块34,设置为在比较结果为一致的情况下,确认内存中的数据没有变化;第二确认模块36,设置为在比较结果为不一致的情况下,确认内存中的数据发生了变化。FIG. 5 is a structural block diagram 3 of a power-down processing apparatus according to an embodiment of the present invention. As shown in FIG. 5, the apparatus further includes: a comparison module 32 connected to the verification module 30, configured to perform data in the memory. The verification result obtained by the ECC check is compared with the pre-stored ECC check value in the memory; the first confirmation module 34 is set to confirm that the data in the memory does not change if the comparison result is consistent; the second confirmation module 36. Set to confirm that the data in the memory has changed if the comparison result is inconsistent.
图6是根据本发明实施例的电子设备的结构框图,如图6所示,该电子设备包括:微处理控制器62、ECC内存64和缓冲存储器66;微处理控制器62,设置为在检测到电子设备掉电时,产生控制指令;缓冲存储器66,设置为接收控制指令,并在控制指令的触发下,将缓冲存储器66缓存的数据同步到ECC内存64中。其中,缓冲存储器66,可以是微处理控制器62的一部分,俗称刷新高速缓冲存储器(cache),集成在中央处理器(Central Processing Unit,CPU)内部。 6 is a structural block diagram of an electronic device according to an embodiment of the present invention. As shown in FIG. 6, the electronic device includes: a microprocessor controller 62, an ECC memory 64, and a buffer memory 66. The microprocessor controller 62 is configured to detect When the electronic device is powered down, a control command is generated; the buffer memory 66 is configured to receive the control command, and the data buffered by the buffer memory 66 is synchronized to the ECC memory 64 under the trigger of the control command. The buffer memory 66 may be part of the microprocessor controller 62, commonly referred to as a refresh cache, and integrated in a central processing unit (CPU).
图7是根据本发明实施例的电子设备的结构框图一,如图7所示,该电子设备还包括:非易失性存储器68,设置为存储用于标识电子设备是否异常掉电的标志位。FIG. 7 is a structural block diagram of an electronic device according to an embodiment of the present invention. As shown in FIG. 7, the electronic device further includes: a non-volatile memory 68 configured to store a flag for identifying whether the electronic device is abnormally powered down. .
针对相关技术中存在的上述问题,下面结合优选实施例进行说明,本优选实施例结合了上述实施例及其优选实施方式。The above-described problems existing in the related art will be described below in conjunction with the preferred embodiments, which combine the above-described embodiments and preferred embodiments thereof.
本优选实施例提供了一种基于ECC内存特性的内存掉电保护方法。该方法的几个组成要素:通信设备使用的网络处理芯片的内存控制器单元能够对内存中的数据进行ECC校验,系统掉电后为内存供电的电池,中央处理器(CPU)通过CPU总线(local bus)外接一片非易失性随机访问存储器(Non-Volatile Random Access Memory,简称为NVRAM)存储系统异常掉电标志(此处可以使用任何一种掉电不丢失数据的存储介质代替),通信设备使用带有ECC功能的内存条。The preferred embodiment provides a memory power down protection method based on ECC memory characteristics. Several components of the method: the memory controller unit of the network processing chip used by the communication device can perform ECC check on the data in the memory, the battery that supplies power to the memory after the system is powered off, and the central processing unit (CPU) passes through the CPU bus. (local bus) external non-volatile random access memory (Non-Volatile Random Access Memory, NVRAM for short) storage system abnormal power-down flag (here can use any kind of storage medium that loses power without losing data) The communication device uses a memory module with an ECC function.
电子设备系统异常掉电时,硬件检测到主电源输出电压异常,处理器芯片接收到主电源输出异常中断,通过内存控制器发出内存自刷新命令,同时将NVRAM中对应的地址置位,硬件逻辑控制打开电池电源,开始为内存供电,之后主电源输出失效。When the electronic device system is abnormally powered down, the hardware detects that the main power output voltage is abnormal, the processor chip receives the main power output abnormal interrupt, sends a memory self-refresh command through the memory controller, and sets the corresponding address in the NVRAM, hardware logic. Control turns on the battery and starts to supply power to the memory, after which the main power output fails.
电子设备重启时,在cpu uboot引导阶段,从NVRAM中读出异常掉电标志位,若之前发生系统异常掉电,则进入数据ECC校验流程。When the electronic device restarts, during the cpu uboot boot phase, the abnormal power-down flag is read from the NVRAM. If the system abnormal power failure occurs before, the data ECC verification process is entered.
下面结合附图对本优选实施例进行详细说明。The preferred embodiment will be described in detail below with reference to the accompanying drawings.
首先该方法基于一定的硬件条件,电子设备使用的网络处理芯片的内存控制器单元能够对内存中的数据进行ECC校验,使用的内存带有ECC功能,与该方法相关的设备框图如图8所示。其中CPU是电子设备的核心,完成网络协议处理和报文分发等基本功能。ECC内存,存储电子设备正常工作时的程序和数据。NVRAM断电后仍能保持数据的一种RAM,设备在异常掉电时,会将一个标志位存储在NVRAM中,设备重新启动时,从NVRAM中读取对应的标志,判断上次掉电是否是异常掉电,以区分本次上电流程。电池(Battery)在设备异常掉电时继续为内存供电,保持内存中的数据不丢失。Firstly, the method is based on certain hardware conditions, and the memory controller unit of the network processing chip used by the electronic device can perform ECC check on the data in the memory, and the used memory carries the ECC function, and the device block diagram related to the method is shown in FIG. 8 . Shown. The CPU is the core of the electronic device, and completes basic functions such as network protocol processing and message distribution. ECC memory, which stores programs and data when the electronic device is working properly. After the NVRAM is powered off, it can still maintain a kind of RAM. When the device is powered off abnormally, it will store a flag in the NVRAM. When the device restarts, the corresponding flag is read from the NVRAM to determine whether the last power failure occurred. It is abnormally powered down to distinguish this power-on process. The battery continues to supply power to the memory when the device is powered down, keeping the data in the memory intact.
设备在异常掉电时,硬件会检测到主电源电压输出异常,图9是根据本发明实施例的掉电处理方法的流程图一,如图9所示,该流程包括如下步骤:When the device is powered off abnormally, the hardware detects that the main power voltage output is abnormal. FIG. 9 is a flowchart 1 of the power-down processing method according to the embodiment of the present invention. As shown in FIG. 9, the process includes the following steps:
步骤S902,电源输出异常;Step S902, the power output is abnormal;
步骤S904,进入中断处理入口; Step S904, entering an interrupt processing entry;
步骤S906,NVRAM进行标识,即对标志位进行置位;Step S906, the NVRAM performs identification, that is, sets the flag bit;
步骤S908,刷新缓存(cache),即刷新高速缓冲存储器,将其缓存的数据同步到内存中;Step S908, refreshing the cache (cache), that is, refreshing the cache memory, and synchronizing the cached data into the memory;
步骤S910,启动内存自刷新;Step S910, starting a memory self-refresh;
步骤S912,硬件启动电池为内存电池。In step S912, the hardware boot battery is a memory battery.
具体地,硬件检测到这个异常后,会向CPU发送一个中断信号触发设备异常掉电中断,随后软件进入中断流程,触发通过request_irq挂接的中断处理函数,中断处理函数主要完成两个工作:1、设置NVRAM中对应的标志位,表明此次掉电是设备异常掉电,设备在下次启动时要对内存中的数据进行ECC校验;2、刷新高速缓冲存储器(cache)同时内存开启自刷新模式,刷新cache是为了将cache中的数据同步到内存,自刷新(Self-Refresh)在无时钟输人时使用,先执行进人自刷新命令(REFS-EN)进人自刷新模式,开始内部刷新地址计数器计数和刷新操作,刷新控制电路按一定的时间间隔提供刷新控制,Self-Refresh通常用在节能(power-saving)模式,或是睡眠模式(sleep mode),可以少耗电,刷新周期越短,耗电量越大,为求省电,通常都尽可能的将刷新周期加长,但是周期太长是有危险的,一旦不足以保持DRAM的内容,就会造成丢失。对NVRAM的置位操作,可以采用直接向固定地址写入值的方式,设计时可以将NVRAM挂接在CPU的local bus下,然后选取它对应地址空间的一个字节作为标志位,将该字节存储的值改写为1。刷新cache可以采用向无用内存地址写入值的方式,内存大小直接能覆盖cache大小即可,这是为了保证正常运行时cache中的值已全部同步到内存。在软件处理中断的同时,硬件逻辑会打开电池(battery)的开关,开始为内存供电,之后主电源失效,电子设备掉电。Specifically, after detecting the abnormality, the hardware sends an interrupt signal to the CPU to trigger the device abnormal power-down interrupt. Then the software enters the interrupt process and triggers the interrupt handler function that is attached by request_irq. The interrupt handler mainly performs two tasks: Setting the corresponding flag bit in NVRAM indicates that the power failure is abnormal power failure of the device, and the device performs ECC check on the data in the memory at the next startup; 2. Refreshing the cache memory (cache) and starting the self-refresh memory Mode, refresh the cache is to synchronize the data in the cache to the memory, self-refresh (Self-Refresh) is used when there is no clock input, first execute the self-refresh command (REFS-EN) into the self-refresh mode, start the internal Refresh address counter counting and refresh operation, refresh control circuit provides refresh control at certain time intervals, Self-Refresh is usually used in power-saving mode, or sleep mode, which can consume less power and refresh cycle The shorter the power consumption is, the longer the refresh cycle is, as long as possible, in order to save power, but the cycle is too long, it is dangerous. Once it is not enough to keep the contents of the DRAM, it will be lost. For the NVRAM set operation, you can directly write the value to the fixed address. You can mount the NVRAM under the local bus of the CPU during design, and then select one byte of its corresponding address space as the flag. The value stored in the section is rewritten to 1. Refreshing the cache can use the way of writing values to the useless memory address. The memory size can directly cover the size of the cache. This is to ensure that the values in the cache are all synchronized to the memory during normal operation. While the software is processing the interrupt, the hardware logic turns on the battery switch and starts to supply power to the memory. After that, the main power fails and the electronic device loses power.
由于在电子设备掉电过程中,内存一直是由电池来供电的,因此内存中的数据不会丢失。但是对于软件来说依然需要保证内存中数据的可靠性,或者至少能够确定数据是否发生了变化,这主要依靠设备重新上电时进行的一些操作。Since the memory is always powered by the battery during the power-down of the electronic device, the data in the memory is not lost. However, for software, it is still necessary to ensure the reliability of the data in the memory, or at least to determine whether the data has changed. This mainly depends on some operations performed when the device is powered on again.
电子设备在重新上电时,CPU采用uboot进行引导,uboot将CPU的内存控制器初始化后,会经过图10中所示的一个过程,其具体过程如下:When the electronic device is powered on again, the CPU uses uboot to boot. After uboot initializes the CPU's memory controller, it will go through a process as shown in Figure 10. The specific process is as follows:
步骤S1002,NVRAM中读取标志位,即进入该过程后,首先软件从NVRAM中读取表示设备是否异常掉电的标志位,其操作同设备掉电时相同,标志位对应的地址不变,一个是写操作,一个是读操作。 Step S1002, the flag bit is read in the NVRAM, that is, after entering the process, the software first reads a flag indicating whether the device is abnormally powered down from the NVRAM, and the operation is the same as when the device is powered off, and the address corresponding to the flag bit does not change. One is a write operation and the other is a read operation.
步骤S1004,判断标志位是否被置1,如果标志位置1,表示上次掉电为异常掉电,内存在掉电过程中使用电池进行了供电,其中的数据需要进行校验,如果标志位没有被置1,则跳过该过程,执行步骤S1012。如果标志位被置1,执行步骤S1006。这里所采用的标志位置1的方式只是为了区分是否是异常掉电而采用的一种方法,判断标志位的方式可以另外选择。进入数据校验流程后所要进行的一系列操作主要依赖CPU的硬件特性,这里我们采用的CPU的内存控制器单元必须能对内存中的数据进行ECC校验。这里以一款mips架构的CPU为例来说明该过程。Step S1004, determining whether the flag bit is set to 1, if the flag position is 1, indicating that the last power failure is abnormal power failure, the memory is powered by the battery during the power failure process, and the data needs to be verified, if the flag bit is not When set to 1, the process is skipped, and step S1012 is performed. If the flag bit is set to 1, step S1006 is performed. The method of setting the flag position 1 here is only one method for distinguishing whether it is an abnormal power failure, and the manner of judging the flag bit can be additionally selected. The series of operations to be performed after entering the data verification process mainly depend on the hardware characteristics of the CPU. The memory controller unit of the CPU we use here must be able to perform ECC check on the data in the memory. Here is a mips architecture CPU as an example to illustrate the process.
步骤S1006,确定开始地址和结束地址。基于该CPU内存控制器的特点,首先选择需要的内存空间,用开始地址和结束地址这个区间来表示,这里的地址值是相对于内存大小来说的,比如内存大小为2G,开始地址为0,结束地址为1G,表示要对内存的前半部分进行校验,而非CPU所见的物理空间地址0~1G。In step S1006, a start address and an end address are determined. Based on the characteristics of the CPU memory controller, first select the required memory space, and use the interval of the start address and the end address to indicate that the address value here is relative to the memory size, for example, the memory size is 2G, and the start address is 0. The end address is 1G, indicating that the first half of the memory is to be verified, not the physical space address 0~1G seen by the CPU.
步骤S1008,ECC校验流程,即进行64字节ECC校验。后面就要借助该内存控制器中的一个硬件模块来实现数据的校验了,该模块可以从支持ECC功能的ddr3内存中一次读取64字节的数据,并且计算出这些数据对应的ECC校验值,然后将该值与从内存中读取的已经存在的ECC校验值进行比较,如果一致,则认为内存中的数据没有变化,如果不一致,则认为内存中的值发生了变化。由于该模块一次只能处理64字节的数据,如果校验的内存大小大于64字节,需要从开始地址到结束地址循环进行,每校验完成64字节就比较一次,如果有失败,就将失败计数(errcount)进行加一操作,直到把所有需要的内存都校验完成。Step S1008, the ECC check process, that is, performing a 64-byte ECC check. Later, a hardware module in the memory controller is used to verify the data. The module can read 64 bytes of data from the ddr3 memory supporting the ECC function, and calculate the ECC school corresponding to the data. The value is checked, and then the value is compared with the existing ECC check value read from the memory. If they are consistent, the data in the memory is considered to have not changed. If not, the value in the memory is changed. Since the module can only process 64 bytes of data at a time, if the size of the checked memory is greater than 64 bytes, it needs to be cycled from the start address to the end address. Each check completes 64 bytes and compares once. If there is a failure, The failure count (errcount) is incremented until all required memory is verified.
步骤S1010,将errcount写入NVRAM,即校验完成后,将errcount也写入NVRAM中对应的一个地址,在电子设备重新完成上电后,从NVRAM中读取该值,软件根据数据校验错误的多少来决定,内存中保存的数据能否继续使用。从数据校验的过程中我们能够看出,该方法主要依赖CPU内存控制器的内存ECC校验模块,特别是它能够完成64字节数据ECC校验值计算和从内存中读出原有ECC校验值的特性。当然,方法的具体实现并不局限于以上说明,比如如果某系列的CPU能够完成内存中数据的ECC校验,但并不是每次只能处理64字节长度的数据,方法的实现就要做相应的修改,这里只是基于已经应用的一款处理器做的方法说明。Step S1010, the errcount is written into the NVRAM, that is, after the verification is completed, the errcount is also written to a corresponding address in the NVRAM, and after the electronic device is completely powered on, the value is read from the NVRAM, and the software verifies the error according to the data. How much to decide whether the data stored in memory can continue to be used. From the process of data verification, we can see that this method mainly relies on the memory ECC check module of the CPU memory controller, especially it can complete the calculation of 64-byte data ECC check value and read the original ECC from the memory. The nature of the check value. Of course, the specific implementation of the method is not limited to the above description, for example, if a series of CPUs can complete the ECC check of the data in the memory, but not only can process 64 bytes of data at a time, the implementation of the method will be The corresponding modification, here is only based on the method description of a processor that has been applied.
步骤S1012,流程结束。In step S1012, the process ends.
综上所述,通过本发明实施例采用的方法省去了数据搬移的过程,在设备掉电的过程中,数据仍然存在于设备内存中。并且可以借鉴ECC内存的特性保证对内存单独 供电时数据的正确性,使设备重启后能正常使用内存中的数据,这也是本发明中内存掉电保护功能的一个关键。In summary, the method adopted by the embodiment of the present invention saves the process of data movement. In the process of powering down the device, the data still exists in the device memory. And can learn from the characteristics of ECC memory to ensure separate memory The correctness of the data during power supply enables the data in the memory to be used normally after the device is restarted, which is also a key to the memory power-down protection function of the present invention.
显然,本领域的技术人员应该明白,上述的本发明的各模块或各步骤可以用通用的计算装置来实现,它们可以集中在单个的计算装置上,或者分布在多个计算装置所组成的网络上,可选地,它们可以用计算装置可执行的程序代码来实现,从而,可以将它们存储在存储装置中由计算装置来执行,并且在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤,或者将它们分别制作成各个集成电路模块,或者将它们中的多个模块或步骤制作成单个集成电路模块来实现。这样,本发明不限制于任何特定的硬件和软件结合。It will be apparent to those skilled in the art that the various modules or steps of the present invention described above can be implemented by a general-purpose computing device that can be centralized on a single computing device or distributed across a network of multiple computing devices. Alternatively, they may be implemented by program code executable by the computing device such that they may be stored in the storage device by the computing device and, in some cases, may be different from the order herein. The steps shown or described are performed, or they are separately fabricated into individual integrated circuit modules, or a plurality of modules or steps thereof are fabricated as a single integrated circuit module. Thus, the invention is not limited to any specific combination of hardware and software.
以上所述仅为本发明的优选实施例而已,并不用于限制本发明,对于本领域的技术人员来说,本发明可以有各种更改和变化。凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。The above description is only the preferred embodiment of the present invention, and is not intended to limit the present invention, and various modifications and changes can be made to the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and scope of the present invention are intended to be included within the scope of the present invention.
工业实用性Industrial applicability
本发明实施例提供的上述技术方案,可以用于电子设备的掉电检测过程中,采用检测到电子设备掉电;将电子设备中的缓冲存储器缓存的数据同步到电子设备的内存中。解决了现有技术中在电子设备异常断电后使内存中数据不丢失的实现方法复杂的问题,进而在电子设备异常断电后,实现了内存中数据不丢失的操作简单,保证了内存中数据的正确性,提升了用户体验。 The foregoing technical solution provided by the embodiment of the present invention can be used to detect that the electronic device is powered off during the power failure detection process of the electronic device, and synchronize the data buffered by the buffer memory in the electronic device into the memory of the electronic device. The invention solves the problem that the implementation method of the data in the memory is not lost after the abnormal power-off of the electronic device in the prior art, and further, after the abnormal power-off of the electronic device, the operation of not losing the data in the memory is realized, and the memory is guaranteed. The correctness of the data enhances the user experience.

Claims (14)

  1. 一种掉电处理方法,包括:A power-down processing method includes:
    检测到电子设备掉电;The electronic device is detected to be powered down;
    将所述电子设备中的缓冲存储器缓存的数据同步到所述电子设备的内存中。Synchronizing data buffered by the buffer memory in the electronic device into a memory of the electronic device.
  2. 根据权利要求1所述的方法,其中,所述电子设备掉电的情况包括以下之一:The method of claim 1, wherein the electronic device is powered down comprises one of the following:
    所述电子设备正常掉电、所述电子设备异常掉电。The electronic device is powered off normally, and the electronic device is powered off abnormally.
  3. 根据权利要求2所述的方法,其中,所述内存为错误检查和纠正ECC内存。The method of claim 2 wherein said memory is error checking and correcting ECC memory.
  4. 根据权利要求3所述的方法,其中,检测到所述电子设备掉电之后包括:The method of claim 3, wherein detecting that the electronic device is powered down comprises:
    将用于标识所述电子设备是否异常掉电的标志位设置为异常掉电。A flag bit for identifying whether the electronic device is abnormally powered down is set to be abnormally powered down.
  5. 根据权利要求4所述的方法,其中,将所述电子设备中的缓冲存储器缓存的数据同步到所述电子设备的内存中之后,所述方法还包括:The method of claim 4, wherein after the data of the buffer memory cache in the electronic device is synchronized into the memory of the electronic device, the method further comprises:
    从非易失性存储器中读取用于标识所述电子设备是否异常掉电的标志位;Reading a flag for identifying whether the electronic device is abnormally powered down from a non-volatile memory;
    在所述标志位指示异常掉电时,对所述ECC内存中的数据进行校验。The data in the ECC memory is verified when the flag bit indicates an abnormal power down.
  6. 根据权利要求5所述的方法,其中,通过所述ECC内存对所述ECC内存中的数据进行校验之后,包括:The method according to claim 5, wherein after the data in the ECC memory is verified by the ECC memory, the method comprises:
    将对所述内存中的数据进行ECC校验得到的校验结果与所述内存中预先存储的ECC校验值进行比较,在比较结果为一致的情况下,确认所述内存中的数据没有变化,在比较结果为不一致的情况下,确认所述内存中的数据发生了变化。Comparing the verification result obtained by performing ECC check on the data in the memory with the ECC check value pre-stored in the memory, and confirming that the data in the memory does not change if the comparison result is consistent When the comparison result is inconsistent, it is confirmed that the data in the memory has changed.
  7. 一种掉电处理装置,包括:A power-down processing device includes:
    检测模块,设置为检测到电子设备掉电;a detection module configured to detect that the electronic device is powered off;
    同步模块,设置为将所述电子设备中的缓冲存储器缓存的数据同步到所述电子设备的内存中。 And a synchronization module configured to synchronize data buffered by the buffer memory in the electronic device into a memory of the electronic device.
  8. 根据权利要求7所述的装置,其中,所述检测模块检测到的所述电子设备掉电情况包括以下之一:The device according to claim 7, wherein the electronic device power-off condition detected by the detecting module comprises one of the following:
    所述电子设备正常掉电、所述电子设备异常掉电。The electronic device is powered off normally, and the electronic device is powered off abnormally.
  9. 根据权利要求8所述的装置,其中,所述内存为错误检查和纠正ECC内存。The apparatus of claim 8 wherein said memory is error checking and correcting ECC memory.
  10. 根据权利要求9所述的装置,其中,所述装置还包括:The apparatus of claim 9 wherein said apparatus further comprises:
    设置模块,将用于标识所述电子设备是否异常掉电的标志位设置为异常掉电。The setting module sets a flag bit for identifying whether the electronic device is abnormally powered down to be abnormally powered down.
  11. 根据权利要求10所述的装置,其中,所述装置还包括:The device of claim 10, wherein the device further comprises:
    读取模块,设置为从非易失性存储器中读取用于标识所述电子设备是否异常掉电的标志位;a reading module configured to read, from the non-volatile memory, a flag bit for identifying whether the electronic device is abnormally powered down;
    校验模块,设置为在所述标志位指示异常掉电时,对所述ECC内存中的数据进行校验。The verification module is configured to verify data in the ECC memory when the flag bit indicates abnormal power failure.
  12. 根据权利要求11所述的装置,其中,所述装置还包括:The apparatus of claim 11 wherein said apparatus further comprises:
    比较模块,设置为将对所述内存中的数据进行ECC校验得到的校验结果与所述内存中预先存储的ECC校验值进行比较;a comparison module, configured to compare a verification result obtained by performing ECC check on the data in the memory with an ECC check value pre-stored in the memory;
    第一确认模块,设置为在比较结果为一致的情况下,确认所述内存中的数据没有变化;The first confirmation module is configured to confirm that the data in the memory does not change if the comparison result is consistent;
    第二确认模块,设置为在比较结果为不一致的情况下,确认所述内存中的数据发生了变化。The second confirmation module is configured to confirm that the data in the memory has changed if the comparison result is inconsistent.
  13. 一种电子设备,包括:微处理控制器、ECC内存和缓冲存储器;An electronic device comprising: a micro processing controller, an ECC memory, and a buffer memory;
    微处理控制器,设置为在检测到所述电子设备掉电时,产生控制指令;a microprocessor controller configured to generate a control command upon detecting that the electronic device is powered down;
    所述缓冲存储器,设置为接收所述控制指令,并在所述控制指令的触发下,将所述缓冲存储器缓存的数据同步到所述ECC内存中。The buffer memory is configured to receive the control instruction and synchronize data buffered by the buffer memory into the ECC memory under the trigger of the control instruction.
  14. 根据权利要求13所述的电子设备,其中,所述电子设备还包括:The electronic device of claim 13, wherein the electronic device further comprises:
    非易失性存储器,设置为存储用于标识所述电子设备是否异常掉电的标志位。 A non-volatile memory is arranged to store a flag bit for identifying whether the electronic device is abnormally powered down.
PCT/CN2015/079611 2014-10-24 2015-05-22 Power-off processing method and apparatus, and electronic device WO2016062084A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410583786.4A CN105528308A (en) 2014-10-24 2014-10-24 Power failure processing method and device and electronic apparatus
CN201410583786.4 2014-10-24

Publications (1)

Publication Number Publication Date
WO2016062084A1 true WO2016062084A1 (en) 2016-04-28

Family

ID=55760221

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/079611 WO2016062084A1 (en) 2014-10-24 2015-05-22 Power-off processing method and apparatus, and electronic device

Country Status (2)

Country Link
CN (1) CN105528308A (en)
WO (1) WO2016062084A1 (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110308861A (en) * 2018-03-20 2019-10-08 浙江宇视科技有限公司 Storing data store method, device, electronic equipment and readable storage medium storing program for executing
CN110673998A (en) * 2019-09-20 2020-01-10 济南浪潮数据技术有限公司 Method, device and equipment for positioning SSD (solid State disk) disk-dropping reason
CN112799595A (en) * 2021-02-02 2021-05-14 联想(北京)有限公司 Data processing method, device and storage medium
CN113960391A (en) * 2021-09-13 2022-01-21 珠海亿智电子科技有限公司 Abnormal power failure testing device and method for storage medium

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107797642B (en) * 2016-09-07 2019-12-06 华为技术有限公司 power backup method and device
CN108572926B (en) * 2017-03-13 2022-02-22 阿里巴巴集团控股有限公司 Method and device for synchronizing caches of central processing units
CN107329912B (en) * 2017-07-04 2020-05-26 浪潮集团有限公司 Power failure processing method of NAND FLASH array
CN108255423B (en) * 2017-12-28 2020-12-18 深圳忆联信息系统有限公司 Method for reducing power consumption of RAID solid state disk and RAID solid state disk
CN109976939B (en) * 2019-03-28 2021-03-19 联想(北京)有限公司 Data processing method and device
CN111370045B (en) * 2020-03-06 2022-02-01 上海芯波电子科技有限公司 Nonvolatile computing system based on resistive memory
CN112231139A (en) * 2020-09-11 2021-01-15 莱芜职业技术学院 Computer memory data protection method
CN113464481A (en) * 2021-08-23 2021-10-01 小熊电器股份有限公司 Desktop fan, and power-off protection control method and device for desktop fan
CN115185359B (en) * 2022-09-09 2023-01-06 粤港澳大湾区数字经济研究院(福田) Crypto-coprocessor system and power-down protection method thereof
CN116126576A (en) * 2023-01-10 2023-05-16 奉加微电子(上海)有限公司 Data verification method, electronic device and storage medium
CN117112290A (en) * 2023-10-20 2023-11-24 广州翼辉信息技术有限公司 Power-down messy code protection method for yaffs file system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101097479A (en) * 2006-06-30 2008-01-02 精英电脑股份有限公司 Reserve source of electrical power supply device, desk computer and data protection method thereof
CN101187830A (en) * 2007-12-27 2008-05-28 华为技术有限公司 Power off protection method, device and logic device and storage system
CN102662802A (en) * 2012-05-08 2012-09-12 无锡云动科技发展有限公司 Full-system power failure recovery method and equipment based on nonvolatile memory
CN103530242A (en) * 2012-07-06 2014-01-22 河南思维自动化设备股份有限公司 Method for power down protection in write operation process of NandFlash memory
US20140310574A1 (en) * 2012-12-28 2014-10-16 Super Talent Technology, Corp. Green eMMC Device (GeD) Controller with DRAM Data Persistence, Data-Type Splitting, Meta-Page Grouping, and Diversion of Temp Files for Enhanced Flash Endurance

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101183801B (en) * 2007-12-07 2011-03-16 杭州华三通信技术有限公司 Power-off protection method, system and device
JP5906966B2 (en) * 2012-06-29 2016-04-20 富士通株式会社 Control device, power supply device, and power control method
CN102929805A (en) * 2012-10-19 2013-02-13 浪潮电子信息产业股份有限公司 Power-down protection method for cache data in memory system
US9286203B2 (en) * 2013-01-07 2016-03-15 Avago Technologies General Ip (Singapore) Pte. Ltd. Control logic design to support USB cache offload

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101097479A (en) * 2006-06-30 2008-01-02 精英电脑股份有限公司 Reserve source of electrical power supply device, desk computer and data protection method thereof
CN101187830A (en) * 2007-12-27 2008-05-28 华为技术有限公司 Power off protection method, device and logic device and storage system
CN102662802A (en) * 2012-05-08 2012-09-12 无锡云动科技发展有限公司 Full-system power failure recovery method and equipment based on nonvolatile memory
CN103530242A (en) * 2012-07-06 2014-01-22 河南思维自动化设备股份有限公司 Method for power down protection in write operation process of NandFlash memory
US20140310574A1 (en) * 2012-12-28 2014-10-16 Super Talent Technology, Corp. Green eMMC Device (GeD) Controller with DRAM Data Persistence, Data-Type Splitting, Meta-Page Grouping, and Diversion of Temp Files for Enhanced Flash Endurance

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110308861A (en) * 2018-03-20 2019-10-08 浙江宇视科技有限公司 Storing data store method, device, electronic equipment and readable storage medium storing program for executing
CN110308861B (en) * 2018-03-20 2023-07-21 浙江宇视科技有限公司 Storage data storage method, device, electronic equipment and readable storage medium
CN110673998A (en) * 2019-09-20 2020-01-10 济南浪潮数据技术有限公司 Method, device and equipment for positioning SSD (solid State disk) disk-dropping reason
CN112799595A (en) * 2021-02-02 2021-05-14 联想(北京)有限公司 Data processing method, device and storage medium
CN112799595B (en) * 2021-02-02 2023-06-23 联想(北京)有限公司 Data processing method, device and storage medium
CN113960391A (en) * 2021-09-13 2022-01-21 珠海亿智电子科技有限公司 Abnormal power failure testing device and method for storage medium

Also Published As

Publication number Publication date
CN105528308A (en) 2016-04-27

Similar Documents

Publication Publication Date Title
WO2016062084A1 (en) Power-off processing method and apparatus, and electronic device
US9098301B2 (en) Electronic device and booting method
US10860302B2 (en) Memory-efficient upgrade staging
US20170344421A1 (en) Integral post package repair
US20120096255A1 (en) Server and method for managing i2c bus of the server
JP2012038305A (en) Data processing system having error detection of set information of peripheral device
US9250920B2 (en) Initializing processor cores in a multiprocessor system
US9286992B2 (en) Refresh apparatus and electronic device that ensure simplified refresh process of flash memory
JP2008009721A (en) Evaluation system and evaluation method thereof
WO2016209476A1 (en) Flushing and restoring core memory content to external memory
TWI534707B (en) Computer system, shutdown and boot method thereof
JP2019133623A (en) Computer system for preserving data in memory module and computer-implemented method using the same
US10657003B2 (en) Partial backup during runtime for memory modules with volatile memory and non-volatile memory
JP5561791B2 (en) Information processing apparatus, information processing method, and information processing program
JP6021597B2 (en) Information processing apparatus, information processing method, and computer program
TWI308694B (en) Method of data protection for computers
JPH06324914A (en) Runaway detecting method for computer
JP2011154582A (en) Integrated circuit device and electronic equipment
US9817672B2 (en) Information processing apparatus and method for controlling information processing apparatus
JP4856023B2 (en) Real-time watch apparatus and method
WO2018028410A1 (en) Method for intel platform detection of parameters in flash rom
US11640327B2 (en) Circuit detection method and data detection circuit
JP6130735B2 (en) Microcontroller and error detection method
JP2000194605A (en) Refreshing device of flash memory, its refreshing method, and flash memory
JP2008217636A (en) Data processor and program start method

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15852917

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15852917

Country of ref document: EP

Kind code of ref document: A1