示例#1
0
uint32_t bootloader_dfu_sd_update_continue(void)
{
    uint32_t err_code;

    if ((dfu_sd_image_validate() == NRF_SUCCESS) &&
        (dfu_bl_image_validate() == NRF_SUCCESS))
    {
        return NRF_SUCCESS;
    }

    // Ensure that flash operations are not executed within the first 100 ms seconds to allow
    // a debugger to be attached.
    nrf_delay_ms(100);

    err_code = dfu_sd_image_swap();
    APP_ERROR_CHECK(err_code);

    err_code = dfu_sd_image_validate();
    APP_ERROR_CHECK(err_code);

    err_code = dfu_bl_image_swap();
    APP_ERROR_CHECK(err_code);

    return err_code;
}
示例#2
0
文件: bootloader.c 项目: IOIOI/nRF51
uint32_t bootloader_dfu_sd_update_continue()
{
    uint32_t err_code = NRF_SUCCESS;
    const bootloader_settings_t * p_bootloader_settings;

    bootloader_util_settings_get(&p_bootloader_settings);

    /* Ignore update attempts on invalid src_image_address */
    if( (p_bootloader_settings->src_image_address == SRC_IMAGE_ADDRESS_EMPTY)   ||
        (p_bootloader_settings->src_image_address == SRC_IMAGE_ADDRESS_INVALID))
    {
        return NRF_SUCCESS;
    }

    if( (p_bootloader_settings->sd_image.st.bank == NEW_IMAGE_BANK_0)           ||
        (p_bootloader_settings->sd_image.st.bank == NEW_IMAGE_BANK_1))
    {
        debugger_delay();

        err_code = dfu_sd_image_swap();
        if (dfu_sd_image_validate() == NRF_SUCCESS)
        {
            /* This is a manual write to flash, non-softdevice managed */
            uint32_t address    = (uint32_t)p_bootloader_settings + BOOTLOADER_SETTINGS_SD_IMAGE_SIZE_ADR_OFFSET;
            temp_value          = p_bootloader_settings->sd_image.all & 0x3FFFFFFF; // clears image bank bits.
            err_code            = blocking_flash_word_write((uint32_t *)address, temp_value);
            //TODO need to catch verification error
        }
    }
    return err_code;
}