MBoot Interfaces#
Module implementing the Mboot communication protocol.
MBoot UART#
UART Mboot interface implementation.
- class spsdk.mboot.interfaces.uart.MbootUARTInterface(device)#
Bases:
MbootSerialProtocol
UART interface.
Initialize the MbootUARTInterface object.
- Parameters:
device (
SerialDevice
) – The device instance
- default_baudrate = 57600#
-
device:
SerialDevice
#
- identifier: str = 'uart'#
- classmethod scan(port=None, baudrate=None, timeout=None)#
Scan connected UART devices.
Returns list of serial ports with devices that respond to PING command. If ‘port’ is specified, only that serial port is checked If no devices are found, return an empty list.
- Parameters:
port (
Optional
[str
]) – name of preferred serial port, defaults to Nonebaudrate (
Optional
[int
]) – speed of the UART interface, defaults to 56700timeout (
Optional
[int
]) – timeout in milliseconds, defaults to 5000
- Return type:
list
[Self
]- Returns:
list of interfaces responding to the PING command
MBoot USB#
USB Mboot interface implementation.
- class spsdk.mboot.interfaces.usb.MbootUSBInterface(device)#
Bases:
MbootBulkProtocol
USB interface.
Initialize the MbootUSBInterface object.
- Parameters:
device (
UsbDevice
) – The device instance
- identifier: str = 'usb'#
-
device:
UsbDevice
#
- property name: str#
Get the name of the device.
- classmethod get_devices()#
Get list of all supported devices from the database.
- Return type:
dict
[str
,list
[UsbId
]]- Returns:
Dictionary containing device names with their usb configurations
- classmethod scan(device_id=None, timeout=None)#
Scan connected USB devices.
- Parameters:
device_id (
Optional
[str
]) – Device identifier <vid>, <vid:pid>, device/instance path, device name are supportedtimeout (
Optional
[int
]) – Read/write timeout
- Return type:
list
[Self
]- Returns:
list of matching RawHid devices
MBoot USBSIO#
USBSIO Mboot interface implementation.
- class spsdk.mboot.interfaces.usbsio.MbootUsbSioInterface(device)#
Bases:
MbootSerialProtocol
USBSIO interface.
Initialize the MbootSerialProtocol object.
- Parameters:
device (
DeviceBase
) – The device instance
-
device:
Union
[UsbSioI2CDevice
,UsbSioSPIDevice
]#
- class spsdk.mboot.interfaces.usbsio.MbootUsbSioI2CInterface(device)#
Bases:
MbootUsbSioInterface
USBSIO I2C interface.
Initialize the UsbSioI2CDevice object.
- Parameters:
device (
UsbSioI2CDevice
) – The device instance
-
device:
UsbSioI2CDevice
#
- identifier: str = 'usbsio_i2c'#
- classmethod scan(config, timeout=None)#
Scan connected USB-SIO bridge devices.
- Parameters:
config (
str
) – Configuration string identifying spi or i2c SIO interface and could filter out USB devicestimeout (
Optional
[int
]) – Read timeout in milliseconds, defaults to 5000
- Return type:
list
[Self
]- Returns:
List of interfaces
- class spsdk.mboot.interfaces.usbsio.MbootUsbSioSPIInterface(device)#
Bases:
MbootUsbSioInterface
USBSIO I2C interface.
Initialize the UsbSioSPIDevice object.
- Parameters:
device (
UsbSioSPIDevice
) – The device instance
- FRAME_START_NOT_READY_LIST = [0, 255]#
-
device:
UsbSioSPIDevice
#
- identifier: str = 'usbsio_spi'#
- classmethod scan(config, timeout=None)#
Scan connected USB-SIO bridge devices.
- Parameters:
config (
str
) – Configuration string identifying spi or i2c SIO interface and could filter out USB devicestimeout (
Optional
[int
]) – Read timeout in milliseconds, defaults to 5000
- Return type:
list
[Self
]- Returns:
List of interfaces
MBoot SDIO#
Sdio Mboot interface implementation.
- class spsdk.mboot.interfaces.sdio.MbootSdioInterface(device)#
Bases:
MbootSerialProtocol
Sdio interface.
Initialize the MbootSdioInterface object.
- Parameters:
device (
SdioDevice
) – The device instance
- identifier: str = 'sdio'#
-
device:
SdioDevice
#
- sdio_devices = {'RW61x': (1137, 521)}#
- property name: str#
Get the name of the device.
- Returns:
Name of the device.
- classmethod scan(device_path, timeout=None)#
Scan connected SDIO devices.
- Parameters:
device_path (
str
) – device path stringtimeout (
Optional
[int
]) – Interface timeout
- Return type:
list
[Self
]- Returns:
matched SDIO device
- open()#
Open the interface.
- Return type:
None
- read(length=None)#
Read data on the IN endpoint associated to the HID interface.
- Return type:
Union
[CmdResponse
,bytes
]- Returns:
Return CmdResponse object.
- Raises:
McuBootConnectionError – Raises an error if device is not opened for reading
McuBootConnectionError – Raises if device is not available
McuBootDataAbortError – Raises if reading fails
TimeoutError – When timeout occurs
MBoot BUSPAL#
Buspal Mboot device implementation.
- class spsdk.mboot.interfaces.buspal.SpiModeCommand(value)#
Bases:
Enum
Spi mode commands.
- exit = 0#
- version = 1#
- chip_select = 2#
- sniff = 12#
- bulk_transfer = 16#
- config_periph = 64#
- set_speed = 96#
- config_spi = 128#
- write_then_read = 4#
- class spsdk.mboot.interfaces.buspal.SpiConfigShift(value)#
Bases:
Enum
Spi configuration shifts for the mask.
- direction = 0#
- phase = 1#
- polarity = 2#
- class spsdk.mboot.interfaces.buspal.SpiClockPolarity(value)#
Bases:
Enum
SPI clock polarity configuration.
- active_high = 0#
- active_low = 1#
- class spsdk.mboot.interfaces.buspal.SpiClockPhase(value)#
Bases:
Enum
SPI clock phase configuration.
- first_edge = 0#
- second_edge = 1#
- class spsdk.mboot.interfaces.buspal.SpiShiftDirection(value)#
Bases:
Enum
SPI clock phase configuration.
- msb_first = 0#
- lsb_first = 1#
- class spsdk.mboot.interfaces.buspal.SpiConfiguration#
Bases:
object
Dataclass to store SPI configuration.
-
speed:
int
#
-
polarity:
SpiClockPolarity
#
-
phase:
SpiClockPhase
#
-
direction:
SpiShiftDirection
#
-
speed:
- class spsdk.mboot.interfaces.buspal.BBConstants(value)#
Bases:
Enum
Constants.
- reset_count = 20#
- response_ok = 1#
- bulk_transfer_max = 4096#
- packet_timeout_ms = 10#
- class spsdk.mboot.interfaces.buspal.Response(value)#
Bases:
str
,Enum
Response to enter bit bang mode.
- BITBANG = 'BBIO1'#
- SPI = 'SPI1'#
- I2C = 'I2C1'#
- class spsdk.mboot.interfaces.buspal.BuspalMode(value)#
Bases:
Enum
Bit Bang mode command.
- RESET = 0#
- SPI = 1#
- I2C = 2#
- class spsdk.mboot.interfaces.buspal.MbootBuspalProtocol(device)#
Bases:
MbootSerialProtocol
Mboot Serial protocol.
Initialize the MbootBuspalProtocol object.
- Parameters:
device (
SerialDevice
) – The device instance
- default_baudrate = 57600#
- default_timeout = 5000#
-
device:
SerialDevice
#
-
mode:
BuspalMode
#
- open()#
Open the interface.
- Return type:
None
- classmethod scan(port=None, props=None, timeout=None)#
Scan connected serial ports and set BUSPAL properties.
Returns list of serial ports with devices that respond to BUSPAL communication protocol. If ‘port’ is specified, only that serial port is checked If no devices are found, return an empty list.
- Parameters:
port (
Optional
[str
]) – name of preferred serial port, defaults to Nonetimeout (
Optional
[int
]) – timeout in millisecondsprops (
Optional
[list
[str
]]) – buspal target properties
- Return type:
list
[Self
]- Returns:
list of available interfaces
- class spsdk.mboot.interfaces.buspal.MbootBuspalSPIInterface(device)#
Bases:
MbootBuspalProtocol
BUSPAL SPI interface.
Initialize the BUSPAL SPI interface.
- Parameters:
device (
SerialDevice
) – The device instance
- TARGET_SETTINGS = ['speed', 'polarity', 'phase', 'direction']#
- HDR_FRAME_RETRY_CNT = 3#
- ACK_WAIT_DELAY = 0.01#
-
device:
SerialDevice
#
- identifier: str = 'buspal_spi'#
- class spsdk.mboot.interfaces.buspal.I2cModeCommand(value)#
Bases:
Enum
I2c mode commands.
- exit = 0#
- version = 1#
- start_bit = 2#
- stop_bit = 3#
- read_byte = 4#
- ack_bit = 6#
- nack_bit = 7#
- bus_sniff = 15#
- bulk_write = 16#
- configure_periph = 64#
- pull_up_select = 80#
- set_speed = 96#
- set_address = 112#
- write_then_read = 8#
- class spsdk.mboot.interfaces.buspal.MbootBuspalI2CInterface(device)#
Bases:
MbootBuspalProtocol
BUSPAL I2C interface.
Initialize the BUSPAL I2C interface.
- Parameters:
port – name of the serial port, defaults to None
timeout – read/write timeout in milliseconds
- TARGET_SETTINGS = ['speed', 'address']#
- HDR_FRAME_RETRY_CNT = 3#
-
device:
SerialDevice
#
- identifier: str = 'buspal_i2c'#
Mboot CAN#
CAN Mboot interface implementation.
- class spsdk.mboot.interfaces.can_interface.MbootCANInterface(device)#
Bases:
MbootSerialProtocol
UART interface.
Initialize the MbootCANInterface object.
- Parameters:
device (
CANDevice
) – The device instance
- default_bitrate = 1000000#
-
device:
CANDevice
#
- identifier: str = 'can'#
- classmethod scan(interface, channel=None, bitrate=None, timeout=None, txid=None, rxid=None)#
Scan connected UART devices.
Returns list of CAN interfaces with devices that respond to PING command. If no devices are found, return an empty list.
- Parameters:
interface (
str
) – name of preferred CAN interfacechannel (
Union
[str
,int
,None
]) – channel of the CAN interfacebitrate (
Optional
[int
]) – bitrate of the CAN interfacetimeout (
Optional
[int
]) – timeout for the scantxid (
Optional
[int
]) – default arbitration ID for TXrxid (
Optional
[int
]) – default arbitration ID for RX
- Return type:
list
[Self
]- Returns:
list of interfaces responding to the PING command