Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/linux-sunxi/sunxi-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Przywara <osp@andrep.de>2020-12-19 13:27:39 +0300
committerAndre Przywara <osp@andrep.de>2020-12-29 05:03:48 +0300
commit75960dd232e593d99ed6585b07ccfbd24c0a6173 (patch)
tree8fd4e7b82072b936c80a69d3c381dec48389b57e
parent2b67b2d784b2e7e7c3923acf8f13d615d5a09dae (diff)
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>
-rw-r--r--fel.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/fel.c b/fel.c
index 8990e6e..8e2a1d8 100644
--- a/fel.c
+++ b/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);
}