DFU BLE bootloader doesn't seem to work

I am trying to implement the smp_svr example as described here: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/samples/subsys/mgmt/mcumgr/smp_svr/README.html.

I have successfully built and flashed the MCU bootloader. (to a nRF52840dk)

I have successfully built, the mcumgr.

I have successfully built, signed, and flashed the smp_svr.

At this point I looked at my nRF_CONNECT_FOR_MOBILE scanner but I do not see the device.

I modified the smp_svr bluetooth.c as follows:

/*
static const struct bt_data ad[] = {
BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
BT_DATA_BYTES(BT_DATA_UUID128_ALL,
0x84, 0xaa, 0x60, 0x74, 0x52, 0x8a, 0x8b, 0x86,
0xd3, 0x4c, 0xb7, 0x1d, 0x1d, 0xdc, 0x53, 0x8d),
};
*/
static const struct bt_data ad[] = {
BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
BT_DATA_BYTES(BT_DATA_UUID128_ALL,
0x84, 0xaa, 0x60, 0x74, 0x52, 0x8a, 0x8b, 0x86,
0xd3, 0x4c, 0xb7, 0x1d, 0x1d, 0xdc, 0x53, 0x8d),
BT_DATA(BT_DATA_NAME_COMPLETE, "Zephyr_DFU", 8),
};

This I did because I was unsure what the default advertising name was.

I then rebuilt, resigned, and re-flashed.

I still did not see the the device on my scanner.

When I attempt to flash with mcumgr It doesn't connect.

sudo ~/go/bin/mcumgr --conntype ble --connstring ctlr_name=hci0,peer_name='Zephyr' echo hello
hello
Error: Failed to connect to peer after 10s

and

sudo ~/go/bin/mcumgr --conntype ble --connstring ctlr_name=hci0,peer_name='ZephyrDFU' echo hello
Error: Failed to connect to peer after 10s

This suggests to me the smp_svr program isn't working correctly.

I'm not sure where to go with this, any suggestions?

Regards,

Jerry

