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

NRF DFU HARDWARE VERSION reply not working as expected

Hello,

I am using SDK 15.3 for the development. During the upgrade process I wanted to send the hardware version when requested by the host.

//nrf_dfu_req_handler.c LINE: ~126

static void on_hw_version_request(nrf_dfu_request_t const * p_req, nrf_dfu_response_t * p_res)
{
    NRF_LOG_DEBUG("Handle NRF_DFU_OP_HARDWARE_VERSION");

    p_res->hardware.hw_version = NRF_DFU_HW_VERSION;
    p_res->hardware.part    = NRF_FICR->INFO.PART;
    p_res->hardware.variant = NRF_FICR->INFO.VARIANT;


    /* FICR values are in Kilobytes, we report them in bytes. */
    p_res->hardware.memory.ram_size      = NRF_FICR->INFO.RAM   * 1024;
    p_res->hardware.memory.rom_size      = NRF_FICR->INFO.FLASH * 1024;
    p_res->hardware.memory.rom_page_size = NRF_FICR->CODEPAGESIZE;
}

////////////////////////////////////////////////////////
//  nrf_dfu_req_handler.h    LINE: ~130
typedef struct
{

    uint32_t part;                      //!< Hardware part, from FICR register.
    uint32_t variant;                   //!< Hardware variant, from FICR register.
    struct
    {
        uint32_t rom_size;              //!< ROM size, in bytes.
        uint32_t ram_size;              //!< RAM size, in bytes.
        uint32_t rom_page_size;         //!< ROM flash page size, in bytes.
    } memory;
    uint32_t hw_version;

} nrf_dfu_response_hardware_t;


I have made the changes as seen in the code snippet. But I receive just the 32 bytes before modification. Any changes to these variables is reflected in the output that is read.

The problem is when I add an extra uint32_t variable, it doesn't reply!

What could be the problem?

In the image below the value for Hw Version is supposed to be 9(Nine).

HW Output

Thank you!

Best regards,

Navin

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Upgrade Type: NRF_SERIAL_DFU

Device: nRF52832

I have also checked this line, which makes sense. 

#define NRF_SERIAL_MAX_RESPONSE_SIZE (sizeof(nrf_dfu_response_t))

Parents
  • Hi Navin, 

    I am not sure I fully understand what you wrote here: 

    I have made the changes as seen in the code snippet. But I receive just the 32 bytes before modification. Any changes to these variables is reflected in the output that is read.

    The problem is when I add an extra uint32_t variable, it doesn't reply!

    So what exactly happened after you add the uint32_t variable in ? it didn't reply or you still receive the 32bytes before modification ? 

    Could you try putting a log or debug the bootloader to see what is used in   p_req->callback.response(&response, p_req->p_context); call ? To check if the hardware version is included ? 
    If you capture an UART trace, what would you see in the trace ? Is there any chance that the hardware version is replied but the DFU master didn't parse it ? 

  • Hi Hung Bui,

    I found the problem.

    Although the hardware structure was modified to accommodate HW Version, it was not serialized. 

    case NRF_DFU_OP_HARDWARE_VERSION:
                {
                    index += uint32_encode(p_response->hardware.part,                 &p_serialized_rsp[index]);
                    index += uint32_encode(p_response->hardware.variant,              &p_serialized_rsp[index]);
                    index += uint32_encode(p_response->hardware.memory.rom_size,      &p_serialized_rsp[index]);
                    index += uint32_encode(p_response->hardware.memory.ram_size,      &p_serialized_rsp[index]);
                    index += uint32_encode(p_response->hardware.memory.rom_page_size, &p_serialized_rsp[index]);
                    index += uint32_encode(p_response->hardware.hw_version, 		  &p_serialized_rsp[index]);
                } break;

    This is the reason it was missing on the response from the slave.

    Thank you for your response!

    Best regards,

    Navin

Reply
  • Hi Hung Bui,

    I found the problem.

    Although the hardware structure was modified to accommodate HW Version, it was not serialized. 

    case NRF_DFU_OP_HARDWARE_VERSION:
                {
                    index += uint32_encode(p_response->hardware.part,                 &p_serialized_rsp[index]);
                    index += uint32_encode(p_response->hardware.variant,              &p_serialized_rsp[index]);
                    index += uint32_encode(p_response->hardware.memory.rom_size,      &p_serialized_rsp[index]);
                    index += uint32_encode(p_response->hardware.memory.ram_size,      &p_serialized_rsp[index]);
                    index += uint32_encode(p_response->hardware.memory.rom_page_size, &p_serialized_rsp[index]);
                    index += uint32_encode(p_response->hardware.hw_version, 		  &p_serialized_rsp[index]);
                } break;

    This is the reason it was missing on the response from the slave.

    Thank you for your response!

    Best regards,

    Navin

Children
No Data
Related