#ifdef CONFIG_SPL_BUILD
+/* Define board data structure */
+static struct bd_info bdata __attribute__ ((section(".data")));
+
void spl_board_init(void)
{
#if defined(CONFIG_NXP_ESBC) && defined(CONFIG_FSL_LSCH2)
get_clocks();
preloader_console_init();
- spl_set_bd();
+ gd->bd = &bdata;
#ifdef CONFIG_SYS_I2C
#ifdef CONFIG_SPL_I2C_SUPPORT
Create boot binary having SPL binary in PBI format concatenated with
u-boot binary.
+config SPL_ALLOC_BD
+ bool "Allocate memory for bd_info"
+ default y if X86 || SANDBOX
+ help
+ Some boards don't allocate space for this in their board_init_f()
+ code. In this case U-Boot can allocate space for gd->bd in the
+ standard SPL flow (board_init_r()). Enable this option to support
+ this feature.
+
endmenu
config HANDOFF
binman_sym_declare(ulong, spl, size);
#endif
-/* Define board data structure */
-static struct bd_info bdata __attribute__ ((section(".data")));
-
/*
* Board-specific Platform code can reimplement show_boot_progress () if needed
*/
return 0;
}
-void spl_set_bd(void)
+int spl_alloc_bd(void)
{
/*
* NOTE: On some platforms (e.g. x86) bdata may be in flash and not
* writeable.
*/
- if (!gd->bd)
- gd->bd = &bdata;
+ if (!gd->bd) {
+ gd->bd = malloc(sizeof(*gd->bd));
+ if (!gd->bd)
+ return -ENOMEM;
+ }
+
+ return 0;
}
int spl_early_init(void)
debug(">>" SPL_TPL_PROMPT "board_init_r()\n");
- spl_set_bd();
-
#if defined(CONFIG_SYS_SPL_MALLOC_START)
mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START,
CONFIG_SYS_SPL_MALLOC_SIZE);
if (spl_init())
hang();
}
+ if (IS_ENABLED(CONFIG_SPL_ALLOC_BD) && spl_alloc_bd()) {
+ puts("Cannot alloc bd\n");
+ hang();
+ }
#if !defined(CONFIG_PPC) && !defined(CONFIG_ARCH_MX6)
/*
* timer_init() does not exist on PPC systems. The timer is initialized
* If not overridden, it is weakly defined in common/spl/spl_mmc.c.
*/
int spl_mmc_boot_partition(const u32 boot_device);
-void spl_set_bd(void);
+
+/**
+ * spl_alloc_bd() - Allocate space for bd_info
+ *
+ * This sets up the gd->bd pointer by allocating memory for it
+ *
+ * @return 0 if OK, -ENOMEM if out of memory
+ */
+int spl_alloc_bd(void);
/**
* spl_set_header_raw_uboot() - Set up a standard SPL image structure