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

52840 DFU operational failure/question

I am porting the Microsoft Sphere example (https://github.com/Azure/azure-sphere-samples/tree/master/Samples/ExternalMcuUpdate) that updates a Nordic nRF52 Development Kit over UART using the MT3620 Sphere Development Kit. The port involves moving this example from the Nordic nRF52 kit to an Avnet PMOD using the 52840 rather than the nRF52 Development Kit.

The Nordic nRF52 DK uses the S132 softdevice in conjunction with the PCA10040 hardware platform and utilizes LED2 and LED4 to indicate which application software (BlinkV1 or Blinkv2) is running.  The changes necessary for the PMOD involve mostly changing the LED operation to account for a single tri-color LED rather than seperate LED's.  So the changes involved in the port are:

1) the bootloader was changed to handle the LED changes.

2) The Application files were changes to handle LED changes.

3) The Sphere Applications were changes to indicate different LED colors to represent the different Apps

4) The softdevice was changes changed to use the S140 bootloader rather than the S132.

All these changes are have been captured in the https://github.com/jflynn129/FlashPMOD github repository.


├── AzureSphere_HighLevelApp
│   ├── External NRF52 Firmware
│   │THIS FOLDER CONTAINS ALL APPLICATIOIN AND SOFTDEVICES USED DURING DFU
│   ├── ExternalMcuUpdateNrf52
│   │CONTAINS THE APPLICATION CODE USED IN SPHERE APPLICATION
│   └── ExternalMcuUpdateNrf52.sln
├── Binaries
│   CONTAINS THE SOFTDEVICE USING BY THE PMOD
├── Hardware
│   CONTAINS THE HARDEWARE FOLDER FOR THE AVNET ME3620
├── PMODApps
│   CONTAINS THE CODE FOR THE PMOD APPLICATION
├── PMODBootloader
│   CONTAINS THE BOOTLOADER CODE FOR THE PMOD
└── docs
   DOCUMENTATION RELATED TO THE PMOD AND AES-MS-MT3620

I used the Nordic ‘nrfutil’ CLI to convert the hex files into the corresponding files used in Sphere Application to perform the DFU. Specifically, I use the command:

‘nrfutil pkg generate –sd-req “0xA9”,”0xAE” –hw-version 52 –application-version 1 –application blinky_pca10056_mbr.hex BLUEv1.zip’

(when creating the data for the BLUE LED application).  After this command complete, I extracted the *.dat and *.bin files from the zip and add it to the Azure Sphere application. 

All this appears to work correctly, but when the bootloader and Azure Sphere application begins the update process configuration and security information exchange fails as shown below:

<info> app: Initialization complete, Inside main

<debug> app: In nrf_bootloader_init

<debug> app: DFU pin is active...

<debug> nrf_dfu_settings: Calling nrf_dfu_settings_init()...

<debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.

<debug> nrf_dfu_settings: Settings OK

<debug> app: Enter nrf_bootloader_fw_activate

<info> app: No firmware to activate.

<debug> app: Enter nrf_dfu_app_is_valid

<debug> app: No valid app to boot.

<debug> app: DFU mode because app is not valid.

<info> nrf_bootloader_wdt: WDT is not enabled

<debug> app: in weak nrf_dfu_init_user

<debug> app: timer_stop (0x20000060)

<debug> app: timer_activate (0x20000060)

<info> app: Entering DFU mode.

<debug> app: Initializing transports (found: 1)

<debug> nrf_dfu_serial_uart: serial_dfu_transport_init()

<debug> nrf_dfu_serial_uart: serial_dfu_transport_init() completed

<debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.

<debug> app: Enter main loop

<debug> app: Shutting down transports (found: 1)

<debug> nrf_dfu_serial: Received ping 2

 

<info> nrf_dfu_serial_uart: Allocated buffer 20002948

<debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_PING

<debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1

<debug> nrf_dfu_serial: Sending Response: [0x9, 0x1]

