OS Management¶
The Simple Management Protocol (SMP) OS Management group.
AnyBootloaderInformationReadResponse: TypeAlias = BootloaderInformationReadResponse | MCUbootModeReadResponse
module-attribute
¶
The bootloader information response variants, one per request.
EchoWriteRequest
¶
Bases: WriteRequest
Echo back the provided string.
Source code in src/smp/os_management.py
d: str
instance-attribute
¶
String to echo.
EchoWriteResponse
¶
Bases: WriteResponse
Success response to an echo request.
Source code in src/smp/os_management.py
r: str
instance-attribute
¶
Echoed string.
BootMode
¶
Bases: IntEnum
Boot mode requested by the OS management reset command.
Mirrors Zephyr's enum BOOT_MODE_TYPES in
include/zephyr/retention/bootmode.h.
Source code in src/smp/os_management.py
ResetWriteRequest
¶
Bases: WriteRequest
Performs reset of system.
The device should issue response before resetting so that the SMP client
could receive information that the command has been accepted. By default,
this command is accepted in all conditions, however if the
CONFIG_MCUMGR_GRP_OS_RESET_HOOK is enabled and an application registers a
callback, the callback will be called when this command is issued and can be
used to perform any necessary tidy operations prior to the module rebooting,
or to reject the reset request outright altogether with an error response.
For details on this functionality, see callbacks. # noqa: E501
Source code in src/smp/os_management.py
force: Literal[0, 1] | None = None
class-attribute
instance-attribute
¶
Force reset.
Normally the command sends an empty CBOR map as data, but if a previous reset attempt has responded with “rc” equal to MGMT_ERR_EBUSY then the following map may be sent to force a reset
boot_mode: BootMode | Annotated[int, Field(ge=0, le=255)] | None = Field(default=None, union_mode='left_to_right')
class-attribute
instance-attribute
¶
Boot mode to set via the retention boot mode module before resetting.
A value of BootMode.BOOTLOADER (1) requests, for example, that an MCUboot
built with CONFIG_BOOT_SERIAL_BOOT_MODE enter serial recovery on the next
boot. The server casts the value to a uint8_t, so any value in [0, 255]
is accepted and passed to bootmode_set(); known values are surfaced as
BootMode members.
Requires the server to be built with CONFIG_MCUMGR_GRP_OS_RESET_BOOT_MODE,
which depends on CONFIG_RETENTION_BOOT_MODE. Added to the SMP OS
management group in Zephyr v4.2.0 (zephyrproject-rtos/zephyr#91510).
ResetWriteResponse
¶
TaskStatisticsReadRequest
¶
TaskStatistics
¶
Bases: BaseModel
Task statistics.
Source code in src/smp/os_management.py
model_config = ConfigDict(extra='forbid', frozen=True)
class-attribute
instance-attribute
¶
prio: int
instance-attribute
¶
Task priority.
tid: int
instance-attribute
¶
Numeric task ID.
state: int
instance-attribute
¶
Numeric task state.
stkuse: int
instance-attribute
¶
Stack usage.
The unit is system dependent and in case of Zephyr this is number of 4 byte words.
stksiz: int
instance-attribute
¶
Stack size.
The unit is system dependent and in case of Zephyr this is number of 4 byte words.
cswcnt: int
instance-attribute
¶
Number of context switches.
runtime: int
instance-attribute
¶
Runtime in ticks.
last_checkin: int
instance-attribute
¶
Set to 0 by Zephyr.
next_checkin: int
instance-attribute
¶
Set to 0 by Zephyr.
TaskStatisticsZephyr
¶
Bases: BaseModel
Task statistics for Zephyr when CONFIG_MCUMGR_GRP_OS_TASKSTAT_ONLY_SUPPORTED_STATS=y.
In this configuration, Zephyr may omit fields that are not supported by the underlying RTOS. Only prio, tid, and state are guaranteed to be present.
Source code in src/smp/os_management.py
model_config = ConfigDict(extra='forbid', frozen=True)
class-attribute
instance-attribute
¶
prio: int
instance-attribute
¶
Task priority.
tid: int
instance-attribute
¶
Numeric task ID.
state: int
instance-attribute
¶
Numeric task state.
stkuse: int | None = None
class-attribute
instance-attribute
¶
Stack usage.
The unit is system dependent and in case of Zephyr this is number of 4 byte words.
stksiz: int | None = None
class-attribute
instance-attribute
¶
Stack size.
The unit is system dependent and in case of Zephyr this is number of 4 byte words.
cswcnt: int | None = None
class-attribute
instance-attribute
¶
Number of context switches.
runtime: int | None = None
class-attribute
instance-attribute
¶
Runtime in ticks.
last_checkin: int | None = None
class-attribute
instance-attribute
¶
Set to 0 by Zephyr.
next_checkin: int | None = None
class-attribute
instance-attribute
¶
Set to 0 by Zephyr.
TaskStatisticsReadResponse
¶
Bases: ReadResponse
Task statistics response.
Source code in src/smp/os_management.py
tasks: dict[str, TaskStatistics | TaskStatisticsZephyr]
instance-attribute
¶
Task statistics map.
MemoryPoolStatisticsReadRequest
¶
MemoryPoolStatistics
¶
Bases: BaseModel
Memory pool statistics.
Source code in src/smp/os_management.py
model_config = ConfigDict(extra='forbid', frozen=True)
class-attribute
instance-attribute
¶
blksize: int
instance-attribute
¶
Size of the memory block in the pool.
nblks: int
instance-attribute
¶
Number of memory blocks in the pool.
nfree: int
instance-attribute
¶
Number of free memory blocks in the pool.
min: int
instance-attribute
¶
Lowest number of free blocks the pool reached during run-time.
MemoryPoolStatisticsReadResponse
¶
Bases: ReadResponse
The memory pools are accessed by name.
Source code in src/smp/os_management.py
model_config = ConfigDict(extra='allow', frozen=True)
class-attribute
instance-attribute
¶
DateTimeReadRequest
¶
DateTimeReadResponse
¶
Bases: ReadResponse
Response to a date and time request.
Source code in src/smp/os_management.py
datetime: str
instance-attribute
¶
DateTimeWriteRequest
¶
Bases: WriteRequest
Set the current date and time.
Source code in src/smp/os_management.py
datetime: str
instance-attribute
¶
DateTimeWriteResponse
¶
Bases: WriteResponse
Success response to a date and time request.
Source code in src/smp/os_management.py
MCUMgrParametersReadRequest
¶
MCUMgrParametersReadResponse
¶
Bases: ReadResponse
Success response to a MCU Manager parameters request.
Source code in src/smp/os_management.py
OSApplicationInfoReadRequest
¶
Bases: ReadRequest
Request information about the application running on the device.
Source code in src/smp/os_management.py
format: str | None = None
class-attribute
instance-attribute
¶
Format specifier of returned response.
Fields are appended in their natural ascending index order, not the order of characters that are received by the command.
Format specifiers:
* s Kernel name
* n Node name
* r Kernel release
* v Kernel version
* b Build date and time (requires CONFIG_MCUMGR_GRP_OS_INFO_BUILD_DATE_TIME)
* m Machine
* p Processor
* i Hardware platform
* o Operating system
* a All fields (shorthand for all above options)
If this option is not provided, the s Kernel name option will be used.
OSApplicationInfoReadResponse
¶
Bases: ReadResponse
Success response to an application information request.
Source code in src/smp/os_management.py
output: str
instance-attribute
¶
Text response including requested parameters.
BootloaderInformationReadRequest
¶
BootloaderInformationReadResponse
¶
Bases: ReadResponse
Success response to a bootloader information request.
Source code in src/smp/os_management.py
bootloader: str
instance-attribute
¶
String identifying the bootloader. For MCUboot it will be "MCUboot".
MCUbootModeReadRequest
¶
Bases: ReadRequest
Request MCUboot's mode of operation.
Source code in src/smp/os_management.py
query: Literal['mode']
instance-attribute
¶
MCUbootMode
¶
Bases: IntEnum
Source code in src/smp/os_management.py
UNKNOWN = -1
class-attribute
instance-attribute
¶
APPLICATION = 0
class-attribute
instance-attribute
¶
SWAP_USING_SCRATCH = 1
class-attribute
instance-attribute
¶
OVERWRITE_ONLY = 2
class-attribute
instance-attribute
¶
SWAP_WITHOUT_SCRATCH = 3
class-attribute
instance-attribute
¶
DIRECT_XIP_WITHOUT_REVERT = 4
class-attribute
instance-attribute
¶
DIRECT_XIP_WITH_REVERT = 5
class-attribute
instance-attribute
¶
RAM_LOADER = 6
class-attribute
instance-attribute
¶
FIRMWARE_LOADER = 7
class-attribute
instance-attribute
¶
SINGLE_SLOT_RAM_LOADER = 8
class-attribute
instance-attribute
¶
SWAP_USING_OFFSET = 9
class-attribute
instance-attribute
¶
MCUbootModeReadResponse
¶
Bases: ReadResponse
Success response to an MCUboot mode request.
Source code in src/smp/os_management.py
model_config = ConfigDict(populate_by_name=True)
class-attribute
instance-attribute
¶
mode: MCUbootMode | Annotated[int, Field(ge=(-2 ** 31), le=(2 ** 31 - 1))] = Field(union_mode='left_to_right')
class-attribute
instance-attribute
¶
no_downgrade: Literal[True] | None = Field(default=None, validation_alias='no-downgrade', serialization_alias='no-downgrade')
class-attribute
instance-attribute
¶
MCUboot will not update to an image whose version is lower than the running one.
OS_MGMT_RET_RC
¶
Bases: IntEnum
OS Management return codes.
Source code in src/smp/os_management.py
OK = 0
class-attribute
instance-attribute
¶
No error, this is implied if there is no ret value in the response.
UNKNOWN = 1
class-attribute
instance-attribute
¶
Unknown error occurred.
INVALID_FORMAT = 2
class-attribute
instance-attribute
¶
The provided format value is not valid.
QUERY_YIELDS_NO_ANSWER = 3
class-attribute
instance-attribute
¶
Query was not recognized.
RTC_NOT_SET = 4
class-attribute
instance-attribute
¶
RTC is not set.
RTC_COMMAND_FAILED = 5
class-attribute
instance-attribute
¶
RTC command failed.
OSManagementErrorV1
¶
OSManagementErrorV2
¶
loads_bootloader_information_response(data: bytes) -> AnyBootloaderInformationReadResponse
¶
Deserialize a bootloader information response as the variant that its payload names.