Cannot write a simple program based on ZTEST(mcumgr_smp_client_test, test_erase_and_confirm)

Hi,

My main() program is

maiin()

{

    int rc;

    //rc = mcumgr_smp_client_erase();
    //printk("mcumgr_smp_client_erase rc=%d\n", rc);
    //rc = mcumgr_smp_client_confirm_image();
    //printk("mcumgr_smp_client_confirm_image rc=%d\n", rc);
    rc = mcumgr_smp_client_init(NULL);
    printk("mcumgr_smp_client_init rc=%d\n", rc);
    if (rc) return 0;

}

I also added a printk in nrf system code

iff --git a/subsys/dfu/dfu_target/src/dfu_target_smp.c b/subsys/dfu/dfu_target/src/dfu_target_smp.c
index 81b20d69ab..c3a90d86e0 100644
--- a/subsys/dfu/dfu_target/src/dfu_target_smp.c
+++ b/subsys/dfu/dfu_target/src/dfu_target_smp.c
@@ -68,6 +68,7 @@ int dfu_target_smp_client_init(void)
        int rc;
 
        rc = smp_client_object_init(&smp_client, SMP_SERIAL_TRANSPORT);
+       printk("%s rc=%d\n", __func__, rc);
        if (rc) {
                return rc;
        }

But this is what I get

*** Booting nRF Connect SDK v3.3.0-ba167d9f3db4 ***
*** Using Zephyr OS v4.3.99-fd9204a02d52 ***
dfu_target_smp_client_init rc=3
[00:00:00.259,674] <err> nrf_mcumgr_smp_client: Failed to init DFU target SMP, 3
mcumgr_smp_client_init rc=3

Please debug this for me and also debug the commented code. Also, I wish to do a FOTA update through my nRF9160 BLE gateway that I have coded, to my BLE connected peripheral, using SMP, MCUMGR, and all that jazz. I would be grateful if you could provide a complete implementation from the point in which I have downloaded code into a partition on the external flash on the nRF9160DK. I am able to use downloader and get an image from AWS, with some mods to aws_fota. But as you can see from my simple example, I cannot get to first base with the smp and mcumgr code. Thanks. Barring a complete implementation, get me past all the bugs that show up in the library code.

Burt Silverman

  • Sorry for my typos: maiin is main and iff is diff. (I don't know how the first one happened!)

  • Your AI tells me to add

    CONFIG_MCUMGR=y CONFIG_MCUMGR_TRANSPORT_UART=y CONFIG_MCUMGR_GRP_IMG=y CONFIG_MCUMGR_GRP_OS=y CONFIG_NET_BUF=y CONFIG_ZCBOR=y

    and the only one I was missing is CONFIG_MCUMGR_TRANSPORT__UART=y. If I add that, then I get this result

    [00:00:00.254,669] <inf> spi_nor: mx25r6435f@1: 8 MiBy flash
    *** Booting nRF Connect SDK v3.3.0-ba167d9f3db4 ***
    *** Using Zephyr OS v4.3.99-fd9204a02d52 ***
    dfu_target_smp_client_init rc=0
    mcumgr_smp_client_init rc=0
    [00:00:00.264,343] <err> os: ***** SECURE FAULT *****
    [00:00:00.264,373] <err> os:   Address: 0x8
    [00:00:00.264,373] <err> os:   Attribution unit violation
    [00:00:00.264,404] <err> os: r0/a1:  0x00000000  r1/a2:  0x00000000  r2/a3:  0x00000032
    [00:00:00.264,404] <err> os: r3/a4:  0x00000032 r12/ip:  0x0000000c r14/lr:  0x00074c21
    [00:00:00.264,434] <err> os:  xpsr:  0x61000000
    [00:00:00.264,465] <err> os: s[ 0]:  0x40015000  s[ 1]:  0x00000000  s[ 2]:  0x000020e5  s[ 3]:  0x00000000
    [00:00:00.264,495] <err> os: s[ 4]:  0x00000000  s[ 5]:  0x40015000  s[ 6]:  0x00000000  s[ 7]:  0x0005c339
    [00:00:00.264,495] <err> os: s[ 8]:  0x00000000  s[ 9]:  0x0005c27d  s[10]:  0x0007d3ec  s[11]:  0x00000020
    [00:00:00.264,526] <err> os: s[12]:  0x0000210e  s[13]:  0x00070de1  s[14]:  0x20013d40  s[15]:  0x00070d63
    [00:00:00.264,526] <err> os: fpscr:  0x20013d40
    [00:00:00.264,556] <err> os: Faulting instruction address (r15/pc): 0x00074bfa
    [00:00:00.264,587] <err> os: >>> ZEPHYR FATAL ERROR 41: Unknown error on CPU 0
    [00:00:00.264,617] <err> os: Current thread: 0x20013c28 (main)
    [00:00:00.393,188] <err> os: Halting system

    That fault is somewhere in function is_in_flash_area_bounds(). Before we figure that out, here's a problem perhaps: I am not interested in UART transport. I am interested in BT transport, but that cannot be specified in my prj.conf because that is only used for peripherals.

    And here is an example where after I enabled the ...TRANSPORT_UART config option, I also uncommented everything:

    *** Booting nRF Connect SDK v3.3.0-ba167d9f3db4 ***
    *** Using Zephyr OS v4.3.99-fd9204a02d52 ***
    [00:00:00.260,223] <inf> dfu_target_smp: MCUBoot SMP image upgrade aborted 0
    mcumgr_smp_client_erase rc=0
    [00:00:00.260,253] <inf> dfu_target_smp: Confirm Image
    [00:00:00.265,686] <err> os: ***** SECURE FAULT *****
    [00:00:00.265,716] <err> os:   Address: 0x34
    [00:00:00.265,716] <err> os:   Attribution unit violation
    [00:00:00.265,747] <err> os: r0/a1:  0x00000021  r1/a2:  0x00000000  r2/a3:  0x00000001
    [00:00:00.265,777] <err> os: r3/a4:  0x00083aed r12/ip:  0x00000000 r14/lr:  0x0004ff0b
    [00:00:00.265,777] <err> os:  xpsr:  0x61000000
    [00:00:00.265,808] <err> os: s[ 0]:  0x40015000  s[ 1]:  0x00000000  s[ 2]:  0x000020e6  s[ 3]:  0x00000000
    [00:00:00.265,838] <err> os: s[ 4]:  0x00000000  s[ 5]:  0x40015000  s[ 6]:  0x00000000  s[ 7]:  0x0005c359
    [00:00:00.265,838] <err> os: s[ 8]:  0x00000000  s[ 9]:  0x0005c29d  s[10]:  0x0007d4ac  s[11]:  0x00000020
    [00:00:00.265,869] <err> os: s[12]:  0x0000210f  s[13]:  0x00070e9d  s[14]:  0x20013d40  s[15]:  0x00070e1f
    [00:00:00.265,869] <err> os: fpscr:  0x20013d40
    [00:00:00.265,899] <err> os: Faulting instruction address (r15/pc): 0x0004ff0a
    [00:00:00.265,930] <err> os: >>> ZEPHYR FATAL ERROR 41: Unknown error on CPU 0
    [00:00:00.265,960] <err> os: Current thread: 0x20013c28 (main)
    [00:00:00.404,907] <err> os: Halting system

    This time the fault is in smp_client_buf_allocation().

Related