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

NRF52832 buttonless dfu IAR

Hi.

I did the secure bootloader DFU. I attained step 8 in document.


I instal softdevice and secure bootloader to flash nRF52832. After make the ble_app_buttonless_dfu start download and debug but program not start.

If install only softdevice and buttonless_dfu then I got error "No bootloader was found".

If install softdevice and bootloader after buttonless dfu then I got not start programs.

Although security bootloader work. 
The verification was performed in the following steps:

E1. Generate new firmware.

E2. Generate new DFU .zip package.

E3. Switch the device to DFU mode, do DFU update and verify new image is running.

Help me.

Parents
  • Hi Alex, 

    Could you test first with a normal application instead of the buttonless example ? For example ble_app_hrs ? 

    Buttonless example requires bootloader setting to be generated and flashed. 

    I would suggest you to follow the tutorial here

  • I made the following:

    Step A. Generating keys.

    Step B. Build the bootloader.

    B1. Compile the uECC library.

    I download the library to the SDK folder.

     start building uECC.

    Copy the public_key in IAR.

    Build the bootloader.

    Step C.

    generate bootloader setting.

    mergehex


    zip file



    watch the video here

    What do I do wrong? 
  • In project ble_app_uart function advertising_start have the form 

    static void advertising_start(void)
    {
        uint32_t err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);
        APP_ERROR_CHECK(err_code);
    }

    In project ble_app_buttonless_dfu function advertising_start have the form 

    static void advertising_start(bool erase_bonds)
    {
        if (erase_bonds == true)
        {
            delete_bonds();
            // Advertising is started by PM_EVT_PEERS_DELETE_SUCCEEDED event.
        }
        else
        {
            uint32_t err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);
            APP_ERROR_CHECK(err_code);
    
            NRF_LOG_DEBUG("advertising is started");
        }
    }

    What function to use advertising_start ?

  • I solved the compilation problems. I changed the function "services_init(void)" of project ble_app_uart in:

    static void services_init(void)
    {
        uint32_t           err_code;
        ble_nus_init_t     nus_init;
        nrf_ble_qwr_init_t qwr_init = {0};
        ble_dfu_buttonless_init_t dfus_init = {0};
    
        // Initialize Queued Write Module.
        qwr_init.error_handler = nrf_qwr_error_handler;
    
        err_code = nrf_ble_qwr_init(&m_qwr, &qwr_init);
        APP_ERROR_CHECK(err_code);
    
        // Initialize NUS.
        memset(&nus_init, 0, sizeof(nus_init));
    
        nus_init.data_handler = nus_data_handler;
    
        err_code = ble_nus_init(&m_nus, &nus_init);
        APP_ERROR_CHECK(err_code);
        
        //***** buttonless DFU *****
    
        // Initialize the async SVCI interface to bootloader.
        err_code = ble_dfu_buttonless_async_svci_init();
        APP_ERROR_CHECK(err_code);
    
        dfus_init.evt_handler = ble_dfu_evt_handler;
    
        err_code = ble_dfu_buttonless_init(&dfus_init);
        APP_ERROR_CHECK(err_code);
    
       //**************************
    }

    and add peer_manager_init

    nt main(void)
    {
        bool erase_bonds;
        
      //  static uint32_t pages_to_erase = 1;
        
        // Initialize.
        log_init();
        timers_init();
        buttons_leds_init(&erase_bonds);
        power_management_init();
        ble_stack_init();
        peer_manager_init();
        gap_params_init();
        gatt_init();
        services_init();
        advertising_init();
        conn_params_init();
    
        // Start execution.
        
        advertising_start(erase_bonds);

    I want start buttonless DFU with command. I get command through ble uart.  How do I may it make?

  • I got an error again.

    What do I do wrong?

    bootloader uploaded

  • How do start work DFU? I use function ble_dfu_buttonless_bootloader_start_finalize(); but she not started DFU. 

  • Hi Alex, 

    Have you tried and have an overview of how the ble_app_buttonless_dfu works ? 

    Like what is the main purpose of the buttonless service ? When would the buttonless service execute a reset to switch to bootloader, how to trigger that  ? 

    The documentation is a little bit vague about this but it's something you need to study and understand before porting it to you application. 

    I attached here the example I made to integrate dfu buttonless into ble uart. It's only KEIL support for now, but you can follow the exact project setting and the same main.c should works for you. It's for SDK v15.0 (most likely also works on 15.2)

    ble_app_uart - Buttonless.zip

Reply
  • Hi Alex, 

    Have you tried and have an overview of how the ble_app_buttonless_dfu works ? 

    Like what is the main purpose of the buttonless service ? When would the buttonless service execute a reset to switch to bootloader, how to trigger that  ? 

    The documentation is a little bit vague about this but it's something you need to study and understand before porting it to you application. 

    I attached here the example I made to integrate dfu buttonless into ble uart. It's only KEIL support for now, but you can follow the exact project setting and the same main.c should works for you. It's for SDK v15.0 (most likely also works on 15.2)

    ble_app_uart - Buttonless.zip

Children
  • I get error.

    Function sd_ble_gap_sec_params_reply(m_conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL) return error 8. 

  • Hi,

    Error code 8 meant invalid state. I'm not sure why you received that error. 

    Have you tried to test with the ble_app_buttonless with no modification ? Have you got an overview of how it work ? 

  • Hi.

    Yes I have overview of how it work. See video.

    I got error in function:

    static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
    {
        uint32_t err_code;
    
        switch (p_ble_evt->header.evt_id)
        {
            case BLE_GAP_EVT_CONNECTED:
                NRF_LOG_INFO("Connected");
                err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
                APP_ERROR_CHECK(err_code);
                m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
                err_code = nrf_ble_qwr_conn_handle_assign(&m_qwr, m_conn_handle);
                APP_ERROR_CHECK(err_code);
                break;
    
            case BLE_GAP_EVT_DISCONNECTED:
                NRF_LOG_INFO("Disconnected");
                // LED indication will be changed when advertising starts.
                m_conn_handle = BLE_CONN_HANDLE_INVALID;
                break;
    
            case BLE_GAP_EVT_PHY_UPDATE_REQUEST:
            {
                NRF_LOG_DEBUG("PHY update request.");
                ble_gap_phys_t const phys =
                {
                    .rx_phys = BLE_GAP_PHY_AUTO,
                    .tx_phys = BLE_GAP_PHY_AUTO,
                };
                err_code = sd_ble_gap_phy_update(p_ble_evt->evt.gap_evt.conn_handle, &phys);
                APP_ERROR_CHECK(err_code);
            } break;
    
            case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
                // Pairing not supported
                err_code = sd_ble_gap_sec_params_reply(m_conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL);
                APP_ERROR_CHECK(err_code);
                break;
    
            case BLE_GATTS_EVT_SYS_ATTR_MISSING:
                // No system attributes have been stored.
                err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0, 0);
                APP_ERROR_CHECK(err_code);
                break;
    
            case BLE_GATTC_EVT_TIMEOUT:
                // Disconnect on GATT Client timeout event.
                err_code = sd_ble_gap_disconnect(p_ble_evt->evt.gattc_evt.conn_handle,
                                                 BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
                APP_ERROR_CHECK(err_code);
                break;
    
            case BLE_GATTS_EVT_TIMEOUT:
                // Disconnect on GATT Server timeout event.
                err_code = sd_ble_gap_disconnect(p_ble_evt->evt.gatts_evt.conn_handle,
                                                 BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
                APP_ERROR_CHECK(err_code);
                break;
    
            default:
                // No implementation needed.
                break;
        }
    }

    In line 

            case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
                // Pairing not supported
                err_code = sd_ble_gap_sec_params_reply(m_conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL);
                APP_ERROR_CHECK(err_code);
                break;

    It may be error in ROM? 

  • Hi Alex, 
    The sd_ble_gap_sec_params_reply() would not be related to the buttonless DFU. I'm not so sure the err_code is actually 8 in your case. Could you put a log and print out the err_code after the call ? 

    Please try to test again without the buttonless DFU code added. 

    Please add stuff one at a time, having a fresh start will help you. Please refer to the main.c I have in the project I sent you. 

    I would suggest to test the buttonless without bonding first. Try to combine ble_app_uart with buttonless first . Please reuse the project I sent you (main.c and sdk_config.h)

    Please be aware that when you add buttonless service into your project you need to increase NRF_SDH_BLE_VS_UUID_COUNT by 1. I assume you already have done this. 

    When you do bonding (so that bond information has to be forwarded to bootloader) you would need to generate the bootloader setting before testing. Please have a look at appendix 4 here.

    But I strongly suggest to test without using bonding (make sure you erase bonding on the phone) and make sure it works first before you test with bonding. 

    By default ble_app_uart doesn't require bonding.  

Related