drivers/ecos_lpc2138_sja1000/nvram_readme
changeset 93 16c8ceea8f18
parent 92 0d84d95790d9
child 94 bdf4c86be6b2
equal deleted inserted replaced
92:0d84d95790d9 93:16c8ceea8f18
     1 procedure for NVRAM
       
     2 ===================
       
     3 
       
     4 data block 0
       
     5 ------------
       
     6 This data block is located at the beginning of the NVRAM and contains
       
     7 a series of registers.
       
     8 eg. 1. the version number of the current dictionnary (32 bits)
       
     9     2. pointer to the current dictionnary (32 bits)
       
    10     3. date of last dictionnary dump (32 bits)
       
    11     4. pointer to the last dict (32 bits)
       
    12     5. size in page of the current dict
       
    13 
       
    14 a minimum number of registers should always be in this block (including a number of 'for future use' 32 bits registers). the remaining space will be left to the developper
       
    15 
       
    16 a 256kb data block could handled 64 registers 
       
    17 
       
    18 data block 1 to N
       
    19 -----------------
       
    20 The place where to put the content of the dictionnary
       
    21 
       
    22 
       
    23 procedure to write in the NVRAM
       
    24 -------------------------------
       
    25 for each sub-index
       
    26 add a flag indicating the state
       
    27 	= 0  : normal
       
    28 	= -1 : this is a old sub-index, no longer used
       
    29 	= +1 : this is a new sub-index
       
    30 
       
    31 the sub-indexed flaged to -1 could be remove when doing a new release of dictionnary
       
    32 eg. from BIOS V0 to V1, flag the old sub-index to -1.  but when going to V2, those must be remove from the dictionnary
       
    33 
       
    34 this flag is important when reloading the old NVRAM content. Since the writing and reading are done sequentially, the dictionnary and the NVRAM must be synchronised.
       
    35 
       
    36 
       
    37 ON BOOT
       
    38 -------
       
    39 1. read the block data 0 and check the NVRAM version number against the current dictionnary
       
    40 if the dict version = NVRAM version, then read the NVRAM using the normal procedure (state=0 and state=+1)
       
    41 if the dict version is newer then the NVRAM, read the NVRAM using the state=0 and state=-1 . this will ensure a synchone reading of the data
       
    42 
       
    43 2. if this is a new NVRAM, write the whole dictionnary to a NEW position in the NVRAM.
       
    44 	write all sub-indexes with state=0 and =+1, do not write does with state=-1
       
    45 	write the new version number in the registery and the date
       
    46 
       
    47 
       
    48 ON WRITE
       
    49 --------
       
    50 write the content of the whole dict (only those sub-indexes that must be saved) to the NVRAM
       
    51 write the version number  
       
    52 write the date
       
    53 
       
    54 
       
    55 NEW VERSION OF BIOS
       
    56 -------------------
       
    57 When a new version of BIOS is downloaded into the device, special procedure must be taken (cf. ON BOOT and ON WRITE). But to avoid problem during the update (i.e. lost of NVRAM data or worst NVRAM corruption) fewer NVRAM manipulation should be performed. Therefore, when writing the new dictionary to NVRAM, it should be put AFTER the previous one. This will provide a way to go back and fetch the previous dictionnary saved values if needed. 
       
    58 
       
    59 Obviously, the NVRAM has a limited capacity and it is possible that the new BIOS will overshoot the upper limit of memory. In that case, the algorithm should do a loop-around the addressed. Meaning, if the last block of data is reached, go back to data block 1 (data block 0 = registers). If the NVRAM is large enough, it should not cause problem (i.e. overwritting the beginning of the actual dict).
       
    60 
       
    61 Data Block 0 has the offset in memory to access the current dict. It also containt the pointer to the last version of the dict. Since the algo writing to the NVRAM does not compact memory, the size of the dict is not necessarily the size of the NVRAM memory it occupies.