Skip to contentSkip to conversation

Load splash from FIT image (internal, external, offset)

PATCH Superseded Mark Jonas 3 participants 10 messages Feb 5, 2019 – Feb 6, 2019

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Mark Jonas

author
#0 lore raw

v2 cover Load splash from FIT image (internal, external, offset)

We store a splash screen in SPI-NOR. We chose to use a FIT image as a container because we want to
- store more than just the splash screen in SPI-NOR,
- do not create a bunch of MTD partitions,
- do not waste storage space, and
- avoid the overhead of a real file system.

In general U-Boot already supports this. But there were some ripples we had to smooth out. The following patches resolve these.

Changes since v1:
- Document default name in README.splashprepare
- Use ALIGN() macro

Leo Ruan (2):
splash: Use splashfile instead of location->name
splash: Load internal and external data from FIT

 common/splash_source.c   | 65 +++++++++++++++++++++++++++++++-----------------
 doc/README.splashprepare |  9 ++++---
 2 files changed, 48 insertions(+), 26 deletions(-)
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v2 1/2 splash: Use splashfile instead of location->name

From: Leo Ruan <[email protected]>

The splash image could be loaded from different sources (e.g. sf, mmc) with different formats (e.g. raw, file-system). These sources are structured by a board dependent object 'splash_location'. To decide where is the splash image loaded, following environment variables are used to select the splash source and file:
- 'splashsource' is used to select the splash source by setting its value to specified name of splash location.
- 'splashfile' specify the name of splash image file

But, when loads the splash image from FIT, the name of splash image within FIT is specified by splash location name. Due to the splash location name is already used for the splash source, its name may conflicts with the name of splash image.

To solve the conflict, the environment variable 'splashfile' is used to specify the splash image in FIT, and keeps the splash location name for the splash source.

---
 common/splash_source.c   | 10 ++++++++--
 doc/README.splashprepare |  9 ++++++---
 2 files changed, 14 insertions(+), 5 deletions(-)
common/splash_source.c +8 -2
index 62763b9..e1e73db 100644
@@ -303,6 +303,7 @@ static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr)
 {
 	int res;
 	int node_offset;
+	const char *splash_file;
 	int splash_offset;
 	int splash_size;
 	struct image_header *img_header;
@@ -335,10 +336,15 @@ static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr)
 		return -EINVAL;
 	}
 
-	node_offset = fit_image_get_node(fit_header, location->name);
+	/* Get the splash image node */
+	splash_file = env_get("splashfile");
+	if (!splash_file)
+		splash_file = SPLASH_SOURCE_DEFAULT_FILE_NAME;
+
+	node_offset = fit_image_get_node(fit_header, splash_file);
 	if (node_offset < 0) {
 		debug("Could not find splash image '%s' in FIT\n",
-		      location->name);
+		      splash_file);
 		return -ENOENT;
 	}
 
doc/README.splashprepare +6 -3
index f1418de..3cb5b5a 100644
@@ -26,6 +26,9 @@ screen data is loaded as a file. The name of the splash screen file can be
 controlled with the environment variable "splashfile".
 
 To enable loading the splash image from a FIT image, CONFIG_FIT must be
-enabled. Struct splash_location field 'name' should match the splash image
-name within the FIT and the FIT should start at the 'offset' field address in
-the specified storage.
+enabled. The FIT image has to start at the 'offset' field address in the
+selected splash location. The name of splash image within the FIT shall be
+specified by the environment variable "splashfile".
+
+In case the environment variable "splashfile" is not defined the default name
+'splash.bmp' will be used.
Signature · 1 line
2.7.4
#2 lore raw

PATCH v2 1/2 splash: Use splashfile instead of location->name

Quoted 66 lines · Mark Jonas

From: Leo Ruan <[email protected]>

The splash image could be loaded from different sources (e.g. sf, mmc) with different formats (e.g. raw, file-system). These sources are structured by a board dependent object 'splash_location'. To decide where is the splash image loaded, following environment variables are used to select the splash source and file:
- 'splashsource' is used to select the splash source by setting its value to specified name of splash location.
- 'splashfile' specify the name of splash image file

But, when loads the splash image from FIT, the name of splash image within FIT is specified by splash location name. Due to the splash location name is already used for the splash source, its name may conflicts with the name of splash image.

To solve the conflict, the environment variable 'splashfile' is used to specify the splash image in FIT, and keeps the splash location name for the splash source.

---
 common/splash_source.c   | 10 ++++++++--
 doc/README.splashprepare |  9 ++++++---
 2 files changed, 14 insertions(+), 5 deletions(-)
common/splash_source.c +8 -2
index 62763b9..e1e73db 100644
@@ -303,6 +303,7 @@ static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr)
 {
 	int res;
 	int node_offset;
+	const char *splash_file;
 	int splash_offset;
 	int splash_size;
 	struct image_header *img_header;
@@ -335,10 +336,15 @@ static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr)
 		return -EINVAL;
 	}
 
-	node_offset = fit_image_get_node(fit_header, location->name);
+	/* Get the splash image node */
+	splash_file = env_get("splashfile");
+	if (!splash_file)
+		splash_file = SPLASH_SOURCE_DEFAULT_FILE_NAME;
+
+	node_offset = fit_image_get_node(fit_header, splash_file);
 	if (node_offset < 0) {
 		debug("Could not find splash image '%s' in FIT\n",
-		      location->name);
+		      splash_file);
 		return -ENOENT;
 	}
 
doc/README.splashprepare +0 -0
index f1418de..3cb5b5a 100644
@@ -26,6 +26,9 @@ screen data is loaded as a file. The name of the splash screen file can be
 controlled with the environment variable "splashfile".
 

doc/README.splashprepare screen data is loaded as a file. The name of the splash screen file can be · line 34

Quoted 10 lines
doc/README.splashprepare +6 -3
 To enable loading the splash image from a FIT image, CONFIG_FIT must be
-enabled. Struct splash_location field 'name' should match the splash image
-name within the FIT and the FIT should start at the 'offset' field address in
-the specified storage.
+enabled. The FIT image has to start at the 'offset' field address in the
+selected splash location. The name of splash image within the FIT shall be
+specified by the environment variable "splashfile".
+
+In case the environment variable "splashfile" is not defined the default name
+'splash.bmp' will be used.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#3 lore raw

PATCH v2 1/2 splash: Use splashfile instead of location->name

In reply to Mark Jonas

Hi,

Quoted 20 lines · Mark Jonas

From: Leo Ruan <[email protected]>

  common/splash_source.c   | 10 ++++++++--
  doc/README.splashprepare |  9 ++++++---
  2 files changed, 14 insertions(+), 5 deletions(-)
common/splash_source.c +1 -0
index 62763b9..e1e73db 100644
@@ -303,6 +303,7 @@ static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr)
  {
  	int res;
  	int node_offset;
+	const char *splash_file;
  	int splash_offset;
  	int splash_size;
  	struct image_header *img_header;

common/splash_source.c static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr) · line 344

Quoted 10 lines
common/splash_source.c +6 -1
@@ -335,10 +336,15 @@ static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr)
  		return -EINVAL;
  	}
 
-	node_offset = fit_image_get_node(fit_header, location->name);
+	/* Get the splash image node */
+	splash_file = env_get("splashfile");
+	if (!splash_file)
+		splash_file = SPLASH_SOURCE_DEFAULT_FILE_NAME;
+
+	node_offset = fit_image_get_node(fit_header, splash_file);

It looks like this will break boards relying on existing logic with location->name (3 boards upstream).

Could fallback here instead be "location->name" as before, keeping compability with the current implementation? I.e.

+ if (!splash_file)
+ splash_file = location->name;

BR,

Tomas

#4 lore raw

PATCH v2 1/2 splash: Use splashfile instead of location->name

Hi Tomas,

Quoted 13 lines

common/splash_source.c static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr) · line 344

