Abstract:
A method for updating information elements in a memory which includes a plurality of memory locations. An initial value D0 has been written at a first location E0 of the memory, E0 being determined by an initial value of a string of indicator bits, the initial value being defined by the parity of the rank of a last bit of the string of indicator bits in a programmed state. The method includes: writing a new value D1 at another location E1 of the memory, E1 being determined by the initial value of the string of logic indicator bits; verifying the written value in E1 by comparing the written value in E1 with D1; emitting an error code to a processing unit, if, after verifying the written value in El, the written value in E1 does not match D1; erasing the string of indicator bits entirely so that all of the indicator bits are in a blank state and writing the first bit to the programmed state, if, after verifying the written value in El, i) all the indicator bits are in the programmed state and ii) the written value in E1 matches D1, so as to make the value written in E1 accessible in a reading mode; and writing a first bit of the string of indicator bits in a blank state to the programmed state if, after verifying the written value in E1 and before erasing, i) the value written in E1 matches D1 and ii) all the indicator bits are not in the programmed state, so as to make the value written in E1 accessible in a reading mode. The plurality of memory locations are written serially according to successive updatings.

Description:
CROSS-REFERENCE TO RELATED APPLICATION 
     This application claims a benefit of priority under 35 USC §119 based on French patent application 90 10858, filed Aug. 31, 1990. 
     BACKGROUND OF THE INVENTION 
     1. Field of Use 
     The invention relates to the use of memories and, more particularly, an object of the invention is a method and the corresponding device for the updating of information elements in a memory and the use of said method and device in memory cards. 
     In memory cards that enable the updating of information elements recorded therein, notably RAM or EEPROM type memories, as opposed to the EEPROM memories where the updatings by erasure and re-recording are not possible, a major problem relates to possible interruptions in supply during the updating. Indeed, if an interruption of the supply voltage takes place during the updating of an information element, it may be the case that the former value of the data element has been only partially erased or that the new one has been only partially written in the memory. 
     2. Description of Related Art 
     This problem exists notably for the updating of computer memories. Solutions exist in this field. They make use of supplies that are not subject to cuts, or of particular methods for the management of access to information, by software. 
     In the field of memory cards, such solutions are not applicable for it is impossible to maintain the supply without cuts and, since the resources are highly limited in terms of program size, the only solution that can be contemplated is that of an a posterior checking of erased or written data elements, during the final application, in order to detect and then correct the errors if any. 
     SUMMARY OF THE INVENTION 
     An object of the invention is a method, and the corresponding device, for the updating of information elements in a memory that makes it possible, with a minimum use of resources, to ensure that the information that has to be updated is in a known state before the updating or after the updating, but never in an indeterminate state, and consequently makes it possible to carry out a transaction without ambiguity irrespectively of the instant of interruption, in the event of a problem. 
     According to the invention, the method for the updating of information elements in a memory is characterized in that, for the updating of a data element (D), an initial or preceding value (D0) of which has been written in the memory at a first memory location (E0), the method comprises the following steps: 
     in a first step, the writing of the new value (D1) is done in the memory at another memory location (E1), and is associated with a logic indicator that is initially in a first logic state, kept in this state during an updating; 
     in a second step, a verification of the new written value is done, this value being guaranteed in the event of coincidence with the value whose writing has been activated, and an error code being emitted in the event of non-coincidence; 
     and in a final step, the end of the updating activates the passage to a second logic state of the logic indicator, the updated value being then accessible in reading mode. 
     An object of the invention is also the device designed for the implementing of this method. 
     It is also an object of the invention to use a method such as this and a device such as this in memory cards. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     The invention will be understood more clearly, and other features will be revealed by means of the following description, made with reference to the appended figures. 
     FIGS. 1 and 2 respectively illustrate the steps of the updating method and the device designed for its implementation according to a first alternative embodiment. 
     FIGS. 3 and 4 respectively illustrate the steps of the updating method, and the device designed for its implementation according a second alternative embodiment. 
    
    
     DESCRIPTION OF PREFERRED EMBODIMENTS 
     In a re-recordable memory of the EEPROM or RAM type, the safeguarding of an operation for the writing of a data element is most usually done only after a prior operation for resetting the corresponding memory location at zero. Furthermore, the writing operation can generally be done only once. The writting of a data element is done by bits, bytes or words. Consequently, as indicated here above, it is possible that a data element will be only partially written when, owing to an interruption, the sequence of operations necessary for the writing of the data element is interrupted. A state such as this for the incorrect data element cannot be distinguished from that of a correct data element, and the use of an aberrant data element such as this in an application, for example using a memory card, may have grave consequences. 
     To resolve the problem of possible interruptions during the updating of a memory, according to a first characteristic of the invention, the updating method uses a logic indicator that is characteristic of the updating and is itself updated only after the information to be updated has been written in the memory and then verified. This makes it possible to guarantee or secure the integrity of the information even in case of unexpected interruption while, at the same time, making it possible, if necessary, for the aborted operation to be resumed. 
     Furthermore, according to a second characteristic of the invention, so as never to lose trace of the prior data element during an updating operation, any new data value cannot be written at the same physical place as that of the value that it should replace. At least two memory locations are therefore used for a same data element. When the new value of the data element is written in the memory, one of the locations contains a value which shall hereinafter be called a protected or &#34;secured outstanding value&#34;, while the other contains a so-called &#34;non-secured working value&#34;. 
     According to a first variant, with each new updating there is associated a logic indicator characterizing the updating. The updated data element, which is not transferred, is read at the place where it has been written. If more than two memory locations are used, several values could be values of the &#34;secured outstanding value&#34; type, and it is the order in which the automation that uses the data can gain access to these different values that will enable the last secured value to be retrieved, if need be, following an interruption. 
     To this end, in this first variant described in greater detail here below, the device implements a cyclical binary counter without indeterminate state forming a sequence of logic indicators and a table of memory locations in which the information elements are stored. 
     The cyclical binary counter without indeterminate state is a simple logic binary string, for example a string of bits in an EPROM or EEPROM memory, made in such a way that when a bit goes from the blank state, arbitrarily called &#34;0&#34;, to the programmed state, arbitrarily called &#34;1&#34;, none of the other bits of the string suffers deterioration. Conversely, when the counter has to be reset at zero, the blank state for all the bits, the entire string of bits, without exception, is affected and all the bits return together to this blank state, then all the bits being in an identical instant at every instant during this zero-setting operation. 
     For an application to a memory in which it is impossible to update only one bit of one byte without disturbing the others, a string of bytes can be used as updating logic indicators. 
     Memories that can be used to make a binary logic string such as this are commercially available. The function described here above is a standard one in most EPROM memories, the simultaneous erasure being done by exposure to an ultraviolet radiation. This function exists also in certain EEPROM memories, manufactured by SGS THOMSON or by MOTOROLA, that are used chiefly in the field of computerized money applications, i.e. in most of the memories especially adapted to memory cards, where each bit of each byte goes from the blank state &#34;0&#34; to the programmed state &#34;1&#34; without deterioration in any other bit of the byte. 
     The association of the cyclical binary counter and of a table of memory locations for the data element necessitating updatings can be used to eliminate the indeterminate state that is possible during interruptions in the electrical supply. 
     The following detailed description of the updating method according to the invention specifies the sequencing of operations that can be used to arrive at this result: let D0 be the original value memorized and let D1 be the updated value of the data element D. As indicated here above, the data element D1 is written in a memory location other than that in which original value of the data element is located. Let E0 be the memory location of the original value D0, and let E1 be the memory location in which the value D1 will be stored. There is no constraint with respect to the arrangement of the memory locations E0 and E1. Hereinafter, these locations appear to be contiguous only to simplify the explanation. 
     In a first example, it is assumed that the memory is re-recordable: two memory locations alone can be designed for a data element to be updated, namely E0 and E1. 
     The cyclical binary counter is constituted by logic indicators, binary elements for example. Let b1, . . . bn be the logic indicators constituting the counter; the only values possible for these indicators are &#34;0&#34; and &#34;1&#34;. 
     For access to an information element having a length of &#34;N&#34; bytes, the automation works in the following manner, described with reference to FIG. 1. The initial state of the automation is such that: 
     b0, . . . bn =[0, . . . 0] 
     E0 contains D0 and b0 is set at &#34;1&#34;; 
     E1 has an indeterminate content. 
     During a request for the updating of the data element D at an instant t1, the corresponding automation is called. 
     The first byte of D1 is written in the first byte of E1 at the instant t1+l, the second byte of D1 is written in the second byte of E1 at the instant t1+2 . . . , the Nth byte of D1 is written in the Nth byte of E1 at the instant t1+N. 
     at the instant t1+N+l, the automation reads the value present at the location E1, 
     at the instant t1+N+2, the value read at the location E1 is compared with the value D1 of the data element D to be updated, 
     at the instant t1+N+3: 
     in the event of equality between the terms of the above comparison, the updating is ended and the automation writes the first blank bit bi of the counter, i.e. b1 during this first updating which then goes to 1, 
     in the event of inequality between the terms of the comparison, the writing of the value D1 at the location E1 has been badly done, and the automation returns an error code. 
     During the next updating of the same data element D, the value D2 of the data element will be written according to the same procedure at the location E0 and then verified, the first blank bit of the counter in the sequence of the bits of the counter being then written (i.e. b2, during this second updating), when the written value D2 has been verified. 
     During the next updating of the same data element D requested at the instant t, the value Di of this data element will be written again according to the same procedure, either in E0 if i is an even number or in E1 if i is an odd number, the first blank bit of the counter, bi, being written when the written value Di has been verified. 
     The string of indicator bits [b0, b1 . . . bn] has a length n+l. When we reach the (n+l)th updating, the string of indicators is entirely at 1, the writing is then forced to the location E0 and the string of indicators is erased in a single stroke, then b0 is set at &#34;1&#34; after verification of the data element written at E0. The device is then brought to a state similar to the initial state. This operation for the erasure of the indicators is such that all the bits bi are reset at zero simultaneously by a single operation of the type involving exposure to ultraviolet radiation for example. 
     For a reading of the value of the data element D requested at an instant t&#39;, the automation makes a search, in the sequence of the bits of the counter (b0 . . . bn), for the last bit &#34;bi&#34; at &#34;1&#34;: if the value of &#34;i&#34; is even or zero, the value of the data element D is read at the location E0, and if the value of &#34;i&#34; is odd, the value of the data element D is read in E1. 
     A method such as this can give only an accurate value during the reading since the integrity of the writing has been validated. At worst, when an updating has not been carried through to the end, the automation reads the value written during the last accurate updating. Hence a value that may be not up-to-date but never an aberrant value. 
     Naturally, it is possible to provide for a number of locations for the same data data element that is greater than 2, namely E0, E1 . . . Em, with m&lt;n, where m+l is the number of locations and n+l is the number of bits of the counter. This makes it possible, as indicated here above, to have several secured values in progress in the successively used memory locations. 
     In the EEPROM type erasable memories, the possibility of erasing the memory can be turned to advantage to provide for cyclical operation on a set of positions E0, E1, E2 . . . Em; when the automation detects that the validated value of the updated data element has been written in the last memory location Em, it writes the next value at the location E0: the number bi of bits written in the counter is such that i=m+1=0 modulo (m+l). For a cyclical use of memory locations such as this, the binary counter enables the retrieval of the location Ek of the last accurate value by computing simply the value k=i modulo (m+l), i being the rank of the last bit at &#34;1&#34; of the string and by assuming that the locations are written in the order E0, E1 . . . Em. 
     A structure such as this can also be used to update the data elements in the electrically programmable unerasable memories such as EPROMs. In this case, when all the locations E0, E1 . . . Em or when all the bits b0, b1, . . . bn have been written, the memory must be replaced, through the replacement of the card bearing this memory or through the allocation of new zones of the memory to the updating of this data element. In this mode, it is worthwhile for the number of memory locations to be the same as the number of bits of the counter. 
     The updating method described here above can be applied also to the updating of memories in which the writing operation is preceded by an explicit or implicit erasure of the designated location. 
     In brief, if &#34;bi&#34; is the last bit at &#34;1&#34; of the string of indicators, i being its rank in the string, the method is such that the automation obtains access, in reading mode, to the location Ej such that j=i modulo (m+l) and in writing mode to the location Ej+i. In principle, there is but little risk of there being bits that remain at 1 during a full erasure of the string after a cycle of n updatings. However, should such an anomaly occur, for example if the erasing operation is prematurely interrupted, there is a risk of error by the automation during the selection of the location to be read. This risk can be eliminated by a simple test on the string for only the configurations of the following type are normal: those in which all the bits bi are at &#34;0&#34; or in which all the bits preceding the last bit bi at 1 are at 1. All the combined configurations are abnormal and can only correspond to an attempt to zero-set the string of indicators: the location to be read is then, in all the &#34;abnormal&#34; cases, the location E0. 
     The only case of erasure that cannot be detected as being abnormal when it is in fact incomplete is the case where all the erased bits at &#34;1&#34; are to the right of a string of bits which, furthermore, has remained at 1, for this configuration is not &#34;abnormal&#34; from the logic viewpoint and cannot be detected by a check on the shape of the string. 
     To completely remove any risk of error, it is possible to use the same method as above to check the erasure of the string of bits, i.e. a checking indicator bit, namely Cx associated with the string of bits bi: 
     when the string of indicators is in normal use, Cx remains in the initial state: blank=&#34;0&#34; by convention, 
     when the string has to be reset at zero, the bit Cx is placed in the state &#34;1&#34;, which means that the string of indicators is in an intermediate state before being reset at zero. The string is then erased, and then its erasure is verified, and if the erasure is correct (no bit bi at 1), the checking bit Cx associated with the string is reset at &#34;0&#34;. 
     A sequence such as this can be used to remove any indeterminacy in the event of untimely interruption and makes it possible, in the event of an anomaly, to repeat the aborted operation, an error code being returned by the updating operation as soon as it has not been possible to verify an operation. 
     The updating device designed for the implementing of the method described here above, is illustrated by FIG. 2: it is a programmable processor 10, associated with a data memory 20. In this FIG. 2, it is assumed that these elements, i.e. microprocessor and memory, are associated with each other in a card 30 comprising memory and microprocessor. However, in the automation designed for the application required by this card, this microprocessor may be outside the card. The string of indicators 40 has been shown as forming part of a memory 50 which is independent of the memory 20. It may also form part of the memory 20, provided that this memory has the above-described function. The procedure is then commanded by a software program carrying out the steps of the above-described method and designed for this purpose in the microprocessor. However, the updating automation can also be made with specialized circuits performing the elementary circuits described here above. These two embodiments are within the scope of those skilled in the art. 
     In FIG. 2, the memory 20 has been illustrated with a table of memory locations TD [E0, E1, . . . E5], giving m=5 and the string of indicators, 40, with 12 indicators [b0, b1, . . . b11]. In the example illustrated, where [b0, b1, . . . b9] are at &#34;1&#34; and [b10, b11] are at &#34;0&#34;, if a request for reading occurs, the data will be read at the location E3 and if an updating request occurs, the data element will be written at the location E4. As indicated here above, there is no data transfer in this first alternative embodiment, the trade-off here being that the data element should be read at the ad-hoc location after a test on the indicator bits. 
     A variant of the present invention also uses two memory locations but, in order that the data element may be always read at the same memory location E, the value of the updated data element written in another memory location and then verified is thereafter transferred therein. The method described in greater detail here below with reference to FIG. 3 consists in carrying out a request for the updating of a data element D, an initial value D0 of which has been written at the location E by the writing, in a memory space M designed for this purpose, of the following: 
     the value D1 of the updated data element, 
     the address (E) at which it should be written, 
     an indicator in a state 0 for example, for &#34;false&#34; indicating that the value of the data element has to be updated. The indicator will take, as a value &#34;0&#34;, a value different from the value of the initial state of the memory, the value &#34;1&#34; being itself equal to the value of the initial state of the memory. If the application requires the updating of only a data element using this memory space, it is possible not to memorize the address which is always the same and which is a data element for the updating. 
     All these information elements having been written in the memory space designed for this purpose, a reading of this space is done to verify the written data elements: 
     in the event of a writing error, or in the event of a power cut, the verification cannot be used to establish the coincidence, and the value of the data element at the address E is not updated. An error code is transmitted and activates the resumption of the updating operation by a new recording; 
     in the event of coincidence, the data element present in the memory space is copied at the associated address, i.e. at the location E. 
     To this end, the automation that uses the card carries out the following sequence of operations, illustrated in FIG. 3, in performing the operations in a manner that is transparent for the user: 
     in a first step, the state of the indicator b is detected: 
     if the indicator is at &#34;1&#34; (&#34;true&#34;), there is neither an updating to be done nor any updating that has been incompletely done, and the value of the useful data element can be read at its address E; 
     if the indicator is at &#34;0&#34; (&#34;false&#34;), there is an updating in progress or an updating to be done, and the sequence of this updating is done as follows: 
     erasure of the value of the data element D present at the location E; 
     writing of the data element D1, present in the memory space M where it has been verified, at the location E; 
     positioning of the indicator at &#34;1&#34; (&#34;true&#34;) indicating that the updating in progress is over and that the value of the data element D at its address E is a secured value. 
     This variant also makes it possible to have data elements that are always coherent in the useful memory for the application managed by the card. Indeed, after the card has accepted the updating order, the above-described method makes it possible to preserve the integrity of the data elements. If the last part of the sequence relating to the transfer of the data element to definitive memory location is interrupted, for example owing to a cut in the power supply, then the sequence will be resumed when the supply is re-established for the indicator is still in the &#34;0&#34; position (&#34;false&#34;) and marks an updating that is to be done or that has not been completed, the new value being in the memory space that is not accessible in reading. The device always has a coherent value available since the old value is never erased without the system&#39;s knowing the new value and, in the end, the updated value always gets transferred before a reading. 
     As in the first variant described here above, for this second variant the device illustrated by FIG. 4 is such that when the memory is associated with a microprocessor, for example in the application to the cards (30) with memory (20) and microprocessor (10), the automation can be set up by software and may be present in the mask of the microprocessor. It can also be made by specific circuits, and the automation then made takes control over the program of the processor to carry out this updating sequence. 
     However, the device can also be implanted on simple memory components, using only one wired logic circuit (PLA). It is then a circuit coupled to the reading and writing control inputs of the memory. 
     The invention is not limited to the two variants specifically described here above: it can be applied to the updating of a memory word but it can be applied to the making of a smaller-sized memory zone or, on the contrary, to larger assembly of several memorizing &#34;units&#34;, words or bytes. In every case, the new value of the data element is written in a memory location different from the one at which the previous value is available, this value being verified before the former value can be replaced in the application, a logic indicator changing its state to mark the end of the updating and the accessibility, in reading mode, of the new value.