<debug> app: Shutting down transports (found: 1)

<debug> nrf_dfu_serial: Set receipt notif target: 0

 

<info> nrf_dfu_serial_uart: Allocated buffer 20002948

<debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_RECEIPT_NOTIF_SET

<debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1

<debug> nrf_dfu_serial: Sending Response: [0x2, 0x1]

<debug> app: Shutting down transports (found: 1)

<debug> nrf_dfu_serial: Received serial mtu

 

<info> nrf_dfu_serial_uart: Allocated buffer 20002948

<debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_MTU_GET

<debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1

<debug> nrf_dfu_serial: Sending Response: [0x7, 0x1]

<debug> app: Shutting down transports (found: 1)

 

<info> nrf_dfu_serial_uart: Allocated buffer 20002948

<debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_FIRMWARE_VERSION

<debug> nrf_dfu_req_handler: Firmware image requested: 0

<debug> nrf_dfu_req_handler: Bootloader type 2

<debug> nrf_dfu_req_handler: Bootloader version 0

<debug> nrf_dfu_req_handler: Bootloader addr u

<debug> nrf_dfu_req_handler: Bootloader len u

<debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1

<debug> nrf_dfu_serial: Sending Response: [0xB, 0x1]

<debug> app: Shutting down transports (found: 1)

 

 

<info> nrf_dfu_serial_uart: Allocated buffer 20002948

<debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_FIRMWARE_VERSION

<debug> nrf_dfu_req_handler: Firmware image requested: 1

<debug> nrf_dfu_req_handler: No such firmware image

<debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1

<debug> nrf_dfu_serial: Sending Response: [0xB, 0x1]

<debug> app: Shutting down transports (found: 1)

 

<info> nrf_dfu_serial_uart: Allocated buffer 20002948

<debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_SELECT (command)

<debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1

<debug> nrf_dfu_serial: Sending Response: [0x6, 0x1]

<debug> app: Shutting down transports (found: 1)

 

<info> nrf_dfu_serial_uart: Allocated buffer 20002948

<debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_CREATE (command)

<debug> app: timer_stop (0x20000060)

<debug> app: timer_activate (0x20000060)

<debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1

<debug> nrf_dfu_serial: Sending Response: [0x1, 0x1]

<debug> app: Shutting down transports (found: 1)

 

<info> nrf_dfu_serial_uart: Allocated buffer 200029CC

<debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (command)

<debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1

<debug> app: Shutting down transports (found: 1)

 

<info> nrf_dfu_serial_uart: Allocated buffer 20002948

<debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (command)

<debug> app: Shutting down transports (found: 1)

 

<info> nrf_dfu_serial_uart: Allocated buffer 20002948

<debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1

<debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_CRC_GET (command)

<debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1

<debug> nrf_dfu_serial: Sending Response: [0x3, 0x1]

<debug> app: Shutting down transports (found: 1)

 

<info> nrf_dfu_serial_uart: Allocated buffer 20002948

<debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_EXECUTE (command)

<debug> nrf_dfu_validation: PB: Init packet data len: 70

<error> nrf_dfu_ver_validation: The application requires soft device.

<warning> nrf_dfu_ver_validation: SD req not met.

<debug> nrf_dfu_req_handler: Request handling complete. Result: 0xB

<warning> nrf_dfu_serial: DFU request completed with result: 0xB

<debug> nrf_dfu_serial: Sending Response: [0x4, 0xB]  

 

I suspect I have a configuration issue.  I've tried reading through your documentation but there isn't any explaination of what the various codes are and what "SD req not met"  is actually telling me. It says "The application requires soft device" but I am providing one in the download.  Can you point me to some documentation that better describes the errors and interactions needed to resolve this issue?

Additionally, should I switch over and try the open DFU example (from the SDK) rather than the MSFT example?

Thanks for any assistance.