Quoted 6 lines
common/splash_source.c +6 -0
+	/* Get the splash image node */
+	splash_file = env_get("splashfile");
+	if (!splash_file)
+		splash_file = SPLASH_SOURCE_DEFAULT_FILE_NAME;
+
+	node_offset = fit_image_get_node(fit_header, splash_file);

It looks like this will break boards relying on existing logic with location->name (3 boards upstream).

Could fallback here instead be "location->name" as before, keeping compability with the current implementation? I.e.

Review

Quoted 2 lines
(quoted diff) +2 -0
+	if (!splash_file)
+		splash_file = location->name;

Can you point me to the 3 upstream boards which are relying on this?

Is it compulab/cm_fx6, compulab/cm_t35, and menlo/m53menlo?

compulab/cm_fx6 uses .name = "nand" and SPLASH_STORAGE_RAW. Thus it is not be affected by changes in splash_load_fit().

http://git.denx.de/?p=u-boot.git;a=blob;f=board/compulab/cm_t35/cm_t35.c;h=4d171f4900be8eb6deea730435825b3edd805612;hb=HEAD#l63

compulab/cm_fx6 uses four different .name and splash locations. They are either SPLASH_STORAGE_RAW or SPLASH_STORAGE_FS. Thus it is not affected.

http://git.denx.de/?p=u-boot.git;a=blob;f=board/compulab/cm_fx6/cm_fx6.c;h=d42f57d4b7014b3bd6550af186504f2c580585d2;hb=HEAD#l43

menlo/m53menlo uses .name = "mmc_fs" and SPLASH_STORAGE_FS. Thus it is not affected.

http://git.denx.de/?p=u-boot.git;a=blob;f=board/menlo/m53menlo/m53menlo.c;h=6bdd6d5b234dd0474b8288abda32b8099a570348;hb=HEAD#l336

I conclude that no upstream board is actually affected. They would only be affecte if they would use SPLASH_STORAGE_FIT.

http://git.denx.de/?p=u-boot.git;a=blob;f=common/splash_source.c;h=62763b9ebd5698b454280a6d4b62cd23a7312786;hb=HEAD#l409

Regards,
Mark

Building Technologies, Panel Software Fire (BT-FIR/ENG1)
Bosch Sicherheitssysteme GmbH | Postfach 11 11 | 85626 Grasbrunn | GERMANY | www.boschsecurity.com

Sitz: Stuttgart, Registergericht: Amtsgericht Stuttgart HRB 23118
Aufsichtsratsvorsitzender: Christian Fischer; Geschäftsführung: Tanja Rückert, Andreas Bartz, Thomas Quante, Bernhard Schuster

#5 lore raw

PATCH v2 1/2 splash: Use splashfile instead of location->name

Hi Mark,

Quoted 17 lines

Review

Quoted 5 lines

Could fallback here instead be "location->name" as before, keeping compability with the current implementation? I.e.

(quoted diff) +2 -0
+	if (!splash_file)
+		splash_file = location->name;

Can you point me to the 3 upstream boards which are relying on this?

Is it compulab/cm_fx6, compulab/cm_t35, and menlo/m53menlo?

compulab/cm_fx6 uses .name = "nand" and SPLASH_STORAGE_RAW. Thus it is not be affected by changes in splash_load_fit().

http://git.denx.de/?p=u-boot.git;a=blob;f=board/compulab/cm_t35/cm_t35.c;h=4d171f4900be8eb6deea730435825b3edd805612;hb=HEAD#l63

compulab/cm_fx6 uses four different .name and splash locations. They are either SPLASH_STORAGE_RAW or SPLASH_STORAGE_FS. Thus it is not affected.

Quoted 8 lines

http://git.denx.de/?p=u-boot.git;a=blob;f=board/compulab/cm_fx6/cm_fx6.c;h=d42f57d4b7014b3bd6550af186504f2c580585d2;hb=HEAD#l43

