CN112231244A - SIM card file erasing and writing system and method applied to SoftSIM and readable storage medium - Google Patents

SIM card file erasing and writing system and method applied to SoftSIM and readable storage medium Download PDF

Info

Publication number
CN112231244A
CN112231244A CN202011513212.1A CN202011513212A CN112231244A CN 112231244 A CN112231244 A CN 112231244A CN 202011513212 A CN202011513212 A CN 202011513212A CN 112231244 A CN112231244 A CN 112231244A
Authority
CN
China
Prior art keywords
data
erasing times
written
storage
erasing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202011513212.1A
Other languages
Chinese (zh)
Other versions
CN112231244B (en
Inventor
金辉
李路昌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Jieruilian Technology Co ltd
Original Assignee
Shenzhen Jieruilian Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Jieruilian Technology Co ltd filed Critical Shenzhen Jieruilian Technology Co ltd
Priority to CN202011513212.1A priority Critical patent/CN112231244B/en
Publication of CN112231244A publication Critical patent/CN112231244A/en
Application granted granted Critical
Publication of CN112231244B publication Critical patent/CN112231244B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0866Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches for peripheral storage systems, e.g. disk cache
    • G06F12/0873Mapping of cache memory to specific storage devices or parts thereof
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W8/00Network data management
    • H04W8/18Processing of user or subscriber data, e.g. subscribed services, user preferences or user profiles; Transfer of user or subscriber data
    • H04W8/183Processing at user equipment or user record carrier

Abstract

A SIM card file erasing system, method and computer readable storage medium applied to SoftSIM, the system comprises a data management layer, a storage management layer and an application logic layer; the application logic layer exchanges the storage positions of cold data and hot data when the communication module chip is powered on, avoids the situation that the erasing frequency of the hot data storage area is far greater than that of the cold data storage area in the long-term erasing process, so that the loss is too fast, realizes the erasing balance of each storage area, and simultaneously caches the data to be written into the logic page of the memory space when the SIM card file needs to be updated; when the page change condition is met, the storage management layer writes the data to be written in the logical page into the logical address space formed by the data management layer, and then the data to be written is written into the FLASH memory of the communication module chip by the data management layer, so that the erasing times of the FLASH memory are reduced. By realizing erase-write balance and reducing the erase-write times, the service life of the FLASH memory is effectively prolonged.

Description

SIM card file erasing and writing system and method applied to SoftSIM and readable storage medium
Technical Field
The invention relates to the technical field of communication, in particular to a system and a method for erasing and writing a SIM card file applied to a SoftSIM and a readable storage medium.
Background
Today the number of IoT (Internet of Things) devices is growing exponentially, these devices that need to establish interconnection cannot bypass the support of the cellular network, and the use of the cellular network must rely on a SIM (Subscriber Identity Module) card. In the face of such explosive growth, more and more manufacturers are beginning to focus on the development of SIM cards. Suffering from sensitive price benefits, SIM card manufacturers are gradually starting to lay out on soft SIMs, i.e. softsims.
The SoftSIM is an SIM function realized by relying on an operating system in a pure software mode, and an actual physical chip is not needed, namely an SIM card exists. The technical implementation of the traditional entity SIM card is transplanted to the existing external communication module chip side, and the communication module can complete network authentication under the condition of no card by depending on the technical implementation and a small amount of modification of the module chip, so that the aim of using a cellular network to carry out network data interaction is fulfilled.
The FLASH memory of the communication module chip is generally NAND-FLASH, and the capacity of the FLASH memory is generally less than 4 MB. The data of various power failure protections needs to be stored, and the SIM card file content of the SoftSIM is also included. Because of the limited erasing life, if the erasing is performed too frequently, the service life is inevitably greatly reduced. Because of this, softsims also create many unexpected drawbacks behind the ever-exploding demand. Mainly, the FLASH memory of the communication module chip is generally used for storing some solidified configuration data, and the number of times that the FLASH memory may need to be modified in the whole life cycle is very limited, so that the FLASH memory can support the communication module to work for a long time without problems. Meanwhile, SIM card files for realizing the SoftSIM are also required to be stored in a FLASH memory of a communication module chip, the updating frequency of some SIM card files is very high, and the SIM card files can be updated dozens of times or even more in one day, so that the FLASH memory with the erasing life of only 10 ten thousand times can be quickly consumed, the communication module equipment is directly unusable and scrapped in advance, and the benefit of equipment manufacturers is seriously damaged.
Disclosure of Invention
The application provides an SIM card file erasing system, an SIM card file erasing method and a readable storage medium applied to a SoftSIM, and aims to reduce the direct erasing times of a FLASH memory of a communication module chip and realize erasing balance so as to prolong the service life of the FLASH memory.
According to a first aspect, an embodiment provides a SIM card file erasing system applied to SoftSIM, the SIM card file being stored in a FLASH memory of a communication module chip, the system comprising:
the data management layer is used for mapping the physical address of the FLASH memory into a logical address to form a logical address space, providing a data management layer interface comprising the logical address, and writing the data to be written in the logical address space into the FLASH memory;
the storage management layer is used for providing a storage management layer interface comprising a logical page address, wherein the logical page is positioned in a memory of the communication module chip, and is used for calling the data management layer interface to acquire the logical address of the SIM card file to be updated when a page change condition is met, and writing the data to be written cached in the logical page into a logical address space;
and the application logic layer is used for exchanging the storage positions of cold data and hot data when the communication module chip is powered on, calling the storage management layer interface to acquire the logic page address of the SIM card file to be updated when the SIM card file needs to be updated, and caching the data to be written into the logic page indicated by the logic page address.
In one embodiment, the application logic layer exchanges storage locations for cold data and hot data by:
sorting the storage blocks in the FLASH memory according to the erasing times, taking the maximum erasing times and the minimum erasing times, comparing the erasing times of the maximum erasing times and the minimum erasing times, and executing the following steps when the difference between the erasing times of the maximum erasing times and the erasing times of the minimum erasing times is not less than a first threshold value:
and exchanging data stored by the maximum erasing times and the minimum erasing times, taking the maximum erasing times and the minimum erasing times in the un-compared storage blocks, comparing the erasing times of the maximum erasing times and the minimum erasing times, and repeatedly executing the step when the difference between the erasing times of the maximum erasing times and the erasing times of the minimum erasing times is not less than a first threshold until the difference between the erasing times of the maximum erasing times and the erasing times of the minimum erasing times is less than the first threshold.
In one embodiment, the page-change condition indicates that the logical page space has been cached to full or that a page-change request is issued by the application logical layer.
In one embodiment, the data management layer writes the data to be written in the logical address space into the FLASH memory by:
acquiring the name of a storage block to be written, which is indicated by the data to be written;
searching whether a storage block with the same name as the storage block to be written exists in a FLASH memory, writing the data to be written into a storage block in an idle state when the storage block with the same name as the storage block to be written exists, and marking the storage block with the same name as the storage block to be written into the idle state; and when the storage block with the same name as the storage block to be written does not exist, directly writing the data to be written into a storage block in an idle state.
In one embodiment, the SIM card file erasing and writing system further includes a storage interface layer, where the storage interface layer is used to implement uniform conversion and encapsulation on the data management layer interface to form a storage interface, and the storage management layer calls the data management layer interface by calling the storage interface.
According to a second aspect, an embodiment provides a SIM card file erasing method based on the SIM card file erasing system of the first aspect, where the SIM card file is stored in a FLASH memory of a communication module chip, and the method includes:
when the communication module chip is powered on, exchanging the storage positions of cold data and hot data in the FLASH memory;
when the data in the SIM card file needs to be updated, the following steps are executed:
calling a storage management layer interface to obtain a logical page address of an SIM card file to be updated, and caching data to be written into a logical page indicated by the logical page address, wherein the logical page is positioned in a memory of a communication module chip;
and judging whether the logical page meets a page change condition, calling the data management layer interface to acquire the logical address of the SIM card file to be updated when the page change condition is met, writing the data to be written cached in the logical page into a logical address space, and then writing the data to be written in the logical address space into a FLASH memory.
In one embodiment, the exchanging storage locations of cold data and hot data in FLASH memory comprises:
sorting the storage blocks in the FLASH memory according to the erasing times, taking the maximum erasing times and the minimum erasing times, comparing the erasing times of the maximum erasing times and the minimum erasing times, and executing the following steps when the difference between the erasing times of the maximum erasing times and the erasing times of the minimum erasing times is not less than a first threshold value:
and exchanging data stored by the maximum erasing times and the minimum erasing times, taking the maximum erasing times and the minimum erasing times in the un-compared storage blocks, comparing the erasing times of the maximum erasing times and the minimum erasing times, and repeatedly executing the step when the difference between the erasing times of the maximum erasing times and the erasing times of the minimum erasing times is not less than a first threshold until the difference between the erasing times of the maximum erasing times and the erasing times of the minimum erasing times is less than the first threshold.
In one embodiment, the page-change condition indicates that the logical page space has been cached to full or that a page-change request is issued by the application logical layer.
In one embodiment, the writing the data to be written in the logical address space into the FLASH memory includes:
acquiring the name of a storage block to be written, which is indicated by the data to be written;
searching whether a storage block with the same name as the storage block to be written exists in a FLASH memory, writing the data to be written into a storage block in an idle state when the storage block with the same name as the storage block to be written exists, and marking the storage block with the same name as the storage block to be written into the idle state; and when the storage block with the same name as the storage block to be written does not exist, directly writing the data to be written into a storage block in an idle state.
According to a third aspect, an embodiment provides a computer-readable storage medium comprising a program executable by a processor to implement the SIM card file erasing method according to the second aspect.
According to the SIM card file erasing system, the SIM card file erasing method and the computer readable storage medium applied to the SoftSIM, the storage positions of cold data and hot data are exchanged during each power-on, the phenomenon that the erasing frequency of a storage area of the hot data is far greater than that of the storage area of the cold data so that the loss is too fast in a long-term erasing process is avoided, the erasing balance of each storage area is realized, meanwhile, when a file is updated, data to be written is cached in a logic page of a memory space, and then the data to be written is written into a FLASH memory after page changing conditions are met, so that the erasing frequency of the FLASH memory is reduced. By realizing erase-write balance and reducing the erase-write times, the service life of the FLASH memory is effectively prolonged.
Drawings
FIG. 1 is a schematic diagram of a SIM card file erasing system in the prior art;
FIG. 2 is a schematic flow chart illustrating a prior art SIM card file erasure method based on the SIM card file erasure system of FIG. 1;
FIG. 3 is a schematic diagram of an embodiment of a SIM card file erasing system;
FIG. 4 is a schematic diagram illustrating the partitioning of memory blocks in the FLASH memory according to an embodiment;
FIG. 5 is a diagram illustrating the structure of a memory block in the FLASH memory according to an embodiment;
FIG. 6 is a schematic diagram showing the division of the memory blocks in the FLASH memory according to another embodiment;
FIG. 7 is a schematic diagram of another embodiment of a SIM card file erasing system;
FIG. 8 is a flowchart illustrating a method for erasing/writing a SIM card file according to an embodiment;
FIG. 9 is a schematic flow chart illustrating an embodiment of exchanging storage locations for cold data and hot data;
FIG. 10 is a schematic flow chart of equalization erase/write in one embodiment;
FIG. 11 is a flowchart illustrating a method for erasing/writing a SIM card file according to another embodiment.
Detailed Description
The present invention will be described in further detail with reference to the following detailed description and accompanying drawings. Wherein like elements in different embodiments are numbered with like associated elements. In the following description, numerous details are set forth in order to provide a better understanding of the present application. However, those skilled in the art will readily recognize that some of the features may be omitted or replaced with other elements, materials, methods in different instances. In some instances, certain operations related to the present application have not been shown or described in detail in order to avoid obscuring the core of the present application from excessive description, and it is not necessary for those skilled in the art to describe these operations in detail, so that they may be fully understood from the description in the specification and the general knowledge in the art.
Furthermore, the features, operations, or characteristics described in the specification may be combined in any suitable manner to form various embodiments. Also, the various steps or actions in the method descriptions may be transposed or transposed in order, as will be apparent to one of ordinary skill in the art. Thus, the various sequences in the specification and drawings are for the purpose of describing certain embodiments only and are not intended to imply a required sequence unless otherwise indicated where such sequence must be followed.
The numbering of the components as such, e.g., "first", "second", etc., is used herein only to distinguish the objects as described, and does not have any sequential or technical meaning. The term "connected" and "coupled" when used in this application, unless otherwise indicated, includes both direct and indirect connections (couplings).
When the core logic of the SoftSIM is implemented, the most important is the management of the SIM card file, which has some significant characteristics: the number of files is particularly large, the size of the files is usually small (within 1KB, even tens of bytes), and the frequency of some files being updated is very high. It is because of these particularities that storing SIM card files in the SoftSIM solution poses a significant challenge. Prior to describing the present invention, a brief description of the prior art will be provided.
Referring to fig. 1, as shown in fig. 1, a system architecture for erasing and writing a SIM card file of a SoftSIM in the prior art includes an application logic layer and a storage management layer, a FLASH memory is located in a physical layer, and the physical layer provides a hardware driver for erasing and writing the FLASH memory for a SIM card file erasing and writing system.
Referring to fig. 2, as shown in fig. 2, the flow of the SIM card file erasing method based on the SIM card file erasing system architecture includes: when the system starts to work, firstly, initializing, including the initialization of FLASH memory hardware and the initialization of SoftSIM application logic; waiting for an SIM card file processing instruction, and calling a storage management layer interface to acquire a physical address of an SIM card file to be updated when an SIM card file updating instruction is received; and the storage management layer calls a hardware driver of the physical layer to directly erase and write the FLASH memory according to the physical address, and writes the data to be written into the FLASH memory to complete the updating of the SIM card file.
Obviously, in the prior art, when the SIM card file is updated, the physical address of the FLASH memory is directly operated, and the FLASH memory is directly erased and written when data needs to be written each time, so that the erasing times of the FLASH memory are greatly increased, and the service life of the FLASH memory is reduced. Meanwhile, erasing and writing of cold data (data which are hardly updated or have very low updating frequency) and hot data (data which are frequently updated) are not distinguished, balanced erasing and writing of different storage areas of the FLASH memory are not considered, so that the erasing and writing frequency of the storage area for storing the hot data is very high, the loss is very large, the erasing and writing frequency of the storage area for storing the cold data is very low, and according to the wooden barrel principle, the service life of the whole FLASH memory depends on the service life of the storage area for storing the hot data, so that the service life of the FLASH memory is shortened.
Aiming at the defects of the prior art, the applicant reconstructs the framework of the SIM card file erasing and writing system and optimizes the SIM card file erasing and writing method correspondingly, and provides the SIM card file erasing and writing system and method applied to the SoftSIM. The following describes the SIM card file erasing system and method applied to the SoftSIM of the present application, respectively.
Referring to fig. 3, in an embodiment of the present application, a SIM card file erasing system applied to SoftSIM includes a data management layer 1, a storage management layer 2, and an application logic layer 3, a FLASH memory is located in a physical layer 4, and the physical layer 4 provides a hardware driver for erasing the FLASH memory for the SIM card file erasing system, which is described in detail below.
The Data Management layer 1 is located above the physical layer 4, and is also called NVDM (Non-volatile Data Management) layer, and is used for mapping physical addresses of the FLASH memory into logical addresses to form a logical address space, providing a Data Management layer interface including the logical addresses, and writing Data to be written in the logical address space into the FLASH memory. The data management layer 1 maps the physical address of the FLASH memory into a logical address, so that the operating interface provided for the upper layer can not directly expose the FLASH physical address, the purpose of hiding the FLASH physical address is achieved, and the transparent FLASH physical address is ensured when the upper layer calls the interface of the data management layer 1. When data needs to be written into the FLASH memory, the data management layer 1 calls a hardware drive of the physical layer, and the data to be written, which is written into the logic address space by the upper layer, is written into the FLASH memory according to the physical address of the data.
In some embodiments, the data management layer 1 uses a balance erasing strategy when writing the data to be written into the FLASH memory, and the balance erasing strategy of the data management layer 1 is described below. As shown in fig. 4, assuming that a continuous 40KB space in the FLASH memory is fixedly partitioned for the SoftSIM, in the implementation process, the 40KB space is equally partitioned into N equally-located memory blocks, and the size M of each memory block is assumed to be 4KB, so that the size of N is N = 40KB/M = 10. In each memory block, please refer to fig. 5, the memory block includes header information and core data, and the header information is used to identify information such as the erasing times, the free time, the size of the core data content, and the name of the memory block. When the upper layer needs to perform erasing operation, a data management layer interface is called, and the name of the storage block to be written, which is indicated by the data to be written, is transmitted through the data management layer interface; after receiving the name of the storage block to be written, the data management layer 1 traverses all the storage blocks in the FLASH memory by taking the name of the storage block to be written as a main key, and searches whether the storage block with the same name as the storage block to be written exists in the FLASH memory; when a storage block with the same name as the storage block to be written exists, the data to be written is considered as old data, the index number of the storage block is recorded, an unoccupied storage block, namely the storage block in the idle state, is applied again, the data to be written is written into the storage block in the idle state, and then the storage block with the same name as the storage block to be written is marked as the idle state according to the recorded index number so as to be reused next time; when the storage block with the same name as the storage block to be written does not exist, the data to be written is considered to be new data, only an unoccupied storage block, namely the storage block in the idle state, needs to be applied again, and the data to be written is directly written into the storage block in the idle state.
The balanced erasing strategy adopted by the data management layer 1 applies for a new storage area to write when the data to be written is written into the FLASH memory each time, so that the erasing operation can be performed on each FLASH storage area equally, frequent erasing of a certain storage area is avoided, the space utilization rate of the FLASH memory is improved, and the risk of over-fast loss caused by frequent erasing of a single FLASH storage area is effectively reduced.
The storage Management layer 2 is located above the data Management layer 1, and is also called an NVMM (Non-volatile Memory Management) layer, and is configured to provide a storage Management layer interface including a logical page address, where the logical page is located in a Memory of the communication module chip, and to call the data Management layer interface to obtain a logical address of a SIM card file to be updated when a page swap condition is satisfied, and write data to be written cached in the logical page into a logical address space provided by the data Management layer 1. The storage management layer 2 will specify the storage structure and logical location of all SIM card files, i.e. determine which file is stored at what logical address. For the upper layer, the storage management layer 2 provides an interface for reading and writing files for the upper layer, namely a storage management layer interface; for the lower layer, the storage management layer 2 calls a data management layer interface to write the data to be written into the logical address of the SIM card file to be updated. The storage management layer 2 adopts a logical page caching strategy when writing data to be written, namely when the upper layer needs to write data, the management storage layer interface is called first to transmit the data to be written to the storage management layer 2, the storage management layer 2 does not write the data to be written into the lower layer immediately, but caches the data to be written into a logical page space, the logical page space is located in a memory of the communication module chip, and when the logical page space meets a page change condition, the data management layer interface is really called to write the data to be written downwards. When two situations occur, that is, the logical page space is considered to satisfy the page-change condition, one situation is that the logical page space is already cached fully, and the other situation is that although the logical page space is not cached fully, the application logical layer 3 needs to be updated by page-change, that is, the application logical layer 3 sends a page-change request, at this time, the content of the logical page which is not cached fully currently needs to be written downwards, and a new round of logical page caching is started at the same time. By adopting the logic page caching strategy, as the logic page is positioned in the memory, the reading and writing speed is higher, so that the efficiency of the upper layer calling the storage management layer interface to read and write the SIM card file is improved, and meanwhile, the times of directly erasing and writing the FLASH memory are effectively reduced, thereby prolonging the service life of the FLASH memory. The storage management layer interface provided by the storage management layer 2 will include the logical page address of the SIM card file so that the upper layer knows where the data to be written should be written.
The application logic layer 3 is located above the storage management layer 2 and is used for exchanging storage positions of cold data and hot data when the communication module chip is powered on, calling a storage management layer interface to acquire a logic page address of the SIM card file to be updated when the SIM card file needs to be updated, and caching data to be written into a logic page indicated by the logic page address. The SoftSIM application implements management of SIM card files at this layer. The exchange strategy of cold data and hot data is explained below.
Referring to fig. 6, assuming that there are N memory blocks in the FLASH memory, where N is a positive integer greater than 1, the memory blocks are sorted by erasing times, where memory block 1 is the memory block with the smallest erasing times, memory block N is the memory block with the largest erasing times, the erasing times of memory block N and memory block 1 are compared, when the difference between the erasing times of memory block N and memory block 1 is not less than a first threshold, such as not less than 100, the data stored in memory block N and memory block 1 are exchanged, and in the memory blocks not compared, the data stored in memory block (N-1) and memory block 2 with the smallest erasing times are selected for comparison, i.e. the erasing times of memory block (N-1) and memory block 2 are compared, and when the difference between the erasing times of memory block (N-1) and memory block 2 is not less than the first threshold, the data stored in memory block (N-1) and memory block 2 are exchanged, and continuously comparing the erasing times of the storage block (N-2) and the storage block 3, and so on until the difference between the erasing times of the storage block with the maximum erasing times and the erasing times of the storage block with the minimum erasing times is smaller than a first threshold value in the storage blocks which are not compared.
By exchanging the storage positions of the cold data and the hot data during each power-on process, the phenomenon that the erasing times of the hot data storage area are far greater than the erasing times of the cold data storage area in the long-term erasing process, so that the loss is too fast is avoided, the erasing balance of each storage area is realized, and the service life of the FLASH memory is prolonged.
Referring to fig. 7, as shown in fig. 7, in an embodiment of the SIM card file erasing system, the Memory interface layer 5 is further included, and the Memory interface layer 5 is also called an NVM (Non-volatile Memory) layer, which is located above the data management layer 1 and below the Memory management layer 2. The storage interface layer 5 does not specifically process and schedule data, but is used for implementing unified conversion and encapsulation of the data management layer interface to form a storage interface, and the storage management layer 2 calls the storage interface to further call the data management layer interface. By setting the storage interface layer 5, abstract adaptation of interfaces of data management layers with different implementation modes can be facilitated, upper-layer software and bottom-layer hardware are further separated, portability or adaptability of an SIM card file erasing system is enhanced, and the SIM card file erasing system can be conveniently used on different FLASH memories.
Referring to fig. 8, in an embodiment, the method includes steps S100 to S500, which are described in detail below.
Step S100: and when the communication module chip is powered on, the storage positions of cold data and hot data in the FLASH memory are exchanged. This step is implemented in an application logic layer, and referring to fig. 9, exchanging storage locations of cold data and hot data in a FLASH memory specifically includes:
step S101: and sequencing the storage blocks in the FLASH memory according to the erasing times. As shown in fig. 6, it is assumed that there are N memory blocks in the FLASH memory, and after sorting, the memory block 1 is the memory block with the smallest erase count, and the memory block N is the memory block with the largest erase count.
Step S102: and (4) comparing the erasing times of the maximum erasing times and the minimum erasing times, executing the step (S103) when the difference between the erasing times of the maximum erasing times and the erasing times of the minimum erasing times is not less than a first threshold, and otherwise, finishing exchanging the storage positions of the cold data and the hot data. As in fig. 6, the erase counts of the memory block N and the memory block 1 are compared, when the difference between the erase counts of the memory block N and the memory block 1 is not less than the first threshold, such as not less than 100, step S103 is executed, otherwise, the exchange of the storage locations of the cold data and the hot data is finished.
Step S103: and exchanging the data stored by the one with the maximum erasing times and the one with the minimum erasing times. If this step is performed after step S102 is performed, the data stored in the memory block N and the memory block 1 are exchanged.
Step S104: and in the un-compared storage blocks, taking the maximum erasing times and the minimum erasing times, comparing the erasing times of the maximum erasing times and the minimum erasing times, executing the step S103 when the difference between the erasing times of the maximum erasing times and the erasing times of the minimum erasing times is not less than a first threshold, and otherwise, finishing exchanging the storage positions of the cold data and the hot data. As in fig. 6, the erase count of the memory block (N-1) and the memory block 2 are compared, and when the difference between the erase count of the memory block (N-1) and the erase count of the memory block 2 is not less than the first threshold value, the data stored in the memory block (N-1) and the memory block 2 are exchanged, otherwise the exchange of the storage locations of the cold data and the hot data is ended.
In the step, the storage positions of the cold data and the hot data are exchanged during each power-on, so that the phenomenon that the erasing times of the storage area of the hot data are far greater than the erasing times of the storage area of the cold data in the long-term erasing process, so that the loss is too fast is avoided, the erasing balance of each storage area is realized, and the service life of the FLASH memory is prolonged.
Step S200: and waiting for the SIM card file updating command, and executing step S300 when the data in the SIM card file needs to be updated.
Step S300: and calling a storage management layer interface to obtain a logical page address of the SIM card file to be updated, and caching data to be written into a logical page indicated by the logical page address, wherein the logical page is positioned in a memory of the communication module chip. When data needs to be written, the storage management layer interface is called firstly and comprises a logical page address, so that the data to be written is not directly written into the FLASH memory but is cached into the logical page firstly, and the reading and writing speed of the logical page is higher because the logical page is positioned in the memory, thereby improving the efficiency of reading and writing the SIM card file by calling the storage management layer interface by the upper layer, simultaneously effectively reducing the times of directly erasing and writing the FLASH memory, and further prolonging the service life of the FLASH memory.
Step S400: and judging whether the logical page meets the page change condition, and executing the step S500 when the page change condition is met, or executing the step S200. When two situations occur, that is, the logical page space is considered to satisfy the page-change condition, one situation is that the logical page space is already cached fully, and the other situation is that although the logical page space is not cached fully, the application logical layer 3 needs to be updated by page-change, that is, the application logical layer 3 sends a page-change request, at this time, the content of the logical page which is not cached fully currently needs to be written downwards, and a new round of logical page caching is started at the same time.
Step S500: calling a data management layer interface to acquire a logical address of the SIM card file to be updated, writing the data to be written cached in the logical page into a logical address space provided by the data management layer 1, then writing the data to be written in the logical address space into the FLASH memory, and returning to the step S200. In some embodiments, the writing of the data to be written in the logical address space into the FLASH memory employs a balance erasure policy, and referring to fig. 10, the balance erasure policy specifically includes:
step S501: and acquiring the name of the storage block to be written indicated by the data to be written.
As shown in fig. 4, assuming that a continuous 40KB space in the FLASH memory is fixedly partitioned for the SoftSIM, in the implementation process, the 40KB space is equally partitioned into N equally-located memory blocks, and the size M of each memory block is assumed to be 4KB, so that the size of N is N = 40KB/M = 10. In each memory block, please refer to fig. 5, the memory block includes header information and core data, and the header information is used to identify information such as the erasing times, the free time, the size of the core data content, and the name of the memory block. When erasing operation is needed, the data management layer interface is called, and the name of the storage block to be written, which is indicated by the data to be written, is transmitted through the data management layer interface.
Step S502: and traversing all the storage blocks in the FLASH memory by taking the name of the storage block to be written as a main key, searching whether the storage block with the same name as the storage block to be written exists in the FLASH memory, executing the step S503 when the storage block with the same name as the storage block to be written exists, and otherwise executing the step S505.
Step S503: at this time, a storage block with the same name as the storage block to be written exists in the FLASH memory, so that the data to be written is considered to be old data, the index number of the storage block is recorded, then an unoccupied storage block, namely the storage block in the idle state, is applied again, and the data to be written is written into the storage block in the idle state.
Step S504: and according to the recorded index number, marking the storage block with the same name as the storage block to be written into an idle state so as to be reused next time.
Step S505: at this time, the FLASH memory does not have a storage block with the same name as the storage block to be written, so that the data to be written is considered to be new data, and only an unoccupied storage block, namely the storage block in the idle state, is applied for, and the data to be written is directly written into the storage block in the idle state.
By adopting a balanced erasing strategy, when the data to be written is written into the FLASH memory each time, a new storage area is applied for writing, so that erasing operation can be performed on each FLASH storage area equally, frequent erasing of a certain storage area is avoided, the space utilization rate of the FLASH memory is improved, and the risk of over-fast loss caused by frequent erasing of a single FLASH storage area is effectively reduced.
Referring to fig. 7, in some embodiments, the SIM card file erasing and writing system further includes a storage interface layer 5, and the storage interface layer 5 implements unified conversion and encapsulation of the data management layer interface to form a storage interface, and correspondingly, referring to fig. 11, the SIM card file erasing and writing method further includes step S600: and calling the storage interface to further call the data management layer interface.
The present application is described below by way of two specific examples.
Taking the Mediatek MT2625 NB Modem Chip IC as an example, before use, the implementation code of the SoftSIM is first compiled, wherein the implementation code includes the SIM card file erasing and writing system and method applied to the SoftSIM of the present application, and a storage space used by the SoftSIM is configured according to a space of a FLASH memory of the Mediatek MT2625 NB Modem Chip IC, and is integrated and compiled into a firmware of the module. After the module is powered on, the SoftSIM starts to work, the storage positions of cold data and hot data in the FLASH memory are exchanged, and then the SoftSIM enters a command waiting state until relevant commands are input, and the next operation is not carried out. When an instruction is received and the SIM card file needs to be updated, calling a storage management layer interface to obtain a logical page address of the SIM card file to be updated, and caching data to be written into a logical page indicated by the logical page address, wherein the logical page is positioned in a memory of a communication module chip. When the page changing condition is met, calling a data management layer interface to write the data to be written cached in the logical page into a logical address space provided by the data management layer 1, and then writing the data to be written in the logical address space into the FLASH memory. The data to be written can be written into the FLASH memory by adopting a balanced erasing strategy, and a new storage area is applied for writing every time the data to be written is written into the FLASH memory, so that a certain storage area is prevented from being erased frequently. After the data to be written is written into the FLASH memory, the SoftSIM continues to enter a waiting instruction state, waits for the next instruction and then carries out processing.
Taking the BG95 remote module carrying the Qualcomm MDM9205 chip as an example, before use, the implementation code of the SoftSIM is written first, wherein the implementation code comprises the SIM card file erasing and writing system and the method applied to the SoftSIM of the application, the storage space used by the SoftSIM is configured according to the space of the FLASH memory of the Qualcomm MDM9205 chip, and the storage space is compiled into the firmware of the BG95 remote module in an integrated manner. BG95 is powered on and then SoftSIM starts to work, firstly, the storage positions of cold data and hot data in FLASH memory are exchanged, then SoftSIM enters a waiting instruction state, and the next operation is not carried out until relevant instructions are input. When an instruction is received and the SIM card file needs to be updated, calling a storage management layer interface to obtain a logical page address of the SIM card file to be updated, and caching data to be written into a logical page indicated by the logical page address, wherein the logical page is positioned in a memory of a communication module chip. When the page changing condition is met, calling a data management layer interface to write the data to be written cached in the logical page into a logical address space provided by the data management layer 1, and then writing the data to be written in the logical address space into the FLASH memory. The data to be written can be written into the FLASH memory by adopting a balanced erasing strategy, and a new storage area is applied for writing every time the data to be written is written into the FLASH memory, so that a certain storage area is prevented from being erased frequently. After the data to be written is written into the FLASH memory, the SoftSIM continues to enter a waiting instruction state, waits for the next instruction and then carries out processing.
The SIM card file erasing system and the method applied to the SoftSIM exchange the storage positions of cold data and hot data when being electrified every time, avoid the problem that the erasing times of the storage area of the hot data are far greater than the erasing times of the storage area of the cold data in the long-term erasing process, so that the loss is too fast, realize the erasing balance of each storage area, simultaneously cache the data to be written into a logic page of a memory space when updating the file, write the data to be written into a FLASH memory after meeting the page changing condition, and reduce the erasing times of the FLASH memory. The data to be written can be written into the FLASH memory by adopting a balanced erasing strategy. The direct erasing times of the FLASH memory are reduced through cold and hot data exchange, logic page caching and balanced erasing strategies, balanced erasing is realized, and the service life of the FLASH memory is effectively prolonged.
Reference is made herein to various exemplary embodiments. However, those skilled in the art will recognize that changes and modifications may be made to the exemplary embodiments without departing from the scope hereof. For example, the various operational steps, as well as the components used to perform the operational steps, may be implemented in differing ways depending upon the particular application or consideration of any number of cost functions associated with operation of the system (e.g., one or more steps may be deleted, modified or incorporated into other steps).
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. Additionally, as will be appreciated by one skilled in the art, the principles herein may be reflected in a computer program product on a computer readable storage medium, which is pre-loaded with computer readable program code. Any tangible, non-transitory computer-readable storage medium may be used, including magnetic storage devices (hard disks, floppy disks, etc.), optical storage devices (CD-to-ROM, DVD, Blu-Ray discs, etc.), flash memory, and/or the like. These computer program instructions may be loaded onto a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions which execute on the computer or other programmable data processing apparatus create means for implementing the functions specified. These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including means for implementing the function specified. The computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified.
While the principles herein have been illustrated in various embodiments, many modifications of structure, arrangement, proportions, elements, materials, and components particularly adapted to specific environments and operative requirements may be employed without departing from the principles and scope of the present disclosure. The above modifications and other changes or modifications are intended to be included within the scope of this document.
The foregoing detailed description has been described with reference to various embodiments. However, one skilled in the art will recognize that various modifications and changes may be made without departing from the scope of the present disclosure. Accordingly, the disclosure is to be considered in an illustrative and not a restrictive sense, and all such modifications are intended to be included within the scope thereof. Also, advantages, other advantages, and solutions to problems have been described above with regard to various embodiments. However, the benefits, advantages, solutions to problems, and any element(s) that may cause any element(s) to occur or become more pronounced are not to be construed as a critical, required, or essential feature or element of any or all the claims. As used herein, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, system, article, or apparatus. Furthermore, the term "coupled," and any other variation thereof, as used herein, refers to a physical connection, an electrical connection, a magnetic connection, an optical connection, a communicative connection, a functional connection, and/or any other connection.
Those skilled in the art will recognize that many changes may be made to the details of the above-described embodiments without departing from the underlying principles of the invention. Accordingly, the scope of the invention should be determined only by the claims.

Claims (10)

1. A SIM card file erasing system applied to SoftSIM, the SIM card file being stored in a FLASH memory of a communication module chip, the system comprising:
the data management layer is used for mapping the physical address of the FLASH memory into a logical address to form a logical address space, providing a data management layer interface comprising the logical address, and writing the data to be written in the logical address space into the FLASH memory;
the storage management layer is used for providing a storage management layer interface comprising a logical page address, wherein the logical page is positioned in a memory of the communication module chip, and is used for calling the data management layer interface to acquire the logical address of the SIM card file to be updated when a page change condition is met, and writing the data to be written cached in the logical page into a logical address space;
and the application logic layer is used for exchanging the storage positions of cold data and hot data when the communication module chip is powered on, calling the storage management layer interface to acquire the logic page address of the SIM card file to be updated when the SIM card file needs to be updated, and caching the data to be written into the logic page indicated by the logic page address.
2. The SIM card file erasure system of claim 1, wherein the application logic layer exchanges storage locations of cold data and hot data by:
sorting the storage blocks in the FLASH memory according to the erasing times, taking the maximum erasing times and the minimum erasing times, comparing the erasing times of the maximum erasing times and the minimum erasing times, and executing the following steps when the difference between the erasing times of the maximum erasing times and the erasing times of the minimum erasing times is not less than a first threshold value:
and exchanging data stored by the maximum erasing times and the minimum erasing times, taking the maximum erasing times and the minimum erasing times in the un-compared storage blocks, comparing the erasing times of the maximum erasing times and the minimum erasing times, and repeatedly executing the step when the difference between the erasing times of the maximum erasing times and the erasing times of the minimum erasing times is not less than a first threshold until the difference between the erasing times of the maximum erasing times and the erasing times of the minimum erasing times is less than the first threshold.
3. The SIM card file erasure system of claim 1, wherein the paging condition indicates that a logical page space has been cached to full or that a paging request is issued by an application logical layer.
4. The SIM card file erasure system of claim 1, wherein the data management layer writes data to be written in the logical address space into the FLASH memory by:
acquiring the name of a storage block to be written, which is indicated by the data to be written;
searching whether a storage block with the same name as the storage block to be written exists in a FLASH memory, writing the data to be written into a storage block in an idle state when the storage block with the same name as the storage block to be written exists, and marking the storage block with the same name as the storage block to be written into the idle state; and when the storage block with the same name as the storage block to be written does not exist, directly writing the data to be written into a storage block in an idle state.
5. The SIM card file erasure system of claim 1, further comprising a storage interface layer for implementing a unified transformation and encapsulation of the data management layer interface to form a storage interface, the storage management layer invoking the data management layer interface by invoking the storage interface.
6. A SIM card file erasing method based on the SIM card file erasing system of any one of claims 1 to 5, the SIM card file being stored in a FLASH memory of a communication module chip, the method comprising:
when the communication module chip is powered on, exchanging the storage positions of cold data and hot data in the FLASH memory;
when the data in the SIM card file needs to be updated, the following steps are executed:
calling a storage management layer interface to obtain a logical page address of an SIM card file to be updated, and caching data to be written into a logical page indicated by the logical page address, wherein the logical page is positioned in a memory of a communication module chip;
and judging whether the logical page meets a page change condition, calling the data management layer interface to acquire the logical address of the SIM card file to be updated when the page change condition is met, writing the data to be written cached in the logical page into a logical address space, and then writing the data to be written in the logical address space into a FLASH memory.
7. The method of claim 6 wherein said swapping storage locations of cold data and hot data in FLASH memory comprises:
sorting the storage blocks in the FLASH memory according to the erasing times, taking the maximum erasing times and the minimum erasing times, comparing the erasing times of the maximum erasing times and the minimum erasing times, and executing the following steps when the difference between the erasing times of the maximum erasing times and the erasing times of the minimum erasing times is not less than a first threshold value:
and exchanging data stored by the maximum erasing times and the minimum erasing times, taking the maximum erasing times and the minimum erasing times in the un-compared storage blocks, comparing the erasing times of the maximum erasing times and the minimum erasing times, and repeatedly executing the step when the difference between the erasing times of the maximum erasing times and the erasing times of the minimum erasing times is not less than a first threshold until the difference between the erasing times of the maximum erasing times and the erasing times of the minimum erasing times is less than the first threshold.
8. The method of claim 6, wherein the paging condition indicates that a logical page space has been cached to full or that a paging request is issued by an application logical layer.
9. The method of claim 6, wherein writing the data to be written in the logical address space into FLASH memory comprises:
acquiring the name of a storage block to be written, which is indicated by the data to be written;
searching whether a storage block with the same name as the storage block to be written exists in a FLASH memory, writing the data to be written into a storage block in an idle state when the storage block with the same name as the storage block to be written exists, and marking the storage block with the same name as the storage block to be written into the idle state; and when the storage block with the same name as the storage block to be written does not exist, directly writing the data to be written into a storage block in an idle state.
10. A computer-readable storage medium, characterized by comprising a program executable by a processor to implement the method of any one of claims 6 to 9.
CN202011513212.1A 2020-12-21 2020-12-21 SIM card file erasing and writing system and method applied to SoftSIM and readable storage medium Active CN112231244B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011513212.1A CN112231244B (en) 2020-12-21 2020-12-21 SIM card file erasing and writing system and method applied to SoftSIM and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011513212.1A CN112231244B (en) 2020-12-21 2020-12-21 SIM card file erasing and writing system and method applied to SoftSIM and readable storage medium

Publications (2)

Publication Number Publication Date
CN112231244A true CN112231244A (en) 2021-01-15
CN112231244B CN112231244B (en) 2021-04-20

Family

ID=74124924

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011513212.1A Active CN112231244B (en) 2020-12-21 2020-12-21 SIM card file erasing and writing system and method applied to SoftSIM and readable storage medium

Country Status (1)

Country Link
CN (1) CN112231244B (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113282521A (en) * 2021-05-19 2021-08-20 武汉天喻信息产业股份有限公司 Method and device for prolonging service life of smart card
CN113971091A (en) * 2021-10-25 2022-01-25 重庆大学 Persistent memory allocation method considering process difference
CN114237502A (en) * 2021-12-10 2022-03-25 武汉天喻信息产业股份有限公司 Method and device for prolonging FLASH write life of eSIM (embedded subscriber identity Module) smart card
CN114265562A (en) * 2021-12-27 2022-04-01 北京国腾创新科技有限公司 File storage method and system based on flash memory
CN114510198A (en) * 2022-02-16 2022-05-17 北京中电华大电子设计有限责任公司 Method for improving erasing and writing efficiency of NVM
CN115952113A (en) * 2023-03-15 2023-04-11 力高(山东)新能源技术股份有限公司 EEPROM storage protection method
CN113971091B (en) * 2021-10-25 2024-05-14 重庆大学 Method for distributing persistent memory in consideration of process difference

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101030166A (en) * 2006-03-03 2007-09-05 凌阳科技股份有限公司 Wear leveling method and apparatus for nonvolatile memory
CN101140586A (en) * 2007-09-30 2008-03-12 浙江大学 Method for building file systems on NAND flash memory in embedded system
CN101441599A (en) * 2008-11-28 2009-05-27 成都市华为赛门铁克科技有限公司 Solid hard disk and equilibrium method of the same
CN101526920A (en) * 2008-12-31 2009-09-09 北京飞天诚信科技有限公司 Method and device for writing data
CN102402698A (en) * 2010-09-08 2012-04-04 中兴通讯股份有限公司 Method and device for decreasing frequency of erasing and writing subscriber identity module files
CN103702449A (en) * 2012-09-27 2014-04-02 重庆重邮信科通信技术有限公司 Communication method of subscriber identity module (SIM) card and device
CN108848491A (en) * 2018-03-16 2018-11-20 深圳杰睿联科技有限公司 Virtual SIM card creates system

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101030166A (en) * 2006-03-03 2007-09-05 凌阳科技股份有限公司 Wear leveling method and apparatus for nonvolatile memory
CN101140586A (en) * 2007-09-30 2008-03-12 浙江大学 Method for building file systems on NAND flash memory in embedded system
CN101441599A (en) * 2008-11-28 2009-05-27 成都市华为赛门铁克科技有限公司 Solid hard disk and equilibrium method of the same
CN101526920A (en) * 2008-12-31 2009-09-09 北京飞天诚信科技有限公司 Method and device for writing data
CN102402698A (en) * 2010-09-08 2012-04-04 中兴通讯股份有限公司 Method and device for decreasing frequency of erasing and writing subscriber identity module files
CN103702449A (en) * 2012-09-27 2014-04-02 重庆重邮信科通信技术有限公司 Communication method of subscriber identity module (SIM) card and device
CN108848491A (en) * 2018-03-16 2018-11-20 深圳杰睿联科技有限公司 Virtual SIM card creates system

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113282521A (en) * 2021-05-19 2021-08-20 武汉天喻信息产业股份有限公司 Method and device for prolonging service life of smart card
CN113971091A (en) * 2021-10-25 2022-01-25 重庆大学 Persistent memory allocation method considering process difference
CN113971091B (en) * 2021-10-25 2024-05-14 重庆大学 Method for distributing persistent memory in consideration of process difference
CN114237502A (en) * 2021-12-10 2022-03-25 武汉天喻信息产业股份有限公司 Method and device for prolonging FLASH write life of eSIM (embedded subscriber identity Module) smart card
CN114265562A (en) * 2021-12-27 2022-04-01 北京国腾创新科技有限公司 File storage method and system based on flash memory
CN114510198A (en) * 2022-02-16 2022-05-17 北京中电华大电子设计有限责任公司 Method for improving erasing and writing efficiency of NVM
CN114510198B (en) * 2022-02-16 2023-06-30 北京中电华大电子设计有限责任公司 Method for improving erasing and writing efficiency of NVM (non-volatile memory)
CN115952113A (en) * 2023-03-15 2023-04-11 力高(山东)新能源技术股份有限公司 EEPROM storage protection method
CN115952113B (en) * 2023-03-15 2023-06-13 力高(山东)新能源技术股份有限公司 EEPROM storage protection method

Also Published As

Publication number Publication date
CN112231244B (en) 2021-04-20

Similar Documents

Publication Publication Date Title
CN112231244B (en) SIM card file erasing and writing system and method applied to SoftSIM and readable storage medium
CA2673434C (en) Memory device performance enhancement through pre-erase mechanism
US8250286B2 (en) Block management method, and storage system and controller using the same
US8386698B2 (en) Data accessing method for flash memory and storage system and controller using the same
US7882301B2 (en) Wear leveling in storage devices based on flash memories and related circuit, system, and method
US8180955B2 (en) Computing systems and methods for managing flash memory device
US8117374B2 (en) Flash memory control devices that support multiple memory mapping schemes and methods of operating same
KR100816761B1 (en) Memory card system including nand flash memory and sram/nor flash memory and data storage method thereof
US20070214309A1 (en) Nonvolatile storage device and data writing method thereof
CN101625897B (en) Data write-in method, storage system and controller used for quick flash memory
CN101556555B (en) Block managing method for flash memory as well as controller and storage system thereof
CN101727295A (en) Method for writing in and reading out data based on virtual block flash memory address mapping
KR100845552B1 (en) Method for address mapping in Flash Translation LayerFTL
US20090259796A1 (en) Data writing method for non-volatile memory and storage system and controller using the same
US20100180072A1 (en) Memory controller, nonvolatile memory device, file system, nonvolatile memory system, data writing method and data writing program
JP4829202B2 (en) Storage device and memory control method
CN106326132B (en) Storage system, storage management device, memory, hybrid storage device, and storage management method
CN113885808A (en) Mapping information recording method, memory control circuit unit and memory device
CN110312986B (en) Opportunistic use of streams for storing data on solid state devices
CN101739350B (en) Memory storage device and control method thereof
JP4308780B2 (en) Semiconductor memory device, memory controller, and data recording method
CN106021124B (en) A kind of storage method and storage system of data
KR100638638B1 (en) Method for controling flash memory device
CN112148203B (en) Memory management method, device, electronic equipment and storage medium
US20080109588A1 (en) Memory Card and Method of Driving the Same

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant