ifeq ($(CONFIG_SPL_FRAMEWORK),y)
INPUTS-$(CONFIG_OF_SEPARATE) += u-boot-dtb.img
endif
-INPUTS-$(CONFIG_OF_HOSTFILE) += u-boot.dtb
+INPUTS-$(CONFIG_SANDBOX) += u-boot.dtb
ifneq ($(CONFIG_SPL_TARGET),)
INPUTS-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%)
endif
u-boot-dtb.img u-boot.img u-boot.kwb u-boot.pbl u-boot-ivt.img: \
$(if $(CONFIG_SPL_LOAD_FIT),u-boot-nodtb.bin \
- $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_OF_HOSTFILE)$(CONFIG_BINMAN_STANDALONE_FDT),dts/dt.dtb) \
+ $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_SANDBOX)$(CONFIG_BINMAN_STANDALONE_FDT),dts/dt.dtb) \
,$(UBOOT_BIN)) FORCE
$(call if_changed,mkimage)
$(BOARD_SIZE_CHECK)
ifdef U_BOOT_ITS
u-boot.itb: u-boot-nodtb.bin \
- $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_OF_HOSTFILE),dts/dt.dtb) \
+ $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_SANDBOX),dts/dt.dtb) \
$(U_BOOT_ITS) FORCE
$(call if_changed,mkfitimage)
$(BOARD_SIZE_CHECK)
* Use the saved FDT address provided by TF-A at boot time (NT_FW_CONFIG =
* Non Trusted Firmware configuration file) when the pointer is valid
*/
-void *board_fdt_blob_setup(void)
+void *board_fdt_blob_setup(int *err)
{
log_debug("%s: nt_fw_dtb=%lx\n", __func__, nt_fw_dtb);
+ *err = 0;
/* use external device tree only if address is valid */
if (nt_fw_dtb >= STM32_DDR_BASE) {
if (fdt_magic(nt_fw_dtb) == FDT_MAGIC)
{
}
-int sandbox_read_fdt_from_file(void)
+void *board_fdt_blob_setup(int *ret)
{
struct sandbox_state *state = state_get_current();
const char *fname = state->fdt_fname;
- void *blob;
+ void *blob = NULL;
loff_t size;
int err;
int fd;
blob = map_sysmem(CONFIG_SYS_FDT_LOAD_ADDR, 0);
+ *ret = 0;
if (!state->fdt_fname) {
err = fdt_create_empty_tree(blob, 256);
if (!err)
goto done;
printf("Unable to create empty FDT: %s\n", fdt_strerror(err));
- return -EINVAL;
+ *ret = -EINVAL;
+ goto fail;
}
err = os_get_filesize(fname, &size);
if (err < 0) {
- printf("Failed to file FDT file '%s'\n", fname);
- return err;
+ printf("Failed to find FDT file '%s'\n", fname);
+ *ret = err;
+ goto fail;
}
fd = os_open(fname, OS_O_RDONLY);
if (fd < 0) {
printf("Failed to open FDT file '%s'\n", fname);
- return -EACCES;
+ *ret = -EACCES;
+ goto fail;
}
+
if (os_read(fd, blob, size) != size) {
os_close(fd);
- return -EIO;
+ printf("Failed to read FDT file '%s'\n", fname);
+ *ret = -EIO;
+ goto fail;
}
os_close(fd);
done:
- gd->fdt_blob = blob;
-
- return 0;
+ return blob;
+fail:
+ return NULL;
}
ulong timer_get_boot_us(void)
*/
void sandbox_set_enable_pci_map(int enable);
-/**
- * sandbox_read_fdt_from_file() - Read a device tree from a file
- *
- * Read a device tree file from a host file and set it up for use as the
- * control FDT.
- */
-int sandbox_read_fdt_from_file(void);
-
/**
* sandbox_reset() - reset sandbox
*
return 0;
}
-void *board_fdt_blob_setup(void)
+void *board_fdt_blob_setup(int *err)
{
+ *err = 0;
#if CONFIG_IS_ENABLED(OF_BOARD)
return (void *)(ulong)gd->arch.firmware_fdt_addr;
#elif CONFIG_IS_ENABLED(OF_SEPARATE)
return (void *)CONFIG_SYS_FDT_BASE;
#else
+ *err = -EINVAL;
return NULL;
#endif
}
*
* @return FDT base address received from ATF in x1 register
*/
-void *board_fdt_blob_setup(void)
+void *board_fdt_blob_setup(int *err)
{
+ *err = 0;
return (void *)fdt_base_addr;
}
*
* @return FDT base address received from ATF in x1 register
*/
-void *board_fdt_blob_setup(void)
+void *board_fdt_blob_setup(int *err)
{
+ *err = 0;
return (void *)fdt_base_addr;
}
uboot_entry_t entry;
ulong addr;
void *fdt;
+ int err;
if (argc < 2)
return CMD_RET_USAGE;
addr = hextoul(argv[1], NULL);
- fdt = board_fdt_blob_setup();
+ fdt = board_fdt_blob_setup(&err);
entry = (uboot_entry_t)addr;
flush_cache((ulong)addr, 1 << 20); /* 1MiB should be enough */
dcache_disable();
return ~0;
}
-void *board_fdt_blob_setup(void)
+void *board_fdt_blob_setup(int *err)
{
phys_addr_t fdt_rom_addr = find_dtb_in_nor_flash(CONFIG_JUNO_DTB_PART);
- if (fdt_rom_addr == ~0UL)
+ *err = 0;
+ if (fdt_rom_addr == ~0UL) {
+ *err = -ENXIO;
return NULL;
+ }
return (void *)fdt_rom_addr;
}
return 0;
}
-void *board_fdt_blob_setup(void)
+void *board_fdt_blob_setup(int *err)
{
+ *err = 0;
/* Stored the DTB address there during our init */
return (void *)prior_stage_fdt_address;
}
return 0;
}
-void *board_fdt_blob_setup(void)
+void *board_fdt_blob_setup(int *err)
{
+ *err = 0;
/* QEMU loads a generated DTB for us at the start of RAM. */
return (void *)CONFIG_SYS_SDRAM_BASE;
}
*
* @return virtual address of FDT received from QEMU in r3 register
*/
-void *board_fdt_blob_setup(void)
+void *board_fdt_blob_setup(int *err)
{
+ *err = 0;
return get_fdt_virt();
}
}
#endif
-void *board_fdt_blob_setup(void)
+void *board_fdt_blob_setup(int *err)
{
+ *err = 0;
/* Stored the DTB address there during our init */
return (void *)(ulong)gd->arch.firmware_fdt_addr;
}
}
#endif
-void *board_fdt_blob_setup(void)
+void *board_fdt_blob_setup(int *err)
{
+ *err = 0;
/*
* The ECME management processor loads the DTB from NOR flash
* into DRAM (at 4KB), where it gets patched to contain the
/*
* If the firmware passed a device tree use it for U-Boot.
*/
-void *board_fdt_blob_setup(void)
+void *board_fdt_blob_setup(int *err)
{
- if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC)
+ *err = 0;
+ if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC) {
+ *err = -ENXIO;
return NULL;
+ }
+
return (void *)fw_dtb_pointer;
}
#endif
-void *board_fdt_blob_setup(void)
+void *board_fdt_blob_setup(int *err)
{
+ *err = 0;
if (IS_ENABLED(CONFIG_OF_SEPARATE)) {
if (gd->arch.firmware_fdt_addr)
return (ulong *)(uintptr_t)gd->arch.firmware_fdt_addr;
#include <dm.h>
#include <asm/sections.h>
-void *board_fdt_blob_setup(void)
+void *board_fdt_blob_setup(int *err)
{
+ *err = 0;
if (IS_ENABLED(CONFIG_OF_SEPARATE)) {
if (gd->arch.firmware_fdt_addr)
return (ulong *)(uintptr_t)gd->arch.firmware_fdt_addr;
#endif /* CONFIG_OF_BOARD_SETUP */
#if defined(CONFIG_OF_SEPARATE)
-void *board_fdt_blob_setup(void)
+void *board_fdt_blob_setup(int *err)
{
void *fw_dtb;
+ *err = 0;
fw_dtb = (void *)(CONFIG_SYS_TEXT_BASE - CONFIG_ENV_SECT_SIZE);
if (fdt_magic(fw_dtb) != FDT_MAGIC) {
printf("DTB is not passed via %x\n", (u32)fw_dtb);
+ *err = -ENXIO;
return NULL;
}
* x0 is the physical address of the device tree blob (dtb) in system RAM.
* This is stored in rom_pointer during low level init.
*/
-void *board_fdt_blob_setup(void)
+void *board_fdt_blob_setup(int *err)
{
- if (fdt_magic(rom_pointer[0]) != FDT_MAGIC)
+ *err = 0;
+ if (fdt_magic(rom_pointer[0]) != FDT_MAGIC) {
+ *err = -ENXIO;
return NULL;
+ }
return (void *)rom_pointer[0];
}
}
#if defined(CONFIG_OF_BOARD) || defined(CONFIG_OF_SEPARATE)
-void *board_fdt_blob_setup(void)
+void *board_fdt_blob_setup(int *err)
{
void *fdt_blob;
+ *err = 0;
if (!IS_ENABLED(CONFIG_SPL_BUILD) &&
!IS_ENABLED(CONFIG_VERSAL_NO_DDR) &&
!IS_ENABLED(CONFIG_ZYNQMP_NO_DDR)) {
CONFIG_AMIGA_PARTITION=y
CONFIG_OF_CONTROL=y
CONFIG_OF_LIVE=y
-CONFIG_OF_HOSTFILE=y
CONFIG_ENV_IS_NOWHERE=y
CONFIG_ENV_IS_IN_EXT4=y
CONFIG_ENV_EXT4_INTERFACE="host"
CONFIG_AMIGA_PARTITION=y
CONFIG_OF_CONTROL=y
CONFIG_OF_LIVE=y
-CONFIG_OF_HOSTFILE=y
CONFIG_ENV_IS_NOWHERE=y
CONFIG_ENV_IS_IN_EXT4=y
CONFIG_ENV_EXT4_INTERFACE="host"
CONFIG_MAC_PARTITION=y
CONFIG_AMIGA_PARTITION=y
CONFIG_OF_CONTROL=y
-CONFIG_OF_HOSTFILE=y
CONFIG_ENV_IS_NOWHERE=y
CONFIG_ENV_IS_IN_EXT4=y
CONFIG_ENV_EXT4_INTERFACE="host"
CONFIG_AMIGA_PARTITION=y
CONFIG_OF_CONTROL=y
CONFIG_SPL_OF_CONTROL=y
-CONFIG_OF_HOSTFILE=y
CONFIG_SPL_OF_PLATDATA=y
CONFIG_ENV_IS_NOWHERE=y
CONFIG_ENV_IS_IN_EXT4=y
CONFIG_AMIGA_PARTITION=y
CONFIG_OF_CONTROL=y
CONFIG_SPL_OF_CONTROL=y
-CONFIG_OF_HOSTFILE=y
CONFIG_SPL_OF_PLATDATA=y
CONFIG_SPL_OF_PLATDATA_INST=y
CONFIG_ENV_IS_NOWHERE=y
CONFIG_BOOTP_DNS2=y
# CONFIG_CMD_DATE is not set
CONFIG_OF_CONTROL=y
-CONFIG_OF_HOSTFILE=y
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
CONFIG_BOOTP_SEND_HOSTNAME=y
CONFIG_IP_DEFRAG=y
devicetree at runtime, for example if an earlier bootloader stage creates
it and passes it to U-Boot.
-If CONFIG_OF_HOSTFILE is defined, then it will be read from a file on
-startup. This is only useful for sandbox. Use the -d flag to U-Boot to
-specify the file to read, -D for the default and -T for the test devicetree,
-used to run sandbox unit tests.
+If CONFIG_SANDBOX is defined, then it will be read from a file on
+startup. Use the -d flag to U-Boot to specify the file to read, -D for the
+default and -T for the test devicetree, used to run sandbox unit tests.
You cannot use more than one of these options at the same time.
choice
prompt "Provider of DTB for DT control"
depends on OF_CONTROL
+ default OF_BOARD if SANDBOX
config OF_SEPARATE
bool "Separate DTB for DT control"
config OF_BOARD
bool "Provided by the board (e.g a previous loader) at runtime"
- depends on !SANDBOX
help
If this option is enabled, the device tree will be provided by
the board at runtime if the board supports it, instead of being
bundled with the image.
-config OF_HOSTFILE
- bool "Host filed DTB for DT control"
- depends on SANDBOX
- help
- If this option is enabled, DTB will be read from a file on startup.
- This is only useful for Sandbox. Use the -d flag to U-Boot to
- specify the file to read.
-
endchoice
config DEFAULT_DEVICE_TREE
* Board-specific FDT initialization. Returns the address to a device tree blob.
* Called when CONFIG_OF_BOARD is defined, or if CONFIG_OF_SEPARATE is defined
* and the board implements it.
+ *
+ * @err internal error code if we fail to setup a DTB
*/
-void *board_fdt_blob_setup(void);
+void *board_fdt_blob_setup(int *err);
/*
* Decode the size of memory
* For CONFIG_OF_SEPARATE, the board may optionally implement this to
* provide and/or fixup the fdt.
*/
-__weak void *board_fdt_blob_setup(void)
+__weak void *board_fdt_blob_setup(int *err)
{
void *fdt_blob = NULL;
+
+ *err = 0;
#ifdef CONFIG_SPL_BUILD
/* FDT is at end of BSS unless it is in a different memory region */
if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS))
/* FDT is at end of image */
fdt_blob = (ulong *)&_end;
#endif
+
return fdt_blob;
}
#endif
# endif
# elif defined(CONFIG_OF_BOARD) || defined(CONFIG_OF_SEPARATE)
/* Allow the board to override the fdt address. */
- gd->fdt_blob = board_fdt_blob_setup();
-# elif defined(CONFIG_OF_HOSTFILE)
- if (sandbox_read_fdt_from_file()) {
- puts("Failed to read control FDT\n");
- return -1;
- }
+ gd->fdt_blob = board_fdt_blob_setup(&ret);
+ if (ret)
+ return ret;
# endif
# ifndef CONFIG_SPL_BUILD
/* Allow the early environment to override the fdt address */
# - we have either OF_SEPARATE or OF_HOSTFILE
build_dtb :=
ifneq ($(CONFIG_$(SPL_TPL_)OF_REAL),)
-ifeq ($(CONFIG_OF_SEPARATE)$(CONFIG_OF_HOSTFILE),y)
+ifeq ($(CONFIG_OF_SEPARATE)$(CONFIG_SANDBOX),y)
build_dtb := y
endif
endif