menlo/m53menlo uses .name = "mmc_fs" and SPLASH_STORAGE_FS. Thus it is not affected.

http://git.denx.de/?p=u-boot.git;a=blob;f=board/menlo/m53menlo/m53menlo.c;h=6bdd6d5b234dd0474b8288abda32b8099a570348;hb=HEAD#l336

I conclude that no upstream board is actually affected. They would only be affecte if they would use SPLASH_STORAGE_FIT.

You are right, indeed upstream boards should be ok. However, some other non upstream boards I know of would be affected.

So my initial question still stands, could existing implementation be kept as fallback?

+ if (!splash_file)
+ splash_file = location->name;

location->name has worked fine for those cases, so it would be nice to keep that option intact.

BR,

Tomas

Quoted 12 lines

http://git.denx.de/?p=u-boot.git;a=blob;f=common/splash_source.c;h=62763b9ebd5698b454280a6d4b62cd23a7312786;hb=HEAD#l409

Regards,
Mark

Building Technologies, Panel Software Fire (BT-FIR/ENG1)
Bosch Sicherheitssysteme GmbH | Postfach 11 11 | 85626 Grasbrunn | GERMANY | www.boschsecurity.com

Sitz: Stuttgart, Registergericht: Amtsgericht Stuttgart HRB 23118
Aufsichtsratsvorsitzender: Christian Fischer; Geschäftsführung: Tanja Rückert, Andreas Bartz, Thomas Quante, Bernhard Schuster

#6 lore raw

PATCH v2 1/2 splash: Use splashfile instead of location->name

Hi Thomas,

Quoted 24 lines · Melin Tomas

Hi Mark,

Quoted 22 lines

Review

Quoted 5 lines

Could fallback here instead be "location->name" as before, keeping compability with the current implementation? I.e.

(quoted diff) +2 -0
+	if (!splash_file)
+		splash_file = location->name;

Can you point me to the 3 upstream boards which are relying on this?

Is it compulab/cm_fx6, compulab/cm_t35, and menlo/m53menlo?

compulab/cm_fx6 uses .name = "nand" and SPLASH_STORAGE_RAW. Thus it is not be affected by changes in splash_load_fit().

http://git.denx.de/?p=u-boot.git;a=blob;f=board/compulab/cm_t35/cm_t35.c;h=4d171f4900be8eb6deea730435825b3edd805612;hb=HEAD#l63

compulab/cm_fx6 uses four different .name and splash locations. They are either SPLASH_STORAGE_RAW or SPLASH_STORAGE_FS. Thus it is not affected.

http://git.denx.de/?p=u-boot.git;a=blob;f=board/compulab/cm_fx6/cm_fx6.c;h=d42f57d4b7014b3bd6550af186504f2c580585d2;hb=HEAD#l43

menlo/m53menlo uses .name = "mmc_fs" and SPLASH_STORAGE_FS. Thus it is not affected.

Quoted 7 lines
Quoted 3 lines

http://git.denx.de/?p=u-boot.git;a=blob;f=board/menlo/m53menlo/m53menlo.c;h=6bdd6d5b234dd0474b8288abda32b8099a570348;hb=HEAD#l336

I conclude that no upstream board is actually affected. They would only be affecte if they would use SPLASH_STORAGE_FIT.

You are right, indeed upstream boards should be ok. However, some other non upstream boards I know of would be affected.

Well, to be honest: we cannot care in mainline about non upstream boards. They are not tested at all and they can go broken at any time.

If people / companies want that their board are efficeintly maintained, they have to take the path to work for including boards into official tree, and maintain them.

Quoted 8 lines

So my initial question still stands, could existing implementation be kept as fallback?

(quoted diff) +2 -0
+	if (!splash_file)
+		splash_file = location->name;

location->name has worked fine for those cases, so it would be nice to keep that option intact.

Best regards,
Stefano Babic

Quoted 18 lines

BR,

Tomas

Quoted 12 lines

