:py:mod:`expliot.core.interfaces.busauditor.stm32f411` ====================================================== .. py:module:: expliot.core.interfaces.busauditor.stm32f411 .. autoapi-nested-parse:: STM32F411 usb driver. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: expliot.core.interfaces.busauditor.stm32f411.STM32F411 .. py:class:: STM32F411 Bases: :py:obj:`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 .. py:attribute:: USB_DIR_OUT :annotation: = 64 .. py:attribute:: USB_DIR_IN :annotation: = 192 .. py:attribute:: USB_DATA_EP :annotation: = 129 .. py:attribute:: USB_VID :annotation: = 1155 .. py:attribute:: USB_PID :annotation: = 47648 .. py:attribute:: USB_OP_TIMEOUT_ERROR :annotation: = 110 .. py:attribute:: SRV_GET_REVISIONS :annotation: = 1 .. py:attribute:: SRV_GET_SERVICES :annotation: = 2 .. py:attribute:: SRV_JTAG_IDCODE_SCAN :annotation: = 17 .. py:attribute:: SRV_JTAG_PATTERN_SCAN :annotation: = 18 .. py:attribute:: SRV_JTAG_IDCODE_TRST_SCAN :annotation: = 19 .. py:attribute:: SRV_JTAG_PATTERN_TRST_SCAN :annotation: = 20 .. py:attribute:: SRV_SWD_IDCODE_SCAN :annotation: = 27 .. py:attribute:: SRV_UART_TX_SCAN :annotation: = 33 .. py:attribute:: SRV_UART_TX_RX_SCAN :annotation: = 34 .. py:attribute:: SRV_I2C_ADDR_SCAN :annotation: = 35 .. py:attribute:: SRV_SPI_SCAN :annotation: = 36 .. py:attribute:: SERVICE_RESP_BIT :annotation: = 128 .. py:attribute:: SRV_GET_REVISIONS_RESP .. py:attribute:: SRV_GET_SERVICES_RESP .. py:attribute:: SRV_GET_REVISIONS_RESP_LEN :annotation: = 8 .. py:attribute:: SRV_GET_SERVICES_RESP_LEN :annotation: = 7 .. py:attribute:: SRV_JTAG_SCAN_BIT :annotation: = 1 .. py:attribute:: SRV_SWD_SCAN_BIT :annotation: = 2 .. py:attribute:: SRV_UART_SCAN_BIT :annotation: = 16 .. py:attribute:: SRV_I2C_SCAN_BIT :annotation: = 32 .. py:attribute:: SRV_SPI_SCAN_BIT :annotation: = 16 .. py:attribute:: SRV_RESP_BYTE_1 :annotation: = 3 .. py:attribute:: SRV_RESP_BYTE_2 :annotation: = 4 .. py:attribute:: SRV_RESP_BYTE_3 :annotation: = 5 .. py:attribute:: SRV_RESP_BYTE_4 :annotation: = 6 .. py:attribute:: _srv_err :annotation: = ['No error', 'Service error', 'Device busy', 'Same start and end channel', 'Invalid start... .. py:method:: 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") .. py:method:: 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") .. py:method:: __build_jtag_idcode_dict(resp_array, include_trst=False) :staticmethod: 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 .. py:method:: 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 .. py:method:: __build_jtag_patten_dict(resp_array, include_trst=False) :staticmethod: 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 .. py:method:: 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 .. py:method:: __extract_jtag_idcode_pins_data(idcode_list, pattern_dict) :staticmethod: 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 .. py:method:: 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 .. py:method:: __build_swd_idcode_dict(resp_array) :staticmethod: 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 .. py:method:: 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 .. py:method:: __build_uart_pin_dict(resp_array) :staticmethod: 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 .. py:method:: 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 .. py:method:: 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 .. py:method:: 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 .. py:method:: __build_i2c_addr_dict(resp_array) :staticmethod: 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 .. py:method:: 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 .. py:method:: __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 .. py:method:: 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 .. py:method:: 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 .. py:method:: 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 .. py:method:: get_device_fw_rev_str() Return firmware revision in string format. Args: Nothing Returns: str: firmware revision Raises: Nothing .. py:method:: get_device_hw_rev_str() Return hardware revision in string format. Args: Nothing Returns: str: firmware revision Raises: Nothing .. py:method:: get_device_name() Return the device name. Args: Nothing Returns: str: Device Name Raises: Nothing .. py:method:: get_device_serial_num() Return the device serial number. Args: Nothing Returns: str: Device serial number Raises: Nothing .. py:method:: close() Close usb device and cleanup. Args: Nothing Returns: Nothing Raises: Nothing .. py:method:: __del__() Close device.