Commit 4c6a1a01 authored by Andre Przywara's avatar Andre Przywara
Browse files

fel: Observe SRAM size to extend SPL load size



At the moment we limit the maximum SPL load size to 32 KB, because this
was a BROM limit in previous SoCs.
Newer SoCs (H6 and later) lift this limit, but also this tool is not
bound by the BROM limit, since we can load any size.

Use the just introduced SRAM size to establish an upper limit for the
SPL size, then limit this as we go if any part of the memory is used for
the FEL backup buffers.

Given the buffer addresses chosen wisely, this can drastically increase
the maximum SPL load size, even on those SoCs with a 32KB BROM limit.
Signed-off-by: default avatarAndre Przywara <osp@andrep.de>
parent 276a97da
...@@ -715,11 +715,8 @@ void aw_restore_and_enable_mmu(feldev_handle *dev, ...@@ -715,11 +715,8 @@ void aw_restore_and_enable_mmu(feldev_handle *dev,
free(tt); free(tt);
} }
/* /* Minimum offset of the main U-Boot image within u-boot-sunxi-with-spl.bin. */
* Maximum size of SPL, at the same time this is the start offset #define SPL_MIN_OFFSET 0x8000
* of the main U-Boot image within u-boot-sunxi-with-spl.bin
*/
#define SPL_LEN_LIMIT 0x8000
uint32_t 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)
{ {
...@@ -729,7 +726,7 @@ uint32_t aw_fel_write_and_execute_spl(feldev_handle *dev, uint8_t *buf, size_t l ...@@ -729,7 +726,7 @@ uint32_t aw_fel_write_and_execute_spl(feldev_handle *dev, uint8_t *buf, size_t l
size_t i, thunk_size; size_t i, thunk_size;
uint32_t *thunk_buf; uint32_t *thunk_buf;
uint32_t sp, sp_irq; uint32_t sp, sp_irq;
uint32_t spl_checksum, spl_len, spl_len_limit = SPL_LEN_LIMIT; uint32_t spl_checksum, spl_len, spl_len_limit;
uint32_t *buf32 = (uint32_t *)buf; uint32_t *buf32 = (uint32_t *)buf;
uint32_t cur_addr = soc_info->spl_addr; uint32_t cur_addr = soc_info->spl_addr;
uint32_t *tt = NULL; uint32_t *tt = NULL;
...@@ -782,6 +779,8 @@ uint32_t aw_fel_write_and_execute_spl(feldev_handle *dev, uint8_t *buf, size_t l ...@@ -782,6 +779,8 @@ uint32_t aw_fel_write_and_execute_spl(feldev_handle *dev, uint8_t *buf, size_t l
tt = aw_generate_mmu_translation_table(); tt = aw_generate_mmu_translation_table();
} }
spl_len_limit = soc_info->sram_size;
swap_buffers = soc_info->swap_buffers; swap_buffers = soc_info->swap_buffers;
for (i = 0; swap_buffers[i].size; i++) { for (i = 0; swap_buffers[i].size; i++) {
if ((swap_buffers[i].buf2 >= soc_info->spl_addr) && if ((swap_buffers[i].buf2 >= soc_info->spl_addr) &&
...@@ -939,8 +938,8 @@ void aw_fel_process_spl_and_uboot(feldev_handle *dev, const char *filename) ...@@ -939,8 +938,8 @@ void aw_fel_process_spl_and_uboot(feldev_handle *dev, const char *filename)
/* check for optional main U-Boot binary (and transfer it, if applicable) */ /* check for optional main U-Boot binary (and transfer it, if applicable) */
if (size > offset) { if (size > offset) {
/* U-Boot pads to at least 32KB */ /* U-Boot pads to at least 32KB */
if (offset < 32768) if (offset < SPL_MIN_OFFSET)
offset = 32768; offset = SPL_MIN_OFFSET;
aw_fel_write_uboot_image(dev, buf + offset, size - offset); aw_fel_write_uboot_image(dev, buf + offset, size - offset);
} }
free(buf); free(buf);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment