expliot.core.interfaces.busauditor

Wrapper for BusAuditor interface.

Submodules

Package Contents

Classes

STM32F411

Driver for STM32F411 BusAuditor Hardware.

BusAuditor

BusAuditor interface class.

class expliot.core.interfaces.busauditor.STM32F411

Bases: expliot.core.interfaces.common_services.BusAuditorServices

Driver for STM32F411 BusAuditor Hardware. Search, initialized BusAuditor Device and related driver Initialized flags related to driver Read FW, HW revisions and supported services

USB_DIR_OUT = 64
USB_DIR_IN = 192
USB_DATA_EP = 129
USB_VID = 1155
USB_PID = 47648
USB_OP_TIMEOUT_ERROR = 110
SRV_GET_REVISIONS = 1
SRV_GET_SERVICES = 2
SRV_JTAG_IDCODE_SCAN = 17
SRV_JTAG_PATTERN_SCAN = 18
SRV_JTAG_IDCODE_TRST_SCAN = 19
SRV_JTAG_PATTERN_TRST_SCAN = 20
SRV_SWD_IDCODE_SCAN = 27
SRV_UART_TX_SCAN = 33
SRV_UART_TX_RX_SCAN = 34
SRV_I2C_ADDR_SCAN = 35
SRV_SPI_SCAN = 36
SERVICE_RESP_BIT = 128
SRV_GET_REVISIONS_RESP
SRV_GET_SERVICES_RESP
SRV_GET_REVISIONS_RESP_LEN = 8
SRV_GET_SERVICES_RESP_LEN = 7
SRV_JTAG_SCAN_BIT = 1
SRV_SWD_SCAN_BIT = 2
SRV_UART_SCAN_BIT = 16
SRV_I2C_SCAN_BIT = 32
SRV_SPI_SCAN_BIT = 16
SRV_RESP_BYTE_1 = 3
SRV_RESP_BYTE_2 = 4
SRV_RESP_BYTE_3 = 5
SRV_RESP_BYTE_4 = 6
_srv_err = ['No error', 'Service error', 'Device busy', 'Same start and end channel', 'Invalid start...
get_device_revisions()

Read Firmware and Hardware revision by Get Revision Service. This method save FW and HW revision for BusAuditor instance Args:

Nothing

Returns:
byte array: Five bytes of fw and hw revision,

[FW_MAJOR, FW_MINOR, FW_SUNMINOR, HW_MAJOR, HW_MINOR]

Raises:

NotImplementedError(“Invalid response for Get FW Version”)

read_supported_service()

Read services supported by BusAuditor hardware, and stores supported services info for service validation

Args:

Nothing

Returns:

Nothing

Raises:

ValueError(“Invalid response for Get Services”)

static __build_jtag_idcode_dict(resp_array, include_trst=False)

Build JTAG idcode list from idcode scan response array

Args:

resp_array (byte array): Jtag idcode scan service response from BusAuditor

Returns:

list: List of device ID code and corresponding JTAG pins

Raises:

Nothing

device_jtag_idcode_scan(start, end, volts, include_trst=False)

Send request for JTAG pattern scan, TRST pin not included.

Args:

start (int): First pin (channel number) to start the scan stop (int): Last pin (channel number) to stop the scan volts (str): Target voltage out

Returns:

list: List of device ID code and corresponding JTAG Pins

Raises:

Nothing

static __build_jtag_patten_dict(resp_array, include_trst=False)

Build JTAG pin dict from pattern scan response array

Args:

resp_array (byte array): Jtag pattern scan service response from BusAuditor

Returns:

dict: dict of JTAG pins on which pattern found and dict of active pins where pattern not found but pins are active

Raises:

Nothing

device_jtag_pattern_scan(start, end, volts, include_trst=False)

Send request for JTAG pattern scan, TRST pin not included.

Args:

start (int): First pin (channel number) to start the scan stop (int): Last pin (channel number) to stop the scan volts (str): Target voltage out

Returns:

dict: dict of JTAG pins on which pattern found and dict of active pins where pattern not found but pins are active

Raises:

Nothing

static __extract_jtag_idcode_pins_data(idcode_list, pattern_dict)

This method compares matched pins from pattern_dict to pins from idcode_list and build idcode list for JTAG devices from idcode_list.

Args:

idcode_list (list): List of ID code and corresponding JTAG pins pattern_dict (dict): Dict of Matched and Active pins

Returns:

dict: dict of JTAG device ID code and JTAG pins

Raises:

Nothing

device_jtag_scan(start, end, volts, include_trst=False)

This method initiates JTAG ID code scan and followed by Pattern scan

Args:

start (int): First pin (channel number) to start the scan stop (int): Last pin (channel number) to stop the scan volts (str): Target voltage out include_trst (boolean): Include trst pin in scan.

trst pin excluded by default

Returns:

dict: dict of JTAG device ID code and JTAG pins

Raises:

Nothing

static __build_swd_idcode_dict(resp_array)

Build SWD idcode dict from swd scan response array

Args:
resp_array (byte array): SWD idcode scan service response

from BusAuditor

Returns:

dict: dict of SWD device ID code and SWD pins

Raises:

Nothing

device_swd_scan(start, end, volts)

This method initiates SWD ID code scan to find SWD pins

Args:

start (int): First pin (channel number) to start the scan stop (int): Last pin (channel number) to stop the scan volts (str): Target voltage out

Returns:

dict: dict of SWD device ID code and SWD pins

Raises:

Nothing

static __build_uart_pin_dict(resp_array)

Build dict of TX, RX and Baudrate of UART port from response array

Args:
resp_array (byte array): UART scan service response

from BusAuditor

Returns:

dict: dict of TX, RX and Baudrate of UART port

Raises:

Nothing

device_uart_tx_scan(start, end, volts)

This method initiates UART port scan for TX pin and Baudrate

Args:

start (int): First pin (channel number) to start the scan stop (int): Last pin (channel number) to stop the scan volts (str): Target voltage out

Returns:

dict: dict of RX, TX and Baudrate of UART port

Raises:

Nothing

device_uart_tx_rx_scan(start, end, volts)

This method initiates UART port scan for TX, RX pin and Baudrate

Args:

start (int): First pin (channel number) to start the scan stop (int): Last pin (channel number) to stop the scan volts (str): Target voltage out

Returns:

dict: dict of JTAG device ID code and JTAG pins

Raises:

Nothing

device_uart_scan(start, end, volts)

This method initiates UART port scan for TX pin first, followed by TX, RX pins scan. if tx pin is actively transmitting data then method returns TX pin and baudrate. if tx pin is not active, then this method generate data on RX pin with fixed baudrate and wait for activity on tx pin to find baudrate

Args:

start (int): First pin (channel number) to start the scan stop (int): Last pin (channel number) to stop the scan volts (str): Target voltage out

Returns:

dict: dict of JTAG device ID code and JTAG pins

Raises:

Nothing

static __build_i2c_addr_dict(resp_array)

Build dict of I2C device addr and I2C pins from response array

Args:
resp_array (byte array): I2C scan service response

from BusAuditor

Returns:

dict: dict of SCL, SDA and addr of I2C device on I2C bus

Raises:

Nothing

device_i2c_scan(start, end, volts)

This method initiates I2C bus scan for active I2C devices

Args:

start (int): First pin (channel number) to start the scan stop (int): Last pin (channel number) to stop the scan volts (str): Target voltage out

Returns:

dict: dict of I2C pins and I2C device addr on I2C bus

Raises:

Nothing

__read_service_response(service)

This method read data from USB core driver on fixed EP of BusAuditor

Args:

service (int): Service response to be verified.

Returns:

list: List of valid service response packets

Raises:

USBError

usb_cntrl_read(brequest, wvalue=0, windex=0, data_or_wlength=None, timeout=100)

USB Control Transfer, EP0 DIR IN

Args:

brequest (int): usb bRequest wvalue (int): usb wValue windex (int): usb wIndex data_or_wlength (int/list): usb data to be write timeout (int): timeout for write transaction

Returns:

bytes array: bytes read from driver (array object)

Raises:

Nothing

usb_cntrl_write(brequest, wvalue=0, windex=0, data_or_wlength=None, timeout=100)

USB Control Transfer, EP0 DIR OUT

Args:

brequest (int): usb bRequest wvalue (int): usb wValue windex (int): usb wIndex data_or_wlength (int/list): usb data to be write timeout (int): timeout for write transaction

Returns:

int: number of bytes written

Raises:

Nothing

usb_read(size_or_buffer, timeout=1000)

USB Bulk read for EP1.

Args:

size_or_buffer (int/list): data buffer or size to be read timeout (int): timeout for write transaction

Returns:

bytes array: bytes read from driver (array object)

Raises:

Nothing

get_device_fw_rev_str()

Return firmware revision in string format.

Args:

Nothing

Returns:

str: firmware revision

Raises:

Nothing

get_device_hw_rev_str()

Return hardware revision in string format.

Args:

Nothing

Returns:

str: firmware revision

Raises:

Nothing

get_device_name()

Return the device name.

Args:

Nothing

Returns:

str: Device Name

Raises:

Nothing

get_device_serial_num()

Return the device serial number.

Args:

Nothing

Returns:

str: Device serial number

Raises:

Nothing

close()

Close usb device and cleanup.

Args:

Nothing

Returns:

Nothing

Raises:

Nothing

__del__()

Close device.

class expliot.core.interfaces.busauditor.BusAuditor

BusAuditor interface class.

get_interface_info()

Returns Device information in dictionary format.

Args:

Nothing

Return:

dict: The dict containing Device Name, FW, HW Revision, Services

Raises:

Nothing

jtag_scan(start, end, volts, include_trst=False)

Call BusAuditor driver to scan JTAG port pins using IDCODE and pattern scan.

Args:

start (int): First pin (channel number) to start the scan stop (int): Last pin (channel number) to stop the scan volts (str): Target voltage out include_trst (boolean): Include TRST pin in scan.

TRST pin excluded by default

Return:

list: The list of dict containing JTAG ID and pin info

Raises:

Nothing

swd_scan(start, end, volts)

Returns SWD IDCODE scan result in dictionary format.

Args:

start (int): First pin (channel number) to start the scan stop (int): Last pin (channel number) to stop the scan volts (str): Target voltage out

Return:

list: The list of dict containing SWD ID and pin info

Raises:

Nothing

uart_scan(start, end, volts)

Returns UART Rx, Tx and baudrate scan result in dictionary format.

Args:

start (int): First pin (channel number) to start the scan stop (int): Last pin (channel number) to stop the scan volts (str): Target voltage out

Return:

list: The list of dict containing UART baudrate and pin info

Raises:

Nothing

i2c_scan(start, end, volts)

Returns I2C device addr, and pin scan result in dictionary format.

Args:

start (int): First pin (channel number) to start the scan stop (int): Last pin (channel number) to stop the scan volts (str): Target voltage out

Return:

list: The list of dict containing I2C device addr and pin info

Raises:

Nothing

close()

Close USB port of BUS Auditor.

Args:

Nothing

Retrun:

Nothing

Raises:

Nothing