http://git.denx.de/?p=u-boot.git;a=blob;f=common/splash_source.c;h=62763b9ebd5698b454280a6d4b62cd23a7312786;hb=HEAD#l409

Regards,
Mark

Building Technologies, Panel Software Fire (BT-FIR/ENG1)
Bosch Sicherheitssysteme GmbH | Postfach 11 11 | 85626 Grasbrunn | GERMANY | www.boschsecurity.com

Sitz: Stuttgart, Registergericht: Amtsgericht Stuttgart HRB 23118
Aufsichtsratsvorsitzender: Christian Fischer; Geschäftsführung: Tanja Rückert, Andreas Bartz, Thomas Quante, Bernhard Schuster

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#7 lore raw

PATCH v2 1/2 splash: Use splashfile instead of location->name

In reply to Mark Jonas
Quoted 65 lines · Mark Jonas

From: Leo Ruan <[email protected]>

The splash image could be loaded from different sources (e.g. sf, mmc) with different formats (e.g. raw, file-system). These sources are structured by a board dependent object 'splash_location'. To decide where is the splash image loaded, following environment variables are used to select the splash source and file:
- 'splashsource' is used to select the splash source by setting its value to specified name of splash location.
- 'splashfile' specify the name of splash image file

But, when loads the splash image from FIT, the name of splash image within FIT is specified by splash location name. Due to the splash location name is already used for the splash source, its name may conflicts with the name of splash image.

To solve the conflict, the environment variable 'splashfile' is used to specify the splash image in FIT, and keeps the splash location name for the splash source.

---
  common/splash_source.c   | 10 ++++++++--
  doc/README.splashprepare |  9 ++++++---
  2 files changed, 14 insertions(+), 5 deletions(-)
common/splash_source.c +8 -2
index 62763b9..e1e73db 100644
@@ -303,6 +303,7 @@ static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr)
  {
  	int res;
  	int node_offset;
+	const char *splash_file;
  	int splash_offset;
  	int splash_size;
  	struct image_header *img_header;
@@ -335,10 +336,15 @@ static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr)
  		return -EINVAL;
  	}
 
-	node_offset = fit_image_get_node(fit_header, location->name);
+	/* Get the splash image node */
+	splash_file = env_get("splashfile");
+	if (!splash_file)
+		splash_file = SPLASH_SOURCE_DEFAULT_FILE_NAME;
+
+	node_offset = fit_image_get_node(fit_header, splash_file);
  	if (node_offset < 0) {
  		debug("Could not find splash image '%s' in FIT\n",
-		      location->name);
+		      splash_file);
  		return -ENOENT;
  	}
 
doc/README.splashprepare +0 -0
index f1418de..3cb5b5a 100644
@@ -26,6 +26,9 @@ screen data is loaded as a file. The name of the splash screen file can be
  controlled with the environment variable "splashfile".
 

doc/README.splashprepare screen data is loaded as a file. The name of the splash screen file can be · line 34

Quoted 10 lines
doc/README.splashprepare +6 -3
  To enable loading the splash image from a FIT image, CONFIG_FIT must be
-enabled. Struct splash_location field 'name' should match the splash image
-name within the FIT and the FIT should start at the 'offset' field address in
-the specified storage.
+enabled. The FIT image has to start at the 'offset' field address in the
+selected splash location. The name of splash image within the FIT shall be
+specified by the environment variable "splashfile".
+
+In case the environment variable "splashfile" is not defined the default name
+'splash.bmp' will be used

Regards,
Tomas Melin

author
#8 lore raw

PATCH v2 2/2 splash: Load internal and external data from FIT

In reply to Mark Jonas

From: Leo Ruan <[email protected]>

The FIT image could contain the splash data in 3 different structure:
- The splash data is embedded in FIT image (internal)
In this case, the property 'data' presents in FIT image header. And internal information 'start' and 'end' represent the location and size of splash data inside of FIT image.
- The splash data is external with absolute position in FIT image This case is made by 'mkimage -p [pos]'. The splash data is stored at the absolute position. Instead the property 'data', the properties 'data-position' and 'data-size' are used to specify the location and size of the splash data.
- the splash data is external with relative offset in FIT image This case is made by 'mkimage -E'. The splash data is placed after the FIT image header with 4 byte alignment. Instead the property 'data', the properties 'data-offset' and 'data-size' are used to specify the location and size of the splash data.

