WO2023000552A1 - 一种存储器、数据存储方法以及门锁系统 - Google Patents

一种存储器、数据存储方法以及门锁系统 Download PDF

Info

Publication number
WO2023000552A1
WO2023000552A1 PCT/CN2021/129834 CN2021129834W WO2023000552A1 WO 2023000552 A1 WO2023000552 A1 WO 2023000552A1 CN 2021129834 W CN2021129834 W CN 2021129834W WO 2023000552 A1 WO2023000552 A1 WO 2023000552A1
Authority
WO
WIPO (PCT)
Prior art keywords
user
sector
user information
target
sectors
Prior art date
Application number
PCT/CN2021/129834
Other languages
English (en)
French (fr)
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 WO2023000552A1 publication Critical patent/WO2023000552A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/16Error detection or correction of the data by redundancy in hardware
    • G06F11/20Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements
    • G06F11/2053Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements where persistent mass storage functionality or persistent mass storage control functionality is redundant
    • G06F11/2094Redundant storage or storage space
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0238Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory
    • G06F12/0246Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory in block erasable memory, e.g. flash memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/50Information retrieval; Database structures therefor; File system structures therefor of still image data
    • G06F16/51Indexing; Data structures therefor; Storage structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/72Details relating to flash memory management
    • G06F2212/7204Capacity control, e.g. partitioning, end-of-life degradation