Parents
  • Hi JMF, 

    if you take a look at the sd_req_ok() in nrf_dfu_ver_validation.c

    static bool sd_req_ok(dfu_init_command_t const * p_init)
    {
        ASSERT(p_init != NULL);
        bool result;
    #if defined(BLE_STACK_SUPPORT_REQD) || defined(ANT_STACK_SUPPORT_REQD)
        // The bootloader needs the SoftDevice, so disabling NRF_DFU_APP_DOWNGRADE_PREVENTION
        // should not be applied to SoftDevice updates.
        const bool prevent_downgrade = NRF_DFU_APP_DOWNGRADE_PREVENTION || (p_init->type == DFU_FW_TYPE_SOFTDEVICE);
    #else
        const bool prevent_downgrade = NRF_DFU_APP_DOWNGRADE_PREVENTION;
    #endif
    
        if (SD_PRESENT)
        {
            if (p_init->sd_req_count == 0)
            {
                result = false;
            }
            else if (p_init->sd_req[0] != SD_REQ_APP_OVERWRITES_SD)
            {
                result = sd_req_check(p_init->sd_req,
                                      p_init->sd_req_count,
                                      (p_init->type == DFU_FW_TYPE_EXTERNAL_APPLICATION));
            }
            else if (p_init->type == DFU_FW_TYPE_APPLICATION)
            {
                // The application wants to overwrite the SoftDevice.
                if (prevent_downgrade && (p_init->sd_req_count > 1) && (p_init->sd_req[0] == SD_REQ_APP_OVERWRITES_SD))
                {
                    // The application can overwrite the SD if sd_req[0] == 0 and table has the FWID of the current SD.
                    result = sd_req_check(p_init->sd_req, p_init->sd_req_count, false);
    
                    // Prevent BLE bootloaders from allowing applications overwriting the SoftDevice.
    #ifdef BLE_STACK_SUPPORT_REQD
                    result = false;
    #endif // BLE_STACK_SUPPORT_REQD
                }
                else
                {
                    result = true;
                }
            }
    #if NRF_DFU_SUPPORTS_EXTERNAL_APP
            else if(p_init->type == DFU_FW_TYPE_EXTERNAL_APPLICATION)
            {
                // Won't accept FW upgrade using external application to
                // enforce replacing SoftDevice (SD_REQ_APP_OVERWRITES_SD)
                result = false;
            }
    #endif // NRF_DFU_SUPPORTS_EXTERNAL_APP
            else
            {
                // Don't allow SoftDevice updates which assume no SD is present already.
                result = !prevent_downgrade || (p_init->type != DFU_FW_TYPE_SOFTDEVICE);
            }
        }
    
        else
        {
            if (p_init->sd_req_count && (p_init->sd_req[0] != SD_REQ_APP_OVERWRITES_SD))
            {
                // Fail if there is no SD and the update requires SD. The special "any" FWID is valid
                // for external apps only.
                result = false;
    #if NRF_DFU_SUPPORTS_EXTERNAL_APP
                result = sd_req_check(p_init->sd_req,
                                      p_init->sd_req_count,
                                      (p_init->type == DFU_FW_TYPE_EXTERNAL_APPLICATION));
    #endif // NRF_DFU_SUPPORTS_EXTERNAL_APP
            }
            else
            {
                // If there is no SD and update has SD it is accepted only if it has a fw_version.
                result = !prevent_downgrade || p_init->has_fw_version;
            }
        }
        return result;
    }

    Then you'll see that the bootloader does not allow SoftDevice updates if there are no SD already present on the nRF device. So you will have to flash a SoftDevice together with the Bootloader eventhough the Bootloader does not require the SD. 

    Best regards

    Bjørn

  • Bjorn, thank you for the response. I am using the SEGGER Embedded Stdio, can you possible tell me how do I add the SD to the bootloader so that when it downloads, it includes the SD?  Also, is there anyway to tell the DFU SW to ignore the presence of a SD and simply program the one that is provided?

Reply Children
Related