Zephyr Project API  3.3.0
A Scalable Open Source RTOS
MCUmgr img_mgmt API

MCUmgr img_mgmt API. More...

Data Structures

struct  img_mgmt_upload_req
 
struct  img_mgmt_state
 
struct  img_mgmt_upload_action
 

Macros

#define IMG_MGMT_HASH_STR   48
 
#define IMG_MGMT_HASH_LEN   32
 
#define IMG_MGMT_DATA_SHA_LEN   32 /* SHA256 */
 
#define IMG_MGMT_STATE_F_PENDING   0x01
 
#define IMG_MGMT_STATE_F_CONFIRMED   0x02
 
#define IMG_MGMT_STATE_F_ACTIVE   0x04
 
#define IMG_MGMT_STATE_F_PERMANENT   0x08
 
#define IMG_MGMT_VER_MAX_STR_LEN   (sizeof("255.255.65535.4294967295"))
 
#define IMG_MGMT_SWAP_TYPE_NONE   0
 
#define IMG_MGMT_SWAP_TYPE_TEST   1
 
#define IMG_MGMT_SWAP_TYPE_PERM   2
 
#define IMG_MGMT_SWAP_TYPE_REVERT   3
 
#define IMG_MGMT_SWAP_TYPE_UNKNOWN   255
 
#define IMG_MGMT_ID_STATE   0
 
#define IMG_MGMT_ID_UPLOAD   1
 
#define IMG_MGMT_ID_FILE   2
 
#define IMG_MGMT_ID_CORELIST   3
 
#define IMG_MGMT_ID_CORELOAD   4
 
#define IMG_MGMT_ID_ERASE   5
 
#define IMG_MGMT_UPLOAD_ACTION_SET_RC_RSN(action, rsn)
 
#define IMG_MGMT_UPLOAD_ACTION_RC_RSN(action)   NULL
 

Enumerations

enum  img_mgmt_id_upload_t { IMG_MGMT_ID_UPLOAD_STATUS_START = 0 , IMG_MGMT_ID_UPLOAD_STATUS_ONGOING , IMG_MGMT_ID_UPLOAD_STATUS_COMPLETE }
 

Functions

int img_mgmt_read_info (int image_slot, struct image_version *ver, uint8_t *hash, uint32_t *flags)
 
int img_mgmt_my_version (struct image_version *ver)
 Get the image version of the currently running application. More...
 
int img_mgmt_ver_str (const struct image_version *ver, char *dst)
 Format version string from struct image_version. More...
 
int img_mgmt_slot_in_use (int slot)
 Check if the image slot is in use. More...
 
int img_mgmt_state_any_pending (void)
 Check if any slot is in MCUboot pending state. More...
 
uint8_t img_mgmt_state_flags (int query_slot)
 Returns state flags set to slot. More...
 
int img_mgmt_state_set_pending (int slot, int permanent)
 Sets the pending flag for the specified image slot. More...
 
int img_mgmt_state_confirm (void)
 Confirms the current image state. More...
 
int img_mgmt_vercmp (const struct image_version *a, const struct image_version *b)
 

Variables

int boot_current_slot
 
struct img_mgmt_state g_img_mgmt_state
 

Detailed Description

MCUmgr img_mgmt API.

Macro Definition Documentation

◆ IMG_MGMT_DATA_SHA_LEN

#define IMG_MGMT_DATA_SHA_LEN   32 /* SHA256 */

◆ IMG_MGMT_HASH_LEN

#define IMG_MGMT_HASH_LEN   32

◆ IMG_MGMT_HASH_STR

#define IMG_MGMT_HASH_STR   48

◆ IMG_MGMT_ID_CORELIST

#define IMG_MGMT_ID_CORELIST   3

◆ IMG_MGMT_ID_CORELOAD

#define IMG_MGMT_ID_CORELOAD   4

◆ IMG_MGMT_ID_ERASE

#define IMG_MGMT_ID_ERASE   5

◆ IMG_MGMT_ID_FILE

#define IMG_MGMT_ID_FILE   2

◆ IMG_MGMT_ID_STATE

#define IMG_MGMT_ID_STATE   0

#include <include/zephyr/mgmt/mcumgr/grp/img_mgmt/img_mgmt.h>

Command IDs for image management group.

◆ IMG_MGMT_ID_UPLOAD

#define IMG_MGMT_ID_UPLOAD   1

◆ IMG_MGMT_STATE_F_ACTIVE

#define IMG_MGMT_STATE_F_ACTIVE   0x04

◆ IMG_MGMT_STATE_F_CONFIRMED

#define IMG_MGMT_STATE_F_CONFIRMED   0x02

◆ IMG_MGMT_STATE_F_PENDING

#define IMG_MGMT_STATE_F_PENDING   0x01

◆ IMG_MGMT_STATE_F_PERMANENT

#define IMG_MGMT_STATE_F_PERMANENT   0x08

◆ IMG_MGMT_SWAP_TYPE_NONE

#define IMG_MGMT_SWAP_TYPE_NONE   0

#include <include/zephyr/mgmt/mcumgr/grp/img_mgmt/img_mgmt.h>

Swap Types for image management state machine

◆ IMG_MGMT_SWAP_TYPE_PERM

