Hung-Te Lin (hungte(a)chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2211
-gerrit
commit e82955f2f382f5a6548358b837720fafab2f4de0
Author: Hung-Te Lin <hungte(a)chromium.org>
Date: Tue Jan 29 03:16:20 2013 +0800
cbfstool: Fix incorrect CBFS free space by old cbfstool.
Old CBFStool may produce CBFS image with calculation error in size of last empty
entry, and then corrupts master header data when you really use every bits in
last entry. This CL will correct size when you load ROM images with cbfs_image
API (cbfs_image_from_file).
Change-Id: I2ada319728ef69ab9296ae446c77d37e05d05fce
Signed-off-by: Hung-Te Lin <hungte(a)chromium.org>
---
util/cbfstool/cbfs_image.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c
index 24759c9..e7e5053 100644
--- a/util/cbfstool/cbfs_image.c
+++ b/util/cbfstool/cbfs_image.c
@@ -104,6 +104,31 @@ static int cbfs_calculate_file_header_size(const char *name) {
align_up(strlen(name) + 1, CBFS_FILENAME_ALIGN));
}
+static int cbfs_fix_legacy_size(struct cbfs_image *image) {
+ // A bug in old CBFStool may produce extra few bytes (by alignment) and
+ // cause cbfstool to overwrite things after free space -- which is
+ // usually CBFS header on x86. We need to workaround that.
+
+ struct cbfs_file *entry, *first = NULL, *last = NULL;
+ for (first = entry = cbfs_find_first_entry(image);
+ entry && cbfs_is_valid_entry(entry);
+ entry = cbfs_find_next_entry(image, entry)) {
+ last = entry;
+ }
+ if ((char *)first < (char *)image->header &&
+ (char *)entry > (char *)image->header) {
+ WARN("CBFS image was created with old cbfstool with size bug. "
+ "Fixing size in last entry...\n");
+ last->len = htonl(ntohl(last->len) -
+ ntohl(image->header->align));
+ DEBUG("Last entry has been changed from 0x%x to 0x%x.\n",
+ cbfs_get_entry_addr(image, entry),
+ cbfs_get_entry_addr(image,
+ cbfs_find_next_entry(image, last)));
+ }
+ return 0;
+}
+
int cbfs_image_from_file(struct cbfs_image *image, const char *filename) {
if (buffer_from_file(&image->buffer, filename) != 0)
return -1;
@@ -116,6 +141,7 @@ int cbfs_image_from_file(struct cbfs_image *image, const char *filename) {
cbfs_image_delete(image);
return -1;
}
+ cbfs_fix_legacy_size(image);
return 0;
}
the following patch was just integrated into master:
commit 657ea6a13db5ad34dac80be8e77cc5406f0fe33b
Author: Hung-Te Lin <hungte(a)chromium.org>
Date: Mon Jan 28 23:00:47 2013 +0800
cbfstool: Change "locate" output to prefix "0x".
Currently "cbfstool locate" outputs a hex number without "0x" prefix.
This makes extra step (prefix 0x, and then generate another temp file) in build
process, and may be a problem when we want to allow changing its output format
(ex, using decimal). Adding the "0x" in cbfstool itself should be better.
Change-Id: I639bb8f192a756883c9c4b2d11af6bc166c7811d
Signed-off-by: Hung-Te Lin <hungte(a)chromium.org>
Reviewed-on: http://review.coreboot.org/2201
Tested-by: build bot (Jenkins)
Reviewed-by: David Hendricks <dhendrix(a)chromium.org>
Build-Tested: build bot (Jenkins) at Tue Jan 29 03:10:04 2013, giving +1
Reviewed-By: David Hendricks <dhendrix(a)chromium.org> at Tue Jan 29 04:58:50 2013, giving +2
See http://review.coreboot.org/2201 for details.
-gerrit
the following patch was just integrated into master:
commit 4505cebdad4637762ae1ae10dcb43eb4f2b3784f
Author: Hung-Te Lin <hungte(a)chromium.org>
Date: Mon Jan 28 22:40:10 2013 +0800
cbfstool: Remove unused header files.
cbfs-mk*.c does not work with real files / command line so header files with
file I/O and getopt can be removed.
Change-Id: I9d93152982fd4abdc98017c983dd240b81c965f5
Signed-off-by: Hung-Te Lin <hungte(a)chromium.org>
Reviewed-on: http://review.coreboot.org/2200
Tested-by: build bot (Jenkins)
Reviewed-by: David Hendricks <dhendrix(a)chromium.org>
Build-Tested: build bot (Jenkins) at Tue Jan 29 03:03:16 2013, giving +1
Reviewed-By: David Hendricks <dhendrix(a)chromium.org> at Tue Jan 29 04:14:43 2013, giving +2
See http://review.coreboot.org/2200 for details.
-gerrit
Hung-Te Lin (hungte(a)chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2215
-gerrit
commit 3c92da93c38d93445bbf50eee0d56a8a0e2155cf
Author: Hung-Te Lin <hungte(a)chromium.org>
Date: Tue Jan 29 10:30:17 2013 +0800
cbfstool: Update example file.
The syntax of cbfstool has been changed for a while (using getopt). Updated
EXAMPLE file to show the right way to test cbfstool.
Change-Id: I5cb41b76712d8c2403fffc9fdad83c61fb2af98c
Signed-off-by: Hung-Te Lin <hungte(a)chromium.org>
---
util/cbfstool/EXAMPLE | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/util/cbfstool/EXAMPLE b/util/cbfstool/EXAMPLE
index 0f7aea6..81aa7fb 100644
--- a/util/cbfstool/EXAMPLE
+++ b/util/cbfstool/EXAMPLE
@@ -1,8 +1,6 @@
rm coreboot.rom;
-./cbfstool coreboot.rom create 0x80000 0x10000 /tmp/coreboot.strip
-./cbfstool coreboot.rom add-payload /tmp/filo.elf normal/payload l
+./cbfstool coreboot.rom create -m x86 -s 256K -B /tmp/coreboot.strip -o 0x1000
+./cbfstool coreboot.rom add-stage -f romstage.bin -n fallback/romstage
+./cbfstool coreboot.rom add-payload -f /tmp/filo.elf -n normal/payload -c lzma
./cbfstool coreboot.rom print
-#./cbfstool coreboot.rom add-stage /tmp/filo.elf normal/payload
-
-./cbfstool coreboot.rom print
-cp coreboot.rom /home/rminnich/qemutest/
+qemu-system-i386 -bios coreboot.rom -nographic