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

Can not save boot loader setting (bootloader_settings_t) when disable IS_SRVC_CHANGED_CHARACT_PRESENT 0 in bootloader

I'm using SDK 12.2.0, SofDevice 3.0 and my chip nRF52832.

In my boot-loader project i disable IS_SRVC_CHANGED_CHARACT_PRESENT by define to 0.

The dfu process is completed and firmware was tranferred but boot-loader can not jump to application because the 

bootloader_settings_t cannot saved in method bootloader_settings_save of bootloader.c file

I have another test with enable IS_SRVC_CHANGED_CHARACT_PRESENT the dfu process was successful. 

Parents
  • I am afraid that I dont understand what the issue. Why are you removing the Service Changed Characteristic in the bootloader project if that results in it not working? Unless there is a specific reason for removing the SC characteristic, then keep it in. 

  • Thanks for your reply,

    I have reason to disable IS_SRVC_CHANGED_CHARACT_PRESENT both in my application and boot loader. 

    Right now, i can do the dfu process with some changes in bootloader_settings_save method.

    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.

    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_completed(&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?

Reply
  • Thanks for your reply,

    I have reason to disable IS_SRVC_CHANGED_CHARACT_PRESENT both in my application and boot loader. 

    Right now, i can do the dfu process with some changes in bootloader_settings_save method.

    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.

    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_completed(&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?

Children
Related