Definitions

  • the invention relates to the technical field of computers, in particular to a memory, a data storage method and a door lock system.
  • a storage medium such as a Flash memory is usually used for data storage.
  • data is usually stored directly through a memory, and the stored data is directly extracted from the memory for use during extraction.
  • the problem with the existing technology is that the memory may be damaged, especially the Flash memory is fragile, which will cause errors in the stored data, reduce the accuracy of the data, and cause the business system based on the data to function abnormally. run.
  • the main purpose of the present invention is to provide a memory, a data storage method and a door lock system, aiming to solve the problem of directly storing data through a memory in the prior art, which will cause errors in stored data and reduce data accuracy when the memory is damaged , resulting in the problem that the functions of the business system based on the data cannot operate normally.
  • the first aspect of the present invention provides a memory, the above memory includes:
  • At least one main sector and multiple candidate sectors wherein each of the above-mentioned main sectors corresponds to a plurality of the above-mentioned candidate sectors as backups, and each of the above-mentioned candidate sectors is used as a backup of one of the above-mentioned main sectors,
  • Each of the above-mentioned candidate sectors is used to store data when the corresponding above-mentioned main sector is found to be damaged.
  • each of the above-mentioned primary sectors and each of the above-mentioned candidate sectors respectively includes a user unit and an index unit
  • the above-mentioned user unit is used to store user information
  • the above-mentioned index unit is used to store user unit addresses corresponding to all user information.
  • the memory includes a plurality of primary sectors, and each of the primary sectors corresponds to at least 3 candidate sectors as backups.
  • the second aspect of the present invention provides a data storage method, the above-mentioned method is applied to the above-mentioned memory, and the above-mentioned method includes:
  • Each of the above-mentioned user information is written into the user unit of different master sectors respectively and judges whether the above-mentioned user information is written successfully;
  • each target user information into the user unit of each target candidate sector and judge whether each of the above-mentioned target user information is written successfully, wherein the above-mentioned target candidate sector is a candidate sector corresponding to the target main sector,
  • the target master sector is a master sector corresponding to the target user information, and the target user information is user information in a subscriber unit that has not been successfully written into the master sector.
  • the above-mentioned writing each of the above-mentioned user information into the user units of different master sectors and judging whether the above-mentioned user information is successfully written includes:
  • the above-mentioned writing of each target user information into the user unit of each target candidate sector and judging whether each of the above-mentioned target user information is written successfully wherein the above-mentioned target candidate sector is corresponding to the target main sector
  • the above-mentioned target main sector is the main sector corresponding to the above-mentioned target user information
  • the above-mentioned target user information is the user information in the user unit that has not been successfully written into the main sector, including:
  • For each of the above-mentioned target user information acquire a target main sector corresponding to the above-mentioned target user information and a plurality of target candidate sectors corresponding to the above-mentioned target main sector;
  • the above method further includes:
  • the user unit address data string corresponding to the successfully written user information wherein the above-mentioned successfully written user information includes all user information successfully written in the user unit of the main sector and all successfully written target candidate sectors.
  • the above-mentioned writing of the above-mentioned user unit address data string into the index unit of the main sector or the index unit of the candidate sector includes:
  • the above-mentioned user unit address data string into an index unit of a target index main sector and judging whether the writing is successful, wherein the above-mentioned target index main sector is any one of the main sectors of the above-mentioned memory;
  • the above-mentioned user unit address data string is written into the index unit of the candidate sector corresponding to the above-mentioned target index main sector.
  • the third aspect of the present invention provides a door lock system, the door lock system includes:
  • a user information module configured to acquire user information and send the above user information to a memory for storage
  • a memory for storing data wherein the above-mentioned memory includes at least one main sector and multiple candidate sectors, each of the above-mentioned main sectors corresponds to a plurality of the above-mentioned candidate sectors as backup, and each of the above-mentioned candidate sectors As a backup of one of the above-mentioned main sectors, each of the above-mentioned candidate sectors is used to store data when the corresponding above-mentioned main sector is found to be damaged, and each of the above-mentioned main sectors and each of the above-mentioned candidate sectors includes a user unit and an index unit respectively , the user unit is used to store user information, the index unit is used to store the address of the user unit corresponding to each user, and the memory stores data based on any one of the above data storage methods.
  • the above user information module includes:
  • An image acquisition unit configured to acquire a face image of a target object
  • the processing unit is configured to acquire user information of each target object based on the face image, and send each user information to the memory for storage.
  • the memory provided in the solution of the present invention includes: at least one main sector and a plurality of candidate sectors, wherein each of the above-mentioned main sectors corresponds to a plurality of the above-mentioned candidate sectors as backups, and each of the above-mentioned backup sectors
  • the selected sectors are respectively used as a backup for one of the above-mentioned primary sectors
  • each of the above-mentioned candidate sectors is used to store data when the corresponding above-mentioned primary sector is found to be damaged.
  • at least one main sector and multiple candidate sectors are set in the memory, and each main sector corresponds to multiple candidate sectors.
  • the sector is used as a backup.
  • the data is stored in the corresponding alternative sector, which is conducive to improving the accuracy of data storage, enhancing the reliability of the memory, and is conducive to ensuring the business system based on stored data.
  • the function works normally.
  • FIG. 1 is a schematic structural diagram of a memory provided by an embodiment of the present invention.
  • FIG. 2 is a schematic structural diagram of the memory 1 in FIG. 1 according to an embodiment of the present invention
  • FIG. 3 is a schematic flowchart of a data storage method provided by an embodiment of the present invention.
  • FIG. 4 is a schematic flowchart of step S200 in FIG. 3 according to an embodiment of the present invention.
  • FIG. 5 is a schematic flowchart of step S300 in FIG. 3 according to an embodiment of the present invention.
  • FIG. 6 is a schematic flowchart of another data storage method provided by an embodiment of the present invention.
  • FIG. 7 is a schematic flowchart of step S500 in FIG. 6 according to an embodiment of the present invention.
  • FIG. 8 is a schematic flowchart of a data storage method provided by an embodiment of the present invention.
  • Fig. 9 is a schematic diagram of a primary sector and its candidate sectors provided by an embodiment of the present invention.
  • Fig. 10 is a schematic structural diagram of a door lock system provided by an embodiment of the present invention.
  • FIG. 11 is a schematic structural diagram of the user information module 21 in FIG. 10 according to an embodiment of the present invention.
  • the term “if” may be construed as “when” or “once” or “in response to determining” or “in response to detecting” depending on the context.
  • the phrases “if determined” or “if detected [the described condition or event]” may be construed, depending on the context, to mean “once determined” or “in response to the determination” or “once detected [the described condition or event]” event]” or “in response to detection of [described condition or event]”.
  • Flash memory is usually used for data storage.
  • Flash memory is generally used as a storage medium on which non-volatile data is stored.
  • file systems can be established on the Flash memory, such as FATFS, JFFS2, YAFFS, EXT4, etc. These file systems can combine the characteristics of the storage medium, use read-write verification, wear leveling and other mechanisms to ensure the correctness of the stored data sex.
  • data is usually stored directly through a memory, and the stored data is directly extracted from the memory for use during extraction.
  • the problem with the existing technology is that the memory may be damaged, especially the Flash memory is fragile, which will cause errors in the stored data, reduce the accuracy of the data, and cause the business system based on the data to function abnormally. run.
  • the present invention provides a memory, a data storage method, and a door lock system, wherein the above-mentioned memory includes: at least one main sector and multiple alternative sectors, wherein each of the above-mentioned main sectors Each of the above-mentioned candidate sectors is used as a backup for one of the above-mentioned main sectors, and each of the above-mentioned candidate sectors is used to store data when the corresponding above-mentioned main sector is found to be damaged. .
  • the scheme of the present invention at least one main sector and multiple candidate sectors are set in the memory, and each main sector corresponds to multiple candidate sectors.
  • the sector is used as a backup.
  • the data is stored in the corresponding alternative sector, which is conducive to improving the accuracy of data storage and extraction, enhancing the reliability of the memory, and is conducive to ensuring the business based on the stored data.
  • the system is functioning normally.
  • an embodiment of the present invention provides a memory 1, the above-mentioned memory 1 includes: at least one main sector 11 and a plurality of candidate sectors 12, wherein each of the above-mentioned main sectors 11 corresponds to a plurality of the above-mentioned
  • the spare sectors 12 are used as spares.
  • Each of the spare sectors 12 serves as a spare for one of the master sectors 11.
  • Each spare sector 12 is used to store data when the corresponding master sector 11 is found to be damaged.
  • the above-mentioned memory 1 is a Flash memory
  • the Flash memory is composed of multiple sectors, including at least one main sector 11 and a plurality of alternative sectors 12, and the above-mentioned Flash memory provides complete addressing and data bus , allowing data stored in any area on the Flash memory to be read at any time.
  • a single sector of the Flash memory is easily damaged, if the correctness of the data is not guaranteed, the function of the business system (such as a door lock system) based on the data stored in the Flash memory may not be able to operate normally. Therefore, in this embodiment, a plurality of alternative sectors 12 are set for each primary sector 11 in the memory 1 as a backup. The data is stored in the sector 12, that is, the data that originally needs to be stored in the primary sector 11 is stored in the corresponding backup sector 12, so as to improve the accuracy of the stored data.
  • the above-mentioned memory 1 includes two main sectors 11 and six candidate sectors 12 as an example for illustration. It is set and adjusted according to actual needs, and no specific limitation is made here.
  • each primary sector 11 corresponds to three candidate sectors 12, but this is not specifically limited.
  • FIG. 2 is a schematic structural diagram of a memory 1 provided by an embodiment of the present invention.
  • each of the above-mentioned primary sectors 11 and each of the above-mentioned candidate sectors 12 includes a user unit and an index unit, respectively.
  • each sector in the memory 1 can be divided into an index unit and a user unit, wherein each main sector 11 and each candidate sector 12
  • the storage spaces are all the same size.
  • the user unit can be used to store user information, which is data that needs to be stored in the memory 1 .
  • the above-mentioned user information may include the user's basic information (such as name, gender, etc.), registration features, and difficult supplementary-entry features, wherein the above-mentioned registration features are facial feature information when the user performs identity registration, and the above-mentioned difficult supplementary-entry features It is the feature information that the user has repeatedly recorded and successfully identified after unsuccessful identification. It should be noted that the above user information may also be other information that the user needs to store, which is not specifically limited here.
  • the index unit is used to save the address of the user unit corresponding to all user information, that is, the storage location where the above index unit records the user information, so that the corresponding user information can be obtained quickly according to the data in the index unit.
  • the storage location of the user information is represented in the form of an offset address, that is, the address of a certain user unit is the address of the user unit relative to the first user unit in the memory 1
  • one index unit is used to store the user unit addresses corresponding to all user information
  • one user unit is used to store user information corresponding to one user, so one sector (one main sector 11 or one alternative sector 12 ) can save all index information and a user information.
  • the user ID of the user when storing user information in the user unit, the user ID of the user will be stored correspondingly, and when the address of the user unit is stored in the index unit, the corresponding user ID will also be stored, so that the user ID corresponding to the user that can be searched according to needs can be stored by the index unit
  • the user address corresponding to the user ID of the user can quickly address the user unit corresponding to a certain user and obtain the corresponding user information.
  • each primary sector 11 corresponds to at least three candidate sectors 12 as backups, and the primary sector 11 and its corresponding candidate sectors 12 are actually used to store the same data (user information), When the system reads and writes data, it defaults to read and write the main sector 11 earlier. If the user unit of the main sector 11 is not damaged, then the user information is directly written into the user unit of the main sector 11, and the address of the user unit is used as Subscriber unit address.
  • the user information was written in the subscriber unit of a candidate sector 12 corresponding to the above-mentioned master sector 11, if the subscriber unit of the candidate sector 12 was also damaged, Then this data is written in the user unit of another alternative sector 12 corresponding to the above-mentioned master sector 11, and so on, until data is successfully written into the user unit of an undamaged alternative sector 12 (the standby Select the address of the user unit of the sector 12 as the user address corresponding to the user information); or the user units of all the candidate sectors 12 corresponding to the master sector 11 are damaged, and the writing of the user information fails, and then the user is fed back Information writing failed.
  • a new primary sector 11 may be allocated for the user information.
  • the method is similar to the above method of writing user information into user units. First, obtain the user unit addresses corresponding to all user information as Index information, wherein the index information may further include a user ID corresponding to each user information. Write the index information into the index unit of any one of the main sectors 11, if the index unit of the main sector 11 is not damaged, the writing is successful. Otherwise, the index information is written into the index unit of a candidate sector 12 corresponding to the primary sector 11 .
  • index units of all candidate sectors 12 corresponding to the main sector 11 are damaged, then write the index information into the index unit of the next main sector 11, and so on, until the above-mentioned index information is successfully written Into a certain index unit, or all index units are damaged, and the writing fails, and the feedback index information writing fails. In this way, when the main sector 11 is found to be damaged, data can be stored through the corresponding spare sector 12 .
  • each master sector 11 is used to store user information corresponding to a user. Therefore, when the number of users is n, the number of required sectors is not less than 4n, which can be set and adjusted according to actual needs , not specifically limited here.
  • the memory 1 provided by the embodiment of the present invention supports read-write verification, fast addressing and multiple fault tolerance, which is conducive to improving the accuracy of data storage and extraction, enhancing the reliability of the memory 1, and is conducive to ensuring the business system based on stored data (e.g. door lock system) functioning normally.
  • Fig. 3 is a schematic flow chart of a data storage method provided by an embodiment of the present invention.
  • the above-mentioned data storage method is applied to the above-mentioned memory.
  • the above-mentioned memory includes at least one primary sector and multiple candidate sectors, wherein each The above-mentioned primary sector corresponds to a plurality of the above-mentioned candidate sectors as backups, and each of the above-mentioned candidate sectors is used as a backup of one of the above-mentioned primary sectors, and each of the above-mentioned candidate sectors is used to find that the corresponding above-mentioned primary sector is damaged.
  • Each of the above-mentioned main sectors and each of the above-mentioned candidate sectors includes a user unit and an index unit, the above-mentioned user unit is used to store user information, and the above-mentioned index unit is used to store user unit addresses corresponding to all user information.
  • the above method includes the following steps:
  • Step S100 acquiring at least one piece of user information.
  • the above user information includes user basic information, registration features and difficult supplementary record features.
  • the above basic user information includes user name (and/or user ID), user age, user gender and other information.
  • the above-mentioned registration feature is the facial feature information of the user when the identity registration is performed
  • the above-mentioned difficult supplementary-record feature is the feature information of the user's supplementary record and successful recognition after repeated unsuccessful identifications. It should be noted that the above data storage method can be applied to the memory in the door lock system, and the door lock system judges whether to open the door for the user according to the user information stored in the memory.
  • the door lock system Before the door lock system performs face recognition and unlocking, the user needs to enter information first, for example, by capturing the face image of the target user and obtaining the face feature information of the target user based on the face image for storage. This process is called The user registers, and the facial feature information obtained is the above-mentioned registered feature (for example, it may include key points of the human face, depth information, infrared features of the human face, etc.). Furthermore, the door lock system collects the user's registration features in real time, so some of the collected registration features may not be very accurate. When identifying the user, some registration features cannot be successfully identified.
  • the process of user registration may include initializing the collected face image (including standardizing face size, face angle, and illumination), and then extracting the features of the initialized face image as User's registration characteristics and save.
  • the process of user registration may include initializing the collected face image (including standardizing face size, face angle, and illumination), and then extracting the features of the initialized face image as User's registration characteristics and save.
  • the recognition fails, the user information needs to add the difficult supplementary recording feature or the data bit corresponding to the difficult supplementary recording feature can be set according to the captured feature, and there is no limitation here. That is, only when the current user's face has been successfully registered multiple times and the recognition is unsuccessful, the corresponding difficult re-recording feature is acquired for supplementary recording.
  • Step S200 writing each of the above user information into user units of different primary sectors and judging whether the above user information is successfully written.
  • one master sector is used to store user information corresponding to one user, so it is necessary to write user information of different users into user units of different master sectors. Specifically, the user information written in the user unit of the main sector may be read back and compared with the obtained user information to determine whether the writing of the user information is successful.
  • Step S300 write each target user information into the user unit of each target candidate sector and judge whether each of the above-mentioned target user information is successfully written, wherein the above-mentioned target candidate sector is a candidate corresponding to the target main sector sector, the above-mentioned target primary sector is a primary sector corresponding to the above-mentioned target user information, and the above-mentioned target user information is user information in a user unit that has not been successfully written into the primary sector.
  • target user information user information
  • target user information it means that all user information has been successfully written into the user unit of each master sector, and there is no need to rewrite user information.
  • the user unit of a certain master sector is damaged, so that the user information cannot be written, the user information will be written into the corresponding alternative sector.
  • At least one main sector and multiple candidate sectors are set in the memory, and each main sector corresponds to multiple candidate sectors as backups, and the verification judgment is performed during data storage Whether the writing is successful or not, when the main sector is found to be damaged, the data is stored in the corresponding alternative sector.
  • the scheme of directly storing data through a memory in the prior art it is beneficial to improve the accuracy of data storage and improve Data storage reliability.
  • step S200 more specifically includes steps as shown in FIG. 4:
  • Step S201 acquiring first check codes of each of the above user information respectively.
  • Step S202 write each of the above user information into the user units of different master sectors, read back and obtain the second verification code of the written information stored in each of the above user units.
  • Step S203 based on the above-mentioned first check code and the above-mentioned second check code, it is judged whether the above-mentioned written information is consistent with the above-mentioned user information.
  • the above-mentioned user information is successfully written, otherwise the above-mentioned Failed to write user information.
  • the first check code and the second check code are cyclic redundancy check (CRC, Cyclic Redundancy Check) codes.
  • CRC Cyclic Redundancy Check
  • the data strings generated by each piece of user information are obtained separately, and a polynomial is preset (the general formula of the polynomial can be expressed as Wherein, C i is equal to 0 or 1, and j is the highest power), obtain the highest power and coefficient of the polynomial, and fill zero at the end of the data string generated by each user information according to the highest power of the polynomial.
  • the data string used to calculate the first check code is 1101001000.
  • the preset polynomial is the i-order
  • the data string (1101001000 in this embodiment) used to generate the first check code is used as the dividend
  • the i-order polynomial coefficient is used as the divisor, and the two are performed In the division operation, the first check code is obtained, and the bit length of the first check code is i.
  • the division operation can be realized through the XOR operation of the data string and the polynomial coefficient, assuming that the polynomial is x 3 +x+1, the polynomial coefficient is 1011, and the data string used to calculate the first check code is 1101001000, then the two The first check code obtained by the division operation is 100, and the first check code is assigned to the end of the data string to generate the user information to be written, that is, 1101001000100.
  • CRC32 is used to generate the first check code, which can improve the efficiency of data error correction, but the specific CRC polynomial design can be based on the total length of the user information to be protected, the required The actual conditions such as the error protection function and the processor capability for realizing the CRC are set and adjusted, and are not specifically limited here.
  • the user unit of a master sector is only used to save a user information corresponding to a user, and after writing a user information into the user unit of a master sector, read back the stored information in the user unit. Writing information, and calculating and obtaining a second check code according to the read written information; wherein, the written information is user information written and stored in the user unit. For a plurality of user information, the user information of all users is traversed, respectively written into the user units of different primary sectors, and a plurality of second check codes are calculated respectively.
  • the written information obtained and used to calculate the second check code does not include the above-mentioned first check code.
  • the calculation method of the above-mentioned second check code is the same as that of the above-mentioned first check code, and will not be repeated here; the check code used and its calculation method can also be set and adjusted according to actual needs , not specifically limited here.
  • the first check code and the second check code corresponding to each user information respectively, compare the first check code and the second check code of each user information element by element, and determine whether the two Is it consistent. Obtain the judgment result, if the two are consistent, it means that the written information is consistent with the user information to be written, and the user information is successfully written, otherwise, the user information is not successfully written, and it can be judged as the user unit of the main sector damaged, it needs to address to the corresponding alternative sector to write the user information.
  • the written information used to calculate the second check code includes the above-mentioned first check code, when the second check code is 0, it means that the user information is written successfully.
  • step S300 more specifically includes steps as shown in FIG. 5:
  • Step S301 for each piece of target user information, acquire a target main sector corresponding to the target user information and a plurality of target candidate sectors corresponding to the target main sector.
  • Step S302 writing the above-mentioned target user information into the user units of the above-mentioned plurality of target candidate sectors in sequence and judging whether the above-mentioned target user information is written successfully, until the above-mentioned target user information is successfully written into one of the above-mentioned target candidate sectors In the user unit, or in the user units of all the above-mentioned target candidate sectors, the above-mentioned user information cannot be written successfully.
  • the above-mentioned target user information is the user information in the user unit of the main sector that has not been written successfully, and the user unit of the target main sector corresponding to the target user information has been damaged, so it is necessary to write the target user information into the corresponding user unit of the target main sector. in the target candidate sector.
  • the specific judgment method is the same as the method of calculating the first check code and the second check code when writing into the subscriber unit of the master sector, and will not be repeated here. If the user information is written successfully when writing the user unit of the first candidate sector, then it is not necessary to write the user unit of the next candidate sector, otherwise, write the next one (can be any other one, or It may be in the user unit of the candidate sector whose storage address is the closest to the last candidate sector, and judge whether the writing is successful or not.
  • the above data storage method further includes:
  • Step S400 obtain the user unit address data string corresponding to the successfully written user information, wherein the above-mentioned successfully written user information includes all user information in the user unit successfully written into the master sector and all successfully written target candidates Target user information in the user unit of the sector.
  • Step S500 write the above-mentioned subscriber unit address data string into the index unit of the main sector or the index unit of the candidate sector.
  • the above-mentioned index information needs to be stored, so as to quickly search and obtain the user information corresponding to each user according to the index information, wherein the above-mentioned index information may include successfully written user information
  • the address of the corresponding user unit can also include the user ID corresponding to each user information.
  • each user ID can also be pre-stored in the corresponding index unit.
  • the user unit address data string is stored in association with the corresponding user ID, which is not specifically limited here.
  • the user unit address data strings corresponding to all successfully written user information are obtained and stored in an index unit (which can be an index unit of a main sector or an index unit of an alternate sector) , can realize quick index to obtain each user information;
  • an index unit which can be an index unit of a main sector or an index unit of an alternate sector
  • the user unit address data strings corresponding to all successfully written user information are obtained and stored in an index unit (which can be an index unit of a main sector or an index unit of an alternate sector) , can realize quick index to obtain each user information;
  • an index unit which can be an index unit of a main sector or an index unit of an alternate sector
  • the storage location of user information in the form of offset address namely a certain user unit address is the address of this user unit relative to the first user unit in the memory (that is, the offset of the first address of the memory), which is not limited here.
  • step S500 more specifically includes steps as shown in FIG. 7:
  • Step S501 writing the above-mentioned user unit address data string into the index unit of a target index main sector and judging whether the writing is successful, wherein the above-mentioned target index main sector is any one of the main sectors of the above-mentioned memory.
  • Step S502 when the writing is not successful, write the above-mentioned user unit address data string into the index unit of the candidate sector corresponding to the above-mentioned target index main sector.
  • the above-mentioned target index main sector is a main sector for storing index information (address information) of the subscriber unit.
  • an index unit is used to store the user unit address strings corresponding to all user information, so any master sector can be selected as the target index master sector.
  • a master sector can also be preset as the target
  • the main sector of the index is not specifically limited here.
  • the above-mentioned user unit address data string (or index information including the user unit data string and user ID) is written into the index unit of the target index master sector, and it is judged whether the writing is successful.
  • the specific method of judging whether the writing is successful is similar to the method of judging whether the user information is successfully written, and specifically includes: calculating the third check code of the user unit address data string to be written and the index of the main sector of the write target The fourth check code of the written user unit address data string (not including the third check code added at the end and written) obtained after the unit, judges to be written according to the third check code and the fourth check code Whether the input user unit address data string is consistent with the written user unit address data string, if it is consistent, it will be judged that the writing is successful, if it is inconsistent, it will be judged that the writing is not successful.
  • the above-mentioned third check code and fourth check code can be set and adjusted according to actual needs.
  • a CRC code is used, and the specific calculation and comparison methods are the same as those used when writing user information above. This will not be repeated here.
  • the writing is not successful, it means that the index unit of the main sector of the target index is damaged, then address the index unit of the alternative sector corresponding to the main sector of the target index, write the above-mentioned user unit address data string and rewrite judge.
  • one master sector may correspond to multiple candidate sectors (3 in this embodiment), then the above-mentioned user unit address data string may be sequentially written into the multiple candidate sectors corresponding to the above-mentioned target index master sector.
  • the index unit of the area In the index unit of the area, and judge whether the writing is successful, and so on, until the above-mentioned user unit address data string is successfully written in the index unit of a candidate sector; or the index units of all candidate sectors are damaged and cannot be stored For the address data string of the subscriber unit, it is reported that the address data string of the subscriber unit fails to be written at this time.
  • the next target index primary sector (which can be any other primary sector, or It can be the next main sector whose storage address is closest to the previous target index main sector), and write the user unit address data string again and judge whether the writing is successful, and so on, until the writing is successful; or all main sectors
  • the index units of the index unit and all the index units of the alternative sectors are damaged, and the above-mentioned user unit address data string cannot be stored. At this time, it is fed back that all index units are damaged, and the user is prompted to replace the memory.
  • the written subscriber unit address data string used to calculate the fourth check code includes the above-mentioned third check code, then when the fourth check code is 0, it means that the subscriber unit address data The string was written successfully.
  • the index unit stores the address (or offset address) of the user unit corresponding to all user information, that is, the address of the user unit corresponding to all users in the memory, therefore, the user information corresponding to all users needs to be After the corresponding subscriber unit is successfully written, the corresponding subscriber unit data string can be obtained and written into an index unit.
  • the main sector and the backup sector of the above-mentioned memory may also include other units for storing information, such as a parameter unit for storing parameter information.
  • a parameter unit for storing parameter information into the above-mentioned parameter unit.
  • FIG. 8 is a specific flowchart of a data storage method provided by an embodiment of the present invention.
  • FIG. 9 is a main flow chart provided by an embodiment of the present invention. Schematic diagram of a sector and its alternative sectors.
  • a piece of user information is stored as an example for illustration.
  • the user information is acquired, and k is initialized to 0, where k is a parameter used for counting when acquiring a candidate sector.
  • Calculate the first check code (CRC32 check code) of the user information put the check code at the end of the user information to obtain the user information data string to be written and write it in the user unit of a master sector, specifically, put The check code is also written together, so that the first check code can be directly obtained when reading back, and a quick check can be performed.
  • CRC32 check code CRC32 check code
  • the writing is unsuccessful, the next candidate sector is obtained again, until the user information is successfully written or the user units of the three candidate sectors are all damaged, the user information writing fails.
  • the address of the user unit corresponding to the user information needs to be written into an index unit.
  • Figure 9 shows the position of each sector on the memory
  • the user ID is the ID number corresponding to the user
  • the index unit offset address is the position offset relative to the first index unit of the main sector A
  • the user unit The offset address is the position offset of the first subscriber unit relative to the main sector A
  • the unit is KB, and in this embodiment, the subscriber units of all sectors are continuous on the memory location, and the Index units are contiguous in memory location.
  • a master sector includes only one user unit, and is used to store user ID and user information corresponding to one user.
  • different users have different user IDs, and the user information of different users is written into the user units of different master sectors, which is equivalent to different master sectors having different user IDs.
  • the offset address of the corresponding main sector user unit is 0, and the user ID of the second user is 2, then the offset address of the corresponding main sector user unit is 4KB, and so on, give each user the corresponding user ID in turn, and then you can get the user unit offset address corresponding to the main sector.
  • an index unit can save the offset addresses of all users corresponding to the user units, and can calculate and obtain the index unit offset address (ie, the index unit offset address) according to the user ID.
  • the offset address of the index unit of the user ID in the candidate sector is [(ID-1)+N*4], the unit is KB, where N Indicates the Nth candidate sector.
  • At least 3 alternative sectors are preferably set. According to the calculation of the failure rate of the FLASH memory as "single failure/100,000 times of reading and writing", the failure of four sectors at the same time may be equivalent to to zero. If the verification of the information obtained by reading back in all alternative sectors fails, it means that the memory needs to be replaced or the current user information is damaged and needs to be rewritten.
  • FIG. 10 is a schematic structural diagram of a door lock system provided by the embodiment of the present invention. As shown in FIG. 10, the above door lock system 2 includes:
  • the memory 22 is used to store data, wherein the above-mentioned memory 22 includes at least one main sector 221 and multiple candidate sectors 222, and each of the above-mentioned main sectors 221 corresponds to a plurality of the above-mentioned candidate sectors 222 as backup, each Each of the above-mentioned candidate sectors 222 is respectively used as a backup of the above-mentioned primary sector 221, each of the above-mentioned candidate sectors 222 is used to store data when the corresponding above-mentioned primary sector 221 is found to be damaged, each of the above-mentioned primary sectors 221 and each of the above-mentioned
  • the alternative sectors 222 respectively include a user unit and an index unit, the user unit is used to store user information, the index unit is used to store the address of the user unit corresponding to each user, and the memory 22 is based on any data storage method in this embodiment for data storage.
  • door lock system 2 can also include other modules for realizing its specific required functions, such as an information comparison module, a control unlocking module, etc., which can be set and adjusted according to its actual required functions, here Not specifically limited.
  • the above-mentioned user information module 21 includes: an image acquisition unit 211, which is used to collect the face image of the target object; a processing unit 212, which is used to obtain the face image of each target object based on the above-mentioned face image User information, and send each of the user information to the memory 22 for storage.
  • the above-mentioned target object is a user who needs to use the door lock system
  • the above-mentioned face image may include a depth image and an infrared image of the user.
  • the face image is recognized, and the user information is acquired and stored in the memory 22, wherein the above user information may include user basic information, registration features and difficult supplementary record features.
  • the above basic user information includes user name (and/or user ID), user age, user gender and other information.
  • the above-mentioned registration feature is the facial feature information (such as face key points, depth information, face infrared feature information, etc.) when the user registers for identity. characteristic information.
  • At least one main sector 221 and multiple alternative sectors 222 are set in the memory 22 of the door lock system 2, and each main sector 221 corresponds to a plurality of alternative sectors 222 as Backup, when it is found that the main sector 221 is damaged, the data is stored in the corresponding alternative sector 222.
  • the disclosed apparatus/terminal equipment and method may be implemented in other ways.
  • the device/terminal device embodiments described above are only illustrative.
  • the division of the above-mentioned modules or units is only a logical function division.
  • other division methods may be used, such as multiple units or Components may be combined or integrated into another system, or some features may be omitted, or not implemented.
  • the above-mentioned integrated modules/units are realized in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the present invention realizes all or part of the processes in the methods of the above embodiments, and can also be completed by instructing related hardware through computer programs.
  • the above computer programs can be stored in a computer-readable storage medium. When executed by the processor, the steps in the above-mentioned various method embodiments can be realized.
  • the above-mentioned computer program includes computer program code, and the above-mentioned computer program code may be in the form of source code, object code, executable file or some intermediate form.
  • the above-mentioned computer-readable medium may include: any entity or device capable of carrying the above-mentioned computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random Access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the above computer-readable storage medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Quality & Reliability (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Storage Device Security (AREA)

Abstract

本发明公开了一种存储器、数据存储方法以及门锁系统,其中,上述存储器包括:至少一个主扇区以及多个备选扇区,其中,每个上述主扇区对应有多个上述备选扇区作为备用,每个上述备选扇区分别作为一个上述主扇区的备用,各上述备选扇区用于在发现对应的上述主扇区损坏时存储数据。与现有技术中直接通过一个存储器进行数据存储的方案相比,本发明方案中在存储器中设置至少一个主扇区以及多个备选扇区,且每个主扇区对应有多个备选扇区作为备用,在发现主扇区损坏时将数据存储到对应的备选扇区,有利于提高数据存储的准确性,增强存储器的可靠性,且有利于保证基于存储的数据的业务系统的功能正常运行。

Description

一种存储器、数据存储方法以及门锁系统
本申请要求于2021年7月21日提交中国专利局,申请号为202110826779.2,发明名称为“一种存储器、数据存储方法以及门锁系统”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明涉及计算机技术领域,尤其涉及的是一种存储器、数据存储方法以及门锁系统。
背景技术
随着科学技术的进步,尤其是计算机技术的迅速发展,对于数据的处理和存储越来越受到重视。目前通常采用Flash存储器等存储介质来进行数据存储。具体的,现有技术中通常直接通过一个存储器进行数据存储,在提取时直接从存储器中提取出已存储的数据进行使用。现有技术的问题在于,存储器可能会出现损坏的情况,尤其是Flash存储器具有易损坏的特性,因此会导致存储的数据出错,降低数据准确性,从而导致基于该数据的业务系统的功能无法正常运行。
发明内容
本发明的主要目的在于提供一种存储器、数据存储方法以及门锁系统,旨在解决现有技术中直接通过一个存储器进行数据存储,在存储器出现损坏时会导致存储的数据出错,降低数据准确性,从而导致基于该数据的业务系统的功能无法正常运行的问题。
为了实现上述目的,本发明第一方面提供一种存储器,上述存储器包括:
至少一个主扇区以及多个备选扇区,其中,每个上述主扇区对应有多个上述备选扇区作为备用,每个上述备选扇区分别作为一个上述主扇区的备用,各 上述备选扇区用于在发现对应的上述主扇区损坏时存储数据。
可选地,各上述主扇区和各上述备选扇区分别包括用户单元和索引单元,上述用户单元用于存储用户信息,上述索引单元用于存储所有用户信息对应的用户单元地址。
可选地,上述存储器包括多个主扇区且每个上述主扇区对应有至少3个备选扇区作为备用。
本发明第二方面提供一种数据存储方法,上述方法应用于上述存储器,且上述方法包括:
获取至少一个用户信息;
将各上述用户信息分别写入不同的主扇区的用户单元中并判断上述用户信息是否写入成功;
将各目标用户信息写入各目标备选扇区的用户单元中并判断各上述目标用户信息是否写入成功,其中,上述目标备选扇区是与目标主扇区对应的备选扇区,上述目标主扇区是与上述目标用户信息对应的主扇区,上述目标用户信息是未成功写入主扇区的用户单元中的用户信息。
可选地,上述将各上述用户信息分别写入不同的主扇区的用户单元中并判断上述用户信息是否写入成功,包括:
分别获取各上述用户信息的第一校验码;
将各上述用户信息分别写入不同的主扇区的用户单元中,回读并获取各上述用户单元中存储的已写入信息的第二检验码;
基于上述第一校验码和上述第二检验码判断上述已写入信息与上述用户信息是否一致,当上述已写入信息与上述用户信息一致时上述用户信息写入成功,反之上述用户信息写入不成功。
可选地,上述将各目标用户信息写入与各目标备选扇区的用户单元中并判断各上述目标用户信息是否写入成功,其中,上述目标备选扇区是与目标主扇区对应的备选扇区,上述目标主扇区是与上述目标用户信息对应的主扇区,上 述目标用户信息是未成功写入主扇区的用户单元中的用户信息,包括:
对于每一个上述目标用户信息,获取与上述目标用户信息对应的目标主扇区以及与上述目标主扇区对应的多个目标备选扇区;
将上述目标用户信息依次写入上述多个目标备选扇区的用户单元中并判断上述目标用户信息是否写入成功,直到上述目标用户信息成功写入一个上述目标备选扇区的用户单元中,或者所有上述目标备选扇区的用户单元中都未能成功写入上述用户信息。
可选地,在上述将各目标用户信息写入各目标备选扇区的用户单元中并判断各上述目标用户信息是否写入成功之后,上述方法还包括:
获取写入成功的用户信息对应的用户单元地址数据串,其中,上述写入成功的用户信息包括所有成功写入主扇区的用户单元中的用户信息以及所有成功写入目标备选扇区的用户单元中的目标用户信息;
将上述用户单元地址数据串写入主扇区的索引单元或备选扇区的索引单元。
可选地,上述将上述用户单元地址数据串写入主扇区的索引单元或备选扇区的索引单元,包括:
将上述用户单元地址数据串写入一个目标索引主扇区的索引单元中并判断是否写入成功,其中,上述目标索引主扇区是上述存储器的任意一个主扇区;
当未写入成功时,将上述用户单元地址数据串写入与上述目标索引主扇区对应的备选扇区的索引单元中。
本发明第三方面提供一种门锁系统,上述门锁系统包括:
用户信息模块,用于获取用户信息并将上述用户信息发送至存储器进行存储;
存储器,用于存储数据,其中,上述存储器包括至少一个主扇区以及多个备选扇区,每个上述主扇区对应有多个上述备选扇区作为备用,每个上述备选扇区分别作为一个上述主扇区的备用,各上述备选扇区用于在发现对应的上述主扇区损坏时存储数据,各上述主扇区和各上述备选扇区分别包括用户单元和 索引单元,上述用户单元用于存储用户信息,上述索引单元用于存储各用户对应的用户单元地址,上述存储器基于如上述任意一种数据存储方法进行数据存储。
可选地,上述用户信息模块包括:
图像采集单元,用于采集目标对象的人脸图像;
处理单元,用于基于上述人脸图像获取各目标对象的用户信息,并将各上述用户信息发送至上述存储器进行存储。
由上可见,本发明方案中提供的存储器包括:至少一个主扇区以及多个备选扇区,其中,每个上述主扇区对应有多个上述备选扇区作为备用,每个上述备选扇区分别作为一个上述主扇区的备用,各上述备选扇区用于在发现对应的上述主扇区损坏时存储数据。与现有技术中直接通过一个存储器进行数据存储的方案相比,本发明方案中在存储器中设置至少一个主扇区以及多个备选扇区,且每个主扇区对应有多个备选扇区作为备用,在发现主扇区损坏时将数据存储到对应的备选扇区,有利于提高数据存储的准确性,增强存储器的可靠性,且有利于保证基于存储的数据的业务系统的功能正常运行。
附图说明
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其它的附图。
图1是本发明实施例提供的一种存储器的结构示意图;
图2是本发明实施例图1中存储器1的具体结构示意图;
图3是本发明实施例提供的一种数据存储方法的流程示意图;
图4是本发明实施例图3中步骤S200的具体流程示意图;
图5是本发明实施例图3中步骤S300的具体流程示意图;
图6是本发明实施例提供的另一种数据存储方法的流程示意图;
图7是本发明实施例图6中步骤S500的具体流程示意图;
图8是本发明实施例提供的一种数据存储方法的具体流程示意图;
图9是本发明实施例提供的一个主扇区及其备选扇区的示意图;
图10是本发明实施例提供的一种门锁系统结构示意图;
图11是本发明实施例图10中用户信息模块21的具体结构示意图。
具体实施方式
以下描述中,为了说明而不是为了限定,提出了诸如特定系统结构、技术之类的具体细节,以便透彻理解本发明实施例。然而,本领域的技术人员应当清楚,在没有这些具体细节的其它实施例中也可以实现本发明。在其它情况下,省略对众所周知的系统、装置、电路以及方法的详细说明,以免不必要的细节妨碍本发明的描述。
应当理解,当在本说明书和所附权利要求书中使用时,术语“包括”指示所描述特征、整体、步骤、操作、元素和/或组件的存在,但并不排除一个或多个其它特征、整体、步骤、操作、元素、组件和/或其集合的存在或添加。
还应当理解,在本发明说明书中所使用的术语仅仅是出于描述特定实施例的目的而并不意在限制本发明。如在本发明说明书和所附权利要求书中所使用的那样,除非上下文清楚地指明其它情况,否则单数形式的“一”、“一个”及“该”意在包括复数形式。
还应当进一步理解,在本发明说明书和所附权利要求书中使用的术语“和/或”是指相关联列出的项中的一个或多个的任何组合以及所有可能组合,并且包括这些组合。
如在本说明书和所附权利要求书中所使用的那样,术语“如果”可以依据上下文被解释为“当…时”或“一旦”或“响应于确定”或“响应于检测到”。类似的,短语“如果确定”或“如果检测到[所描述条件或事件]”可以依据上下文被解释为意指“一旦确定”或“响应于确定”或“一旦检测到[所描述的条件或事件]”或“响应于检测到[所描述条件或事件]”。
下面结合本发明实施例的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明的一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本发明保护的范围。
在下面的描述中阐述了很多具体细节以便于充分理解本发明,但是本发明还可以采用其它不同于在此描述的其它方式来实施,本领域技术人员可以在不违背本发明内涵的情况下做类似推广,因此本发明不受下面公开的具体实施例的限制。
随着科学技术的进步,尤其是计算机技术的迅速发展,对于数据的处理和存储越来越受到重视。目前通常采用Flash存储器等存储介质来进行数据存储。在嵌入式系统中,一般会使用Flash存储器作为存储介质,在上面保存非易失性数据。在部分系统中,可以在Flash存储器上建立文件系统,如FATFS、JFFS2、YAFFS、EXT4等,这些文件系统可以结合存储介质的特性,使用读写校验、磨损均衡等机制来保证存储数据的正确性。但使用上述文件系统进行数据存储和管理需要占用较大的内存,对于内存较小的系统(例如门锁系统)则难以实现,且该类型的文件系统对存储数据的可靠性的帮助很难量化。
具体地,现有技术中通常直接通过一个存储器进行数据存储,在提取时直接从存储器中提取出已存储的数据进行使用。现有技术的问题在于,存储器可能会出现损坏的情况,尤其是Flash存储器具有易损坏的特性,因此会导致存储的数据出错,降低数据准确性,从而导致基于该数据的业务系统的功能无法正常运行。
为了解决现有技术的问题,本发明方案提供一种存储器、数据存储方法以及门锁系统,其中,上述存储器包括:至少一个主扇区以及多个备选扇区,其中,每个上述主扇区对应有多个上述备选扇区作为备用,每个上述备选扇区分别作为一个上述主扇区的备用,各上述备选扇区用于在发现对应的上述主扇区损坏时存储数据。与现有技术中直接通过一个存储器进行数据存储的方案相比,本发 明方案中在存储器中设置至少一个主扇区以及多个备选扇区,且每个主扇区对应有多个备选扇区作为备用,在发现主扇区损坏时将数据存储到对应的备选扇区,有利于提高数据存储以及提取的准确性,增强存储器的可靠性,且有利于保证基于存储的数据的业务系统的功能正常运行。
如图1所示,本发明实施例提供一种存储器1,上述存储器1包括:至少一个主扇区11以及多个备选扇区12,其中,每个上述主扇区11对应有多个上述备选扇区12作为备用,每个上述备选扇区12分别作为一个上述主扇区11的备用,各上述备选扇区12用于在发现对应的上述主扇区11损坏时存储数据。在一个实施例中,上述存储器1为Flash存储器,Flash存储器由多个扇区组成,包括至少一个主扇区11以及多个备选扇区12,且上述Flash存储器提供完整的寻址和数据总线,允许随时读取存储在Flash存储器上任何区域中的数据。需要说明的是,由于Flash存储器单扇区易损坏,如果不对数据正确性加以保证,则可能导致基于该Flash存储器存储的数据的业务系统(例如门锁系统)的功能无法正常运行。因此本实施例中,为存储器1中的每个主扇区11设置多个备选扇区12作为备用,当发现某一个主扇区11损坏时,可以在该主扇区11对应的备选扇区12中存储数据,即将原本需要存储到主扇区11中的数据存储到对应的备选扇区12中,从而提升存储的数据的准确性。
其中,图1中以上述存储器1包括两个主扇区11和六个备选扇区12为例进行说明,实际使用过程中,主扇区11和备选扇区12的具体数目还可以根据实际需求进行设置和调整,在此不作具体限定。图1中,每个主扇区11分别与3个备选扇区12相对应,但不作为具体限定。
图2是本发明实施例提供的一种存储器1的具体结构示意图,在一些实施例中,上述存储器1中,各上述主扇区11和各上述备选扇区12分别包括用户单元和索引单元,即存储器1中的每个扇区(包括主扇区11和备选扇区12)都可划分为索引单元和用户单元,其中,每个主扇区11和每个备选扇区12的存储空间大小都相同。
在一个实施例中,用户单元可以用于存储用户信息,上述用户信息是需要存储到上述存储器1中的数据。更具体地,上述用户信息可以包括用户的基础信息(如名字、性别等)、注册特征以及困难补录特征,其中,上述注册特征是用户进行身份注册时的面部特征信息,上述困难补录特征是用户多次识别未成功后补录并识别成功的特征信息。需要说明的是,上述用户信息还可以是用户需要进行存储的其它信息,在此不作具体限定。
在一个实施例中,索引单元用于保存所有用户信息对应的用户单元地址,即上述索引单元记录用户信息的存储位置,从而可以根据索引单元中的数据快速寻址获得对应的用户信息。优选地以偏移地址的形式表示用户信息的存储位置,即某用户单元地址是该用户单元相对于存储器1中第一个用户单元的地址
(或存储器1的首地址)的偏移量。
更具体地,一个索引单元用于存储所有用户信息对应的用户单元地址,且一个用户单元用于存储一个用户对应的用户信息,因此一个扇区(一个主扇区11或一个备选扇区12)可以保存所有的索引信息和一个用户信息。其中,用户单元中存储用户信息时会对应存储该用户的用户ID,索引单元中存储用户单元地址时也会存储对应的用户ID,从而可以根据需要查找的用户对应的用户ID,通过索引单元存储的用户ID对应的用户地址快速寻址到某用户对应的用户单元并获取对应的用户信息。
在一个实施例中,每个主扇区11对应有至少3个备选扇区12作为备用,主扇区11与其对应的备选扇区12实际上用于存储相同的数据(用户信息),在系统读写数据时,默认先读写主扇区11,如果该主扇区11的用户单元未损坏,则用户信息直接写入该主扇区11的用户单元,将该用户单元的地址作为用户单元地址。当该主扇区11的用户单元损坏时,将该用户信息写入与上述主扇区11对应的一个备选扇区12的用户单元中,如果该备选扇区12的用户单元也损坏,则将该数据写入与上述主扇区11对应的另一个备选扇区12的用户单元中,如此循环,直到数据成功写入一个未损坏的备选扇区12的用户单元(将该 备选扇区12的用户单元的地址作为该用户信息对应的用户地址);或者与该主扇区11对应的所有备选扇区12的用户单元都损坏,用户信息写入失败,则反馈该用户信息写入失败。在一种应用场景中,在上述用户信息写入失败后,可以为该用户信息分配一个新的主扇区11。
待所有用户信息写入完成后,将所有用户信息对应的用户单元地址写入索引单元,其方法与上述将用户信息写入用户单元的方法相似,首先获取所有用户信息对应的用户单元地址,作为索引信息,其中,上述索引信息中还可以包括各用户信息对应的用户ID。将索引信息写入任意一个主扇区11的索引单元,如果该主扇区11的索引单元未损坏,则写入成功。反之,则将索引信息写入与该主扇区11对应的一个备选扇区12的索引单元中。进一步地,如果与该主扇区11对应的所有备选扇区12的索引单元都损坏,则将索引信息写入下一个主扇区11的索引单元中,如此循环,直到上述索引信息成功写入某一索引单元中,或者所有索引单元都损坏,写入失败,则反馈索引信息写入失败。如此,在发现主扇区11损坏时,可以通过对应的备选扇区12存储数据。
在一个实施例中,写入数据后,需要对数据进行读写校验从而判断数据写入是否成功,当数据写入成功时判断对应的用户单元或索引单元未损坏,反之则损坏,上述数据包括用户信息和索引信息。进一步地,本实施例中,每一个主扇区11用于存储一个用户对应的用户信息,因此,当用户数量为n时,需要的扇区数量不小于4n,可以根据实际需求进行设置和调整,在此不作具体限定。
需要说明的是,本发明实施例中为每一个主扇区11设置至少3个备选扇区12,根据Flash存储器发生故障率为“单次故障/10万次读写”计算,则四重扇区同时发生故障的概率可以等同为0。本发明实施例提供的存储器1支持读写校验、快速寻址以及多重容错,有利于提高数据存储以及提取的准确性,增强存储器1的可靠性,且有利于保证基于存储的数据的业务系统(如门锁系统)的功能正常运行。
图3是本发明实施例提供的一种数据存储方法的流程示意图,上述数据存储方 法应用于上述存储器,具体的,上述存储器包括至少一个主扇区以及多个备选扇区,其中,每个上述主扇区对应有多个上述备选扇区作为备用,每个上述备选扇区分别作为一个上述主扇区的备用,各上述备选扇区用于在发现对应的上述主扇区损坏时存储数据;各上述主扇区和各上述备选扇区分别包括用户单元和索引单元,上述用户单元用于存储用户信息,上述索引单元用于存储所有用户信息对应的用户单元地址。如图3所示,上述方法包括如下步骤:
步骤S100,获取至少一个用户信息。
在一个实施例中,上述用户信息包括用户基础信息、注册特征以及困难补录特征。其中,上述用户基础信息包括用户姓名(和/或用户ID)、用户年龄、用户性别等信息。上述注册特征是用户进行身份注册时的面部特征信息,上述困难补录特征是用户多次识别未成功后补录并识别成功的特征信息。需要说明的是,上述数据存储方法可应用于门锁系统中的存储器,门锁系统根据存储器中存储的用户信息判断是否为用户开门。
具体地,门锁系统在进行人脸识别开锁之前,用户需要先录入信息,例如通过捕获目标用户的人脸图像并基于人脸图像获得该目标用户的人脸特征信息进行存储,这个过程称为用户注册,获得的人脸特征信息即为上述注册特征(例如,可以包括人脸关键点、深度信息、人脸红外特征等)。进一步地,门锁系统是实时采集获得用户的注册特征的,因此可能存在采集获得的部分注册特征并不十分准确,在对用户进行识别时,无法成功识别某些注册特征,此时则需要进一步补录获得困难补录特征,即上述困难补录特征是用户已存在注册特征但多次识别失败后补录获得的特征。
例如,在一种应用场景中,用户已经进行特征注册,但根据注册特征无法成功识别用户人脸,在捕获人脸多次后门锁仍未识别出人脸,则将下次门锁识别成功的特征进行信息录入。优选地,进行用户注册的流程可以包括先对采集的人脸图像进行初始化处理(包括对人脸尺寸、人脸角度以及光照等进行标准化),进而提取初始化后的人脸图像特征,将其作为用户的注册特征并保存。 进一步地,若用户未经多次已注册成功但识别失败,则用户信息中不需要添加困难补录特征或困难补录特征对应的数据位应当全部为0;若用户经过多次已注册成功但识别失败,则用户信息中需要添加困难补录特征或困难补录特征对应的数据位可根据捕获的特征进行设置,此处不作限制。即只有在当前用户的人脸已经多次注册成功且识别不成功时,才补录获取对应的困难补录特征。
步骤S200,将各上述用户信息分别写入不同的主扇区的用户单元中并判断上述用户信息是否写入成功。
在一个实施例中,一个主扇区用于存储一个用户对应的用户信息,因此需要将不同用户的用户信息分别写入不同的主扇区的用户单元中。具体地,可以对写入主扇区的用户单元中的用户信息进行回读,并与获得的用户信息进行比较,判断用户信息的写入是否成功。
步骤S300,将各目标用户信息写入各目标备选扇区的用户单元中并判断各上述目标用户信息是否写入成功,其中,上述目标备选扇区是与目标主扇区对应的备选扇区,上述目标主扇区是与上述目标用户信息对应的主扇区,上述目标用户信息是未成功写入主扇区的用户单元中的用户信息。
如果存在未成功写入主扇区的用户单元中的用户信息(即目标用户信息),则需要将目标用户信息写入与其对应的目标主扇区对应的目标备选扇区中。具体地,如果不存在目标用户信息,则说明所有的用户信息都成功写入各主扇区的用户单元中,无需重新写入用户信息。而某个主扇区的用户单元损坏,导致用户信息无法写入时,该用户信息会被写入对应的备选扇区。
由上可见,本发明方案中在存储器中设置至少一个主扇区以及多个备选扇区,且每个主扇区对应有多个备选扇区作为备用,在数据存储时进行校验判断是否写入成功,在发现主扇区损坏时将数据存储到对应的备选扇区,与现有技术中直接通过一个存储器进行数据存储的方案相比,有利于提高数据存储的准确性,提高数据存储的可靠性。
在一个实施例中,上述步骤S200更具体地包括如图4所示的步骤:
步骤S201,分别获取各上述用户信息的第一校验码。
步骤S202,将各上述用户信息分别写入不同的主扇区的用户单元中,回读并获取各上述用户单元中存储的已写入信息的第二检验码。
步骤S203,基于上述第一校验码和上述第二检验码判断上述已写入信息与上述用户信息是否一致,当上述已写入信息与上述用户信息一致时上述用户信息写入成功,反之上述用户信息写入不成功。
在一个实施例中,上述第一校验码和上述第二校验码为循环冗余校验(CRC,Cyclic Redundancy Check)码。具体地,分别获取每一条用户信息生成的数据串,通过预先设定一个多项式(多项式的通式可以表示为
Figure PCTCN2021129834-appb-000001
其中,C i等于0或1,j为最高次幂),获取多项式的最高次幂及系数,根据多项式的最高次幂对各用户信息生成的数据串末端进行补零。例如,在一种应用场景中,若预设的多项式的最高次幂为3,某一用户信息生成的数据串为1101001,则在末端补充零,获得用于计算第一校验码的数据串为1101001000。进一步的,假设预设的多项式为i阶,根据CRC原理,将用于生成第一校验码的数据串(本实施例中为1101001000)作为被除数,i阶多项式系数作为除数,将两者进行除运算,获取第一校验码,第一校验码位长为i。
进一步地,除运算可通过数据串与多项式系数的异或运算实现,假设多项式为x 3+x+1,则多项式系数为1011,用于计算第一校验码的数据串为1101001000,则两者的除运算得到的第一校验码为100,将第一校验码赋予数据串末端,生成待写入用户信息,即1101001000100。需要说明的是,本实施例中使用CRC32进行第一校验码生成,可提高数据纠错效率,但具体的CRC多项式设计可以根据需要保护的待写入的用户信息的总长度、所需的错误保护功能、实现CRC的处理器能力等实际情况进行设置和调整,在此不作具体限定。
需要说明的是,以判断一个用户信息是否写入成功为例进行说明,实际使用过程中,如果存在多个用户信息,则可分别对每个用户信息基于本实施例中的说明进行判断。
在一个实施例中,一个主扇区的用户单元仅用于保存一个用户对应的一个用户信息,将一个用户信息写入一个主扇区的用户单元中之后,回读该用户单元中存储的已写入信息,并根据读取的已写入信息计算获取第二校验码;其中,上述已写入信息为写入用户单元中并存储的用户信息。对于多个用户信息,遍历所有用户的用户信息,将其分别写入不同的主扇区的用户单元,并分别计算多个第二校验码。
应当理解的是,在写入用户信息时如果将第一校验码也写入时,获取并用于计算获得第二校验码的已写入信息不包括上述第一校验码。本实施例中,上述第二校验码的计算方式与上述第一校验码的计算方式相同,在此不再赘述;使用的校验码及其计算方式还可以根据实际需求进行设置和调整,在此不作具体限定。
进一步地,分别获取每个用户信息对应的第一校验码和第二校验码之后,对于每个用户信息的第一校验码和第二校验码进行逐元素比较,并判断两者是否一致。获取判断结果,若两者一致,则说明已写入信息与待写入的用户信息一致,该用户信息写入成功,反之则该用户信息写入不成功,可判断为主扇区的用户单元损坏,需要寻址到对应的备选扇区写入该用户信息。在另一种应用场景中,如果用于计算获得第二校验码的已写入信息包括上述第一校验码,则当第二校验码为0时说明用户信息写入成功。
在一个实施例中,上述步骤S300更具体地包括如图5所示的步骤:
步骤S301,对于每一个上述目标用户信息,获取与上述目标用户信息对应的目标主扇区以及与上述目标主扇区对应的多个目标备选扇区。
步骤S302,将上述目标用户信息依次写入上述多个目标备选扇区的用户单元中并判断上述目标用户信息是否写入成功,直到上述目标用户信息成功写入一个上述目标备选扇区的用户单元中,或者所有上述目标备选扇区的用户单元中都未能成功写入上述用户信息。
其中,上述目标用户信息是未成功写入主扇区的用户单元中的用户信息,目标用户信息对应的目标主扇区的用户单元已经损坏,因此需要将目标用户信息写入目 标主扇区对应的目标备选扇区中。
将上述目标用户信息先写入第一个(可以是任意一个,也可以是存储地址最靠近主扇区的一个)备选扇区的用户单元中,并判断目标用户信息是否写入成功。具体的判断方式与写入主扇区的用户单元时计算第一校验码和第二检验码进行判断的方式相同,在此不再赘述。如果写入第一个备选扇区的用户单元时用户信息写入成功,则不需要再写入下一个备选扇区的用户单元,否则,写入下一个(可以是任意另外一个,也可以是存储地址最靠近上一个备选扇区的一个)备选扇区的用户单元中,并同样判断是否写入成功。如此循环,直到目标用户信息成功写入一个备选扇区的用户单元中;或者所有的备选扇区的用户单元都损坏,目标用户信息无法正常写入,此时则反馈该目标用户信息写入失败。在一种应用场景中,如果还存在空闲的主扇区,则可以为该目标用户信息再分配一个空闲的主扇区进行写入。
具体地,本实施例中,如图6所示,在上述步骤S300之后,上述数据存储方法还包括:
步骤S400,获取写入成功的用户信息对应的用户单元地址数据串,其中,上述写入成功的用户信息包括所有成功写入主扇区的用户单元中的用户信息以及所有成功写入目标备选扇区的用户单元中的目标用户信息。
步骤S500,将上述用户单元地址数据串写入主扇区的索引单元或备选扇区的索引单元。
在一个实施例中,对于所有写入成功的用户信息,需存储其对应的索引信息,以便根据索引信息快速查找获取各用户对应的用户信息,其中,上述索引信息可以包括写入成功的用户信息对应的用户单元的地址,在一种应用场景中,上述索引信息还可以包括各用户信息对应的用户ID,在另一种应用场景中,也可以在对应的索引单元中预先存储各用户ID,并将用户单元地址数据串与对应的用户ID进行关联存储,在此不作具体限定。
需要说明的是,获取所有写入成功的用户信息对应的用户单元地址数据串,存入一个索引单元(可以是一个主扇区的索引单元,也可以是一个备选扇区的索引单元)中,可实现快速索引获取各用户信息;在本实施例中,优选以偏移地址的形式表示用户信息的存储位置,即某用户单元地址是该用户单元相对于存储器中第一个用户单元的地址(即存储器的首地址)的偏移量,此处不作限制。
在一个实施例中,上述步骤S500更具体地包括如图7所示的步骤:
步骤S501,将上述用户单元地址数据串写入一个目标索引主扇区的索引单元中并判断是否写入成功,其中,上述目标索引主扇区是上述存储器的任意一个主扇区。
步骤S502,当未写入成功时,将上述用户单元地址数据串写入与上述目标索引主扇区对应的备选扇区的索引单元中。
其中,上述目标索引主扇区是用于存储用户单元的索引信息(地址信息)的主扇区。具体地,通过一个索引单元存储所有用户信息对应的用户单元地址串,因此可以选择任意一个主扇区作为目标索引主扇区,在一种应用场景中,也可以预先设置一个主扇区作为目标索引主扇区,在此不作具体限定。
在一个实施例中,将上述用户单元地址数据串(或包含用户单元数据串和用户ID的索引信息)写入目标索引主扇区的索引单元中,并判断是否写入成功。其中,判断是否写入成功的具体方式与判断用户信息是否写入成功的方式相似,具体的包括:计算待写入用户单元地址数据串的第三校验码以及写入目标主扇区的索引单元后获得的已写入用户单元地址数据串(不包括加在末尾并写入的第三校验码)的第四校验码,根据第三校验码和第四校验码判断待写入用户单元地址数据串和已写入用户单元地址数据串是否一致,一致则判断写入成功,不一致则判断未写入成功。其中,上述第三校验码和第四校验码可以根据实际需求进行设置和调整,本实施例中采用CRC码,具体计算和比较方式与上述写入用户信息时使用的具体方式相同,在此不再赘述。
进一步地,在一个实施例中,可逐元素判断上述第三校验码和第四校验码 是否一致,两者一致则说明上述用户单元地址数据串写入成功,反之则未写入成功。当未写入成功时,说明该目标索引主扇区的索引单元损坏,则寻址到该目标索引主扇区对应的备选扇区的索引单元,将上述用户单元地址数据串写入并重新进行判断。具体地,一个主扇区可以对应多个备选扇区(本实施例中为3个),则可将上述用户单元地址数据串依次写入上述目标索引主扇区对应的多个备选扇区的索引单元中,并判断是否写入成功,如此循环,直到上述用户单元地址数据串成功写入一个备选扇区的索引单元中;或者所有备选扇区的索引单元都损坏,无法存储上述用户单元地址数据串,此时反馈用户单元地址数据串写入失败。
在一种应用场景中,当一个目标索引主扇区及其对应的所有备选扇区的索引单元都损坏时,可以获取下一个目标索引主扇区(可以是任意另一个主扇区,也可以是存储地址最靠近前一个目标索引主扇区的下一个主扇区),并再次写入用户单元地址数据串且判断是否写入成功,如此循环,直到写入成功;或者所有主扇区的索引单元和所有备选扇区的索引单元都损坏,无法存储上述用户单元地址数据串,此时则反馈所有索引单元损坏,提示用户更换存储器。在另一种应用场景中,如果用于计算获得第四校验码的已写入用户单元地址数据串包括上述第三校验码,则当第四校验码为0时说明用户单元地址数据串写入成功。
需要说明的是,因为索引单元存储的是所有用户信息对应的用户单元的地址(或偏移地址),即所有用户对应的用户单元在存储器中的地址,因此,需要在所有用户对应的用户信息成功写入对应的用户单元之后,才可以获得对应的用户单元数据串并写入一索引单元中。另,上述存储器的主扇区和备选扇区中还可以包括其它用于存储信息的单元,例如用于存储参数信息的参数单元,将上述参数信息存入上述参数单元的具体方法可以参照写入用户信息和索引信息的具体方法,在此不再赘述。
本实施例中,还基于一种具体应用场景对上述数据存储方法进行说明,图8是本发明实施例提供的一种数据存储方法的具体流程示意图,图9是本发明实 施例提供的一个主扇区及其备选扇区的示意图。
图8中以存储一条用户信息及为例进行说明,本实施例中,获取用户信息,初始化k为0,其中k是在获取备选扇区时用于计数的参数。计算用户信息的第一校验码(CRC32校验码),将该校验码放在用户信息末尾后获得待写入用户信息数据串并写入一个主扇区的用户单元中,具体地,将校验码也一并写入可以在回读时直接获得第一校验码,进行快速校验。回读已写入用户信息(不包括末尾的校验码)并计算获得第二校验码(CRC32校验码),判断写入的用户信息第一校验码与已写入用户信息对应的第二校验码是否相同,如果相同则说明用户信息写入成功,反之则本次写入不成功(主扇区的用户单元损坏)。
进一步地,在本次写入不成功时,判断k是否大于或等于3(本实施例中一个主扇区对应3个备选扇区),当k小于3时,令k=k+1,获取与该主扇区对应的第k个备选扇区,将待写入用户信息数据串写入第k个备选扇区的用户单元中,并重新回读判断是否写入成功。写入不成功时再次获得下一个备选扇区,直到用户信息写入成功或者3个备选扇区的用户单元都损坏,该用户信息写入失败。当用户信息写入成功时,需要将该用户信息对应的用户单元地址写入一个索引单元中。具体地,获取用户单元地址数据串(包括所有写入成功的用户信息对应的用户单元地址),并初始化m=0,其中m是在获取备选扇区时用于计数的参数。如图8所示,写入用户单元地址数据串并判断是否写入成功的具体流程与写用户信息时的流程相似,在此不再赘述。
图9中示出了各个扇区在存储器上的位置,用户ID为用户对应的ID编号,索引单元偏移地址是相对于主扇区A的第一个索引单元的位置偏移量,用户单元偏移地址是相对主扇区A的第一个用户单元的位置偏移量,单位为KB,且本实施例中,所有扇区的用户单元在存储器的位置上是连续的,所有扇区的索引单元在存储器的位置上是连续的。
如图9所示,在一个实施例中,一个主扇区仅包括一个用户单元,用于存储一个用户对应的用户ID和用户信息。优选地,不同的用户拥有不用的用户 ID,将不同用户的用户信息写入不同主扇区的用户单元,即等效于不同的主扇区拥有不同的用户ID。
进一步地,在一个实施例中,可以根据用户ID确定主扇区,并获取对应主扇区中用户单元偏移地址ADD1,具体地,ADD1=(ID-1)*4,单位为KB,其中,4KB是用户单元所占主扇区的大小,上述用户单元偏移地址是用户ID对应的用户单元相对第一个主扇区的用户单元的偏移地址。例如,若第一个用户的用户ID为1,对应的主扇区用户单元的偏移地址为0,第二个用户的用户ID为2,则对应的主扇区用户单元的偏移地址为4KB,以此类推,依次赋予每个用户相应的用户ID,即可获得其主扇区对应的用户单元偏移地址。
更具体地,如果主扇区的用户单元损坏,则需要将用户信息存储到备选扇区的用户单元,用户ID在备选扇区中用户单元的偏移地址为[(ID-1)+(128*N)]*4,单位为KB,其中,N代表第N个备选扇区。当用户信息写入完成后需要写入对应的索引信息,优选地,一个索引单元可以保存全部用户对应用户单元的偏移地址,且可根据用户ID计算获得索引单元偏移地址(即索引单元的位置)ADD2=ID-1,单位为KB,即用户ID为1时,对应主扇区中索引单元的偏移地址为0KB,用户ID为2时,对应索引单元偏移地址为1KB,依次类推,可获取全部用户对应的ID与索引单元的偏移地址关系。当需要将索引信息写入备选扇区的索引单元中时,用户ID在备选扇区中索引单元的偏移地址为[(ID-1)+N*4],单位为KB,其中N表示第N个备选扇区。
需要说明的是,本实施例中优选设置至少3个备选扇区,按FLASH存储器发生故障率为“单次故障/10万次读写”计算,则四重扇区同时发生故障概可等同为零。如果在所有备选扇区中回读获取的信息都校验失败,说明需要更换存储器或当前用户信息损坏,需要重新写入。
本发明实施例中,还提供一种门锁系统2,图10是本发明实施例提供的一种门锁系统结构示意图,如图10所示,上述门锁系统2包括:
用户信息模块21,用于获取用户信息并将上述用户信息发送至存储器22 进行存储;
存储器22,用于存储数据,其中,上述存储器22包括至少一个主扇区221以及多个备选扇区222,每个上述主扇区221对应有多个上述备选扇区222作为备用,每个上述备选扇区222分别作为一个上述主扇区221的备用,各上述备选扇区222用于在发现对应的上述主扇区221损坏时存储数据,各上述主扇区221和各上述备选扇区222分别包括用户单元和索引单元,上述用户单元用于存储用户信息,上述索引单元用于存储各用户对应的用户单元地址,上述存储器22基于本实施例中任意一种数据存储方法进行数据存储。
需要说明的是,上述门锁系统2还可以包括用于实现其具体所需的功能的其它模块,例如信息比较模块、控制开锁模块等,可以根据其实际需要的功能进行设置和调整,在此不作具体限定。
如图11所示,在一个实施例中,上述用户信息模块21包括:图像采集单元211,用于采集目标对象的人脸图像;处理单元212,用于基于上述人脸图像获取各目标对象的用户信息,并将各上述用户信息发送至上述存储器22进行存储。
具体地,上述目标对象是需要使用门锁系统的用户,上述人脸图像可以包括用户的深度图像和红外图像。在用户进行信息录入时,对人脸图像进行识别,获取用户信息并存储到存储器22中,其中,上述用户信息可以包括用户基础信息、注册特征以及困难补录特征。上述用户基础信息包括用户姓名(和/或用户ID)、用户年龄、用户性别等信息。上述注册特征是用户进行身份注册时的面部特征信息(例如人脸关键点、深度信息、人脸红外特征信息等),上述困难补录特征是用户多次识别未成功后补录并识别成功的特征信息。
需要说明的是,上述门锁系统2中存储器22的具体结构及其具体数据存储方法可以参照上文的叙述,在此不再赘述。
由上可见,本发明方案中在门锁系统2的存储器22中设置至少一个主扇区221以及多个备选扇区222,且每个主扇区221对应有多个备选扇区222作为备用,在发现主扇区221损坏时将数据存储到对应的备选扇区222,与现有技术 中直接通过一个存储器进行数据存储的方案相比,有利于提高数据存储的准确性,提高数据存储的可靠性。且在提高数据存储可靠性、提高门锁系统2的使用体验的同时,无需在存储器22上建立FATFS、JFFS2、YAFFS、EXT4等文件系统,无需额外的内存占用。
应理解,上述实施例中各步骤的序号大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本发明实施例的实施过程构成任何限定。
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将上述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。实施例中的各功能单元、模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中,上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。另外,各功能单元、模块的具体名称也只是为了便于相互区分,并不用于限制本发明的保护范围。上述系统中单元、模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述或记载的部分,可以参见其它实施例的相关描述。
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各实例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟是以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同法来实现所描述的功能,但是这种实现不应认为超出本发明的范围。
在本发明所提供的实施例中,应该理解到,所揭露的装置/终端设备和方法,可以通过其它的方式实现。例如,以上所描述的装置/终端设备实施例仅仅是示意 性的,例如,上述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以由另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。
上述集成的模块/单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读存储介质中。基于这样的理解,本发明实现上述实施例方法中的全部或部分流程,也可以通过计算机程序来指令相关的硬件来完成,上述计算机程序可存储于一计算机可读存储介质中,该计算机程序在被处理器执行时,可实现上述各个方法实施例的步骤。其中,上述计算机程序包括计算机程序代码,上述计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。上述计算机可读介质可以包括:能够携带上述计算机程序代码的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、计算机存储器、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、电载波信号、电信信号以及软件分发介质等。需要说明的是,上述计算机可读存储介质包含的内容可以根据司法管辖区内立法和专利实践的要求进行适当的增减。
以上所述实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解;其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不是相应技术方案的本质脱离本发明各实施例技术方案的精神和范围,均应包含在本发明的保护范围之内。

Claims (10)

  1. 一种存储器,其特征在于,所述存储器包括:
    至少一个主扇区以及多个备选扇区,其中,每个所述主扇区对应有多个所述备选扇区作为备用,每个所述备选扇区分别作为一个所述主扇区的备用,各所述备选扇区用于在发现对应的所述主扇区损坏时存储数据。
  2. 根据权利要求1所述的存储器,其特征在于,各所述主扇区和各所述备选扇区分别包括用户单元和索引单元,所述用户单元用于存储用户信息,所述索引单元用于存储所有用户信息对应的用户单元地址。
  3. 根据权利要求2所述的存储器,其特征在于,所述存储器包括多个主扇区且每个所述主扇区对应有至少3个备选扇区作为备用。
  4. 一种数据存储方法,其特征在于,所述方法应用于如权利要求2或3所述的存储器,所述方法包括:
    获取至少一个用户信息;
    将各所述用户信息分别写入不同的主扇区的用户单元中并判断所述用户信息是否写入成功;
    将各目标用户信息写入各目标备选扇区的用户单元中并判断各所述目标用户信息是否写入成功,其中,所述目标备选扇区是与目标主扇区对应的备选扇区,所述目标主扇区是与所述目标用户信息对应的主扇区,所述目标用户信息是未成功写入主扇区的用户单元中的用户信息。
  5. 根据权利要求4所述的数据存储方法,其特征在于,所述将各所述用户信息分别写入不同的主扇区的用户单元中并判断所述用户信息是否写入成功,包括:
    分别获取各所述用户信息的第一校验码;
    将各所述用户信息分别写入不同的主扇区的用户单元中,回读并获取各所述用户单元中存储的已写入信息的第二检验码;
    基于所述第一校验码和所述第二检验码判断所述已写入信息与所述用户信息是否一致,当所述已写入信息与所述用户信息一致时所述用户信息写入成功,反之所述用户信息写入不成功。
  6. 根据权利要求5所述的数据存储方法,其特征在于,所述将各目标用户信息写入与各目标备选扇区的用户单元中并判断各所述目标用户信息是否写入成功,其中,所述目标备选扇区是与目标主扇区对应的备选扇区,所述目标主扇区是与所述目标用户信息对应的主扇区,所述目标用户信息是未成功写入主扇区的用户单元中的用户信息,包括:
    对于每一个所述目标用户信息,获取与所述目标用户信息对应的目标主扇区以及与所述目标主扇区对应的多个目标备选扇区;
    将所述目标用户信息依次写入所述多个目标备选扇区的用户单元中并判断所述目标用户信息是否写入成功,直到所述目标用户信息成功写入一个所述目标备选扇区的用户单元中,或者所有所述目标备选扇区的用户单元中都未能成功写入所述用户信息。
  7. 根据权利要求4所述的数据存储方法,其特征在于,在所述将各目标用户信息写入各目标备选扇区的用户单元中并判断各所述目标用户信息是否写入成功之后,所述方法还包括:
    获取写入成功的用户信息对应的用户单元地址数据串,其中,所述写入成功的用户信息包括所有成功写入主扇区的用户单元中的用户信息以及所有成功写入目标备选扇区的用户单元中的目标用户信息;
    将所述用户单元地址数据串写入主扇区的索引单元或备选扇区的索引单元。
  8. 根据权利要求7所述的数据存储方法,其特征在于,所述将所述用户单元地址数据串写入主扇区的索引单元或备选扇区的索引单元,包括:
    将所述用户单元地址数据串写入一个目标索引主扇区的索引单元中并判断是否写入成功,其中,所述目标索引主扇区是所述存储器的任意一个主扇区;
    当未写入成功时,将所述用户单元地址数据串写入与所述目标索引主扇区对应的备选扇区的索引单元中。
  9. 一种门锁系统,其特征在于,所述门锁系统包括:
    用户信息模块,用于获取用户信息并将所述用户信息发送至存储器进行存储;
    存储器,用于存储数据,其中,所述存储器包括至少一个主扇区以及多个备选扇区,每个所述主扇区对应有多个所述备选扇区作为备用,每个所述备选扇区分别作为一个所述主扇区的备用,各所述备选扇区用于在发现对应的所述主扇区损坏时存储数据,各所述主扇区和各所述备选扇区分别包括用户单元和索引单元,所述用户单元用于存储用户信息,所述索引单元用于存储各用户对应的用户单元地址,所述存储器基于如权利要求4-8任意一项的数据存储方法进行数据存储。
  10. 根据权利要求9所述的门锁系统,其特征在于,所述用户信息模块包括:
    图像采集单元,用于采集目标对象的人脸图像;
    处理单元,用于基于所述人脸图像获取各目标对象的用户信息,并将各所述用户信息发送至所述存储器进行存储。
PCT/CN2021/129834 2021-07-21 2021-11-10 一种存储器、数据存储方法以及门锁系统 WO2023000552A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110826779.2A CN113704028B (zh) 2021-07-21 2021-07-21 一种存储器、数据存储方法以及门锁系统
CN202110826779.2 2021-07-21

Publications (1)

Publication Number Publication Date
WO2023000552A1 true WO2023000552A1 (zh) 2023-01-26

Family

ID=78650260

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/129834 WO2023000552A1 (zh) 2021-07-21 2021-11-10 一种存储器、数据存储方法以及门锁系统

Country Status (2)

Country Link
CN (1) CN113704028B (zh)
WO (1) WO2023000552A1 (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080263429A1 (en) * 2005-12-09 2008-10-23 Jong-Sik Jeong Method and Device for Correcting Code Data Error
US20190042103A1 (en) * 2017-08-02 2019-02-07 Kove Ip, Llc Resilient external memory
CN109521960A (zh) * 2018-11-02 2019-03-26 格力电器(合肥)有限公司 数据读写方法、装置和系统
CN112596672A (zh) * 2020-12-18 2021-04-02 珠海格力电器股份有限公司 主控芯片的存储处理方法及装置、处理器和电子设备

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8489833B2 (en) * 2010-08-20 2013-07-16 Transcend Information, Inc. Data backup method for flash memory module and solid state drive
CN109947369A (zh) * 2019-03-22 2019-06-28 河南卓正电子科技有限公司 数据存储方法及装置
CN110187999B (zh) * 2019-05-09 2021-04-27 新华三技术有限公司 地址映射数据备份方法及装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080263429A1 (en) * 2005-12-09 2008-10-23 Jong-Sik Jeong Method and Device for Correcting Code Data Error
US20190042103A1 (en) * 2017-08-02 2019-02-07 Kove Ip, Llc Resilient external memory
CN109521960A (zh) * 2018-11-02 2019-03-26 格力电器(合肥)有限公司 数据读写方法、装置和系统
CN112596672A (zh) * 2020-12-18 2021-04-02 珠海格力电器股份有限公司 主控芯片的存储处理方法及装置、处理器和电子设备

Also Published As

Publication number Publication date
CN113704028B (zh) 2023-02-28
CN113704028A (zh) 2021-11-26

Similar Documents

Publication Publication Date Title
KR101103885B1 (ko) 데이터 확인을 위한 방법, 장치, 시스템 및 컴퓨터 판독가능한 기록 매체
US8448018B2 (en) Stripe-based memory operation
US10922234B2 (en) Method and system for online recovery of logical-to-physical mapping table affected by noise sources in a solid state drive
US7395496B2 (en) Systems and methods for enhanced stored data verification utilizing pageable pool memory
US7237141B2 (en) Method for recovering data from a redundant storage object
CN102937922B (zh) 查询和修复数据
US9727244B2 (en) Expanding effective storage capacity of a data storage system while providing support for address mapping recovery
US9727411B2 (en) Method and processor for writing and error tracking in a log subsystem of a file system
US11874741B2 (en) Data recovery method in storage medium, data recovery system, and related device
WO2017143843A1 (zh) 元数据修复方法及装置
CN115544377A (zh) 基于云端存储的档案的热度评估和更新方法
US20090125753A1 (en) Handling of data storage within a flash media device
CN114155906A (zh) 一种数据块修复方法、装置、设备及存储介质
US7577804B2 (en) Detecting data integrity
WO2023000552A1 (zh) 一种存储器、数据存储方法以及门锁系统
WO2021027271A1 (zh) 坏块信息保护方法、装置、计算机设备及存储介质
CN113724774B (zh) 解码方法、存储器存储装置及存储器控制电路单元
CN116048876A (zh) 数据存储方法、数据检测方法、装置及可读取存储介质
US9934093B2 (en) Control device, method of controlling a storage device, and storage system
US9262264B2 (en) Error correction code seeding
US11269746B1 (en) Recovery of page description blocks based on context
CN116301654A (zh) 数据迁移方法、装置、电子设备及存储介质
US10613973B1 (en) Garbage collection in solid state drives
CN117312184A (zh) 数据存储方法、装置及电子设备
WO2019090657A1 (zh) 一种存储器容错保护方法、装置、设备及存储介质

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: 21950790

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: 21950790

Country of ref document: EP

Kind code of ref document: A1