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

buttonless DFU integration in BLE app uart example: compiling problem

I'm trying to integrate buttonless DFU in BLE app uart example. I added the file: ble_dfu.c, ble_dfu_bonded.c, ble_dfu_unbonded.c in the project. I added the following folder:

C:\Nordic_Semi\nRF5_SDK_15.0.0_a53641a\components\libraries\svc

C:\Nordic_Semi\nRF5_SDK_15.0.0_a53641a\components\libraries\bootloader\dfu

C:\Nordic_Semi\nRF5_SDK_15.0.0_a53641a\components\libraries\bootloader

C:\Nordic_Semi\nRF5_SDK_15.0.0_a53641a\components\ble\ble_services\ble_dfu

C:\Nordic_Semi\nRF5_SDK_15.0.0_a53641a\components\libraries\bootloader\ble_dfu

in Preprocessor->User include Directories (in Options of the project). I'm using segger embedded studio.

I've got several compilation errors:

2> C:\Nordic_Semi\nRF5_SDK_15.0.0_a53641a\components\ble\ble_services\ble_dfu\ble_dfu_unbonded.c:61:55: error: unknown type name 'nrf_dfu_set_adv_name_svci_async_t'
2> C:\Nordic_Semi\nRF5_SDK_15.0.0_a53641a\components\ble\ble_services\ble_dfu\ble_dfu_unbonded.c:61:77: error: unknown type name 'nrf_dfu_adv_name_t'
2> c:\nordic_semi\nrf5_sdk_15.0.0_a53641a\components\libraries\svc\nrf_svci_async_function.h:174:35: error: request for member 'sys_evt_handler' in something not a structure or union
2> c:\nordic_semi\nrf5_sdk_15.0.0_a53641a\components\libraries\svc\nrf_svci_async_function.h:174:85: error: request for member 'state' in something not a structure or union
2> c:\nordic_semi\nrf5_sdk_15.0.0_a53641a\components\libraries\svc\nrf_svci_async_function.h:179:36: error: request for member 'async_func' in something not a structure or union
2> c:\nordic_semi\nrf5_sdk_15.0.0_a53641a\components\libraries\svc\nrf_svci_async_function.h:180:32: error: request for member 'sys_evt_handler' in something not a structure or union
2> C:\Nordic_Semi\nRF5_SDK_15.0.0_a53641a\components\ble\ble_services\ble_dfu\ble_dfu_unbonded.c:67:8: error: unknown type name 'nrf_dfu_adv_name_t'
2> C:\Nordic_Semi\nRF5_SDK_15.0.0_a53641a\components\ble\ble_services\ble_dfu\ble_dfu_unbonded.c:78:30: error: unknown type name 'nrf_dfu_adv_name_t'
2> C:\Nordic_Semi\nRF5_SDK_15.0.0_a53641a\components\ble\ble_services\ble_dfu\ble_dfu_unbonded.c:283:34: error: request for member 'name' in something not a structure or union
2> C:\Nordic_Semi\nRF5_SDK_15.0.0_a53641a\components\ble\ble_services\ble_dfu\ble_dfu_unbonded.c:284:27: error: request for member 'len' in something not a structure or union
Build failed

There is a guide or an application note that explains the several steps needed to integrate buttonless DFU to a custom application???

