TIFlash¶
This module contains the core functions used for interacting with CCS. These functions are not specific to any particular device family and thus can be used on any device.
# All core functions are provided in the tiflash module
import tiflash
-
exception
TIFlashAPIError
¶ Bases:
tiflash.core.core.TIFlashError
Generic TIFlash API Error
-
attach
(ccs=None, **session_args)¶ Attach command; opens a CCS session and attaches to device.
Parameters: - ccs (str) – version number of CCS to use or path to custom installation
- session_args (**dict) – keyword arguments containing settings for the device connection
Raises: TIFlashError
– raises error when expression error is raised
-
detect_devices
(ccs=None, **session_args)¶ Detect devices connected to machine.
Returns: list of dictionaries describing connected devices Return type: list
-
erase
(options=None, ccs=None, **session_args)¶ Erases device; setting ‘options’ before erasing device
Parameters: - options (dict) – dictionary of options in the format {option_id: option_val}; These options are set first before calling erase function.
- ccs (str) – version number of CCS to use or path to custom installation
- session_args (**dict) – keyword arguments containing settings for the device connection
Returns: Result of erase operation (success/failure)
Return type: bool
Raises: TIFlashError
– raises error if option invalid
-
evaluate
(expr, symbol_file=None, ccs=None, **session_args)¶ Evaluates the given C/GEL expression
Parameters: - expr (str) – C or GEL expression
- symbol_file (str) – .out or GEL symbol file to load before evaluating
- ccs (str) – version number of CCS to use or path to custom installation
- session_args (**dict) – keyword arguments containing settings for the device connection
Returns: String result from evaluating expression
Return type: str
Raises: TIFlashError
– raises error when expression error is raised
-
flash
(image, binary=False, address=None, options=None, ccs=None, **session_args)¶ Flashes device; setting ‘options’ before flashing device
Parameters: - image (str) – path to image to use for flashing
- binary (bool) – flashes image as binary if True
- address (int) – offset address to flash image
- options (dict) – dictionary of options in the format {option_id: option_val}; These options are set first before calling flash function.
- ccs (str) – version number of CCS to use or path to custom installation
- session_args (**dict) – keyword arguments containing settings for the device connection
Returns: Result of flash operation (success/failure)
Return type: bool
Raises: TIFlashError
– raises error if option invalid
-
get_connections
(ccs=None, search=None)¶ Gets list of all connections installed on machine (ccs installation)
Parameters: - search (str) – String to filter connections by
- ccs (str) – version number of CCS to use or path to custom installation
Returns: list of connection types installed in ccs
Return type: list
Raises: FindCCSError
– raises exception if cannot find ccs installation
-
get_cpus
(ccs=None, search=None)¶ Gets list of all cpus installed on machine (ccs installation)
Parameters: - search (str) – String to filter cpus by
- ccs (str) – version number of CCS to use or path to custom installation
Returns: list of cpus types installed in ccs
Return type: list
Raises: FindCCSError
– raises exception if cannot find ccs installation
-
get_devicetypes
(ccs=None, search=None)¶ Gets list of all devicetypes installed on machine (ccs installation)
Parameters: - search (str) – String to filter devices by
- ccs (str) – version number of CCS to use or path to custom installation
Returns: list of device types installed in ccs
Return type: list
Raises: FindCCSError
– raises exception if cannot find ccs installation
-
get_info
(ccs=None, **session_args)¶ Returns dict of information regarding tiflash environment
Parameters: ccs (str) – version number of CCS to use or path to custom installation Returns: dictionary of information regarding tiflash environment Return type: dict
-
get_option
(option_id, pre_operation=None, ccs=None, **session_args)¶ Reads and returns the value of the option_id.
Parameters: - option_id (str) – Option ID to request the value of. These ids are device specific and can viewed using TIFlash.print_options().
- pre_operation (str) – Operation to run prior to reading option_id.
- ccs (str) – version number of CCS to use or path to custom installation
- session_args (**dict) – keyword arguments containing settings for the device connection
Returns: Value of option_id
Return type: str
Raises: TIFlashError
– raises error if option does not exist
-
list_options
(option_id=None, ccs=None, **session_args)¶ “Gets all options for the session device.
Parameters: - option_id (str, optional) – string used to filter options returned
- ccs (str) – version number of CCS to use or path to custom installation
Returns: list of option dictionaries
Return type: list(dict)
-
memory_read
(address, num_bytes=1, page=0, ccs=None, **session_args)¶ Reads specified bytes from memory
Parameters: - address (long) – memory address to read from
- num_bytes (int) – number of bytes to read
- page (int, optional) – page number to read memory from
- ccs (str) – version number of CCS to use or path to custom installation
- session_args (**dict) – keyword arguments containing settings for the device connection
Returns: Returns list of bytes read from memory
Return type: list
-
memory_write
(address, data, page=0, ccs=None, **session_args)¶ Writes specified data to memory
Parameters: - address (long) – memory address to read from
- data (list) – list of bytes to write to memory
- page (int, optional) – page number to read memory from
- ccs (str) – version number of CCS to use or path to custom installation
- session_args (**dict) – keyword arguments containing settings for the device connection
Raises: TIFlashError
– raises error when memory read error received
-
register_read
(regname, ccs=None, **session_args)¶ Reads specified register of device
Parameters: - regname (str) – register name to read from
- ccs (str) – version number of CCS to use or path to custom installation
- session_args (**dict) – keyword arguments containing settings for the device connection
Returns: value of register
Return type: int
Raises: TIFlashError
– raised if regname is invalid
-
register_write
(regname, value, ccs=None, **session_args)¶ Writes a value to specified register of device
Parameters: - regname (str) – register name to read from
- value (int) – value to write to register
- ccs (str) – version number of CCS to use or path to custom installation
- session_args (**dict) – keyword arguments containing settings for the device connection
Raises: TIFlashError
– raised if regname is invalid
-
reset
(options=None, ccs=None, **session_args)¶ Performs a Board Reset on device
Parameters: - options (dict) – dictionary of options in the format {option_id: option_val}; These options are set first before calling reset function.
- ccs (str) – version number of CCS to use or path to custom installation
- session_args (**dict) – keyword arguments containing settings for the device connection
Returns: True if reset was successful; False otherwise
Return type: bool
-
set_option
(option_id, option_val, post_operation=None, ccs=None, **session_args)¶ Sets the value of the option_id.
Parameters: - option_id (str) – Option ID to set value of. These ids are device specific and can viewed using TIFlash.print_options().
- option_val (str or int) – Value to set option to.
- post_operation (str) – Operation to run after to setting option_id.
- ccs (str) – version number of CCS to use or path to custom installation
- session_args (**dict) – keyword arguments containing settings for the device connection
Raises: TIFlashError
– raises error if option does not exist
-
verify
(image, binary=False, address=None, options=None, ccs=None, **session_args)¶ Verifies device; setting ‘options’ before erasing device
Parameters: - image (str) – path to image to use for verifying
- binary (bool) – verifies image as binary if True
- address (int) – offset address to verify image
- options (dict) – dictionary of options in the format {option_id: option_val}; These options are set first before calling verify function.
- ccs (str) – version number of CCS to use or path to custom installation
- session_args (**dict) – keyword arguments containing settings for the device connection
Returns: Result of verify operation (success/failure)
Return type: bool
Raises: TIFlashError
– raises error if option invalid
-
xds110_list
(ccs=None, **session_args)¶ Returns list of sernos and xds110 version numbers of connected XDS110 devices.
Parameters: - ccs (str) – version number of CCS to use or path to custom installation
- session_args (**dict) – keyword arguments containing settings for the device connection
Returns: list of tuples (serno, version) of connected XDS110 devices
Return type: list
Raises: XDS110Error
– raises if xdsdfu does not exist or fails
-
xds110_reset
(ccs=None, **session_args)¶ Calls xds110reset command on specified serno.
Parameters: - ccs (str) – version number of CCS to use or path to custom installation
- session_args (**dict) – keyword arguments containing settings for the device connection
Returns: True if xds110reset was successful
Return type: bool
Raises: TIFlashError
– raises if serno not setXDS110Error
– raises if xds110_reset fails
-
xds110_upgrade
(ccs=None, **session_args)¶ Upgrades/Flashes XDS110 firmware on board.
Firmware flashed is found in xds110 directory (firmware.bin). This function uses the ‘xdsdfu’ executable to put device in DFU mode. Then performs the flash + reset functions of xdsdfu to flash the firmware.bin image
Parameters: - ccs (str) – version number of CCS to use or path to custom installation
- session_args (**dict) – keyword arguments containing settings for the device connection
Returns: True if successful
Return type: bool
Raises: XDS110Error
– raises if xds110 firmware update fails