How to use the pyocd.core.exceptions.ProbeError function in pyocd

To help you get started, we’ve selected a few pyocd examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mbedmicro / pyOCD / pyocd / core / exceptions.py View on Github external
"""! @brief Any sort of timeout"""
    pass

class TimeoutError(Error):
    """! @brief Any sort of timeout"""
    pass

class TargetSupportError(Error):
    """! @brief Error related to target support"""
    pass

class ProbeError(Error):
    """! @brief Error communicating with the debug probe"""
    pass

class ProbeDisconnected(ProbeError):
    """! @brief The connection to the debug probe was lost"""
    pass

class TargetError(Error):
    """! @brief An error that happens on the target"""
    pass

class DebugError(TargetError):
    """! @brief Error controlling target debug resources"""
    pass

class TransferError(DebugError):
    """! @brief Error ocurred with a transfer over SWD or JTAG"""
    pass

class TransferTimeoutError(TransferError):
github mbedmicro / pyOCD / pyocd / probe / stlink / stlink.py View on Github external
def set_jtag_frequency(self, freq=1120000):
        with self._lock:
            if self._hw_version >= 3:
                self.set_com_frequency(self.Protocol.JTAG, freq)
            else:
                for f, d in JTAG_FREQ_MAP.items():
                    if freq >= f:
                        response = self._device.transfer([Commands.JTAG_COMMAND, Commands.JTAG_SET_FREQ, d], readSize=2)
                        self._check_status(response)
                        return
                else:
                    raise exceptions.ProbeError("Selected JTAG frequency is too low")
github mbedmicro / pyOCD / pyocd / probe / stlink / usb.py View on Github external
# Debug interface is always interface 0, alt setting 0.
        config = self._dev.get_active_configuration()
        interface = config[(self.DEBUG_INTERFACE_NUMBER, 0)]
        
        # Look up endpoint objects.
        for endpoint in interface:
            if endpoint.bEndpointAddress == self._info.out_ep:
                self._ep_out = endpoint
            elif endpoint.bEndpointAddress == self._info.in_ep:
                self._ep_in = endpoint
            elif endpoint.bEndpointAddress == self._info.swv_ep:
                self._ep_swv = endpoint
        
        if not self._ep_out:
            raise exceptions.ProbeError("Unable to find OUT endpoint")
        if not self._ep_in:
            raise exceptions.ProbeError("Unable to find IN endpoint")

        self._max_packet_size = self._ep_in.wMaxPacketSize
        
        # Claim this interface to prevent other processes from accessing it.
        usb.util.claim_interface(self._dev, self.DEBUG_INTERFACE_NUMBER)
        
        self._flush_rx()
        self._closed = False
github mbedmicro / pyOCD / pyocd / probe / stlink / stlink.py View on Github external
#   1: SWIM version
            #   2: JTAG/SWD version
            #   3: MSC/VCP version
            #   4: Bridge version
            #   5-7: reserved
            #   8-9: ST_VID
            #   10-11: STLINK_PID
            response = self._device.transfer([Commands.GET_VERSION_EXT], readSize=12)
            hw_vers, _, self._jtag_version, self._msc_version = struct.unpack('<4B', response[0:4])

        self._version_str = "V%dJ%dM%d" % (self._hw_version, self._jtag_version, self._msc_version)
        LOG.debug("STLink probe %s firmware version: %s", self.serial_number, self._version_str)

        # Check versions.
        if self._jtag_version == 0:
            raise exceptions.ProbeError("%s firmware does not support JTAG/SWD. Please update"
                "to a firmware version that supports JTAG/SWD" % (self._version_str))
        if not self._check_version(self.MIN_JTAG_VERSION):
            raise exceptions.ProbeError("STLink %s is using an unsupported, older firmware version. "
                "Please update to the latest STLink firmware. Current version is %s, must be at least version v2J%d.)" 
                % (self.serial_number, self._version_str, self.MIN_JTAG_VERSION))
github XIVN1987 / DAPCmdr / pyocd / probe / stlink / stlink.py View on Github external
# Handle transfer faults specially so we can assign the address info.
                if status != Status.JTAG_OK:
                    error_message = Status.get_error_message(status)
                    if status in self._MEM_FAULT_ERRORS:
                        # Clear sticky errors.
                        self._clear_sticky_error()
                
                        exc = exceptions.TransferFaultError()
                        exc.fault_address = faultAddr
                        exc.fault_length = thisTransferSize - (faultAddr - addr)
                        raise exc
                    elif status in self._ERROR_CLASSES:
                        raise self._ERROR_CLASSES[status](error_message)
                    elif status != Status.JTAG_OK:
                        raise exceptions.ProbeError(error_message)
github XIVN1987 / DAPCmdr / pyocd / probe / stlink / usb.py View on Github external
# Debug interface is always interface 0, alt setting 0.
        config = self._dev.get_active_configuration()
        interface = config[(self.DEBUG_INTERFACE_NUMBER, 0)]
        
        # Look up endpoint objects.
        for endpoint in interface:
            if endpoint.bEndpointAddress == self._info.out_ep:
                self._ep_out = endpoint
            elif endpoint.bEndpointAddress == self._info.in_ep:
                self._ep_in = endpoint
            elif endpoint.bEndpointAddress == self._info.swv_ep:
                self._ep_swv = endpoint
        
        if not self._ep_out:
            raise exceptions.ProbeError("Unable to find OUT endpoint")
        if not self._ep_in:
            raise exceptions.ProbeError("Unable to find IN endpoint")

        self._max_packet_size = self._ep_in.wMaxPacketSize
        
        # Claim this interface to prevent other processes from accessing it.
        usb.util.claim_interface(self._dev, self.DEBUG_INTERFACE_NUMBER)
        
        self._flush_rx()
        self._closed = False
github mbedmicro / pyOCD / pyocd / probe / stlink / stlink.py View on Github external
def set_swd_frequency(self, freq=1800000):
        with self._lock:
            if self._hw_version >= 3:
                self.set_com_frequency(self.Protocol.JTAG, freq)
            else:
                for f, d in SWD_FREQ_MAP.items():
                    if freq >= f:
                        response = self._device.transfer([Commands.JTAG_COMMAND, Commands.SWD_SET_FREQ, d], readSize=2)
                        self._check_status(response)
                        return
                else:
                    raise exceptions.ProbeError("Selected SWD frequency is too low")