From 77fbe691f3b1607acfb6f84e978f73ad4fd5d6a0 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Fri, 17 Feb 2012 16:04:29 -0800 Subject: Fix vbexport_test display It turns out that running 'vbexport_test display' on coreboot platforms fails to display bitmap images, sometimes reporting memory corruption and rebooting the system. The problem was twofold: - the gbb pointer is not properly initialized (as it is supposed to when CONFIG_HARDWARE_MAPPED_SPI is defined). - the bitmap images block includes an element which in fact is not a bitmap. When scanning the block, the test tried displaying all elements, generating an error when this one-off element is encountered. This change fixes both issues. BUG=chromium-os:26586 TEST=manual . build a new chromeos-bootimage . reboot the system stopping it in u-boot console dialogue . run `vbexport_test display' command from the console The test was failing before this change, it is passing now. Change-Id: Iee9491d150b9ce5513f7446ab4df806d23e6d4d8 Signed-off-by: Vadim Bendebury Reviewed-on: https://gerrit.chromium.org/gerrit/16206 Reviewed-by: Bill Richardson --- common/cmd_vbexport_test.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/common/cmd_vbexport_test.c b/common/cmd_vbexport_test.c index cf7b9f95ac..1c3efb2694 100644 --- a/common/cmd_vbexport_test.c +++ b/common/cmd_vbexport_test.c @@ -423,6 +423,10 @@ static uint8_t *read_gbb_from_firmware(void) return NULL; } +#ifdef CONFIG_HARDWARE_MAPPED_SPI + gbb = (void *) (fmap.readonly.gbb.offset + fmap.flash_base); +#endif + if (gbb_init(gbb, &file, fmap.readonly.gbb.offset, gbb_size)) { VbExDebug("Failed to read GBB!\n"); return NULL; @@ -449,6 +453,14 @@ static int show_images_and_delay(BmpBlockHeader *bmph, int index) void *rawimg; uint32_t inoutsize; + if (memcmp(bmph->signature, + BMPBLOCK_SIGNATURE, + sizeof(bmph->signature))) { + VbExDebug("%s: corrupted BMP block header at %p\n", + __func__, bmph); + return 1; + } + screen = (ScreenLayout *)(bmph + 1); screen += index; @@ -457,6 +469,10 @@ static int show_images_and_delay(BmpBlockHeader *bmph, int index) i++) { info = (ImageInfo *)((uint8_t *)bmph + screen->images[i].image_info_offset); + + if (info->format != FORMAT_BMP) + continue; + inoutsize = info->original_size; if (COMPRESS_NONE == info->compression) { -- cgit v1.2.3