Parents
  • Hi Jerry, 

    Could you please let me know which NCS SDK version you are using ? The implementation of smp_svr has been changed lately especially in NCS v2.3.0 and NCS v2.4.0

    When you build smp_svr, did you use the overlay-bt.conf in addition to the prj.conf ? 

    Please be aware that when you build smp_svr it will automatically build MCUBoot as the child image so you don't have to flash anything else in addition. 

    My suggestion is to use a phone to check if the device advertise or not after you flash. You then can use nRF Connect app on the phone to do an DFU update. 
    After you can verify that it works with a phone, then you can continue the test with mcumgr on PC. 

  • Hi Hung,

    My SDK is 2.4.1; toolchain is 2.4.0.

    This is the command I used to build thee smp_svr.

    (.venv) jerry@Ubuntu:~/zephyrproject$ west build \
                -b nrf52840dk_nrf52840 \
                zephyr/samples/subsys/mgmt/mcumgr/smp_svr \
                -- \
                -DEXTRA_CONF_FILE=overlay-bt.conf


    :It sounds like you are assuming I'm building smp_svr under VSCODE; I am following the instructions, which use west command line tools to build mcuboot, and smp_svr in discrete steps.  I don't understand how to do this under VSCODE; the documentation is enigmatic and confusing.  In addition, including the necessary prj.conf statements for mcuboot causes build errors.  If you know how to do it under VSCODE I would prefer to do it that way.

    I did use my iPad to check for the advertisement; The scanner did not display the device.

    Regards,

    Jerry

  • Hi Jerry, 
    I attached here how i built the project with VS Code:
    First you create new application based on smp_svr: 


    After that you create the configuration, and select the overlay_bt.conf as the Kconfig fragments, make sure you click OK after you select the file:


    After the build, you should be able to find overlay_bt.conf in the project configuration: 


    I attached here the hex file that worked for me: 
    4544.merged.hex

  • Hi Hung,

    I followed your excellent instructions and voila, I can see the advertisement on iPad!

    Thank you so much!

    Regards,

    Jerry

  • I am trying to upload my blinky sample to the smp_svr; I'm getting errors because the zephyr.bin file is unsigned,  Is there a way to sign it under vscode?

    Regards,

    Jerry

  • Hi Jerry, 

    You should use app_update.bin. It's the signed binary that you can use to do FOTA. 

    You can read more about different hex/bin files here: 
    developer.nordicsemi.com/.../multi_image.html

  • Hi Hung,

    I have (I think) gotten the smp_svr sample working correctly. I have established a serial connection under vscode and it will interact with me.  However, I have modified both the blinky and hello_world sample applications to upload to the smp_svr via ble.  I get the following message: "[00:02:31.535,949] <inf> smp_bt_sample: Disconnected (reason 0x13)" from the smp_svr.  I suspect that I have not correctly configured the apps I am trying to upload.

    This is my prj.conf for blinky:

    CONFIG_GPIO=y
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_MCUBOOT_SIGNATURE_KEY_FILE=""

    This is the serial log file at reset

    uart:~$ *** Booting Zephyr OS build v3.3.99-ncs1-1 ***
    [00:00:00.006,927] <inf> bt_hci_core: Identity: C7:28:33:33:F4:D5 (random)
    [00:00:00.006,958] <inf> bt_hci_core: HCI: version 5.4 (0x0d) revision 0x1077, manufacturer 0x0059
    [00:00:00.006,988] <inf> bt_hci_core: LMP: version 5.4 (0x0d) subver 0x1077
    [00:00:00.007,904] <inf> smp_bt_sample: Advertising successfully started

    In a terminal, I entered my upload command:

    (.venv) jerry@Ubuntu:~/zephyrproject$ sudo ~/go/bin/mcumgr --conntype ble --connstring ctlr_name=hci0,peer_name='Zephyr' image upload ~/MyApps/blinky/build_dk/zephyr/app_update.bin
     23.03 KiB / 23.03 KiB [=====================================================================================================================] 100.00% 9.22 KiB/s 2s
    Done

    The serial log responded with:

    [00:00:00.007,965] <inf> smp_sample: build time: Aug 15 2023 05:04:51
    [00:01:52.927,215] <inf> smp_bt_sample: Connected
    [00:01:53.752,197] <inf> mcumgr_img_grp: Erased 0x6000 bytes of image slot
    [00:01:53.849,670] <inf> mcumgr_img_grp: Erased 0x1000 bytes of image slot trailer
    [00:01:55.670,562] <inf> smp_bt_sample: Disconnected (reason 0x13)
    [00:01:55.672,058] <inf> smp_bt_sample: Advertising successfully started

    The blinky application, apparently, was not started; (led0 not blinking).

    Do you have any ideas?

    Regards,

    Jerry

