Skip to content
Snippets Groups Projects
Commit c9b56669 authored by Lionel Debieve's avatar Lionel Debieve Committed by Sebastien Pasdeloup
Browse files

plat/st: manage backup partition with FIP


Implement the plat_try_next_boot_source to load
backup partition on specific device.

Change-Id: Ica74596838b339e398c335f9e28ebf60795ab508
Signed-off-by: default avatarLionel Debieve <lionel.debieve@st.com>
Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/tf-a/+/179616


Reviewed-by: default avatarCITOOLS <smet-aci-reviews@lists.codex.cro.st.com>
Reviewed-by: default avatarEtienne CARRIERE <etienne.carriere@st.com>
Reviewed-by: default avatarYann GAUTIER <yann.gautier@st.com>
parent fa87c912
No related branches found
No related tags found
No related merge requests found
......@@ -43,6 +43,7 @@ uintptr_t fip_dev_handle;
uintptr_t storage_dev_handle;
static const io_dev_connector_t *fip_dev_con;
static uint32_t nand_bkp_offset;
#if STM32MP_SDMMC || STM32MP_EMMC
static uint32_t block_buffer[MMC_BLOCK_SIZE] __aligned(MMC_BLOCK_SIZE);
......@@ -243,6 +244,8 @@ static void boot_fmc2_nand(boot_api_context_t *boot_context)
io_result = io_dev_open(nand_dev_con, (uintptr_t)&nand_dev_spec,
&storage_dev_handle);
assert(io_result == 0);
nand_bkp_offset = nand_dev_spec.erase_size;
}
#endif /* STM32MP_RAW_NAND */
......@@ -262,6 +265,8 @@ static void boot_spi_nand(boot_api_context_t *boot_context)
(uintptr_t)&spi_nand_dev_spec,
&storage_dev_handle);
assert(io_result == 0);
nand_bkp_offset = spi_nand_dev_spec.erase_size;
}
#endif /* STM32MP_SPI_NAND */
......@@ -478,3 +483,33 @@ int plat_get_image_source(unsigned int image_id, uintptr_t *dev_handle,
return rc;
}
/*
* This function shall return 0 if it cannot find an alternate
* image to be loaded or it returns 1 otherwise.
*/
int plat_try_next_boot_source(unsigned int image_id)
{
static unsigned int backup_id;
static unsigned int backup_nb;
/* No backup available */
if (nand_bkp_offset == 0U) {
return 0;
}
if (backup_id != image_id) {
backup_nb = 0;
backup_id = image_id;
}
backup_nb++;
if (backup_nb >= PLATFORM_MTD_BACKUP_BLOCKS) {
return 0;
}
image_block_spec.offset += nand_bkp_offset;
return 1;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment