spl: fit: add SPL_FIT_IMAGE_TINY config to reduce code-size
A minor code-size increase from the changes for tracking the os-type
of FIT images and from infrastructure for recording the loadables into
the the loaded FDT, broke the builds for sun50i and some OMAP2+ devices.
This change adds a new config option (enabled by default for
MACH_SUN50I, MACH_SUN50I_H5 and ARCH_OMAP2PLUS) that does skips these
processing steps (bringing code size down to below the limit
again). The os-type is not evaluated, but assumed to be IH_OS_UBOOT
(i.e. taking the code-paths intended for backward-compatibility).
Note that enabling this config option precludes any useful downstream
processing, such as utilising a special calling convention for ATF or
OPTEE, based on the os-type of the loadables.
Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index ce7c3af..b1ee15c 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -228,6 +228,22 @@
SHA256 variant is supported: SHA512 and others are not currently
supported in U-Boot.
+config SPL_FIT_IMAGE_TINY
+ bool "Remove functionality from SPL FIT loading to reduce size"
+ depends on SPL_FIT
+ default y if MACH_SUN50I || MACH_SUN50I_H5
+ default y if ARCH_OMAP2PLUS
+ help
+ Enable this to reduce the size of the FIT image loading code
+ in SPL, if space for the SPL binary is very tight.
+
+ This removes the detection of image types (which forces the
+ first image to be treated as having a U-Boot style calling
+ convention) and skips the recording of each loaded payload
+ (i.e. loadable) into the FDT (modifying the loaded FDT to
+ ensure this information is available to the next image
+ invoked).
+
config SPL_CPU_SUPPORT
bool "Support CPU drivers"
help
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 128af1b..72ae8f4 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -275,8 +275,10 @@
/* Make the load-address of the FDT available for the SPL framework */
spl_image->fdt_addr = (void *)image_info.load_addr;
+#if !CONFIG_IS_ENABLED(FIT_IMAGE_TINY)
/* Try to make space, so we can inject details on the loadables */
ret = fdt_shrink_to_minimum(spl_image->fdt_addr, 8192);
+#endif
return ret;
}
@@ -284,8 +286,10 @@
static int spl_fit_record_loadable(const void *fit, int images, int index,
void *blob, struct spl_image_info *image)
{
+ int ret = 0;
+#if !CONFIG_IS_ENABLED(FIT_IMAGE_TINY)
char *name;
- int node, ret;
+ int node;
ret = spl_fit_get_image_name(fit, images, "loadables",
index, &name);
@@ -298,9 +302,19 @@
image->size, image->entry_point,
fdt_getprop(fit, node, "type", NULL),
fdt_getprop(fit, node, "os", NULL));
+#endif
return ret;
}
+static int spl_fit_image_get_os(const void *fit, int noffset, uint8_t *os)
+{
+#if CONFIG_IS_ENABLED(FIT_IMAGE_TINY)
+ return -ENOTSUPP;
+#else
+ return fit_image_get_os(fit, noffset, os);
+#endif
+}
+
int spl_load_simple_fit(struct spl_image_info *spl_image,
struct spl_load_info *info, ulong sector, void *fit)
{
@@ -392,7 +406,7 @@
* For backward compatibility, we treat the first node that is
* as a U-Boot image, if no OS-type has been declared.
*/
- if (!fit_image_get_os(fit, node, &spl_image->os))
+ if (!spl_fit_image_get_os(fit, node, &spl_image->os))
debug("Image OS is %s\n", genimg_get_os_name(spl_image->os));
#if !defined(CONFIG_SPL_OS_BOOT)
else
@@ -420,7 +434,7 @@
if (ret < 0)
continue;
- if (!fit_image_get_os(fit, node, &os_type))
+ if (!spl_fit_image_get_os(fit, node, &os_type))
debug("Loadable is %s\n", genimg_get_os_name(os_type));
if (os_type == IH_OS_U_BOOT) {
diff --git a/include/fdt_support.h b/include/fdt_support.h
index afaf0e7..e0f9086 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -133,7 +133,6 @@
static inline void fdt_fixup_crypto_node(void *blob, int sec_rev) {}
#endif
-#if CONFIG_IS_ENABLED(LOAD_FIT)
/**
* Record information about a processed loadable in /fit-images (creating
* /fit-images if necessary).
@@ -151,7 +150,6 @@
int fdt_record_loadable(void *blob, u32 index, const char *name,
uintptr_t load_addr, u32 size, uintptr_t entry_point,
const char *type, const char *os);
-#endif
#ifdef CONFIG_PCI
#include <pci.h>