Parents
  • I solved the compilation problems. I changed the function "services_init(void)" of project app_uart_example 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);
    
    //**************************
    
    
    }

    but in executio I've got error " NRF_BREAKPOINT_COND;" in function "__WEAK void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)"

    There are news regarding official documentation about integration of buttonless DFU to a custom application?

  • : We do not have an official guide on how to add the DFU service to a custom application. 

    If you're entering the app_error_fault_handler function then there is probably a APP_ERROR_CHECK(err_code) check that is asserting. Could you place a breakpoint in app_error_handler_bare() in app_error.c and take a look at the call stack to see which function that caused the assert?

    Bjørn 

  • Ok, but please could you tell me how to make it and how much memory to allocate.?

    Thank you for the support

  • That is stated in the p_app_ram_start variable, or more correctly in the variable that p_app_ram_start points to, i.e. *p_app_ram_start . If you add p_app_ram_start to watch and then set a breakpoint after sd_ble_enable() you should be able to see which value points top_app_ram_start.

    Take a look at this  video, it explains how to modify the build settings, including the memory settings.

  • I have increased memory and it seems to work. Wow! What a hard job! I suggest you to make a guide or an application note on how to add the DFU service to a custom application..

    Thanks for the support

    Best regards

  • Hi Mdido

    Can I have your integrated main.c and sdk_config.h  file?

    I have tried it so many times but still it is not working.

  • In main.c you have to add the service for buttonless dfu:

    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};
        ble_dis_init_t     dis_init;
    
        // 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);
    
    #if defined(NDEBUG)
    //***** 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);
    
    //**************************
    #endif
    
    //************ Battery Service *********************
        ble_bas_init_t bas_init;
        memset(&bas_init, 0, sizeof(bas_init));
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bas_init.battery_level_char_attr_md.cccd_write_perm);
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bas_init.battery_level_char_attr_md.read_perm);
        BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&bas_init.battery_level_char_attr_md.write_perm);
    
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bas_init.battery_level_report_read_perm);
    
        bas_init.evt_handler = NULL;
        bas_init.support_notification = true;
        bas_init.p_report_ref = NULL;
        bas_init.initial_batt_level = 100;
    
        err_code = ble_bas_init(&m_bas,&bas_init);
        APP_ERROR_CHECK(err_code);
     //****************************************************
    
     //********** Initialize Device Information Service *************
        memset(&dis_init, 0, sizeof(dis_init));
    
        ble_srv_ascii_to_utf8(&dis_init.manufact_name_str, (char *)MANUFACTURER_NAME);
        ble_srv_ascii_to_utf8(&dis_init.fw_rev_str, (char *)SW_REV);
        ble_srv_ascii_to_utf8(&dis_init.sw_rev_str, (char *)SW_REV);
    
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&dis_init.dis_attr_md.read_perm);
        BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&dis_init.dis_attr_md.write_perm);
    
        err_code = ble_dis_init(&dis_init);
        APP_ERROR_CHECK(err_code);
     //**************************************************************
    
    }

    What is the specific problem?

    Best regards

Reply
  • In main.c you have to add the service for buttonless dfu:

    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};
        ble_dis_init_t     dis_init;
    
        // 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);
    
    #if defined(NDEBUG)
    //***** 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);
    
    //**************************
    #endif
    
    //************ Battery Service *********************
        ble_bas_init_t bas_init;
        memset(&bas_init, 0, sizeof(bas_init));
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bas_init.battery_level_char_attr_md.cccd_write_perm);
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bas_init.battery_level_char_attr_md.read_perm);
        BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&bas_init.battery_level_char_attr_md.write_perm);
    
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bas_init.battery_level_report_read_perm);
    
        bas_init.evt_handler = NULL;
        bas_init.support_notification = true;
        bas_init.p_report_ref = NULL;
        bas_init.initial_batt_level = 100;
    
        err_code = ble_bas_init(&m_bas,&bas_init);
        APP_ERROR_CHECK(err_code);
     //****************************************************
    
     //********** Initialize Device Information Service *************
        memset(&dis_init, 0, sizeof(dis_init));
    
        ble_srv_ascii_to_utf8(&dis_init.manufact_name_str, (char *)MANUFACTURER_NAME);
        ble_srv_ascii_to_utf8(&dis_init.fw_rev_str, (char *)SW_REV);
        ble_srv_ascii_to_utf8(&dis_init.sw_rev_str, (char *)SW_REV);
    
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&dis_init.dis_attr_md.read_perm);
        BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&dis_init.dis_attr_md.write_perm);
    
        err_code = ble_dis_init(&dis_init);
        APP_ERROR_CHECK(err_code);
     //**************************************************************
    
    }

    What is the specific problem?

    Best regards

Children
No Data
Related