MBoot Interfaces

Contents

MBoot Interfaces#

SPSDK Mboot communication interfaces.

This module provides interface implementations for the Mboot communication protocol across different transport layers and connection types.

MBoot UART#

SPSDK UART interface implementation for MBoot protocol communication.

This module provides UART-based communication interface for MBoot protocol, enabling secure provisioning operations over serial connections.

class spsdk.mboot.interfaces.uart.MbootUARTInterface(device)#

Bases: MbootSerialProtocol

SPSDK UART interface for MBoot protocol communication.

This class provides UART-based communication interface for MBoot protocol operations, enabling device discovery, connection management, and data exchange over serial ports.

Variables:
  • default_baudrate – Default UART communication speed (57600 baud).

  • identifier – Interface type identifier string.

Initialize the MbootUARTInterface object.

Parameters:

device (SerialDevice) – The serial device instance to use for UART communication.

Raises:

AssertionError – If device is not a SerialDevice 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 None.

  • baudrate (Optional[int]) – Speed of the UART interface, defaults to 56700.

  • timeout (Optional[int]) – Timeout in milliseconds, defaults to 5000.

Return type:

list[Self]

Returns:

List of interfaces responding to the PING command.

MBoot USB#

USB interface implementation for MBoot communication protocol.

This module provides USB-based communication interface for MBoot protocol, enabling secure provisioning operations over USB connections with NXP MCUs.

class spsdk.mboot.interfaces.usb.MbootUSBInterface(device)#

Bases: MbootBulkProtocol

MbootUSB interface for NXP MCU communication.

This class provides USB communication interface for MBoot protocol operations, enabling device discovery, connection management, and data transfer over USB. It extends the bulk protocol implementation with USB-specific functionality for scanning and identifying connected NXP devices.

Variables:

identifier – Interface type identifier for USB communication.

Initialize the MbootUSBInterface object.

Parameters:

device (UsbDevice) – The USB device instance to be used for communication.

Raises:

AssertionError – If device is not an instance of UsbDevice.

identifier: str = 'usb'#
device: UsbDevice#
property name: str#

Get the name of the USB device.

Searches through available USB device configurations to find a matching device based on VID and PID, then returns the corresponding device name.

Returns:

Name of the device if found in configurations, otherwise “Unknown”.

classmethod get_devices()#

Get list of all supported devices from the database.

The method retrieves device information from the database manager and filters devices that have USB configurations available for mboot interface.

Return type:

dict[str, list[UsbId]]

Returns:

Dictionary with device names as keys and lists of UsbId objects as values.

classmethod scan(device_id=None, timeout=None)#

Scan connected USB devices.

Searches for and identifies USB devices that match the specified criteria, creating interface instances for each discovered device.

Parameters:
  • device_id (Optional[str]) – Device identifier supporting multiple formats: <vid>, <vid:pid>, device/instance path, or device name

  • timeout (Optional[int]) – Read/write timeout in seconds for device communication

Return type:

list[Self]

Returns:

List of matching RawHid device interface instances

MBoot USBSIO#

SPSDK USBSIO interface implementation for MBoot protocol communication.

This module provides USBSIO-based communication interfaces for MBoot protocol, supporting both I2C and SPI transport layers through USB-to-serial bridge devices.

class spsdk.mboot.interfaces.usbsio.MbootUsbSioInterface(device)#

Bases: MbootSerialProtocol

USBSIO interface for MBoot communication.

This class provides MBoot protocol communication over USBSIO devices, supporting both I2C and SPI interfaces with enhanced interrupt-based data waiting capabilities.

Initialize the MbootSerialProtocol object.

Parameters:

device (DeviceBase) – The device instance to be used for communication.

device: Union[UsbSioI2CDevice, UsbSioSPIDevice]#
class spsdk.mboot.interfaces.usbsio.MbootUsbSioI2CInterface(device)#

Bases: MbootUsbSioInterface

MBOOT USB-SIO I2C communication interface.

