A splash location reads from the offset baked into the board's
splash_location table, so unlike the device and partition, which
splashdevpart already overrides, the offset cannot be changed at
runtime.

Add a splashoffset environment variable that overrides the offset field
of the selected location, given in hexadecimal.

Note that only the SPI flash and NAND backends read from the offset at
all. splash_mmc_read_raw() always starts at the beginning of the
partition, so splashoffset has no effect there.

Signed-off-by: David Lechner <[email protected]>
---
 common/splash_source.c | 5 +++++
 doc/develop/splash.rst | 7 +++++++
 2 files changed, 12 insertions(+)

diff --git a/common/splash_source.c b/common/splash_source.c
index 162fadc60d1..767e4a44f28 100644
--- a/common/splash_source.c
+++ b/common/splash_source.c
@@ -440,6 +440,7 @@ int splash_source_load(struct splash_location *locations, 
uint size)
        struct splash_location *splash_location;
        char *env_splashimage_value;
        char *devpart;
+       char *env_splashoffset_value;
        ulong bmp_load_addr;
 
        env_splashimage_value = env_get("splashimage");
@@ -460,6 +461,10 @@ int splash_source_load(struct splash_location *locations, 
uint size)
        if (devpart)
                splash_location->devpart = devpart;
 
+       env_splashoffset_value = env_get("splashoffset");
+       if (env_splashoffset_value)
+               splash_location->offset = hextoul(env_splashoffset_value, NULL);
+
        if (splash_location->flags == SPLASH_STORAGE_RAW)
                return splash_load_raw(splash_location, bmp_load_addr);
        else if (splash_location->flags == SPLASH_STORAGE_FS)
diff --git a/doc/develop/splash.rst b/doc/develop/splash.rst
index 994951dec4c..fe58dbf4418 100644
--- a/doc/develop/splash.rst
+++ b/doc/develop/splash.rst
@@ -73,6 +73,13 @@ conventions used by the load commands, e.g. ``0:1`` or 
``0#splash``. When
 *splashdevpart* is not set, the ``devpart`` field of the board's splash 
location
 entry is used instead.
 
+Where the splash data starts in that storage -- the BMP itself for a raw
+location, or the FIT for a FIT location -- can be overridden with the
+environment variable *splashoffset*, given in hexadecimal. When *splashoffset*
+is not set, the ``offset`` field of the board's splash location entry is used
+instead. Only the SPI flash and NAND backends read from the offset at all; MMC
+always starts at the beginning of the partition selected by *splashdevpart*.
+
 The default weak splash_screen_prepare() passes the 
``default_splash_locations``
 array, defined in ``common/splash.c``, to splash_source_load(). It provides the
 following *splashsource* names out of the box:

-- 
2.43.0

Reply via email to