Reply
  • Hi Hung,

    I have (I think) gotten the smp_svr sample working correctly. I have established a serial connection under vscode and it will interact with me.  However, I have modified both the blinky and hello_world sample applications to upload to the smp_svr via ble.  I get the following message: "[00:02:31.535,949] <inf> smp_bt_sample: Disconnected (reason 0x13)" from the smp_svr.  I suspect that I have not correctly configured the apps I am trying to upload.

    This is my prj.conf for blinky:

    CONFIG_GPIO=y
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_MCUBOOT_SIGNATURE_KEY_FILE=""

    This is the serial log file at reset

    uart:~$ *** Booting Zephyr OS build v3.3.99-ncs1-1 ***
    [00:00:00.006,927] <inf> bt_hci_core: Identity: C7:28:33:33:F4:D5 (random)
    [00:00:00.006,958] <inf> bt_hci_core: HCI: version 5.4 (0x0d) revision 0x1077, manufacturer 0x0059
    [00:00:00.006,988] <inf> bt_hci_core: LMP: version 5.4 (0x0d) subver 0x1077
    [00:00:00.007,904] <inf> smp_bt_sample: Advertising successfully started

    In a terminal, I entered my upload command:

    (.venv) jerry@Ubuntu:~/zephyrproject$ sudo ~/go/bin/mcumgr --conntype ble --connstring ctlr_name=hci0,peer_name='Zephyr' image upload ~/MyApps/blinky/build_dk/zephyr/app_update.bin
     23.03 KiB / 23.03 KiB [=====================================================================================================================] 100.00% 9.22 KiB/s 2s
    Done

    The serial log responded with:

    [00:00:00.007,965] <inf> smp_sample: build time: Aug 15 2023 05:04:51
    [00:01:52.927,215] <inf> smp_bt_sample: Connected
    [00:01:53.752,197] <inf> mcumgr_img_grp: Erased 0x6000 bytes of image slot
    [00:01:53.849,670] <inf> mcumgr_img_grp: Erased 0x1000 bytes of image slot trailer
    [00:01:55.670,562] <inf> smp_bt_sample: Disconnected (reason 0x13)
    [00:01:55.672,058] <inf> smp_bt_sample: Advertising successfully started

    The blinky application, apparently, was not started; (led0 not blinking).

    Do you have any ideas?

    Regards,

    Jerry

Children
  • Hi Hung,

    Just a side note:

    I tried to build smp_svr with a board, nreff52840dongle_nrf52840, I get a build error:

    [74/140] Building C object modules/nrf/subsys/bluetooth/controller/CMakeFiles/..__nrf__subsys__bluetooth__controller.dir/hci_driver.c.obj
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: /home/jerry/ncs/toolchains/1f9b40e71a/usr/local/bin/cmake --build /home/jerry/MyApps/smp_svr/build_dongle

    There seems to be some kind of issue with dongles and bootloaders: do you know anything about it? 

    Regards,

    Jerry

  • Hi Jerry, 

    Please try to do FOTA update with your tablet before you try with the mcumgr. You can use nRF Connect or nRF Device Manager to do update. 

    For a FOTA process to complete you would need to either test or confirm the new image (confirm is done automatically in the app on the tablet)

    Please take a look at the documentation here: https://docs.zephyrproject.org/latest/services/device_mgmt/mcumgr.html

    For test (only run new image once then revert back to original application) you need to do: 

    mcumgr <connection-options> image test <hash> 

    + a reset

    For confirm (permanently switch the imag) you need to call: 

    mcumgr <connection-options> image confirm <hash> 

    + a reset.

     

  • What is the <hash> item and how do I obtain it?

    Jerry

  • Hi Jerry, 
    Please read the documentation.
     https://docs.zephyrproject.org/latest/services/device_mgmt/mcumgr.html
    You will see the hash when you call 

    mcumgr <connection-options> image list
  • Hi Hung,

    You will have to forgive me; I have read the documentation a 1000 times; I don't understand it; it if full of buzz words which are not defined and I can't figure out what it is talking about.

    This is what I see:

    Images:
     image=0 slot=0
        version: 0.0.0
        bootable: true
        flags: active confirmed
        hash: ea9c889031e33c8c9c500e00e8ed94454f536368c499c186688f323a48f973b4
     image=0 slot=1
        version: 0.0.0
        bootable: true
        flags: pending
        hash: 582ef2530f15968c39513443f312418a0179dac2050b1146bd727467df042564
    Split status: N/A (0)

    As you can see I have two images. I presume one is my smp_svr application and one is my binky application; I don't know which is which.

    I don't know how this works; I have uploaded my blinky image, apparently, successfully.  From your comments above I need to do two additional steps in order to get my blinky application running.  In order to do that I need to specify the <hash>, of which I have two; which should I use?

    Let us suppose that I have my blinky application up and running and I want to update it; how do I do that if the smp_svr is no longer active?

    Regards,

    Jerry

Related