expliot.core.interfaces.busauditor.stm32f411

STM32F411 usb driver.

Classes

BusAuditorServices

Class to store BusAuditor's Services.

STM32F411

Driver for STM32F411 BusAuditor Hardware.

Module Contents

class expliot.core.interfaces.busauditor.stm32f411.BusAuditorServices

Bases: BaseServices

Class to store BusAuditor’s Services.

JTAG_SCAN = 'jtag_port_scan'
SWD_SCAN = 'swd_port_scan'
UART_SCAN = 'uart_port_scan'
I2C_SCAN = 'i2c_bus_scan'
class expliot.core.interfaces.busauditor.stm32f411.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)

Extract data method compares matched pins.

Sources are pattern_dict and 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)

Initiate a 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)

Initiate a 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)

Initiate an 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)

Initiate an 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)

Scan UART of a device.

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)

Initiate an 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)

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.