Interface Memory

interface Memory {
    fill(location: DSLocation, count: number, value: string | number | bigint, bitSize?: number): void;
    getSupportedFormats(page?: Page): string[];
    loadBinary(location: DSLocation, filepath: string): void;
    loadBinaryProgram(filepath: string, startAddress: Address): void;
    loadData(location: DSLocation, count: number, filepath: string): void;
    loadProgram(filepath: string): void;
    read(location: DSLocation, count: number, bitSize?: number): bigint[];
    readOne(location: DSLocation, bitSize?: number): bigint;
    saveBinary(location: DSLocation, count: number, filepath: string): void;
    saveData(location: DSLocation, count: number, filepath: string, format: string, append?: boolean): void;
    verifyBinaryProgram(filepath: string, startAddress: Address): void;
    verifyProgram(filepath: string): void;
    write(location: DSLocation, values:
        | string
        | number
        | bigint
        | (string | number | bigint)[], bitSize?: number): void;
}

Methods

  • Fill a block of memory with a specified value.

    Parameters

    • location: DSLocation

      The start address of the block of memory

    • count: number

      The number of values to fill in the block

    • value: string | number | bigint

      The value to use to fill memory

    • OptionalbitSize: number

      The bit width of the value. Defaults to the word size. Valid values are 8, 16, 24, 32, 40, 48, and 64.

    Returns void

    // Fill a block of 10 words, starting at 0x2400, with all 1s (assumes words are 32-bit on the target)
    session.memory.fill(0x2400n, 10, 0xFFFFFFFF);

    // Filling the same block with all 1s, but using 64-bit values
    session.memory.fill(0x2400n, 5, -1n, 64);
  • Get a list of the supported formats to be used for Memory.saveData.

    Parameters

    • Optionalpage: Page

      The memory page. If not provided, assumes the default data access page.

    Returns string[]

    A list of supported formats.

    let formats = session.memory.getSupportedFormats();
    // print all the formats
    for (const format : formats) {
    console.log(format);
    }
  • Load a block of memory from a binary file, like the ones created with Memory.saveBinary.

    Parameters

    • location: DSLocation

      The start address of the block of memory

    • filepath: string

      The full path to the file to be loaded

    Returns void

    Unlike loadBinaryProgram, this is not considered a program load. That is, this cannot program flash memory, and the target will not be halted automatically. However, it can load to memory pages other than the program page.

    session.memory.saveBinary(0x2400n, 256, "C:/loadBinaryExample.bin");
    // Load the binary file at a different address
    session.memory.loadBinary(0x3200n, "C:/loadBinaryExample.bin");
  • Load a binary program file to the target.

    Parameters

    • filepath: string

      Full path to the file

    • startAddress: Address

      The address at which the program should be loaded. On targets with memory pages, this address is assumed to be in the program memory page.

    Returns void

    This can be used to program flash memory.

    The target will be halted prior to the load.

    Unlike Memory.loadProgram, this will not clear previously loaded debug symbols.

    // Load a binary program
    session.memory.loadBinaryProgram("C:/workspace/example.bin", 0x2400n);
  • Load a block of memory from a file created using Memory.saveData.

    Parameters

    • location: DSLocation

      The start address of the block of memory.

    • count: number

      The number of words to be loaded form the file.

    • filepath: string

      The full path to the data file.

    Returns void

    This command cannot be used to program flash. If you want to save and load data from and to flash, consider using Memory.saveBinary and Memory.loadBinaryProgram.

    session.memory.saveData(0x2400n, 5, "C:/loadDataExample.dat", "32-Bit Hex - TI Style");
    // Load the saved memory at a different location
    session.memory.loadData(0x3200n, 5, "C:/loadDataExample.dat");
  • Load a program file to the target, and load debug symbols (if any) for debugging. Accepts programs in ELF, COFF, and multiple hex formats.

    Parameters

    • filepath: string

      Full path to the file

    Returns void

    Loading a program will clear any previously loaded debug symbols.

    This returns once the program has been loaded to the target, the debugger is finished loading debug symbols, and the target is halted. By default, the debugger will run to the start of main. This behavior can be configured in the debugger settings.

    Will throw if the program load fails.

    // Load a program
    session.memory.loadProgram("C:/my_project/Debug/example.out");
  • Read a block of values from the target's memory. The memory contents are interpreted as unsigned integers of the specified bit size.

    Parameters

    • location: DSLocation

      The starting location to read from

    • count: number

      The number of values to read

    • OptionalbitSize: number

      The bit width of the values to be read. Defaults to the word size. Valid values are 8, 16, 24, 32, 40, 48, and 64.

    Returns bigint[]

    An array of the values read

    Will throw if any part of the memory read encounters an error.

    // Read 10 words starting at 0x2400
    let values = session.memory.read(0x2400n, 10);

    // Read 2 64-bit values
    let [value1, value2] = session.memory.read(0x2400n, 2, 64);
  • Like Memory.read but reads and returns a single value instead of an array.

    Parameters

    Returns bigint

    // Read one word at 0x24000
    let value = session.memory.readOne(0x2400n);

    // Read one 64-bit value
    let value = session.memory.readOne(0x2400n, 64);
  • Save a block of target memory to a binary file that can be loaded with Memory.loadBinary or Memory.loadBinaryProgram (see the descriptions of these commands for the differences in their behavior).

    Parameters

    • location: DSLocation

      The start address of the block of memory

    • count: number

      The number of words in the block of memory

    • filepath: string

      The full path of the file to be created

    Returns void

    // Save 256 words of memory to a binary file
    session.memory.saveBinary(0x2400n, 256, "C:/saveBinaryExample.bin");
  • Save a block of target memory to a file in a human-readable format.

    Parameters

    • location: DSLocation

      The start address of the block of memory

    • count: number

      The number of words in the block of memory

    • filepath: string

      The full path of the file to be created

    • format: string

      The format in which the contents of memory should be written. A list of allowed formats for the target can be obtained from Memory.getSupportedFormats.

    • Optionalappend: boolean

      A flag indicating if the data should be appended to the file, if it already exists. Different data formats should not be mixed in the same file. If not provided, defaults to false.

    Returns void

    // Save 5 words of memory in 32-bit hex format without a 0x prefix
    session.memory.saveData(0x2400n, 5, "C:/saveDataExample.dat", "32-Bit Hex - TI Style");

    // Save 24 words of memory in ascii character format
    session.memory.saveData(0x2400n, 24, "C:/saveDataExample.dat", "Character");
  • Verifies a binary program file against what is in the target's memory. An error is thrown if the verification fails.

    Parameters

    • filepath: string

      Full path to the file

    • startAddress: Address

      The address at which the binary program is expected to be loaded in memory. On targets with memory pages, this address is assumed to lie in the program memory page.

    Returns void

    // Verify a binary program
    try {
    session.memory.verifyBinaryProgram("C:/workspace/example.bin", 0x2400n);
    console.log("Program verification passed");
    } catch {
    console.log("Program verification failed");
    }
  • Verifies a program file against what is in the target's memory. Accepts programs in ELF, COFF, and multiple hex formats. An error is thrown if the verification fails.

    Parameters

    • filepath: string

      Full path to the file

    Returns void

    // Verify a program
    try {
    session.memory.verifyProgram("C:/my_project/Debug/example.out");
    console.log("Program verification passed");
    } catch {
    console.log("Program verification failed");
    }
  • Write a block of values to the target's memory.

    Negative values can be provided and will be written as a signed integer of the specified size. Values provided will be truncated to fit in an integer of the specified size and appropriate signedness.

    Parameters

    • location: DSLocation

      The starting location to write to

    • values:
          | string
          | number
          | bigint
          | (string | number | bigint)[]

      The values to write. Can be a single value, or an array of values. Each value must be a bigint, or an integer represented as a string or a javascript number

    • OptionalbitSize: number

      The bit width of the values to be written. Defaults to the word size. Valid values are 8, 16, 24, 32, 40, 48, and 64.

    Returns void

    Will throw if any part of the memory write encounters an error.

    // Write 6 words starting at 0x2400
    // values can be specified as numbers, bigints, or strings
    session.memory.write(0x2400n, [0, 1n, -500, 0x4, "5", "-0x3"]);

    // Write one 64 bit value at 0x2400
    session.memory.write(0x2400n, 0x8765432187654312n, 64);
    // equivalently
    session.memory.write(0x2400n, [0x8765432187654312n], 64);