This class provides I2C communication capabilities for MBOOT protocol over USB-SIO bridge devices, enabling secure provisioning operations through I2C connections.

Variables:

identifier – Interface type identifier for USB-SIO I2C communication.

Initialize the UsbSioI2C interface.

Parameters:

device (UsbSioI2CDevice) – The USB-SIO I2C device instance to be used for communication.

device: UsbSioI2CDevice#
identifier: str = 'usbsio_i2c'#
classmethod scan(config, timeout=None)#

Scan connected USB-SIO bridge devices.

The method scans for available USB-SIO bridge devices that match the specified configuration and creates interface instances for communication.

Parameters:
  • config (str) – Configuration string identifying SPI or I2C SIO interface and could filter out USB devices.

  • timeout (Optional[int]) – Read timeout in milliseconds, defaults to 5000.

Return type:

list[Self]

Returns:

List of USB-SIO interface instances.

class spsdk.mboot.interfaces.usbsio.MbootUsbSioSPIInterface(device)#

Bases: MbootUsbSioInterface

SPSDK MBoot USB-SIO SPI interface implementation.

This class provides SPI communication interface for MBoot protocol over USB-SIO bridge devices, enabling secure provisioning operations through SPI transport.

Variables:
  • FRAME_START_NOT_READY_LIST – Valid frame start bytes indicating device not ready state.

  • identifier – String identifier for this interface type.

Initialize the UsbSioSPIDevice object.

Parameters:

device (UsbSioSPIDevice) – The UsbSioSPIDevice instance to be used for SPI communication.

FRAME_START_NOT_READY_LIST = [0, 255]#
device: UsbSioSPIDevice#
identifier: str = 'usbsio_spi'#
classmethod scan(config, timeout=None)#

Scan connected USB-SIO bridge devices.

The method scans for available USB-SIO bridge devices that match the specified configuration and filters them to return only SPI-compatible devices.

Parameters:
  • config (str) – Configuration string identifying SPI or I2C SIO interface and could filter out USB devices

  • timeout (Optional[int]) – Read timeout in milliseconds, defaults to 5000

Return type:

list[Self]

Returns:

List of USB-SIO interface instances

MBoot SDIO#

SPSDK SDIO interface implementation for MBoot protocol communication.

This module provides SDIO (Secure Digital Input Output) interface functionality for communicating with NXP MCUs using the MBoot protocol through SDIO connections.

class spsdk.mboot.interfaces.sdio.MbootSdioInterface(device)#

Bases: MbootSerialProtocol

SPSDK SDIO interface for MBoot protocol communication.

This class provides SDIO (Secure Digital Input Output) communication interface for MBoot protocol operations, enabling secure provisioning and device communication over SDIO connections.

Variables:
  • identifier – Interface type identifier string.

  • sdio_devices – Dictionary mapping of supported SDIO device configurations.

Initialize the MbootSdioInterface object.

Parameters:

device (SdioDevice) – The SDIO device instance to be used for communication.

Raises:

SPSDKError – When SDIO interface is used on unsupported Windows platform.

identifier: str = 'sdio'#
device: SdioDevice#
sdio_devices = {'RW61x': (1137, 521)}#
property name: str#

Get the name of the SDIO device.

Searches through the known SDIO devices dictionary to find a matching device based on vendor ID and product ID, returning the corresponding device name.

Returns:

Name of the device if found in known devices, otherwise “Unknown”.

classmethod scan(device_path, timeout=None)#

Scan connected SDIO devices.

Parameters:
  • device_path (str) – Device path string to scan for SDIO devices.

  • timeout (Optional[int]) – Interface timeout in seconds, defaults to None for no timeout.

Return type:

list[Self]

Returns:

List of matched SDIO device instances.

open()#

Open the SDIO interface.

Establishes connection to the SDIO device and prepares it for communication.

Raises:

SPSDKError – If the SDIO device cannot be opened or is not available.

Return type:

None

read(length=None)#

Read data from SDIO interface.

Reads data frame from the SDIO device, validates CRC, and returns either a parsed command response or raw data based on frame type.

