예제 #1
0
파일: bootloader.c 프로젝트: IOIOI/nRF51
uint32_t bootloader_dfu_bl_update_continue(void)
{
    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->bl_image.st.bank == NEW_IMAGE_BANK_0)           ||
        (p_bootloader_settings->bl_image.st.bank == NEW_IMAGE_BANK_1))
    {
        debugger_delay();

        if (dfu_bl_image_validate() != NRF_SUCCESS)
        {
            err_code = dfu_bl_image_swap(); // reset is built in to the mbr bootloader swap
        }
        else
        {
            /* This is a manual write to flash, non-softdevice managed */
            uint32_t address    = (uint32_t)p_bootloader_settings + BOOTLOADER_SETTINGS_BL_IMAGE_SIZE_ADR_OFFSET;
            uint32_t value      = p_bootloader_settings->bl_image.all & 0x3FFFFFFF; // clears image bank bits.
            err_code            = blocking_flash_word_write((uint32_t *)address, value);
            //TODO need to catch verification error
        }
    }
    return err_code;
}
예제 #2
0
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.
            nrf_nvmc_write_word( address, temp_value);
            //TODO need to catch verification error
        }
    }
    return err_code;
}