SDP Interfaces#
SPSDK SDP communication interfaces.
This module provides interface implementations for Serial Download Protocol (SDP) communication, including UART and USB interface options for connecting to NXP MCUs.
SDP UART#
SPSDK UART interface implementation for Serial Download Protocol.
This module provides UART communication interface for SDP operations, enabling serial communication with NXP MCUs through UART protocol.
- class spsdk.sdp.interfaces.uart.SdpUARTInterface(device)#
Bases:
SDPSerialProtocolSDP UART interface for serial communication with NXP MCU devices.
This class provides UART-based communication interface for Serial Download Protocol (SDP) operations. It handles device scanning, connection management, and serial communication with NXP microcontrollers supporting SDP over UART.
- Variables:
default_baudrate – Default UART communication speed (115200 bps).
identifier – Interface type identifier string.
Initialize the SdpUARTInterface object.
- Parameters:
device (
SerialDevice) – The serial device instance to be used for UART communication.- Raises:
AssertionError – If device is not an instance of SerialDevice.
- default_baudrate = 115200#
-
device:
SerialDevice#
-
identifier:
str= 'uart'#
- classmethod scan(port=None, baudrate=None, timeout=None)#
Scan connected serial ports.
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.
SDP USB#
USB interface implementation for Serial Download Protocol (SDP).
This module provides USB communication interface for SDP operations, enabling secure provisioning and device management over USB connections for NXP MCU devices.
- class spsdk.sdp.interfaces.usb.SdpUSBInterface(device)#
Bases:
SDPBulkProtocolSDP USB interface for NXP MCU communication.
This class provides USB-based communication interface for Serial Download Protocol (SDP) operations. It handles USB device discovery, connection management, and data transfer for secure provisioning and firmware download operations across NXP MCU portfolio.
- Variables:
identifier – Interface type identifier for USB communication.
Initialize the SdpUSBInterface object.
- Parameters:
device (
UsbDevice) – The USB device instance to be used for SDP communication.
-
device:
UsbDevice#
-
identifier:
str= 'usb'#
- 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 for SDP (Serial Download Protocol) or SDPS (Serial Download Protocol Stream) interfaces.
- 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.
- Parameters:
device_id (
Optional[str]) – Device identifier <vid>, <vid:pid>, device/instance path, device name are supported.timeout (
Optional[int]) – Read/write timeout in seconds.
- Return type:
list[Self]- Returns:
List of matching RawHid devices.
SDP Protocol#
SDP protocol base implementation.
This module provides the base class for Serial Download Protocol (SDP) implementations in SPSDK, defining the common interface and functionality for SDP communication.
- class spsdk.sdp.protocol.base.SDPProtocolBase(device)#
Bases:
ProtocolBaseSDP protocol base class.
This class provides the foundation for Serial Download Protocol (SDP) implementations, offering common functionality and interface for SDP communication with NXP devices.
- Variables:
expect_status – Flag indicating whether status response is expected from device.
Initialize the MbootSerialProtocol object.
- Parameters:
device (
DeviceBase) – The device instance to be used for communication.
- configure(config)#
Configure device with provided parameters.
- Parameters:
config (
dict) – Dictionary containing configuration parameters for the device.- Raises:
SPSDKError – If configuration fails or invalid parameters are provided.
- Return type:
None
- expect_status = True#
SDP Bulk#
SDP bulk protocol implementation for secure device communication.
This module provides the SDPBulkProtocol class that implements bulk transfer protocol for Serial Download Protocol (SDP) operations, enabling efficient data transfer with NXP MCU devices during provisioning and programming tasks.
- class spsdk.sdp.protocol.bulk_protocol.SDPBulkProtocol(device)#
Bases:
SDPProtocolBaseSDP Bulk Protocol implementation for NXP MCU communication.
This class provides bulk transfer protocol implementation for Serial Download Protocol (SDP) communication with NXP microcontrollers. It handles frame creation, data encapsulation, and command/response processing over bulk transfer interfaces.
Initialize the MbootSerialProtocol object.
- Parameters:
device (
DeviceBase) – The device instance to be used for communication.
- close()#
Close the interface.
Closes the underlying device connection and releases any associated resources.
- Return type:
None
- configure(config)#
Configure HID report data with communication parameters.
The method updates the global HID_REPORT dictionary with command and data endpoint configurations based on the provided parameters.
- Parameters:
config (
dict) – Configuration dictionary containing ‘hid_ep1’ and ‘pack_size’ keys for HID endpoint and packet size settings- Return type:
None
- property is_opened: bool#
Indicates whether the interface is open.
- Returns:
True if interface is open, False otherwise.
- open()#
Open the interface.
Establishes connection to the underlying device for communication.
- Raises:
SPSDKError – If the device cannot be opened or is already in use.
- Return type:
None
- read(length=None)#
Read data from device.
Reads raw data from the device and decodes it into a command response format. The method reads up to 1024 bytes from the device and processes the response.
- Parameters:
length (
Optional[int]) – Maximum number of bytes to read (currently unused, reserved for future use).- Return type:
- Returns:
Decoded command response from the device.
- write_command(packet)#
Encapsulate command into frames and send them to device.
- Parameters:
packet (
CmdPacketBase) – Command packet object to be sent- Raises:
SPSDKAttributeError – Command packet contains no data to be sent
- Return type:
None
- write_data(data)#
Encapsulate data into frames and send them to device.
The method breaks down the input data into HID report frames using the DATA report configuration and transmits each frame sequentially to the connected device.
- Parameters:
data (
bytes) – Binary data to be sent to the device.- Raises:
SPSDKError – If device write operation fails.
- Return type:
None
SDP Serial#
SDP serial protocol implementation.
This module provides the serial communication protocol implementation for Serial Download Protocol (SDP) operations, enabling communication with NXP MCUs over serial interfaces.
- class spsdk.sdp.protocol.serial_protocol.SDPSerialProtocol(device)#
Bases:
SDPProtocolBaseSDP Serial protocol implementation for NXP MCU communication.
This class provides a concrete implementation of the SDP (Serial Download Protocol) for serial communication interfaces. It handles frame encapsulation, command transmission, and response reading over serial connections to NXP microcontrollers.
Initialize the MbootSerialProtocol object.
- Parameters:
device (
DeviceBase) – The device instance to be used for communication.
- close()#
Close the serial communication interface.
This method properly closes the underlying serial device connection, ensuring all resources are released and the communication channel is terminated cleanly.
- Raises:
SPSDKError – If closing the device fails.
- Return type:
None
- property is_opened: bool#
Indicates whether the serial interface is open.
- Returns:
True if the interface is open, False otherwise.
- open()#
Open the interface.
Establishes connection to the serial device and prepares it for communication.
- Raises:
SPSDKConnectionError – If the device cannot be opened or is already in use.
SPSDKError – If there’s a general communication error during opening.
- Return type:
None
- read(length=None)#
Read data from device.
Reads HAB (High Assurance Boot) information from the connected device and wraps it in a command response object.
- Parameters:
length (
Optional[int]) – Number of bytes to read from device, defaults to 4 if not specified.- Return type:
- Returns:
Command response object containing the expected status and HAB information.
- write_command(packet)#
Encapsulate command into frames and send them to device.
The method exports the command packet data and sends it as a frame to the device. For certain commands (excluding SET_BAUDRATE), it sets the expectation for a status response.
- Parameters:
packet (
CmdPacketBase) – Command packet object to be sent- Raises:
SPSDKAttributeError – Command packet contains no data to be sent
- Return type:
None
- write_data(data)#
Encapsulate data into frames and send them to device.
- Parameters:
data (
bytes) – Data to be sent to the device.- Return type:
None