Load splash from FIT image (internal, external, offset)
v3 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
- Reviewed by Simon Glass
Changes since v2:
- Reviewed by Stefano Babic and Tomas Melin
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
PATCH v3 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
@@ -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
@@ -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
PATCH v3 1/2 splash: Use splashfile instead of location->name
Hi,
Quoted 13 lines · Mark Jonas
common/splash_source.c +1
-0@@ -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 342
Quoted 8 lines
common/splash_source.c +4
-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 ;
As mentioned during latest review round, this default name should really IMO be something else than a file name since it's not a file, it's a FIT node. splash_file should also probably be splash_node or so.
I'm not even sure is this patch really needed, selecting an appropriate name for the splash_location.name, matching the splash image node should work equally.
BR,
Tomas
PATCH v3 2/2 splash: Load internal and external data from FIT
In reply to Mark JonasFrom: 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
@@ -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
v3 cover Load splash from FIT image (internal, external, offset)
In reply to Mark JonasHi,
Quoted 22 lines
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
- UseALIGN()macro
- Reviewed by Simon GlassChanges since v2:
- Reviewed by Stefano Babic and Tomas MelinLeo Ruan (2):
splash: Use splashfile instead oflocation->name
splash: Load internal and external data from FIT
Quoted 7 lines
common/splash_source.c | 65 +++++++++++++++++++++++++++++++----------------- doc/README.splashprepare | 9 ++++--- 2 files changed, 48 insertions(+), 26 deletions(-)--
2.7.4
Gentle ping^2. Ready to apply?
Greetings,
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
v3 cover Load splash from FIT image (internal, external, offset)
Hi,
Quoted 1 line · On 3/29/19 6:17 PM, Jonas Mark (BT-FIR/ENG1) wrote:
Gentle ping^2. Ready to apply?
I was kindof hoping on some follow up on concerns raised during v3, see below.
Quoted 6 lines · Tomas Melin
Quoted 5 lines
-
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;
Quoted 7 lines
As mentioned during latest review round, this default name should really IMO be something else than a file name since it's not a file, it's a FIT node.
splash_fileshould also probably besplash_nodeor so.I'm not even sure is this patch really needed, selecting an appropriate name for the splash_location.name, matching the splash image node should work equally.
BR,
Tomas