Currently, the splash only support to load external data with relative offset from FIT image. This commit make it possible to load the splash data embedded in FIT image or the external data with absolute position

This inspiration comes from Simon Glass <[email protected]>, see common/spl_fit.c

---
 common/splash_source.c | 55 +++++++++++++++++++++++++++++++-------------------
 1 file changed, 34 insertions(+), 21 deletions(-)
common/splash_source.c +34 -21
index e1e73db..8f276a3 100644
@@ -304,8 +304,11 @@ static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr)
 	int res;
 	int node_offset;
 	const char *splash_file;
-	int splash_offset;
-	int splash_size;
+	const void *internal_splash_data;
+	size_t internal_splash_size;
+	int external_splash_addr;
+	int external_splash_size;
+	bool is_splash_external = false;
 	struct image_header *img_header;
 	const u32 *fit_header;
 	u32 fit_size;
@@ -348,29 +351,39 @@ static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr)
 		return -ENOENT;
 	}
 
-	res = fit_image_get_data_offset(fit_header, node_offset,
-					&splash_offset);
-	if (res < 0) {
-		printf("Failed to load splash image (err=%d)\n", res);
-		return res;
+	/* Extract the splash data from FIT */
+	/* 1. Test if splash is in FIT internal data. */
+	if (!fit_image_get_data(fit_header, node_offset, &internal_splash_data, &internal_splash_size))
+		memmove((void *)bmp_load_addr, internal_splash_data, internal_splash_size);
+	/* 2. Test if splash is in FIT external data with fixed position. */
+	else if (!fit_image_get_data_position(fit_header, node_offset, &external_splash_addr))
+		is_splash_external = true;
+	/* 3. Test if splash is in FIT external data with offset. */
+	else if (!fit_image_get_data_offset(fit_header, node_offset, &external_splash_addr)) {
+		/* Align data offset to 4-byte boundary */
+		fit_size = ALIGN(fdt_totalsize(fit_header), 4);
+		/* External splash offset means the offset by end of FIT header */
+		external_splash_addr += location->offset + fit_size;
+		is_splash_external = true;
+	} else {
+		printf("Failed to get splash image from FIT\n");
+		return -ENODATA;
 	}
 
-	res = fit_image_get_data_size(fit_header, node_offset, &splash_size);
-	if (res < 0) {
-		printf("Failed to load splash image (err=%d)\n", res);
-		return res;
+	if (is_splash_external) {
+		res = fit_image_get_data_size(fit_header, node_offset, &external_splash_size);
+		if (res < 0) {
+			printf("Failed to get size of splash image (err=%d)\n", res);
+			return res;
+		}
+
+		/* Read in the splash data */
+		location->offset = external_splash_addr;
+		res = splash_storage_read_raw(location, bmp_load_addr, external_splash_size);
+		if (res < 0)
+			return res;
 	}
 
-	/* Align data offset to 4-byte boundrary */
-	fit_size = fdt_totalsize(fit_header);
-	fit_size = (fit_size + 3) & ~3;
-
-	/* Read in the splash data */
-	location->offset = (location->offset + fit_size + splash_offset);
-	res = splash_storage_read_raw(location, bmp_load_addr , splash_size);
-	if (res < 0)
-		return res;
-
 	return 0;
 }
 #endif /* CONFIG_FIT */
Signature · 1 line
2.7.4
#9 lore raw

PATCH v2 2/2 splash: Load internal and external data from FIT

Quoted 100 lines · Mark Jonas

From: Leo Ruan <[email protected]>

The FIT image could contain the splash data in 3 different structure:
- The splash data is embedded in FIT image (internal)
In this case, the property 'data' presents in FIT image header. And internal information 'start' and 'end' represent the location and size of splash data inside of FIT image.
- The splash data is external with absolute position in FIT image This case is made by 'mkimage -p [pos]'. The splash data is stored at the absolute position. Instead the property 'data', the properties 'data-position' and 'data-size' are used to specify the location and size of the splash data.
- the splash data is external with relative offset in FIT image This case is made by 'mkimage -E'. The splash data is placed after the FIT image header with 4 byte alignment. Instead the property 'data', the properties 'data-offset' and 'data-size' are used to specify the location and size of the splash data.

Currently, the splash only support to load external data with relative offset from FIT image. This commit make it possible to load the splash data embedded in FIT image or the external data with absolute position

This inspiration comes from Simon Glass <[email protected]>, see common/spl_fit.c

---
 common/splash_source.c | 55 +++++++++++++++++++++++++++++++-------------------
 1 file changed, 34 insertions(+), 21 deletions(-)
common/splash_source.c +34 -14
index e1e73db..8f276a3 100644
@@ -304,8 +304,11 @@ static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr)
 	int res;
 	int node_offset;
 	const char *splash_file;
