Shadow Registers API#
SPSDK shadow registers management for Debug Authentication Tool (DAT).
This module provides functionality for controlling and managing shadow registers that enable debug access through the Debug Authentication Tool. It includes register manipulation, debug enablement, and verification capabilities.
- class spsdk.fuses.shadowregs.ShadowRegisters(family, fuse_operator=None, cache=True)#
Bases:
FusesSPSDK Shadow Registers Manager.
This class provides control and management of shadow registers for NXP MCU devices. Shadow registers are temporary storage locations that mirror fuse values and can be modified without permanently altering the actual fuses, enabling safe testing and configuration validation.
- Variables:
FEATURE – Database feature identifier for shadow registers operations.
Initialize Fuses class to control fuse operations.
The Fuses class provides functionality to manage and manipulate fuse registers for NXP MCU devices, including reading, writing, and configuring fuse values.
- Parameters:
family (
FamilyRevision) – Target MCU family and revision information for fuse operations.fuse_operator (
Optional[FuseOperator]) – Optional operator for performing actual fuse operations, defaults to None.cache (
bool) – Enable caching of lock fuse values to prevent multiple reads, defaults to True.
- Raises:
SPSDKError – When the specified family has no fuses definition available.
- FEATURE: str = 'shadow_regs'#
- create_fuse_blhost_script(reg_list)#
Create BLHOST script to burn fuses.
The method generates a script file that can be used with BLHOST tool to program fuses on the target device. It processes the register list, handles antipole registers, and creates appropriate efuse-program-once commands for each register.
- Parameters:
reg_list (
list[str]) – List of register names to be burned to fuses.- Raises:
SPSDKError – Register not found for the target device family.
- Return type:
str- Returns:
Content of BLHOST script file as string.
- classmethod get_init_regs(family)#
Initialize the shadow registers from whole fuse list.
Creates a FuseRegisters object containing only registers that support shadow registers, with computed fields and antipole registers properly configured and hidden.
- Parameters:
family (
FamilyRevision) – Family of device to be loaded.- Return type:
FuseRegisters- Returns:
Register class with loaded just fuses that supports shadow registers.
- get_register(reg_name, force=False)#
Get shadow register value from device.
Reads the shadow register value from the connected device using the debug probe. For group registers, reads all sub-registers and combines their values.
- Parameters:
reg_name (
str) – The register name to read.force (
bool) – Force read even when the fuse is marked as non-readable
- Raises:
SPSDKError – Register not found, invalid configuration, or read operation failed.
SPSDKDebugProbeError – Debug probe is not specified or communication failed.
- Return type:
bytes- Returns:
The value of requested register in bytes.
- reload_registers()#
Reload all the values in managed registers.
This method iterates through all registers in the managed collection and refreshes their values by calling get_register for each one.
- Return type:
None
- set_all_registers(verify=True)#
Update all shadow registers in target using their local values.
This method iterates through all registers and writes their current local values to the target device using the set_register method.
- Parameters:
verify (
bool) – Verify write operation after setting each register.- Return type:
None
- set_loaded_registers(verify=True)#
Update shadow registers in target using their local values.
This method iterates through all loaded registers and writes their current local values to the target device using the set_register method.
- Parameters:
verify (
bool) – Verify write operation after setting each register.- Raises:
SPSDKError – If register write operation fails.
- Return type:
None
- set_register(reg_name, data, verify=True, raw=True)#
Set the value of the specified shadow register.
Writes data to a shadow register on the target device through the debug probe. Supports both individual registers and group registers with sub-registers.
- Parameters:
reg_name (
str) – The register name to write to.data (
int) – The new data to be stored to shadow register.verify (
bool) – Verify write operation after completion.raw (
bool) – Do not use any modification hooks during value setting.
- Raises:
SPSDKDebugProbeError – The debug probe is not specified.
SPSDKError – General error with write of shadow register or register not found.
SPSDKVerificationError – Verification of written data failed.
- Return type:
None