boot: Allow FIT to fall back from best-match option
When the best-match feature fails to find something, use the provided config name as a fallback. The allows SPL to select a suitable config when best-match is enabled. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -1729,13 +1729,13 @@ int fit_conf_find_compat(const void *fit, const void *fdt)
|
|||||||
images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH);
|
images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH);
|
||||||
if (confs_noffset < 0 || images_noffset < 0) {
|
if (confs_noffset < 0 || images_noffset < 0) {
|
||||||
debug("Can't find configurations or images nodes.\n");
|
debug("Can't find configurations or images nodes.\n");
|
||||||
return -1;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
fdt_compat = fdt_getprop(fdt, 0, "compatible", &fdt_compat_len);
|
fdt_compat = fdt_getprop(fdt, 0, "compatible", &fdt_compat_len);
|
||||||
if (!fdt_compat) {
|
if (!fdt_compat) {
|
||||||
debug("Fdt for comparison has no \"compatible\" property.\n");
|
debug("Fdt for comparison has no \"compatible\" property.\n");
|
||||||
return -1;
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1812,7 +1812,7 @@ int fit_conf_find_compat(const void *fit, const void *fdt)
|
|||||||
}
|
}
|
||||||
if (!best_match_offset) {
|
if (!best_match_offset) {
|
||||||
debug("No match found.\n");
|
debug("No match found.\n");
|
||||||
return -1;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return best_match_offset;
|
return best_match_offset;
|
||||||
@@ -2095,17 +2095,18 @@ int fit_image_load(struct bootm_headers *images, ulong addr,
|
|||||||
* fit_conf_get_node() will try to find default config node
|
* fit_conf_get_node() will try to find default config node
|
||||||
*/
|
*/
|
||||||
bootstage_mark(bootstage_id + BOOTSTAGE_SUB_NO_UNIT_NAME);
|
bootstage_mark(bootstage_id + BOOTSTAGE_SUB_NO_UNIT_NAME);
|
||||||
if (IS_ENABLED(CONFIG_FIT_BEST_MATCH) && !fit_uname_config) {
|
ret = -ENXIO;
|
||||||
cfg_noffset = fit_conf_find_compat(fit, gd_fdt_blob());
|
if (IS_ENABLED(CONFIG_FIT_BEST_MATCH) && !fit_uname_config)
|
||||||
} else {
|
ret = fit_conf_find_compat(fit, gd_fdt_blob());
|
||||||
cfg_noffset = fit_conf_get_node(fit, fit_uname_config);
|
if (ret < 0 && ret != -EINVAL)
|
||||||
}
|
ret = fit_conf_get_node(fit, fit_uname_config);
|
||||||
if (cfg_noffset < 0) {
|
if (ret < 0) {
|
||||||
puts("Could not find configuration node\n");
|
puts("Could not find configuration node\n");
|
||||||
bootstage_error(bootstage_id +
|
bootstage_error(bootstage_id +
|
||||||
BOOTSTAGE_SUB_NO_UNIT_NAME);
|
BOOTSTAGE_SUB_NO_UNIT_NAME);
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
cfg_noffset = ret;
|
||||||
|
|
||||||
fit_base_uname_config = fdt_get_name(fit, cfg_noffset, NULL);
|
fit_base_uname_config = fdt_get_name(fit, cfg_noffset, NULL);
|
||||||
printf(" Using '%s' configuration\n", fit_base_uname_config);
|
printf(" Using '%s' configuration\n", fit_base_uname_config);
|
||||||
|
@@ -1411,7 +1411,9 @@ int fit_check_format(const void *fit, ulong size);
|
|||||||
* copied into the configuration node in the FIT image. This is required to
|
* copied into the configuration node in the FIT image. This is required to
|
||||||
* match configurations with compressed FDTs.
|
* match configurations with compressed FDTs.
|
||||||
*
|
*
|
||||||
* Returns: offset to the configuration to use if one was found, -1 otherwise
|
* Returns: offset to the configuration to use if one was found, -EINVAL if
|
||||||
|
* there a /configurations or /images node is missing, -ENOENT if no match was
|
||||||
|
* found, -ENXIO if the FDT node has no compatible string
|
||||||
*/
|
*/
|
||||||
int fit_conf_find_compat(const void *fit, const void *fdt);
|
int fit_conf_find_compat(const void *fit, const void *fdt);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user