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

Setting Up DFU OTA On S110 ( PCA10001 )

Hello I want to setting up DFU in my project. I followed this document : link text I'm using IAR EWARM and nRF51_SDK_8.0.0 and "nRF51_SDK_8.0.0\examples\dfu\bootloader" as bootloader.

It's amazing that when using ble_dfu_init function , program will start from address 0xFFFFFFFE !!! But without ble_dfu_init function , everything's is OK (main program without DFU).

what is the problem?? thanks in advance image description

Parents
  • Thank u Anders Strand this image shows initial PC value is 0xFFFFFFFE instead of main()! but why??!! When i uncheck [Options...->Debugger->Run to main()] , program will start from 0x000006D0 that is OK. but when PC arrive to 0x164FA , jump to 0xFFFFFFFE instead of main()... This problem occurred when ble_dfu_init() added. My project is based on the ble_app_hids_keyboard sample. Summary of my code is :

    .
    .
    .
    #include "ble_dfu.h"
    #include "dfu_app_handler.h"
    .
    .
    .
    #define IS_SRVC_CHANGED_CHARACT_PRESENT  1                                              /**< Include or not the service_changed characteristic. if not enabled, the server's database cannot be changed for the lifetime of the device*/
    .
    .
    .
    #define DFU_REV_MAJOR                    0x00                                       /** DFU Major revision number to be exposed. */
    #define DFU_REV_MINOR                    0x01                                       /** DFU Minor revision number to be exposed. */
    #define DFU_REVISION                     ((DFU_REV_MAJOR << 8) | DFU_REV_MINOR)     /** DFU Revision number to be exposed. Combined of major and minor versions. */
    #define APP_SERVICE_HANDLE_START         0x000C                                     /**< Handle of first application specific service when when service changed characteristic is present. */
    #define BLE_HANDLE_MAX                   0xFFFF                                     /**< Max handle value in BLE. */
    STATIC_ASSERT(IS_SRVC_CHANGED_CHARACT_PRESENT);                                     /** When having DFU Service support in application the Service Changed Characteristic should always be present. */
    .
    .
    .
    static ble_dfu_t                         m_dfus;                                    /**< Structure used to identify the DFU service. */
    .
    .
    .
    .
    static void advertising_stop(void)
    {
        uint32_t err_code;
    
        err_code = sd_ble_gap_adv_stop();
        APP_ERROR_CHECK(err_code);
    
        err_code = bsp_indication_set(BSP_INDICATE_IDLE);
        APP_ERROR_CHECK(err_code);
    }
    
    static void app_context_load(dm_handle_t const * p_handle)
    {
        uint32_t                 err_code;
        static uint32_t          context_data;
        dm_application_context_t context;
    
        context.len    = sizeof(context_data);
        context.p_data = (uint8_t *)&context_data;
    
        err_code = dm_application_context_get(p_handle, &context);
        if (err_code == NRF_SUCCESS)
        {
            // Send Service Changed Indication if ATT table has changed.
            if ((context_data & (DFU_APP_ATT_TABLE_CHANGED << DFU_APP_ATT_TABLE_POS)) != 0)
            {
                err_code = sd_ble_gatts_service_changed(m_conn_handle, APP_SERVICE_HANDLE_START, BLE_HANDLE_MAX);
                if ((err_code != NRF_SUCCESS) &&
                    (err_code != BLE_ERROR_INVALID_CONN_HANDLE) &&
                    (err_code != NRF_ERROR_INVALID_STATE) &&
                    (err_code != BLE_ERROR_NO_TX_BUFFERS) &&
                    (err_code != NRF_ERROR_BUSY) &&
                    (err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING))
                {
                    APP_ERROR_HANDLER(err_code);
                }
            }
    
            err_code = dm_application_context_delete(p_handle);
            APP_ERROR_CHECK(err_code);
        }
        else if (err_code == DM_NO_APP_CONTEXT)
        {
            // No context available. Ignore.
        }
        else
        {
            APP_ERROR_HANDLER(err_code);
        }
    }
    
    
    static void reset_prepare(void)
    {
        uint32_t err_code;
    
        if (m_conn_handle != BLE_CONN_HANDLE_INVALID)
        {
            // Disconnect from peer.
            err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
            APP_ERROR_CHECK(err_code);
            err_code = bsp_indication_set(BSP_INDICATE_IDLE);
            APP_ERROR_CHECK(err_code);
        }
        else
        {
            // If not connected, the device will be advertising. Hence stop the advertising.
            advertising_stop();
        }
    
        err_code = ble_conn_params_stop();
        APP_ERROR_CHECK(err_code);
    
        nrf_delay_ms(500);
    }
    
    
    void dfu_init(){
    
        ble_dfu_init_t   dfus_init;
        uint32_t err_code;
        // Initialize the Device Firmware Update Service.
        memset(&dfus_init, 0, sizeof(dfus_init));
    
        dfus_init.evt_handler   = dfu_app_on_dfu_evt;
        dfus_init.error_handler = NULL;
        dfus_init.evt_handler   = dfu_app_on_dfu_evt;
        dfus_init.revision      = DFU_REVISION;
    
        err_code = ble_dfu_init(&m_dfus, &dfus_init);
        APP_ERROR_CHECK(err_code);
    
        dfu_app_reset_prepare_set(reset_prepare);
        dfu_app_dm_appl_instance_set(m_app_handle);
    
    }
    .
    .
    .
    static void services_init(void)
    {
    .
    .
    .
        dfu_init();
    }
    .
    .
    .
    static void ble_evt_dispatch(ble_evt_t * p_ble_evt)
    {
    .
    .
    .
    ble_dfu_on_ble_evt(&m_dfus, p_ble_evt);
    }
    .
    .
    .
    static uint32_t device_manager_evt_handler(dm_handle_t const    * p_handle,
                                               dm_event_t const     * p_event,
                                               ret_code_t           event_result)
    {
        APP_ERROR_CHECK(event_result);
    
        switch(p_event->event_id)
        {
        	case   DM_EVT_LINK_SECURED:
            	app_context_load(p_handle);
        	break;
            case DM_EVT_DEVICE_CONTEXT_LOADED: // Fall through.
            case DM_EVT_SECURITY_SETUP_COMPLETE:
                m_bonded_peer_handle = (*p_handle);
                break;
        }
    
        return NRF_SUCCESS;
    }
    .
    .
    .
    int main(void)
    {
        uint32_t err_code;
        app_trace_init();
        timers_init();
        buttons_leds_init(&erase_bonds);
        ble_stack_init();
        adc_configure();
        scheduler_init();
        device_manager_init(erase_bonds);
        gap_params_init();
        advertising_init();
        services_init();
        conn_params_init();
        buffer_init();
        timers_start();
        err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
        APP_ERROR_CHECK(err_code);
        InitNVM();
        // Enter main loop.
        for (;;)
        {
            app_sched_execute();
            power_manage();
        }
    }
    

    I tested ble_app_hrs_s110_with_dfu sample and works well.

  • Are you running in debug mode? If yes, this post might help you out.

Reply Children
No Data
Related