mirror of
https://github.com/linux-sunxi/sunxi-tools.git
synced 2024-11-23 18:05:38 +08:00
fel: Check actual SPL size before considering U-Boot proper
At the moment we always use a 32KB offset to place the U-Boot image after the SPL. Newer SoCs can (and will) have bigger SPLs, so we need to become more flexible with this offset. Read the actual SPL size, and assume the U-Boot payload is located right behind the SPL, if the SPL size is bigger than 32KB. We use at least 32KB, because this is how U-Boot is doing it today, even when the SPL size is actually smaller than that. Signed-off-by: Andre Przywara <osp@andrep.de>
This commit is contained in:
parent
2b67b2d784
commit
75960dd232
18
fel.c
18
fel.c
@ -721,7 +721,7 @@ void aw_restore_and_enable_mmu(feldev_handle *dev,
|
||||
*/
|
||||
#define SPL_LEN_LIMIT 0x8000
|
||||
|
||||
void aw_fel_write_and_execute_spl(feldev_handle *dev, uint8_t *buf, size_t len)
|
||||
uint32_t aw_fel_write_and_execute_spl(feldev_handle *dev, uint8_t *buf, size_t len)
|
||||
{
|
||||
soc_info_t *soc_info = dev->soc_info;
|
||||
sram_swap_buffers *swap_buffers;
|
||||
@ -855,6 +855,8 @@ void aw_fel_write_and_execute_spl(feldev_handle *dev, uint8_t *buf, size_t len)
|
||||
/* re-enable the MMU if it was enabled by BROM */
|
||||
if (tt != NULL)
|
||||
aw_restore_and_enable_mmu(dev, soc_info, tt);
|
||||
|
||||
return spl_len;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -927,14 +929,20 @@ void aw_fel_write_uboot_image(feldev_handle *dev, uint8_t *buf, size_t len)
|
||||
*/
|
||||
void aw_fel_process_spl_and_uboot(feldev_handle *dev, const char *filename)
|
||||
{
|
||||
/* load file into memory buffer */
|
||||
size_t size;
|
||||
uint32_t offset;
|
||||
/* load file into memory buffer */
|
||||
uint8_t *buf = load_file(filename, &size);
|
||||
|
||||
/* write and execute the SPL from the buffer */
|
||||
aw_fel_write_and_execute_spl(dev, buf, size);
|
||||
offset = aw_fel_write_and_execute_spl(dev, buf, size);
|
||||
/* check for optional main U-Boot binary (and transfer it, if applicable) */
|
||||
if (size > SPL_LEN_LIMIT)
|
||||
aw_fel_write_uboot_image(dev, buf + SPL_LEN_LIMIT, size - SPL_LEN_LIMIT);
|
||||
if (size > offset) {
|
||||
/* U-Boot pads to at least 32KB */
|
||||
if (offset < 32768)
|
||||
offset = 32768;
|
||||
aw_fel_write_uboot_image(dev, buf + offset, size - offset);
|
||||
}
|
||||
free(buf);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user