-	int splash_offset;
-	int splash_size;
+	const void *internal_splash_data;
+	size_t internal_splash_size;
+	int external_splash_addr;
+	int external_splash_size;
+	bool is_splash_external = false;
 	struct image_header *img_header;
 	const u32 *fit_header;
 	u32 fit_size;
@@ -348,29 +351,39 @@ static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr)
 		return -ENOENT;
 	}
 
-	res = fit_image_get_data_offset(fit_header, node_offset,
-					&splash_offset);
-	if (res < 0) {
-		printf("Failed to load splash image (err=%d)\n", res);
-		return res;
+	/* Extract the splash data from FIT */
+	/* 1. Test if splash is in FIT internal data. */
+	if (!fit_image_get_data(fit_header, node_offset, &internal_splash_data, &internal_splash_size))
+		memmove((void *)bmp_load_addr, internal_splash_data, internal_splash_size);
+	/* 2. Test if splash is in FIT external data with fixed position. */
+	else if (!fit_image_get_data_position(fit_header, node_offset, &external_splash_addr))
+		is_splash_external = true;
+	/* 3. Test if splash is in FIT external data with offset. */
+	else if (!fit_image_get_data_offset(fit_header, node_offset, &external_splash_addr)) {
+		/* Align data offset to 4-byte boundary */
+		fit_size = ALIGN(fdt_totalsize(fit_header), 4);
+		/* External splash offset means the offset by end of FIT header */
+		external_splash_addr += location->offset + fit_size;
+		is_splash_external = true;
+	} else {
+		printf("Failed to get splash image from FIT\n");
+		return -ENODATA;
 	}
 
-	res = fit_image_get_data_size(fit_header, node_offset, &splash_size);
-	if (res < 0) {
-		printf("Failed to load splash image (err=%d)\n", res);
-		return res;
+	if (is_splash_external) {
+		res = fit_image_get_data_size(fit_header, node_offset, &external_splash_size);
+		if (res < 0) {
+			printf("Failed to get size of splash image (err=%d)\n", res);
+			return res;
+		}
+
+		/* Read in the splash data */
+		location->offset = external_splash_addr;
+		res = splash_storage_read_raw(location, bmp_load_addr, external_splash_size);
+		if (res < 0)
+			return res;
 	}
 
-	/* Align data offset to 4-byte boundrary */
-	fit_size = fdt_totalsize(fit_header);
-	fit_size = (fit_size + 3) & ~3;

common/splash_source.c static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr) · line 389

Quoted 10 lines
common/splash_source.c +0 -7
-
-	/* Read in the splash data */
-	location->offset = (location->offset + fit_size + splash_offset);
-	res = splash_storage_read_raw(location, bmp_load_addr , splash_size);
-	if (res < 0)
-		return res;
-
 	return 0;
 }
 #endif /* CONFIG_FIT */

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================