Commit 0435d5d9 authored by Dominik Ermel's avatar Dominik Ermel Committed by Andrzej Puzdrowski
Browse files

zephyr: Add option for enabling the storage erase command



The commit adds Kconfig option that enables the storage erase mgmt
command.
Addition of the Kconfig option fixes the problem where Zephyr spcyfic
mgmt commands support fails to compile when board does not define
a storage partition.

Signed-off-by: default avatarDominik Ermel <dominik.ermel@nordicsemi.no>
parent e1829771
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -578,6 +578,14 @@ menuconfig ENABLE_MGMT_PERUSER
	  function is required to process these commands.

if ENABLE_MGMT_PERUSER
config BOOT_MGMT_CUSTOM_STORAGE_ERASE
	bool "Enable storage erase command"
	help
	  The option enables mcumgr command that allows to erase storage
	  partition.
	  Note that the storage partition needs to be defined, in DTS, otherwise
	  enabling the option will cause a compilation to fail.

config BOOT_MGMT_CUSTOM_IMG_LIST
	bool "Enable custom image list command"
	help
+4 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@

MCUBOOT_LOG_MODULE_DECLARE(mcuboot);

#ifdef CONFIG_BOOT_MGMT_CUSTOM_STORAGE_ERASE
static int bs_custom_storage_erase(cbor_state_t *cs)
{
    int rc;
@@ -49,6 +50,7 @@ static int bs_custom_storage_erase(cbor_state_t *cs)

    return rc;
}
#endif

#ifdef MCUBOOT_MGMT_CUSTOM_IMG_LIST
static int custom_img_status(int image_index, uint32_t slot,char *buffer,
@@ -127,9 +129,11 @@ int bs_peruser_system_specific(const struct nmgr_hdr *hdr, const char *buffer,

    if (hdr->nh_group == ZEPHYR_MGMT_GRP_BASE) {
        if (hdr->nh_op == NMGR_OP_WRITE) {
#ifdef CONFIG_BOOT_MGMT_CUSTOM_STORAGE_ERASE
            if (hdr->nh_id == ZEPHYR_MGMT_GRP_BASIC_CMD_ERASE_STORAGE) {
                mgmt_rc = bs_custom_storage_erase(cs);
            }
#endif
        } else if (hdr->nh_op == NMGR_OP_READ) {
#ifdef MCUBOOT_MGMT_CUSTOM_IMG_LIST
            if (hdr->nh_id == ZEPHYR_MGMT_GRP_BASIC_CMD_IMAGE_LIST) {