Protected Flash Region API¶
Support for Protected Flash Region areas (CMPA, CFPA).
Protected Flash Region¶
Module provides support for Protected Flash Region areas (CMPA, CFPA).
-
class
spsdk.pfr.pfr.
BaseConfigArea
(device=None, revision=None, user_config=None)¶ Bases:
object
Base for CMPA and CFPA classes.
Initialize an instance.
- Parameters
device (
Optional
[str
]) – device to use, list of supported devices is available via ‘devices’ methodrevision (
Optional
[str
]) – silicon revision, if not specified, the latest is being useduser_config (
Optional
[PfrConfiguration
]) – PfrConfiguration with user configuration to use with initialization
-
BINARY_SIZE
= 512¶
-
CONFIG_FILE
= 'database.json'¶
-
DESCRIPTION
= 'Base Config Area'¶
-
MARK
= b'SEAL'¶
-
ROTKH_REGISTER
= 'ROTKH'¶
-
ROTKH_SIZE
= 32¶
-
classmethod
devices
()¶ Classmethod to get list of supported devices.
- Return type
List
[str
]- Returns
List of supported devices.
-
export
(add_seal=False, keys=None)¶ Generate binary output.
- Parameters
add_seal (
bool
) – The export is finished in the PFR record by seal.keys (
Optional
[List
[RSAPublicKey
]]) – List of Keys to compute ROTKH field.
- Return type
bytes
- Returns
Binary block with PFR configuration(CMPA or CFPA).
- Raises
SPSDKPfrRotkhIsNotPresent – This PFR block doesn’t contains ROTKH field.
-
generate_config
(exclude_computed=True)¶ Generate configuration structure for user configuration.
- Parameters
exclude_computed (
bool
) – Exclude computed fields, defaults to True.- Return type
CommentedMap
- Returns
YAML commented map with PFR configuration in reset state.
-
get_yaml_config
(exclude_computed=True, diff=False, indent=0)¶ Return YAML configuration from loaded registers.
- Parameters
exclude_computed (
bool
) – Omit computed registers and fields.diff (
bool
) – Get only configuration with difference value to reset state.indent (
int
) – YAML start indent.
- Return type
CommentedMap
- Returns
YAML PFR configuration in commented map(ordered dict).
-
parse
(data)¶ Parse input binary data to registers.
- Parameters
data (
bytes
) – Input binary data of PFR block.- Return type
None
-
static
pfr_reg_inverse_high_half
(val)¶ Function that inverse low 16-bits of register value to high 16 bits.
- Parameters
val (
bytes
) – Input current reg value.- Return type
bytes
- Returns
Returns the complete register value with updated higher half field.
-
reg_computed_fields_handler
(val, context)¶ Recalculate all fields for given register value.
- Parameters
val (
bytes
) – Input register value.context (
Any
) – The method context (fields).
- Return type
bytes
- Returns
recomputed value.
- Raises
SPSDKPfrError – Raises when the computing routine is not found.
-
set_config
(config, raw=False)¶ Apply configuration from file.
- Parameters
config (
PfrConfiguration
) – PFR configuration.raw (
bool
) – When set all (included computed fields) configuration will be applied.
- Raises
SPSDKPfrConfigError – Invalid config file.
- Return type
None
-
class
spsdk.pfr.pfr.
CFPA
(device=None, revision=None, user_config=None)¶ Bases:
spsdk.pfr.pfr.BaseConfigArea
Customer In-Field Configuration Area.
Initialize an instance.
- Parameters
device (
Optional
[str
]) – device to use, list of supported devices is available via ‘devices’ methodrevision (
Optional
[str
]) – silicon revision, if not specified, the latest is being useduser_config (
Optional
[PfrConfiguration
]) – PfrConfiguration with user configuration to use with initialization
-
DESCRIPTION
= 'Customer In-field Programmable Area'¶
-
class
spsdk.pfr.pfr.
CMPA
(device=None, revision=None, user_config=None)¶ Bases:
spsdk.pfr.pfr.BaseConfigArea
Customer Manufacturing Configuration Area.
Initialize an instance.
- Parameters
device (
Optional
[str
]) – device to use, list of supported devices is available via ‘devices’ methodrevision (
Optional
[str
]) – silicon revision, if not specified, the latest is being useduser_config (
Optional
[PfrConfiguration
]) – PfrConfiguration with user configuration to use with initialization
-
DESCRIPTION
= 'Customer Manufacturing Programable Area'¶
Protected Flash Region Checker for brick-conditions¶
Processor for conditions in rules.
-
class
spsdk.pfr.processor.
Processor
(translator)¶ Bases:
object
Class responsible for processing conditions.
- Processor is responsible for processing condition
parsing the condition string (lookup)
calling translator for individual keys (registers)
Translator is responsible for looking up values for given keys
Initialize processor.
- Parameters
translator (
Translator
) – Translator instance
-
process
(condition)¶ Process individual condition from rules.
- Parameters
condition (
str
) – condition to quantify- Return type
Tuple
[bool
,str
]- Returns
Boolean result and values for translated keys
Translator is responsible for converting stringified keys into values.
-
class
spsdk.pfr.translator.
Translator
(cmpa, cfpa)¶ Bases:
object
Translates single strings (register/key names) into values.
Initialize CMPA and CFPA data.
- Parameters
cmpa (
PfrConfiguration
) – configuration data loaded from CMPA config filecfpa (
PfrConfiguration
) – configuration data loaded from CFPA config file
-
translate
(key)¶ Lookup register’s (or generic key’s) value.
- Parameters
key (
str
) – Register’s (key’s) stringified name- Return type
int
- Returns
Register’s (key’s) value