Has anybody sucessfully enabled SMP (software management protocol) over SHELL using a UART ?

I'm fairly new to Zephyr and initially I'm hoping someone can point me to an example where SMP over UART can be used to update a firmware image slot.  Google seems to have a lot of information relating to KConfig options that no longer seem to exist with regards to using the SMP protocol via Zephyr shell - and browsing through KConfig I cant quite seem to find something that works or a document that explains things nicely.   The typical Google response would be 'do this' (below) but it seems the KConfig options are renamed or missing

# Enable the Zephyr shell subsystem
CONFIG_SHELL=y
CONFIG_SHELL_BACKEND_SERIAL=y

# Enable the Simple Management Protocol (SMP)
CONFIG_MCUMGR=y
CONFIG_MCUMGR_TRANSPORT_SHELL=y
# You may also need general SMP support
CONFIG_MCUMGR_SMP=y

# Enable specific command groups as needed (examples)
CONFIG_MCUMGR_CMD_IMG_MGMT=y    # Image management (for DFU)
CONFIG_MCUMGR_CMD_OS_MGMT=y     # OS management commands (e.g., reset, tasks)
CONFIG_MCUMGR_CMD_FS_MGMT=y     # File system management
Parents
  • So trying to figure out why shell isnt working I set up a debug session with MCUBoot    I found this in main.c.


       
    if (FIH_NOT_EQ(fih_rc, FIH_SUCCESS)) {
            BOOT_LOG_ERR("Unable to find bootable image");

            mcuboot_status_change(MCUBOOT_STATUS_NO_BOOTABLE_IMAGE_FOUND);

    #ifdef CONFIG_BOOT_SERIAL_NO_APPLICATION
            /* No bootable image and configuration set to remain in serial
             * recovery mode
             */
            boot_serial_enter();
    #elif defined(CONFIG_BOOT_USB_DFU_NO_APPLICATION)
            rc = usb_enable(NULL);
            if (rc && rc != -EALREADY) {
                BOOT_LOG_ERR("Cannot enable USB");
            } else {
                BOOT_LOG_INF("Waiting for USB DFU");
                wait_for_usb_dfu(K_FOREVER);
            }
    #endif

            FIH_PANIC;
        }
    I ended up stuck on FIH_PANIC at the bottom.   So I enabled 'CONFIG_BOOT_SERIAL_NO_APPLICATION' in prj.conf to enable  'boot_serial_enter()'    And then got told I need ' 'CONFIG_MCUBOOT_SERIAL' as a dependency.  So I also added that to prjk.conf.
    And finally the build now fails.....
    C:/Code/zephyr/bootloader/mcuboot/boot/boot_serial/src/boot_serial_encryption.c:114:31: warning: 'struct enc_data' declared inside parameter list will not be visible outside of this definition or declaration
    114 | decrypt_region_inplace(struct enc_data *enc_data,
    | ^~~~~~~~
    C:/Code/zephyr/bootloader/mcuboot/boot/boot_serial/src/boot_serial_encryption.c: In function 'decrypt_region_inplace':
    C:/Code/zephyr/bootloader/mcuboot/boot/boot_serial/src/boot_serial_encryption.c:169:30: warning: passing argument 1 of 'boot_enc_decrypt' from incompatible pointer type [-Wincompatible-pointer-types]
    169 | boot_enc_decrypt(enc_data,
    | ^~~~~~~~
    | |
    | struct enc_data *
    In file included from c:\code\zephyr\bootloader\mcuboot\boot\bootutil\src\bootutil_priv.h:44,
    from C:/Code/zephyr/bootloader/mcuboot/boot/boot_serial/src/boot_serial_encryption.c:10:
    C:/Code/zephyr/bootloader/mcuboot/boot/bootutil/include/bootutil/enc_key.h:73:44: note: expected 'struct enc_key_data *' but argument is of type 'struct enc_data *'
    73 | void boot_enc_decrypt(struct enc_key_data *enc_state,
    | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
    C:/Code/zephyr/bootloader/mcuboot/boot/boot_serial/src/boot_serial_encryption.c: In function 'decrypt_image_inplace':
    C:/Code/zephyr/bootloader/mcuboot/boot/boot_serial/src/boot_serial_encryption.c:265:37: error: incompatible type for argument 1 of 'decrypt_region_inplace'
    265 | rc = decrypt_region_inplace(enc_data, fa_p, hdr, size, sect_size);
    | ^~~~~~~~
    | |
    | struct enc_key_data
    C:/Code/zephyr/bootloader/mcuboot/boot/boot_serial/src/boot_serial_encryption.c:114:41: note: expected 'struct enc_data ' but argument is of type 'struct enc_key_data'
    114 | decrypt_region_inplace(struct enc_data *enc_data,
    | ~~~~~~~~~~~~~~~~~^~~~~~~~
    C:/Code/zephyr/bootloader/mcuboot/boot/boot_serial/src/boot_serial_encryption.c:274:5: warning: implicit declaration of function 'boot_enc_zeorize'; did you mean 'boot_enc_zeroize'? [-Wimplicit-function-declaration]
    274 | boot_enc_zeorize(&enc_data);
    | ^~~~~~~~~~~~~~~~
    | boot_enc_zeroize
    C:/Code/zephyr/bootloader/mcuboot/boot/boot_serial/src/boot_serial_encryption.c:275:22: warning: passing argument 1 of 'boot_state_clear' from incompatible pointer type [-Wincompatible-pointer-types]
    275 | boot_state_clear(&state);
    | ^~~~~~
    | |
    | struct boot_loader_state **
    In file included from c:\code\zephyr\bootloader\mcuboot\boot\bootutil\src\bootutil_priv.h:37:
    C:/Code/zephyr/bootloader/mcuboot/boot/bootutil/include/bootutil/bootutil.h:89:49: note: expected 'struct boot_loader_state *' but argument is of type 'struct boot_loader_state **'
    89 | void boot_state_clear(struct boot_loader_state *state);
    | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    [126/355] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf_nano.c.obj
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: 'C:\Program Files\CMake\bin\cmake.EXE' --build 'c:\Code\zephyr\bootloader\mcuboot\boot\zephyr\build'

    (venv_zephyr) c:\Code\zephyr\bootloader\mcuboot\boot\zephyr>
    So I presume I misunderstand something!
Reply
  • So trying to figure out why shell isnt working I set up a debug session with MCUBoot    I found this in main.c.


       
    if (FIH_NOT_EQ(fih_rc, FIH_SUCCESS)) {
            BOOT_LOG_ERR("Unable to find bootable image");

            mcuboot_status_change(MCUBOOT_STATUS_NO_BOOTABLE_IMAGE_FOUND);

    #ifdef CONFIG_BOOT_SERIAL_NO_APPLICATION
            /* No bootable image and configuration set to remain in serial
             * recovery mode
             */
            boot_serial_enter();
    #elif defined(CONFIG_BOOT_USB_DFU_NO_APPLICATION)
            rc = usb_enable(NULL);
            if (rc && rc != -EALREADY) {
                BOOT_LOG_ERR("Cannot enable USB");
            } else {
                BOOT_LOG_INF("Waiting for USB DFU");
                wait_for_usb_dfu(K_FOREVER);
            }
    #endif

            FIH_PANIC;
        }
    I ended up stuck on FIH_PANIC at the bottom.   So I enabled 'CONFIG_BOOT_SERIAL_NO_APPLICATION' in prj.conf to enable  'boot_serial_enter()'    And then got told I need ' 'CONFIG_MCUBOOT_SERIAL' as a dependency.  So I also added that to prjk.conf.
    And finally the build now fails.....
    C:/Code/zephyr/bootloader/mcuboot/boot/boot_serial/src/boot_serial_encryption.c:114:31: warning: 'struct enc_data' declared inside parameter list will not be visible outside of this definition or declaration
    114 | decrypt_region_inplace(struct enc_data *enc_data,
    | ^~~~~~~~
    C:/Code/zephyr/bootloader/mcuboot/boot/boot_serial/src/boot_serial_encryption.c: In function 'decrypt_region_inplace':
    C:/Code/zephyr/bootloader/mcuboot/boot/boot_serial/src/boot_serial_encryption.c:169:30: warning: passing argument 1 of 'boot_enc_decrypt' from incompatible pointer type [-Wincompatible-pointer-types]
    169 | boot_enc_decrypt(enc_data,
    | ^~~~~~~~
    | |
    | struct enc_data *
    In file included from c:\code\zephyr\bootloader\mcuboot\boot\bootutil\src\bootutil_priv.h:44,
    from C:/Code/zephyr/bootloader/mcuboot/boot/boot_serial/src/boot_serial_encryption.c:10:
    C:/Code/zephyr/bootloader/mcuboot/boot/bootutil/include/bootutil/enc_key.h:73:44: note: expected 'struct enc_key_data *' but argument is of type 'struct enc_data *'
    73 | void boot_enc_decrypt(struct enc_key_data *enc_state,
    | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
    C:/Code/zephyr/bootloader/mcuboot/boot/boot_serial/src/boot_serial_encryption.c: In function 'decrypt_image_inplace':
    C:/Code/zephyr/bootloader/mcuboot/boot/boot_serial/src/boot_serial_encryption.c:265:37: error: incompatible type for argument 1 of 'decrypt_region_inplace'
    265 | rc = decrypt_region_inplace(enc_data, fa_p, hdr, size, sect_size);
    | ^~~~~~~~
    | |
    | struct enc_key_data
    C:/Code/zephyr/bootloader/mcuboot/boot/boot_serial/src/boot_serial_encryption.c:114:41: note: expected 'struct enc_data ' but argument is of type 'struct enc_key_data'
    114 | decrypt_region_inplace(struct enc_data *enc_data,
    | ~~~~~~~~~~~~~~~~~^~~~~~~~
    C:/Code/zephyr/bootloader/mcuboot/boot/boot_serial/src/boot_serial_encryption.c:274:5: warning: implicit declaration of function 'boot_enc_zeorize'; did you mean 'boot_enc_zeroize'? [-Wimplicit-function-declaration]
    274 | boot_enc_zeorize(&enc_data);
    | ^~~~~~~~~~~~~~~~
    | boot_enc_zeroize
    C:/Code/zephyr/bootloader/mcuboot/boot/boot_serial/src/boot_serial_encryption.c:275:22: warning: passing argument 1 of 'boot_state_clear' from incompatible pointer type [-Wincompatible-pointer-types]
    275 | boot_state_clear(&state);
    | ^~~~~~
    | |
    | struct boot_loader_state **
    In file included from c:\code\zephyr\bootloader\mcuboot\boot\bootutil\src\bootutil_priv.h:37:
    C:/Code/zephyr/bootloader/mcuboot/boot/bootutil/include/bootutil/bootutil.h:89:49: note: expected 'struct boot_loader_state *' but argument is of type 'struct boot_loader_state **'
    89 | void boot_state_clear(struct boot_loader_state *state);
    | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    [126/355] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf_nano.c.obj
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: 'C:\Program Files\CMake\bin\cmake.EXE' --build 'c:\Code\zephyr\bootloader\mcuboot\boot\zephyr\build'

    (venv_zephyr) c:\Code\zephyr\bootloader\mcuboot\boot\zephyr>
    So I presume I misunderstand something!
Children
No Data
Related