Abstract:
The invention relates to a data erasable method of memory in smart cards and smart cards thereof, which includes: when a CPU in the smart card determines a data erasable operation will be proceed in the specified memory of the smart card, cache the data to be written in a random memory cache of the specified memory; after sending a data erasable signal to the specified memory, control itself to enter a standby sleep mode. The data erasable signal is used to indicate the specified memory to process the data erasable operation by obtaining the data to be written from the random memory cache. Using the provided solution, the current of the machine card interface can be reduced when a data erasable is proceed in the specified memory of the smart card, thus abnormal conditions due to the high current of the machine card interface are avoided, and the power consumption is reduced at the same time, the standby time of the device which the smart card is in is improved.

Description:
[0001]    This application claims the benefit of Chinese Patent Application No. 201010286121.9, filed with the Chinese Patent Office on Sep. 17, 2010 and entitled “Method of Erasing and Writing Data from and to Memory in Smart Card and Smart Card”, which is hereby incorporated by reference in its entirety. 
       FIELD 
       [0002]    The present invention relates to the field of a smart card and particularly to a method of erasing and writing data from and to a memory in a smart card and a smart card. 
       BACKGROUND 
       [0003]    In recent years, a large-capacity smart card has been developed along with higher requirements on an operating speed, a capacity and an interface speed of a smart card as well as the use of the smart card to provide a user with a more variety of services. As compared with a normal smart card, the large-capacity smart card has its CPU (Central Processing Unit), RAM (Random Access Memory). EEPROM (Electrically Erasable Programmable Read-Only Memory), counter and secured processing device unchanged and also the roles and locations of its profile and pins unchanged except an extra large-capacity Flash memory in addition to the original smart card chip, e.g., a nonvolatile NAND flash memory or a nonvolatile NOR flash memory for storage of codes and data. 
         [0004]    The NOR flash memory and the NAND flash memory are two predominant types of nonvolatile flash memories at present. The NOR flash memory is characterized by XIP (eXecute In Place) where an application can be run directly in the flash memory without fetching codes into a system RAM. The NOR flash memory is efficient with transmission and has a very high cost benefit with a capacity of 1 to 4 MB but has its performance degraded by lower writing and erasing speeds. The NAND flash memory can offer an extremely high density of elements and reach a high storage density and also has high writing and erasing speeds but suffers from a drawback of its application arising from a special system interface required for management of the flash memory. 
         [0005]    Both the NOR flash memory and the NAND flash memory are characterized by their large capacities and thus currently have been widely used in large-capacity smart cards, generally in a digital electronic product, an SD card (Secure Digital Memory Card), an SIM (Subscriber Identity Module) card inside a mobile phone terminal, etc., to provide effectively these devices with a sufficient storage capacity available to various applications, data, files, etc. 
         [0006]    At present, a device-card interface between the smart card in use and the device where the smart card is located is at a voltage typically in support of three levels, 5V, 3V and 1.8V respectively, corresponding to three levels of voltage, and also carries limited current. Taking the SIM card in the mobile phone terminal as an example, the device-card interface of the mobile phone terminal to the SIM card carries current of no more than 15 mA, or 20 mA taking some redundancy into account, under a normal operating condition, and the mobile phone terminal may get abnormal with the current of the device-card interface going beyond the limit, for example, the mobile phone may be forced to be powered off so as to be protected against an abnormality attack. 
         [0007]    However for the large-capacity smart card, the current of the device-card interface may be larger than that of the normal smart card due to the characteristic of performing a data erasing and writing operation on the large-capacity memory therein, and results of a test in which 1-byte random numbers were written into the NAND flash memory in the smart card in an Update Binary instruction by way of example showed that the average spike current of the device-card interface reached 23 mA while erasing and writing the data from and to the NAND flash memory, the current of the device-card interface ranged from 6 mA to 10 mA while running another application instead of erasing and writing the data from and to the NAND flash memory, and the current of the device-card interface was approximately 2 mA while the smart card was idle. As can be apparent from the results of the test, the current of the device-card interface was beyond the normal current range while performing the data erasing and writing operation on the NAND flash memory so that the mobile phone terminal became abnormal, and such significant current also had more battery power of the mobile phone terminal consumed and hence a standby period of time of the mobile phone terminal shortened. 
       SUMMARY 
       [0008]    Embodiments of the invention provide a method of erasing and writing data from and to a memory in a smart card and a smart card so as to lower current of a device-card interface while erasing and writing data from and to a specified memory in a smart card and further avoid an abnormality occurring due to over-current of the device-card interface. 
         [0009]    An embodiment of the invention provides a method of erasing and writing data from and to a memory in a smart card, which includes: 
         [0010]    a Central Processing Unit, CPU, in the smart card, buffering data to be written into a random memory buffer of a specified memory in the smart card upon determining a data erasing and writing operation to be performed on the specified memory; and 
         [0011]    controlling itself to enter a standby and sleep mode after transmitting a data erasing and writing signal to the specified memory, wherein the data erasing and writing signal instructs the specified memory to perform the data erasing and writing operation by acquiring the data to be written from the random memory buffer. 
         [0012]    An embodiment of the invention further provides a smart card including a CPU and a memory, wherein: 
         [0013]    the CPU is configured to buffer data to be written into a random memory buffer of the memory upon determining a data erasing and writing operation to be performed on the memory; and to control itself to enter a standby and sleep mode after transmitting a data erasing and writing signal to the memory; and 
         [0014]    the memory is configured to perform the data erasing and writing operation by acquiring the data to be written from the random memory buffer upon reception of the data erasing and writing signal. 
         [0015]    In the method according to the embodiment of the invention, the CPU firstly buffers data to be written into the random memory buffer of the specified memory in the smart card upon determining the data erasing and writing operation to be performed on the specified memory and controls itself to enter a standby and sleep mode after transmitting a data erasing and writing signal to the specified memory, where the data erasing and writing signal instructs the specified memory to perform the data erasing and writing operation by acquiring the data to be written from the random memory buffer. Since the CPU has entered the standby and sleep mode, that is, has stopped its processing operation, while the specified memory performs the data erasing and writing operation, current of a device-card interface at this time includes only current generated for the specified memory to perform the data erasing and writing operation, and thus current generated for the CPU to perform a processing operation and also the current of the device-card interface can be lowered as compared with the prior art to thereby avoid an abnormality occurring due to over-current of the device-card interface and also lower power consumption due to the lowered current and hence improve a standby period of time of a device where the smart card is located. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0016]      FIG. 1  is a flow chart of a method of erasing and writing data from and to a memory in a smart card according to an embodiment of the invention; 
           [0017]      FIG. 2  is a flow chart of a method of erasing and writing data from and to a memory in a smart card according to a first embodiment of the invention; and 
           [0018]      FIG. 3  is a schematic structural diagram of a smart card according to a second embodiment of the invention. 
       
    
    
     DETAILED DESCRIPTION OF THE EMBODIMENTS 
       [0019]    In order to provide a solution to lowering current of a device-card interface while erasing and writing data from and to a specified memory in a smart card and further avoiding an abnormality occurring due to over-current of the device-card interface, embodiments of the invention provide a method of erasing and writing data from and to a memory in a smart card and a smart card, and preferred embodiments of the invention will be described below with reference to the drawings. It shall be appreciated that the preferred embodiments described below are merely intended to illustrate and explain but not to limit the invention. The embodiments of the invention and features in the embodiments can be combined with each other given no confliction. 
         [0020]    An embodiment of the invention provides a method of erasing and writing data from and to a memory in a smart card, as illustrated in  FIG. 1 , which includes: 
         [0021]    Step S 101 . A CPU in the smart card buffers data to be written into a random memory buffer of a specified memory in the smart card upon determining a data erasing and writing operation to be performed on the specified memory. 
         [0022]    Step S 102 . The CPU controls itself to enter a standby and sleep mode after transmitting a data erasing and writing signal to the specified memory, where the data erasing and writing signal instructs the specified memory to perform the data erasing and writing operation by acquiring the data to be written from the random memory buffer. 
         [0023]    The foregoing method may further include: 
         [0024]    The CPU controls itself to enter a normal operating mode from the standby and sleep mode after the specified memory performs the data erasing and writing operation. 
         [0025]    The method and apparatus according to the invention will be described below in details in particular embodiments thereof. 
       First Embodiment 
       [0026]    In the first embodiment of the invention, a flow of performing a data erasing and writing operation on a memory in an SIM card used in a mobile phone terminal will be described in details by way of example, and as illustrated in  FIG. 2 , the flow includes: 
         [0027]    Step S 201 . An SIM chip in the SIM card receives an instruction transmitted from the terminal where the SIM card is located via an I/O interface in the SIM card. 
         [0028]    Step S 202 . A CPU in the SIM chip performs a logic process on the received instruction according to a preset processing strategy to determine an operation instructed by the instruction. 
         [0029]    Step S 203 . The flow proceeds to the step S 204  when the instruction instructs a data erasing and writing operation to be performed on the memory in the SIM card; otherwise, the flow proceeds to the step S 213 . 
         [0030]    Step S 204 . It is determined whether the memory to be subjected to the data erasing and writing operation is an M-level large-capacity memory, and if so, then the flow proceeds to the step S 205 ; otherwise, the data erasing and writing operation is to be performed on a K-level nonvolatile NVM memory embedded in the SIM chip, and the flow goes to the step S 210 . 
         [0031]    In embodiments of the invention, for a large-capacity memory, an NAND flash memory or an NOR flash memory can be used and will be referred collectively as an N chip for the sake of a convenient description. 
         [0032]    Step S 205 , the CPU in the SIM chip acquires data to be written according to the received instruction and buffers the data to be written into a random memory buffer, RAM buffer, of the N chip so that when the CPU subsequently enters a standby and sleep mode, the N chip can acquire the data to be written from its own RAM buffer without the need of the CPU to control in real time transmission of the data to be written to the N chip. 
         [0033]    Step S 206 . The SIM chip transmits a data erasing and writing signal to the N chip and controls the CPU to enter the standby and sleep mode. 
         [0034]    The transmitted data erasing and writing signal may be transmitted as an interruption signal. 
         [0035]    Step S 207 . The N chip performs the data erasing and writing operation by acquiring the data to be written from its own RAM buffer upon reception of the data erasing and writing signal transmitted from the SIM chip, possibly particularly as follows: 
         [0036]    The N chip erases data stored in its own corresponding area, acquires the data to be written from its own RAM buffer and writes the data to be written into the corresponding area to thereby perform the data erasing and writing operation. 
         [0037]    The CPU is in the standby and sleep mode all the time throughout the process of the N chip to perform the data erasing and writing operation. 
         [0038]    Step S 208 . The N chip transmits a recovery signal to the SIM chip after performing the data erasing and writing operation, where the recovery signal instructs the CPU to enter a normal operating mode from the standby and sleep mode, and also the N chip stops operating. 
         [0039]    The transmitted recovery signal may be transmitted as an interruption signal. 
         [0040]    Step S 209 . The SIM chip controls the CPU to enter the normal operating mode from the standby and sleep mode upon reception of the recovery signal. 
         [0041]    Step S 210 . The CPU in the SIM chip sets a register (REG) related to the data erasing and writing operation on the K-level NVM memory to a write mode. 
         [0042]    Step S 211 . The CPU acquires the data to be written and writes the data to be written cyclically into a corresponding area of the K-level NVM memory in the SIM chip. 
         [0043]    Step S 212 . The CPU disables the write mode of the related register REG after the data writing operation is performed on the K-level NVM memory in the SIM chip. 
         [0044]    Step S 213 . The CPU in the SIM chip organizes data for a response and stores the data into the RAM buffer of the SIM chip according to a result of performing the operation instructed by the received instruction. 
         [0045]    Step S 214 . The SIM chip transmits the response to the instruction via the I/O interface to finish a response process to the instruction. 
         [0046]    In the method according to the foregoing first embodiment, all the operations performed by the SIM chip and the N chip can be performed by logic control performed with COS (Chip Operating System) software of the SIM chip. 
         [0047]    With the process flow according to the foregoing first embodiment, when the data erasing and writing operation is performed on the N chip, the CPU is in the standby and sleep mode in which no related processing operation is performed, so current generated at this time includes only current generated for N chip to perform the data erasing and writing operation, and thus the current of the device-card interface can be lowered as compared with the prior art to thereby avoid an abnormality occurring due to over-current of the device-card interface and also lower power consumption and hence improve a standby period of time of the mobile phone terminal where the SIM card is located. 
         [0048]    In the foregoing first embodiment, the smart card being an SIM card and the large-capacity memory being an NAND flash memory or an NOR flash memory have been taken as an example, and for other smart cards including large-capacity memories, a data erasing and writing operation can be performed on the large-capacity memories in a similar processing way as in the first embodiment to lower current of device-card interfaces. 
       Second Embodiment 
       [0049]    Based upon the same inventive idea, following the method for erasing and writing data from and to a memory in a smart card according to the embodiment of the invention, another embodiment of the invention further provides a smart card structured as illustrated in the schematic diagram of  FIG. 3 , which includes a Central Processing Unit (CPU)  310  and a memory  302 , where: 
         [0050]    The CPU  301  is configured to buffer data to be written into a random memory buffer of the memory  302  upon determining a data erasing and writing operation to be performed on the memory  302 ; and to control itself to enter a standby and sleep mode after transmitting a data erasing and writing signal to the memory  302 ; and 
         [0051]    The memory  302  is particularly configured to perform the data erasing and writing operation by acquiring the data to be written from its own random memory buffer upon reception of the data erasing and writing signal. 
         [0052]    Preferably the CPU  301  is further configured to control itself to enter a normal operating mode from the standby and sleep mode after the memory  302  performs the data erasing and writing operation. 
         [0053]    Preferably the memory  302  is further configured to transmit a recovery signal to the CPU  301  after performing the data erasing and writing operation; and 
         [0054]    The CPU  301  is particularly configured to control itself to enter the normal operating mode from the standby and sleep mode according to an instruction of the received recovery signal. 
         [0055]    Preferably the CPU  301  is particularly configured to transmit the data erasing and writing signal as an interruption signal; and/or 
         [0056]    The memory  302  is particularly configured to transmit the recovery signal as an interruption signal. 
         [0057]    Preferably the memory  302  is an NAND flash memory or an NOR flash memory. 
         [0058]    In summary, in the solution according to the embodiments of the invention, a CPU in a smart card buffers data to be written into a random memory buffer of a specified memory in the smart card upon determining a data erasing and writing operation to be performed on the specified memory and controls itself to enter a standby and sleep mode after transmitting a data erasing and writing signal to the specified memory, where the data erasing and writing signal instructs the specified memory to perform the data erasing and writing operation by acquiring the data to be written from the random memory buffer. With the solution according to the embodiments of the invention, current of a device-card interface while erasing and writing data from and to the specified memory in the smart card can be lowered to thereby avoid an abnormality occurring due to over-current of the device-card interface and also lower power consumption and hence improve a standby period of time of a device where the SIM card is located. 
         [0059]    Those skilled in the art shall appreciate that the embodiments of the invention can be embodied as a method, a system or a computer program product. Therefore the invention can be embodied in the form of an all-hardware embodiment, an all-software embodiment or an embodiment of software and hardware in combination. Furthermore the invention can be embodied in the form of a computer program product embodied in one or more computer useable storage mediums (including but not limited to a disk memory, a CD-ROM, an optical memory, etc.) in which computer useable program codes are contained. 
         [0060]    The invention has been described in a flow chart and/or a block diagram of the method, the device (system) and the computer program product according to the embodiments of the invention. It shall be appreciated that respective flows and/or blocks in the flow chart and/or the block diagram and combinations of the flows and/or the blocks in the flow chart and/or the block diagram can be embodied in computer program instructions. These computer program instructions can be loaded onto a general-purpose computer, a specific-purpose computer, an embedded processor or a processor of another programmable data processing device to produce a machine so that the instructions executed on the computer or the processor of the other programmable data processing device create means for performing the functions specified in the flow(s) of the flow chart and/or the block(s) of the block diagram. 
         [0061]    These computer program instructions can also be stored into a computer readable memory capable of directing the computer or the other programmable data processing device to operate in a specific manner so that the instructions stored in the computer readable memory create an article of manufacture including instruction means which perform the functions specified in the flow(s) of the flow chart and/or the block(s) of the block diagram. 
         [0062]    These computer program instructions can also be loaded onto the computer or the other programmable data processing device so that a series of operational steps are performed on the computer or the other programmable data processing device to create a computer implemented process so that the instructions executed on the computer or the other programmable device provide steps for performing the functions specified in the flow(s) of the flow chart and/or the block(s) of the block diagram. 
         [0063]    Although the preferred embodiments of the invention have been described, those skilled in the art benefiting from the underlying inventive concept can make additional modifications and variations to these embodiments. Therefore the appended claims are intended to be construed as encompassing the preferred embodiments and all the modifications and variations coming into the scope of the invention. 
         [0064]    Evidently those skilled in the art can make various modifications and variations to the invention without departing from the scope of the invention. Thus the invention is also intended to encompass these modifications and variations thereto so long as the modifications and variations come into the scope of the claims appended to the invention and their equivalents.