Secure Provisioning SDK (SPSDK)

3.7.1 · active · verified Thu Apr 16

SPSDK (Secure Provisioning SDK) is a Python SDK library designed by NXP to provide a unified, reliable, and easy-to-use solution for secure provisioning and programming across their MCU/MPU portfolio. It supports connecting and communicating with devices, configuring them, preparing/downloading/uploading data, and performing security operations. The library is actively developed, with frequent releases, and is currently at version 3.7.1, though PyPI classifies its development status as '3 - Alpha' which might refer to specific components or a historical classification.

Common errors

Warnings

Install

Imports

Quickstart

SPSDK is primarily used through its command-line applications (like `blhost`, `nxpimage`, `sdphost`). This quickstart demonstrates invoking `blhost` to read a property from a connected NXP MCU. For direct API interaction, modules such as `spsdk.sdp` or `spsdk.image` would be used.

# Connect to a device via blhost (command-line tool wrapper)
# This example assumes a device is connected and blhost is configured.
# For actual usage, replace 'serial' with 'usb' if applicable and provide correct port/device.
# The blhost command-line utility is typically used directly.
import subprocess

try:
    # Example: Get property (e.g., status) from the bootloader
    # In a real scenario, you'd provide specific device connection parameters.
    command = ['blhost', '-p', 'COMx', 'get-property', '1'] # Replace COMx with your serial port
    result = subprocess.run(command, capture_output=True, text=True, check=True)
    print("blhost output:")
    print(result.stdout)
except subprocess.CalledProcessError as e:
    print(f"Error executing blhost: {e}")
    print(f"Stderr: {e.stderr}")
except FileNotFoundError:
    print("Error: 'blhost' command not found. Ensure SPSDK is installed and your PATH is correct, or use the 'spsdk' wrapper utility.")

# For API usage, you might interact with specific modules directly, e.g., spsdk.sdp

view raw JSON →