Working With EEPROM Image Files

You can save the state of EEPROM contents, then load it in a later invocation of the RI. To do this, you must specify an EEPROM image or "store" file to save the EEPROM contents when running cref. The -i and -o flags are used to manipulate the EEPROM image files at the cref command line:

  • The -i flag, followed by a file name, specifies the initial EEPROM image file that initialize the EEPROM portion of the virtual machine before Java Card virtual machine bytecode execution begins.

  • The -o flag, followed by a file name, saves the updated EEPROM portion of the virtual machine to the named file, overwriting any existing file of the same name.

The -i and -o flags do not conflict with the performance of other option flags.

The commit of EEPROM memory changes during the execution of the Java Card RI is not affected by the -o flag. Neither standard nor error output is written to the output file named with the -o option.

This section includes the following topics:

Input EEPROM Image File

The following command example shows how you can use the -i flag to initialize EEPROM from an input EEPROM image file.

To initialize EEPROM from an input EEPROM image file:

  1. Enter the following command:
    cref -i e2save
    

The RI attempts to initialize simulated EEPROM from the EEPROM image file named e2save. No output file is created.

Output EEPROM Image File

The following command example shows how you can use the -o flag to writes EEPROM data to an output EEPROM image file.

To write EEPROM data to an output EEPROM image file:

  1. Enter the following command:
    cref -o e2save
    

The Java Card RI writes EEPROM data in this example to the file e2save. The file is created if it does not currently exist. Any existing EEPROM image file named e2save is overwritten.

Same Input and Output EEPROM Image File

The following example shows how you can use the -o and -i flag to initialize simulated EEPROM from the EEPROM image file, and during processing, save the contents of EEPROM to the same image file, overwriting the contents.

To initialize EEPROM from and write EEPROM data to the same input and output EEPROM image file:

  1. Enter the following command:
    cref -i e2save -o e2save
    

The Java Card RI attempts to initialize simulated EEPROM from the EEPROM image file named e2save, and during processing, saves the contents of EEPROM to e2save, overwriting the contents. This behavior is much like a real Java Card technology-compliant smart card in that the contents of EEPROM are persistent.

Different Input and Output EEPROM Image Files

The following example shows how you can use the -o and -i flag to initialize simulated EEPROM from an EEPROM image file, and during processing, write EEPROM updates to a different EEPROM image file.

  1. Enter the following command:
    cref -i e2save_in -o e2save_out
    

The RI attempts to initialize simulated EEPROM from e2save_in, and during processing, writes EEPROM updates to the file named e2save_out. The output file is created if it does not exist. Using different names for input and output EEPROM image files eliminates much potential confusion.

This command line can be executed multiple times with the same results.