spl_ubi: Support loading FIT from volume in RAM

This commit is contained in:
Jookia 2023-12-08 10:51:34 +11:00
parent 701910350f
commit a2b04d91d2
1 changed files with 27 additions and 3 deletions

View File

@ -12,6 +12,14 @@
#include <ubispl.h>
#include <spl.h>
static ulong ram_spl_load_read(struct spl_load_info *load, ulong sector,
ulong count, void *buf)
{
char* ubi_contents = load->priv;
memcpy(buf, ubi_contents + sector, count);
return count;
}
int spl_ubi_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev)
{
@ -69,7 +77,8 @@ int spl_ubi_load_image(struct spl_image_info *spl_image,
puts("Loading Linux failed, falling back to U-Boot.\n");
}
#endif
header = spl_get_load_buffer(-sizeof(*header), sizeof(header));
/* Ensure there's enough room for the full UBI volume! */
header = (void*)CONFIG_SYS_LOAD_ADDR;
#ifdef CONFIG_SPL_UBI_LOAD_BY_VOLNAME
volumes[0].vol_id = -1;
strncpy(volumes[0].name,
@ -81,8 +90,23 @@ int spl_ubi_load_image(struct spl_image_info *spl_image,
volumes[0].load_addr = (void *)header;
ret = ubispl_load_volumes(&info, volumes, 1);
if (!ret)
spl_parse_image_header(spl_image, bootdev, header);
if (ret)
goto out;
spl_parse_image_header(spl_image, bootdev, header);
if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
image_get_magic(header) == FDT_MAGIC) {
struct spl_load_info load;
printf("Found FIT\n");
load.dev = NULL;
load.priv = (char*)header;
load.filename = NULL;
load.bl_len = 1;
load.read = ram_spl_load_read;
ret = spl_load_simple_fit(spl_image, &load, 0, header);
}
out:
#ifdef CONFIG_SPL_SPI_NAND_SUPPORT
if (bootdev->boot_device == BOOT_DEVICE_SPINAND)