Parameters:

length (Optional[int]) – Optional length parameter (currently unused).

Raises:
Return type:

Union[CmdResponse, bytes]

Returns:

CmdResponse object for command frames or raw bytes for data frames.

MBoot BUSPAL#

SPSDK Buspal interface implementation for MBoot protocol communication.

This module provides Buspal-based communication interfaces for MBoot protocol, supporting SPI and I2C communication modes. It includes configuration management, protocol handling, and device interaction capabilities for NXP MCU provisioning through Buspal bridge devices.

class spsdk.mboot.interfaces.buspal.SpiModeCommand(value)#

Bases: Enum

SPI mode command enumeration for Bus Pal interface communication.

This enumeration defines the command codes used to control SPI operations through the Bus Pal interface, including configuration, data transfer, and peripheral control 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 bit shift positions for mask operations.

This enumeration defines the bit shift positions used when constructing or parsing SPI configuration masks in the buspal interface.

direction = 0#
phase = 1#
polarity = 2#
class spsdk.mboot.interfaces.buspal.SpiClockPolarity(value)#

Bases: Enum

SPI clock polarity configuration for buspal communication.

This enumeration defines the available clock polarity settings for SPI communication, determining whether the clock signal is active-high or active-low during data transmission.

active_high = 0#
active_low = 1#
class spsdk.mboot.interfaces.buspal.SpiClockPhase(value)#

Bases: Enum

SPI clock phase configuration for buspal communication.

This enumeration defines the timing relationship between the SPI clock signal and data sampling, controlling when the first clock edge occurs relative to the data transfer cycle.

first_edge = 0#
second_edge = 1#
class spsdk.mboot.interfaces.buspal.SpiShiftDirection(value)#

Bases: Enum

SPI shift direction configuration for data transfer bit ordering.

This enumeration defines the bit order for SPI data transfers, specifying whether data transmission begins with the most significant bit or least significant bit.

msb_first = 0#
lsb_first = 1#
class spsdk.mboot.interfaces.buspal.SpiConfiguration#

Bases: object

SPI Configuration container for BusPal interface.

This class holds the complete SPI communication parameters including clock speed, polarity, phase, and data shift direction for configuring SPI operations in BusPal interface.

speed: int#
polarity: SpiClockPolarity#
phase: SpiClockPhase#
direction: SpiShiftDirection#
class spsdk.mboot.interfaces.buspal.BBConstants(value)#

Bases: Enum

BusPal Binary Mode constants and configuration values.

This enumeration defines essential constants used for BusPal binary mode communication including reset parameters, response codes, transfer limits, and timing configurations.

reset_count = 20#
response_ok = 1#
bulk_transfer_max = 4096#
packet_timeout_ms = 10#
class spsdk.mboot.interfaces.buspal.Response(value)#

Bases: str, Enum

BusPal communication response codes.

Enumeration of standard response strings returned by BusPal devices when entering different communication modes including bit bang, SPI, and I2C.

BITBANG = 'BBIO1'#
SPI = 'SPI1'#
I2C = 'I2C1'#
class spsdk.mboot.interfaces.buspal.BuspalMode(value)#

Bases: Enum

Buspal communication mode enumeration.

This enumeration defines the available communication modes for Buspal interface, including reset mode and binary communication protocols for SPI and I2C.

RESET = 0#
SPI = 1#
I2C = 2#
class spsdk.mboot.interfaces.buspal.MbootBuspalProtocol(device)#

Bases: MbootSerialProtocol

Mboot BUSPAL communication protocol handler.

This class implements the BUSPAL (Bus Protocol Abstraction Layer) interface for Mboot communication, extending the serial protocol with BUSPAL-specific functionality including mode switching, device scanning, and protocol initialization.

Variables:
  • default_baudrate – Default communication baudrate (57600).

  • default_timeout – Default timeout in milliseconds (5000).

Initialize the MbootBuspalProtocol object.

Parameters:

device (SerialDevice) – The serial device instance to communicate through.

Raises:

SPSDKError – If device initialization fails.

default_baudrate = 57600#
default_timeout = 5000#
device: SerialDevice#
mode: BuspalMode#
open()#

Open the interface.

Initialize the buspal interface by opening the underlying device and configuring it for communication. The method first resets the device by entering reset mode, then switches to bit-bang mode for debugging, and finally enters the target communication mode.

Raises:

SPSDKError – If device opening or mode switching fails.

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 None.

  • props (Optional[list[str]]) – BUSPAL target properties, defaults to None.

  • timeout (Optional[int]) – Timeout in milliseconds, defaults to None.

Return type:

list[Self]

Returns:

List of available BUSPAL interfaces.

class spsdk.mboot.interfaces.buspal.MbootBuspalSPIInterface(device)#

Bases: MbootBuspalProtocol

BUSPAL SPI interface for MBoot communication.

This class implements SPI communication protocol through BUSPAL interface for MBoot operations. It handles SPI-specific configuration including clock polarity, phase, direction, and speed settings, and manages frame transmission with retry mechanisms.

Variables:
  • TARGET_SETTINGS – List of configurable SPI parameters.

  • HDR_FRAME_RETRY_CNT – Number of retry attempts for frame transmission.

  • ACK_WAIT_DELAY – Delay in seconds between acknowledgment attempts.

Initialize the BUSPAL SPI interface.

Parameters:

device (SerialDevice) – The serial device instance to use for communication.

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 command enumeration for Bus Pirate communication protocol.

This enumeration defines the command codes used to control I2C operations through the Bus Pirate interface, including basic I2C operations like start/stop bits, read/write operations, bus configuration, and advanced features like bulk transfers and bus sniffing.

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 for MBoot communication.

This class provides I2C communication capabilities through BUSPAL protocol for MBoot operations. It handles I2C-specific configuration including speed and address settings, and manages frame transmission with retry logic.

Variables:
  • TARGET_SETTINGS – List of configurable I2C parameters (speed, address).

  • HDR_FRAME_RETRY_CNT – Number of retry attempts for frame transmission.

Initialize the BUSPAL I2C interface.

Parameters:

device (SerialDevice) – Serial device instance for communication.

Raises:

SPSDKError – If device initialization fails.

TARGET_SETTINGS = ['speed', 'address']#
HDR_FRAME_RETRY_CNT = 3#
device: SerialDevice#
identifier: str = 'buspal_i2c'#

Mboot CAN#

SPSDK CAN interface implementation for MBoot protocol.

This module provides CAN (Controller Area Network) communication interface for MBoot protocol operations, enabling secure provisioning and device management over CAN bus networks.

class spsdk.mboot.interfaces.can_interface.MbootCANInterface(device)#

Bases: MbootSerialProtocol

MbootCANInterface for CAN communication with MCU bootloader.

This class provides CAN (Controller Area Network) interface implementation for communicating with NXP MCU bootloaders using the MBoot protocol. It handles CAN device scanning, connection management, and protocol communication over CAN bus.

Variables:
  • default_bitrate – Default CAN bus bitrate (1,000,000 bps).

  • identifier – Interface type identifier string.

Initialize the MbootCANInterface object.

Parameters:

device (CANDevice) – The CAN device instance to be used for communication.

Raises:

AssertionError – If device is not an instance of CANDevice.

default_bitrate = 1000000#
device: CANDevice#
identifier: str = 'can'#
classmethod scan(interface, channel=None, bitrate=None, timeout=None, txid=None, rxid=None)#

Scan connected CAN 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 interface.

  • channel (Union[int, str, None]) – Channel of the CAN interface.

  • bitrate (Optional[int]) – Bitrate of the CAN interface.

  • timeout (Optional[int]) – Timeout for the scan operation.

  • txid (Optional[int]) – Default arbitration ID for TX messages.

  • rxid (Optional[int]) – Default arbitration ID for RX messages.

Return type:

list[Self]

Returns:

List of CAN interfaces responding to the PING command.