aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile2
-rw-r--r--lib/binman.c61
-rw-r--r--lib/display_options.c9
-rw-r--r--lib/fdtdec.c5
-rw-r--r--lib/rsa/rsa-verify.c4
5 files changed, 62 insertions, 19 deletions
diff --git a/lib/Makefile b/lib/Makefile
index 851a80ef3b..edc1c3dd4f 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -92,7 +92,9 @@ obj-y += display_options.o
CFLAGS_display_options.o := $(if $(BUILD_TAG),-DBUILD_TAG='"$(BUILD_TAG)"')
obj-$(CONFIG_BCH) += bch.o
obj-$(CONFIG_MMC_SPI) += crc7.o
+#ifndef CONFIG_TPL_BUILD
obj-y += crc32.o
+#endif
obj-$(CONFIG_CRC32C) += crc32c.o
obj-y += ctype.o
obj-y += div64.o
diff --git a/lib/binman.c b/lib/binman.c
index f027d1b304..f415df3054 100644
--- a/lib/binman.c
+++ b/lib/binman.c
@@ -30,6 +30,34 @@ struct binman_info {
static struct binman_info *binman;
+/**
+ * find_image_node() - Find the top-level binman node
+ *
+ * Finds the binman node which can be used to load entries. The correct node
+ * depends on whether multiple-images is in use.
+ *
+ * @nodep: Returns the node found, on success
+ * @return 0 if OK, , -EINVAL if there is no /binman node, -ECHILD if multiple
+ * images are being used but the first image is not available
+ */
+static int find_image_node(ofnode *nodep)
+{
+ ofnode node;
+
+ node = ofnode_path("/binman");
+ if (!ofnode_valid(node))
+ return log_msg_ret("binman node", -EINVAL);
+ if (ofnode_read_bool(node, "multiple-images")) {
+ node = ofnode_first_subnode(node);
+
+ if (!ofnode_valid(node))
+ return log_msg_ret("first image", -ECHILD);
+ }
+ *nodep = node;
+
+ return 0;
+}
+
static int binman_entry_find_internal(ofnode node, const char *name,
struct binman_entry *entry)
{
@@ -88,21 +116,34 @@ int binman_get_rom_offset(void)
return binman->rom_offset;
}
+int binman_select_subnode(const char *name)
+{
+ ofnode node;
+ int ret;
+
+ ret = find_image_node(&node);
+ if (ret)
+ return log_msg_ret("main", -ENOENT);
+ node = ofnode_find_subnode(node, name);
+ if (!ofnode_valid(node))
+ return log_msg_ret("node", -ENOENT);
+ binman->image = node;
+ log_debug("binman: Selected image subnode '%s'\n",
+ ofnode_get_name(binman->image));
+
+ return 0;
+}
+
int binman_init(void)
{
+ int ret;
+
binman = malloc(sizeof(struct binman_info));
if (!binman)
return log_msg_ret("space for binman", -ENOMEM);
- binman->image = ofnode_path("/binman");
- if (!ofnode_valid(binman->image))
- return log_msg_ret("binman node", -EINVAL);
- if (ofnode_read_bool(binman->image, "multiple-images")) {
- ofnode node = ofnode_first_subnode(binman->image);
-
- if (!ofnode_valid(node))
- return log_msg_ret("first image", -ENOENT);
- binman->image = node;
- }
+ ret = find_image_node(&binman->image);
+ if (ret)
+ return log_msg_ret("node", -ENOENT);
binman_set_rom_offset(ROM_OFFSET_NONE);
return 0;
diff --git a/lib/display_options.c b/lib/display_options.c
index b2025eeb5c..cd48998b6d 100644
--- a/lib/display_options.c
+++ b/lib/display_options.c
@@ -169,11 +169,10 @@ int print_buffer(ulong addr, const void *data, uint width, uint count,
x = lb.us[i] = *(volatile uint16_t *)data;
else
x = lb.uc[i] = *(volatile uint8_t *)data;
-#if defined(CONFIG_SPL_BUILD)
- printf(" %x", (uint)x);
-#else
- printf(" %0*lx", width * 2, x);
-#endif
+ if (CONFIG_IS_ENABLED(USE_TINY_PRINTF))
+ printf(" %x", (uint)x);
+ else
+ printf(" %0*lx", width * 2, x);
data += width;
}
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 0ab7105fef..a2d2fb4e1f 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -600,7 +600,8 @@ int fdtdec_prepare_fdt(void)
#ifdef CONFIG_SPL_BUILD
puts("Missing DTB\n");
#else
- puts("No valid device tree binary found - please append one to U-Boot binary, use u-boot-dtb.bin or define CONFIG_OF_EMBED. For sandbox, use -d <file.dtb>\n");
+ printf("No valid device tree binary found at %p\n",
+ gd->fdt_blob);
# ifdef DEBUG
if (gd->fdt_blob) {
printf("fdt_blob=%p\n", gd->fdt_blob);
@@ -1252,7 +1253,7 @@ __weak void *board_fdt_blob_setup(void)
void *fdt_blob = NULL;
#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))
+ if (CONFIG_IS_ENABLED(SEPARATE_BSS))
fdt_blob = (ulong *)&_image_binary_end;
else
fdt_blob = (ulong *)&__bss_end;
diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c
index 0ab0f629d0..e34d3293d1 100644
--- a/lib/rsa/rsa-verify.c
+++ b/lib/rsa/rsa-verify.c
@@ -522,10 +522,10 @@ int rsa_verify_hash(struct image_sign_info *info,
return ret;
/* No luck, so try each of the keys in turn */
- for (ndepth = 0, noffset = fdt_next_node(info->fit, sig_node,
+ for (ndepth = 0, noffset = fdt_next_node(blob, sig_node,
&ndepth);
(noffset >= 0) && (ndepth > 0);
- noffset = fdt_next_node(info->fit, noffset, &ndepth)) {
+ noffset = fdt_next_node(blob, noffset, &ndepth)) {
if (ndepth == 1 && noffset != node) {
ret = rsa_verify_with_keynode(info, hash,
sig, sig_len,