Memory Configuration API#

Module implementing managing the configuration option words for various memories used by BLHOST configure-memory command.

Memory Config API#

Module provides support for Memory configuration (known as a flash configuration option words).

class spsdk.memcfg.memcfg.Memory(name, type, manufacturer, interfaces)#

Bases: object

Memory dataclass.

get_interface(interface)#

Get interface by its name.

Parameters:

interface (str) – Interface name

Raises:

SPSDKValueError – Interface is not presented in memory.

Return type:

MemoryInterface

Returns:

Memory interface

has_interface(interface)#

Check if memory has mentioned interface.

Parameters:

interface (str) – Interface name.

Return type:

bool

interfaces: list[MemoryInterface]#
manufacturer: str#
name: str#
type: str#
class spsdk.memcfg.memcfg.MemoryConfig(family, peripheral, revision='latest', interface=None)#

Bases: BaseClass

General memory configuration class.

Initialize memory configuration class.

Parameters:
  • family (str) – Chip family

  • peripheral (str) – Peripheral name

  • revision (str) – Chip revision

  • interface (Optional[str]) – Memory interface

PERIPHERALS: list[str] = ['flexspi_nor', 'xspi_nor', 'flexspi_nand', 'semc_nor', 'semc_nand', 'spi_nor', 'mmc', 'sd']#
SUPPORTS_FCB_CREATION = [9]#
create_blhost_batch_config(instance=None, fcb_output_name=None, secure_addresses=False)#

Create BLHOST script that configure memory.

Optionally the script can force create of FCB on chip and read back it

Parameters:
  • instance (Optional[int]) – Optional peripheral instance

  • fcb_output_name (Optional[str]) – The name of generated FCB block file, defaults to False

  • secure_addresses (bool) – When defined the script will use secure addresses instead of normal.

Return type:

str

Returns:

BLHOST batch file that configure the external memory

export()#

Export option words to bytes.

Return type:

bytes

get_config()#

Get class configuration.

Return type:

dict[str, Any]

Returns:

Dictionary with configuration of the class.

static get_known_chip_memory(chip_name)#

Get Memory for one chip from database.

Parameters:

chip_name (str) – Chip name to look for

Return type:

Memory

Returns:

The Memory class for known chip.

static get_known_memories(mem_type=None, interfaces=None)#

Get all known supported memory configurations.

Parameters:
  • mem_type (Optional[str]) – Restrict results just for this one memory type if defined

  • interfaces (Optional[list[str]]) – Restrict results just for mentioned memory interfaces if defined

Return type:

list[Memory]

Returns:

List of memories

static get_known_peripheral_memories(family, peripheral=None)#

Get all known supported memory configurations.

Parameters:
  • family (Optional[str]) – The optional chip family

  • peripheral (Optional[str]) – Restrict results just for this one peripheral if defined

Return type:

list[Memory]

Returns:

List of memories

static get_peripheral_cnt(family, peripheral)#

Get count of peripheral instances.

Return type:

int

static get_peripheral_instances(family, peripheral)#

Get peripheral instances.

Return type:

list[int]

static get_supported_families()#

Get the list of supported families.

Return type:

list[str]

Returns:

List of family names that support memory configuration.

static get_supported_interfaces(family, peripheral)#

Get list of supported interfaces by the peripheral for the family.

Return type:

list[str]

static get_supported_peripherals(family)#

Get list of supported peripherals by the family.

Return type:

list[str]

get_validation_schemas()#

Create the validation schema for one peripheral.

Return type:

list[dict[str, Any]]

Returns:

List of validation schemas.

static get_validation_schemas_base()#

Create the validation schema for MemCfg class bases.

Return type:

list[dict[str, Any]]

Returns:

List of validation schemas.

get_yaml()#

Parse the option words to YAML config file.

Return type:

str

Returns:

YAML file content with configuration.

classmethod load_config(config)#

Load Yaml configuration and decode.

Parameters:

config (dict[str, Any]) – Memory configuration dictionary.

Return type:

Self

property option_words: list[int]#

Get option words.

property option_words_count: int#

Get current count of option words.

static option_words_to_bytes(option_words)#

Convert option words to bytes.

Parameters:

option_words (list[int]) – Option words list

Return type:

bytes

Returns:

Bytes with option words

static option_words_to_string(option_words)#

Get option words in string format.

Parameters:

option_words (list[int]) – List of option words.

Return type:

str

Returns:

Option words in string

classmethod parse(data, family, peripheral, revision='latest', interface=None)#

Parse the option words to configuration.

Parameters:
  • data (bytes) – Option words in bytes

  • family (str) – Chip family

  • peripheral (str) – Peripheral name

  • revision (str) – Chip revision

  • interface (Optional[str]) – Memory interface

Return type:

Self

Returns:

Dictionary with parsed configuration.

class spsdk.memcfg.memcfg.MemoryInterface(name, option_words=<factory>, tested=False)#

Bases: object

Memory interface dataclass.

This class represents a memory interface with its associated option words.

Attributes:

name (str): The name of the memory interface. option_words (list): A list of option words for the interface. Defaults to an empty list. tested (bool): Indicates whether the interface has been tested. Defaults to False.

get_option_words_string()#

Get option words in string format.

This method converts the option words to a formatted string representation.

Return type:

str

Returns:

A string containing the option words in hexadecimal format.

If option_words = [0x12345678, 0x9ABCDEF0], the output will be: “Opt0: 0x12345678, Opt1: 0x9ABCDEF0”

name: str#
option_words: list#
tested: bool = False#