MBoot

MBoot#

This example shows how to read properties of the target’s bootloader.

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#
# Copyright 2019-2023 NXP
#
# SPDX-License-Identifier: BSD-3-Clause

from typing import Optional

from spsdk.exceptions import SPSDKError
from spsdk.mboot.interfaces.usb import MbootUSBInterface
from spsdk.mboot.mcuboot import McuBoot

# Uncomment for printing debug messages
# import logging
# logging.basicConfig(level=logging.DEBUG)


def mboot_properties(name: Optional[str] = None) -> Optional[list]:
    """Get McuBoot properties.

    :param name: Device name ('KL27Z', 'LPC55', ...), VID:PID ('0x15A2:0x0073') or None (any from known devices)
    :return: Interface object
    """
    props = None
    interfaces = MbootUSBInterface.scan(device_id=name)
    if interfaces:
        with McuBoot(interfaces[0]) as mb:
            props = mb.get_property_list()
    return props


property_list = mboot_properties()
if not property_list:
    raise SPSDKError("Error reading properties!")
for prop in property_list:
    print(prop)
Current Version = K3.0.0
Available Peripherals = UART, I2C-Slave, SPI-Slave, USB-HID
Flash Start Address = 0x00000000
Flash Size = 244.0 kiB
Flash Sector Size = 32.0 kiB
Available Commands = ['FlashEraseAll', 'FlashEraseRegion', 'ReadMemory', 'WriteMemory', 'FillMemory', 'GetProperty', 'ReceiveSBFile', 'Execute', 'Reset', 'SetProperty', 'ConfigureMemory', 'KeyProvisioning']
CRC Check Status = AppCrcCheckInvalid
Verify Writes = ON
Max Packet Size = 56 B
Reserved Regions =
    Region 0: 0x30000000 - 0x30007FFF; Total Size: 32.0 kiB
    Region 1: 0x20000000 - 0x20007FFF; Total Size: 32.0 kiB
    Region 2: 0x04000000 - 0x04003FFF; Total Size: 16.0 kiB
    Region 3: 0x14000000 - 0x14001FFF; Total Size: 8.0 kiB
RAM Start Address = 0x20000000
RAM Size = 64.0 kiB
Security State = UNSECURE
Unique Device Identification = 2B BF CD 88 F9 4A FC 50 8B 87 80 CB AC EE 79 1F
Target Version = T1.0.4
Flash Page Size = 512 B
Irq Notifier Pin = IRQ Port[0], Pin[0] is disabled
PFR Keystore Update Opt = KEY_PROVISIONING