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

dfu with IS_SRVC_CHANGED_CHARACT_PRESENT set to 0

Hi, I am develop a project with dfu and bond features. I found that in dfu project, IS_SRVC_CHANGED_CHARACT_PRESENT is always set to 1. In my understanding, if set this to 1, each time phone connect to my device, it will read the services, then slow down the connection process. Am I right? If above is true, is it possible to set IS_SRVC_CHANGED_CHARACT_PRESENT to 0, that I make bootloader and my application project with the same services?

  • Hi Loste,

    We set IS_SRVC_CHANGED_CHARACT_PRESENT to 1 is that when we switch from application to bootloader and vice versa, the attributable may change and we need to send service changed indication to tell the central to redo the service discovery.

    You were correct that it may take longer to discover the service if we have service changed characteristic. But I don't think it will increase the discovery time significantly. And note that the central don't do service discovery every time it connects to a bonded device. Only the first time and when receiving service changed indication.

    If your application and the bootloader has the same attribute table, it's true that you can set IS_SRVC_CHANGED_CHARACT_PRESENT to 0.

  • Hi Hung Bui, my application and my bootloader have the same attribute table (same Service, same Chacteristics). But  when i set IS_SRVC_CHANGED_CHARACT_PRESENT to 0, the dfu process can not be done. My question is here  Can not save boot loader setting . 

  • Hi Hoai, 

    Could you check what the error it was when calling bootloader_settings_save() ? 

    I don't see any relation between the service changed characteristic and bootloader setting. Have you made sure the code to send service changed indication has been disabled as well ? 

  • Thanks for your reply Hung Bui,

    This is my old code. When dfu process completed, we call bootloader_settings_save method to clear and save the boot loader setting. And we will not received callbacks from pstorage module, it's mean we can not save the bootloader_setting and can not jump to application.

    static void bootloader_settings_save(bootloader_settings_t * p_settings)
    {
        uint32_t err_code = pstorage_clear(&m_bootsettings_handle, sizeof(bootloader_settings_t));
        APP_ERROR_CHECK(err_code);
    
        err_code = pstorage_store(&m_bootsettings_handle,
                                  (uint8_t *)p_settings,
                                  sizeof(bootloader_settings_t),
                                  0);
        APP_ERROR_CHECK(err_code);
    }
    
    void bootloader_dfu_update_process(dfu_update_status_t update_status)
    {
        static bootloader_settings_t  settings;
        const bootloader_settings_t * p_bootloader_settings;
    
        bootloader_util_settings_get(&p_bootloader_settings);
    
        if (update_status.status_code == DFU_UPDATE_APP_COMPLETE)
        {
            settings.bank_0_crc  = update_status.app_crc;
            settings.bank_0_size = update_status.app_size;
            settings.bank_0      = BANK_VALID_APP;
            settings.bank_1      = BANK_INVALID_APP;
    
            m_update_status      = BOOTLOADER_SETTINGS_SAVING;
            bootloader_settings_save(&settings);
        }
        
        ....

    In my new code. I remove the line call pstorage_clear and the dfu process was successful and boot loader can jump in to application.

    static void bootloader_settings_save_completed(bootloader_settings_t * p_settings)
    {
        uint32_t err_code = pstorage_store(&m_bootsettings_handle,
                                  (uint8_t *)p_settings,
                                  sizeof(bootloader_settings_t),
                                  0);
        APP_ERROR_CHECK(err_code);
    }
    
    
    void bootloader_dfu_update_process(dfu_update_status_t update_status)
    {
        static bootloader_settings_t  settings;
        const bootloader_settings_t * p_bootloader_settings;
    
        bootloader_util_settings_get(&p_bootloader_settings);
    
        if (update_status.status_code == DFU_UPDATE_APP_COMPLETE)
        {
            settings.bank_0_crc  = update_status.app_crc;
            settings.bank_0_size = update_status.app_size;
            settings.bank_0      = BANK_VALID_APP;
            settings.bank_1      = BANK_INVALID_APP;
    
            m_update_status      = BOOTLOADER_SETTINGS_SAVING;
            bootloader_settings_save_completed(&settings);
        }
        
        ...

    So i think the reason for my problem is calling

    pstorage_clear(&m_bootsettings_handle, sizeof(bootloader_settings_t));

    But i can not understand why calling that method is making error?

  • Which SDK are you using ? SDK v11 ? 
    I don't see these has anything to do with IS_SRVC_CHANGED_CHARACT_PRESENT.  

    Removing pstorage_clear() is not a good idea. Without clearing the flash how can you store new data in it ? 
    What kind of modification you did ? Or only to disable Service changed characteristic? 
    I would suggest you to continue on the other case. 

Related