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

The Buttonless DFU Template Application is not working on a custom board

Hi,

I am currently working on a custom product that uses module BMD-300 from u-blox, which has nrf52382 chip in it. My application works fine and now I want to integrate the Secure DFU function into it. I programmed the board with the DFU test image sd_s132_bootloader_buttonless_with_setting_page_dfu_secure_ble_debug_without_bonds.hex but I could not see it advertising when I scan for devices on nrf Connect. Does anyone know what problem could cause it to not advertising? I am using sdk v15.0.0.

Thank you in advance.

Parents
  • The BMD-300 lacks the 32768 Hz RTC (LFXO) quarz crystal that most Nordic examples require. You need to change the LF clock configuration in the source code and recompile - or populate the quarz circuit on XTAL1/XTAL2.

  • I tried your suggestion but the problem still exists. I followed the instruction on this link Add Nordic DFU to SDK Example from u-blox, and then changed the clock configuration afterward, but I still could not see it on the nRF Connect Scanner.

    Now I think the custom board may behave different than the eval board, so I go straight into modify my firmware, which I know is working, and the scanner can see the device. After following the instruction on the link above, I can connect to it through nRF Connect and see the DFU service, but the device is frozen after a few seconds. Same thing happened when I use nRF Connect on Android. The nRF Connect on iOS, on the other hand, can connect to the device without any problem, but it doesn't see the DFU service.

    I know these maybe 2 different problems, but I just want to put it here in case you (or anybody) know the answer for the problems.

  • 00> <info> app: Inside main
    00> <debug> app: In nrf_bootloader_init
    00> <debug> nrf_dfu_settings: Calling nrf_dfu_settings_init()...
    00> <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
    00> <debug> nrf_dfu_settings: Resetting bootloader settings.
    00> <debug> nrf_dfu_settings: Writing settings...
    00> <debug> nrf_dfu_settings: Erasing old settings at: 0x0007F000
    00> <debug> nrf_dfu_flash: nrf_fstorage_erase(addr=0x0x0007F000, len=1 pages), queue usage: 0
    00> <debug> nrf_dfu_flash: Flash erase success: addr=0x0007F000, pending 0
    00> <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x0007F000, src=0x200092A4, len=440 bytes), queue usage: 1
    00> <debug> nrf_dfu_flash: Flash write success: addr=0x0007F000, pending 0
    00> <debug> app: Enter nrf_bootloader_fw_activate
    00> <info> app: No firmwareto activate.
    00> <debug> app: Enter nrf_dfu_app_is_valid
    00> <debug> app: Return false in valid app check
    00> <debug> app: DFU mode because app is not valid.
    00> <info> nrf_bootloader_wdt: WDT is not enabled
    00> <debug> app: in weak nrf_dfu_init_user
    00> <info> app_timer: <info> app: Inside main
    00> <debug> app: In nrf_bootloader_init
    00> <debug> nrf_dfu_settings: Calling nrf_dfu_settings_init()...
    00> <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
    00> <debug> app: Enter nrf_bootloader_fw_activate
    00> <info> app: No firmware to activate.
    00> <debug> app: Enter nrf_dfu_app_is_valid
    00> <debug> app: Return false in valid app check
    00> <debug> app: DFU mode because app is not valid.
    00> <info> nrf_bootloader_wdt: WDT is not enabled
    00> <debug> app: in weak nrf_dfu_init_user
    00> <info> app_timer: RTC: initialized.
    00> <info> app: Entering DFU mode.
    00> <debug> app: Initializing transports (found: 1)
    00> <debug> nrf_dfu_ble: Initializing BLE DFU transport
    00> <debug> nrf_dfu_ble: Setting up vector table: 0x00072000
    00> <debug> nrf_dfu_ble: Enabling SoftDevice.
    00> <debug> nrf_dfu_ble: Configuring BLE stack.
    00> <debug> nrf_dfu_ble: Enabling the BLE stack.
    00> <debug> nrf_dfu_ble: No advertising name found
    00> <debug> nrf_dfu_ble: Using default advertising name
    00> <debug> nrf_dfu_ble: Advertising...
    00> <debug> nrf_dfu_ble: BLE DFU transport initialized.
    00> <debug> nrf_dfu_flash: Initializing nrf_fstorage_sd backend.
    00> <debug> app: Enter main loop

    Here is the log when I run the _debug project. I still can't see the Dfu Targ device when scanning on nRF Connect

  • Now when I rerun it I got an error

    00> <error> app: Fatal error at line 61 in F:\2790_002\sdk\components\libraries\util\app_error_weak.c

    Tracing in the code, line 61 is in the function __WEAK void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info), which is called in sd_softdevice_enable(&clock_lf_cfg, app_error_fault_handler) or __WEAK void assert_nrf_callback(uint16_t line_num, const uint8_t * file_name). The clock is set as follow:

    nrf_clock_lf_cfg_t const clock_lf_cfg =
    {
    .source = NRF_CLOCK_LF_SRC_RC ,
    .rc_ctiv = 0,
    .rc_temp_ctiv = 0,
    .accuracy = NRF_CLOCK_LF_ACCURACY_500_PPM
    };

  • Try setting:

    NRF_SDH_CLOCK_LF_RC_CTIV = 16 and

    NRF_SDH_CLOCK_LF_RC_TEMP_CTIV = 2 in sdk_config.h of your bootloader project.

    You should set these equal to what you set them to in your application's sdk_config.h file.

  • Thank you, my bootloader works now. But my application still freeze after connect on nRF Connect on PC (I haven't even tried to connect to DFU yet). On iOS, I can connect to nRF Connect without freezing, but cannot get into DFU mode. What do you think could cause the problem?

Reply Children
  • Here is where it stops when I try program the device through DFU. If I hit "Connect", it will reconnect to the device like normal and I have to restart the whole process.

  • Do you know whether it is the bootloader or the application that freezes? Try monitoring the log on both.

    Try to monitor the log in the _debug bootloader project. What does it say? Did it change after you changed the LFCLOCK settings?

  • Update: So now everything works with nRF Connect on iOS. I can get the device to go into DFU mode and reprogram it.

    The problem still is that it freezes after connected to nRF Connect on PC. I don't think this problem is related to the DFU function as I haven't even tried to go into DFU mode after the connection. What is the difference between nRF Connect on iOS vs on PC?

  • Can you please let me know what changes you did when everything suddenly started working? Perhaps it is related to the new issues.

    Whenever something works from one device and not another, I suspect bonding issues. Did you enable bonding in the bootloader, or do you use bonding in your application?

    Again, can you try to debug both the application and the bootloader? Does any of the logs give any indications that something is wrong?

    Have you tried to capture a sniffer trace of the BLE connection?

  • I debug the application with IAR. Here is the message I got:

    "The processor has escalated a configurable-priority exception to HardFault. Exception occured at PC = 0x2dd22, LR = 0x2dd71"

    In disassembly, 0x2dd22 and 0x2dd71 are in ble_conn_params.c. 0x2dd22 is at line 4 of this function:

    static bool send_update_request(uint16_t conn_handle, ble_gap_conn_params_t * p_new_conn_params)
    {
        ret_code_t err_code;
        err_code = sd_ble_gap_conn_param_update(conn_handle, p_new_conn_params);
        if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_BUSY)) // NRF_ERROR_BUSY means another conn_param_update request is pending.
        {
            send_error_evt(err_code);
        }
        return (err_code == NRF_SUCCESS);
    }
    
        

    and 0x2dd71 is at line 10 of this function:

    static void update_timeout_handler(void * p_context)
    {
        uint32_t                     conn_handle = (uint32_t)p_context;
        ble_conn_params_instance_t * p_instance  = instance_get(conn_handle);
        if (p_instance != NULL)
        {
            // Check if we have reached the maximum number of attempts
            if (p_instance->update_count < m_conn_params_config.max_conn_params_update_count)
            {
                bool update_sent = send_update_request(conn_handle, &p_instance->preferred_conn_params);
                if (update_sent)
                {
                    p_instance->update_count++;
                }
            }
            else
            {
                p_instance->update_count = 0;
    
                // Negotiation failed, disconnect automatically if this has been configured
                if (m_conn_params_config.disconnect_on_fail)
                {
                    ret_code_t err_code;
                    err_code = sd_ble_gap_disconnect(conn_handle, BLE_HCI_CONN_INTERVAL_UNACCEPTABLE);
                    if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_INVALID_STATE)) // NRF_ERROR_INVALID_STATE means disconnect is already in progress.
                    {
                        send_error_evt(err_code);
                    }
                }
                // Notify the application that the procedure has failed
                if (m_conn_params_config.evt_handler != NULL)
                {
                    ble_conn_params_evt_t evt;
                    evt.evt_type = BLE_CONN_PARAMS_EVT_FAILED;
                    evt.conn_handle = conn_handle;
                    m_conn_params_config.evt_handler(&evt);
                }
            }
        }
    }

    From the log I can see that it happened after the BLE_GAP_EVT_DATA_LENGTH_UPDATE event. 

Related