This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Upgrade firmware from gateway to node over using nRF Connect SDK

Base Samples used -

1. Central DFU SMP Client - <ncs>/nrf/samples/bluetooth/central_dfu_smp

2. SMP Server sample - <ncs>/zephyr/samples/subsys/mgmt/mcumgr/smp_svr

Procedure followed -

1. In the SMP Server sample, commented out "CONFIG_MCUMGR_CMD_FS_MGMT" and "CONFIG_MCUMGR_SMP_SHELL" and kept it running nRF52840DK.

2. Made "hello_world" sample compatible with MCUBoot and generated "app_update.bin".

3. Enabled QSPI flash, LFS and pushed the "app_update.bin" using nRF Device Manager File upload on a modified Central DFU SMP Client running on another nRF52840DK

4. Populated the SMP Command header with Command Group - 1 (IMG_MGMT), Command ID - 1 (Image upload), Operation ID - 2 (Write)

5. As mentioned in this SMP Server limitation, used "seq_num" of the header from base index 0 and also base index 1, to indicate that the data transmitted is part of the same command.

6. Uploaded image is not available in the SMP Server node.

Observations -

1. When the same SMP Server node is used with nRF Connect for Mobile / nRF Device Manager, image upload works fine and the new firmware boots up.

Questions -

1. Is the procedure followed correct? Is there any sample that can help with uploading a firmware image and boot it, from Zephyr (NCS) to Zephyr (NCS) running nodes?

2. In the SMP Server limitation , what does "whole command to be sent in one transfer" mean?

3. Kindly feel free to request any information that could help make the DFU procedure work.

  • I tried to follow your points, but I did not understand what you're were trying to do. If you could add some explanations to each step, that would be nice.

    I do not have too much in-depth knowldege about CBOR, but I think I know what needs to be done in order to achieve your goal: "uploading a firmware image and boot it, from Zephyr (NCS) to Zephyr (NCS) running nodes". I think you have to copy the function send_smp_echo() into several function, to make it possible to issue the commands image uploadimage list, image testreset and image confirm. In addition to the echo command.

    Then you can store a .bin file with the image to be upload on the device (or external flash) with the central_dfu_smp sample and transfer it over BLE to another device with the smp_svr sample.

    If you're unsure how to go about this, please ask, and I will do some more investigation and try to assist you.

    Best regards,

    Simon

  • I understood the steps to complete the DFU. As of now, I could do the steps "image upload", "image list", "reset" successfully. Now facing this issue - Image uploads successfully, and on "image list" command, I get both the slots listed. However when I send "image confirm" using following header and payload, state does not change to "pending":true, which would be required for the slot 1 image to boot up.

    cbor_buf_writer_init(&writer, smp_cmd.payload, sizeof(smp_cmd.payload));
    cbor_encoder_init(&cbor, &writer.enc, 0);
    cbor_encoder_create_map(&cbor, &cbor_map, 2);
    
    	
    cbor_encode_text_stringz(&cbor_map, "confirm");
    cbor_encode_boolean(&cbor_map, true);
    
    cbor_encode_text_stringz(&cbor_map, "hash");
    cbor_encode_text_string(&cbor_map, firmware_hash_sha, strlen(firmware_hash_sha));
    	
    cbor_encoder_close_container(&cbor, &cbor_map);
    
    payload_len = (size_t)(writer.ptr - smp_cmd.payload);
    
    smp_cmd.header.op = 2;
    smp_cmd.header.flags = 0;
    smp_cmd.header.len_h8 = (uint8_t)((payload_len >> 8) & 0xFF);
    smp_cmd.header.len_l8 = (uint8_t)((payload_len >> 0) & 0xFF);
    smp_cmd.header.group_h8 = 0;
    smp_cmd.header.group_l8 = 1;
    smp_cmd.header.seq = 0;
    smp_cmd.header.id = 0;

    What should be the header and payload for "image test" and "image confirm"?

  • I'll look into this the upcoming Monday/Tuesday.

    Best regards,

    Simon

  • Fixed the issue. In that snippet, used CBOR Byte String encode instead of text string encode, and converted the firmware_hash_sha to upper case hex representation (i.e. 0xae to 0xAE). TEST and Confirm swap types are working now. Thank you for spending time on the issue.

Related