mirror of
https://xff.cz/git/u-boot/
synced 2025-09-02 17:22:22 +02:00
fdt: Avoid early panic() when there is no FDT present
CONFIG_OF_CONTROL requires a valid device tree. However, we cannot call panic() before the console is set up since the message does not appear, and we get a silent failure. Remove the panic from fdtdec_check_fdt() and provide a new function to prepare the fdt for use. This will be called after the console is ready. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Warren <twarren@nvidia.com>
This commit is contained in:
committed by
Albert ARIBAUD
parent
87f938c9f7
commit
9a263e55dc
@@ -155,8 +155,21 @@ s32 fdtdec_get_int(const void *blob, int node, const char *prop_name,
|
|||||||
int fdtdec_get_is_enabled(const void *blob, int node);
|
int fdtdec_get_is_enabled(const void *blob, int node);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether we have a valid fdt available to control U-Boot, and panic
|
* Make sure we have a valid fdt available to control U-Boot.
|
||||||
* if not.
|
*
|
||||||
|
* If not, a message is printed to the console if the console is ready.
|
||||||
|
*
|
||||||
|
* @return 0 if all ok, -1 if not
|
||||||
|
*/
|
||||||
|
int fdtdec_prepare_fdt(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks that we have a valid fdt available to control U-Boot.
|
||||||
|
|
||||||
|
* However, if not then for the moment nothing is done, since this function
|
||||||
|
* is called too early to panic().
|
||||||
|
*
|
||||||
|
* @returns 0
|
||||||
*/
|
*/
|
||||||
int fdtdec_check_fdt(void);
|
int fdtdec_check_fdt(void);
|
||||||
|
|
||||||
|
24
lib/fdtdec.c
24
lib/fdtdec.c
@@ -262,17 +262,31 @@ int fdtdec_find_aliases_for_id(const void *blob, const char *name,
|
|||||||
return num_found;
|
return num_found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int fdtdec_check_fdt(void)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* We must have an FDT, but we cannot panic() yet since the console
|
||||||
|
* is not ready. So for now, just assert(). Boards which need an early
|
||||||
|
* FDT (prior to console ready) will need to make their own
|
||||||
|
* arrangements and do their own checks.
|
||||||
|
*/
|
||||||
|
assert(!fdtdec_prepare_fdt());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function is a little odd in that it accesses global data. At some
|
* This function is a little odd in that it accesses global data. At some
|
||||||
* point if the architecture board.c files merge this will make more sense.
|
* point if the architecture board.c files merge this will make more sense.
|
||||||
* Even now, it is common code.
|
* Even now, it is common code.
|
||||||
*/
|
*/
|
||||||
int fdtdec_check_fdt(void)
|
int fdtdec_prepare_fdt(void)
|
||||||
{
|
{
|
||||||
/* We must have an fdt */
|
if (((uintptr_t)gd->fdt_blob & 3) || fdt_check_header(gd->fdt_blob)) {
|
||||||
if (((uintptr_t)gd->fdt_blob & 3) || fdt_check_header(gd->fdt_blob))
|
printf("No valid FDT found - please append one to U-Boot "
|
||||||
panic("No valid fdt found - please append one to U-Boot\n"
|
"binary, use u-boot-dtb.bin or define "
|
||||||
"binary or define CONFIG_OF_EMBED\n");
|
"CONFIG_OF_EMBED\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user