Felix Held has submitted this change. ( https://review.coreboot.org/c/coreboot/+/84204?usp=email )
Change subject: util/cbfstool: Print max empty entry size in error message ......................................................................
util/cbfstool: Print max empty entry size in error message
Currently, cbfstool prints the following error message when the added file doesn't fit in the region:
E: Could not add [file, 1024 bytes (1 KB)@0x0]; too big?
It requires manual inspection to know the space left in the region. To make that easier, also print the maximum empty CBFS entry size in the error message:
E: Could not add file [header 76 + content 1024 bytes (1 KB)] @0x0; Largest empty slot: 512 bytes
Change-Id: I00bcc83abe8b0a33dcd7b75521e6cfccd8953661 Signed-off-by: Yu-Ping Wu yupingso@chromium.org Reviewed-on: https://review.coreboot.org/c/coreboot/+/84204 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Yidi Lin yidilin@google.com --- M util/cbfstool/cbfs_image.c 1 file changed, 10 insertions(+), 4 deletions(-)
Approvals: Yidi Lin: Looks good to me, approved build bot (Jenkins): Verified
diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c index 740a3b2..e935357 100644 --- a/util/cbfstool/cbfs_image.c +++ b/util/cbfstool/cbfs_image.c @@ -743,6 +743,8 @@
uint32_t entry_type; uint32_t addr, addr_next; + uint32_t entry_size; + uint32_t max_null_entry_size = 0; struct cbfs_file *entry, *next; uint32_t need_size; uint32_t header_size = be32toh(header->offset); @@ -766,9 +768,11 @@ addr = cbfs_get_entry_addr(image, entry); next = cbfs_find_next_entry(image, entry); addr_next = cbfs_get_entry_addr(image, next); + entry_size = addr_next - addr; + max_null_entry_size = MAX(max_null_entry_size, entry_size);
DEBUG("cbfs_add_entry: space at 0x%x+0x%x(%d) bytes\n", - addr, addr_next - addr, addr_next - addr); + addr, entry_size, entry_size);
/* Will the file fit? Don't yet worry if we have space for a new * "empty" entry. We take care of that later. @@ -803,7 +807,7 @@ }
DEBUG("section 0x%x+0x%x for content_offset 0x%x.\n", - addr, addr_next - addr, content_offset); + addr, entry_size, content_offset);
if (cbfs_add_entry_at(image, entry, buffer->data, content_offset, header, len_align) == 0) { @@ -812,8 +816,10 @@ break; }
- ERROR("Could not add [%s, %zd bytes (%zd KB)@0x%x]; too big?\n", - buffer->name, buffer->size, buffer->size / 1024, content_offset); + ERROR("Could not add %s [header %d + content %zd bytes (%zd KB)] @0x%x; " + "Largest empty slot: %d bytes\n", + buffer->name, header_size, buffer->size, buffer->size / 1024, content_offset, + max_null_entry_size); return -1; }