#define IMG_MGMT_SWAP_TYPE_PERM   2

◆ IMG_MGMT_SWAP_TYPE_REVERT

#define IMG_MGMT_SWAP_TYPE_REVERT   3

◆ IMG_MGMT_SWAP_TYPE_TEST

#define IMG_MGMT_SWAP_TYPE_TEST   1

◆ IMG_MGMT_SWAP_TYPE_UNKNOWN

#define IMG_MGMT_SWAP_TYPE_UNKNOWN   255

◆ IMG_MGMT_UPLOAD_ACTION_RC_RSN

#define IMG_MGMT_UPLOAD_ACTION_RC_RSN (   action)    NULL

◆ IMG_MGMT_UPLOAD_ACTION_SET_RC_RSN

#define IMG_MGMT_UPLOAD_ACTION_SET_RC_RSN (   action,
  rsn 
)

◆ IMG_MGMT_VER_MAX_STR_LEN

#define IMG_MGMT_VER_MAX_STR_LEN   (sizeof("255.255.65535.4294967295"))

Enumeration Type Documentation

◆ img_mgmt_id_upload_t

#include <include/zephyr/mgmt/mcumgr/grp/img_mgmt/img_mgmt.h>

IMG_MGMT_ID_UPLOAD statuses.

Enumerator
IMG_MGMT_ID_UPLOAD_STATUS_START 
IMG_MGMT_ID_UPLOAD_STATUS_ONGOING 
IMG_MGMT_ID_UPLOAD_STATUS_COMPLETE 

Function Documentation

◆ img_mgmt_my_version()

int img_mgmt_my_version ( struct image_version ver)

#include <include/zephyr/mgmt/mcumgr/grp/img_mgmt/img_mgmt.h>

Get the image version of the currently running application.

Parameters
veroutput buffer for an image version information object.
Returns
0 on success, non-zero on failure.

◆ img_mgmt_read_info()

int img_mgmt_read_info ( int  image_slot,
struct image_version ver,
uint8_t hash,
uint32_t flags 
)

◆ img_mgmt_slot_in_use()

int img_mgmt_slot_in_use ( int  slot)

#include <include/zephyr/mgmt/mcumgr/grp/img_mgmt/img_mgmt.h>

Check if the image slot is in use.

The check is based on MCUboot flags, not image contents. This means that slot with image in it, but no bootable flags set, is considered empty. Active slot is always in use.

Parameters
slotslot number
Returns
0 if slot is not used, non-0 otherwise.

◆ img_mgmt_state_any_pending()

int img_mgmt_state_any_pending ( void  )

#include <include/zephyr/mgmt/mcumgr/grp/img_mgmt/img_mgmt.h>

Check if any slot is in MCUboot pending state.

Function returns 1 if slot 0 or slot 1 is in MCUboot pending state, which means that it has been either marked for test or confirmed.

Returns
1 if there's pending DFU otherwise 0.

◆ img_mgmt_state_confirm()

int img_mgmt_state_confirm ( void  )

#include <include/zephyr/mgmt/mcumgr/grp/img_mgmt/img_mgmt.h>

Confirms the current image state.

Prevents a fallback from occurring on the next reboot if the active image is currently being tested.

Returns
0 on success, non-zero on failure

◆ img_mgmt_state_flags()

uint8_t img_mgmt_state_flags ( int  query_slot)

#include <include/zephyr/mgmt/mcumgr/grp/img_mgmt/img_mgmt.h>

Returns state flags set to slot.

Flags are translated from MCUboot image state flags. Returned value is zero if no flags are set or a combination of: IMG_MGMT_STATE_F_PENDING IMG_MGMT_STATE_F_CONFIRMED IMG_MGMT_STATE_F_ACTIVE IMG_MGMT_STATE_F_PERMANENT

Parameters
query_slotslot number
Returns
return the state flags.

◆ img_mgmt_state_set_pending()

int img_mgmt_state_set_pending ( int  slot,
int  permanent 
)

#include <include/zephyr/mgmt/mcumgr/grp/img_mgmt/img_mgmt.h>

Sets the pending flag for the specified image slot.

Sets specified image slot to be used as active slot during next boot, either for test or permanently. Non-permanent image will be reverted unless image confirms itself during next boot.

Parameters
slotslot number
permanentpermanent or test only
Returns
0 on success, non-zero on failure

◆ img_mgmt_ver_str()

int img_mgmt_ver_str ( const struct image_version ver,
char *  dst 
)

#include <include/zephyr/mgmt/mcumgr/grp/img_mgmt/img_mgmt.h>

Format version string from struct image_version.

Parameters
verpointer to image_version object
dstoutput buffer for image version string
Returns
Non-negative on success, negative value on error.

◆ img_mgmt_vercmp()

int img_mgmt_vercmp ( const struct image_version a,
const struct image_version b 
)

#include <include/zephyr/mgmt/mcumgr/grp/img_mgmt/img_mgmt.h>

Compares two image version numbers in a semver-compatible way.

Parameters
aThe first version to compare
bThe second version to compare
Returns
-1 if a < b
0 if a = b
1 if a > b

Variable Documentation

◆ boot_current_slot

int boot_current_slot
extern

◆ g_img_mgmt_state

struct img_mgmt_state g_img_mgmt_state
extern