From f137c9abc78630971d95c589641e196a11c9584f Mon Sep 17 00:00:00 2001 From: Amithash Prasad Date: Tue, 6 Apr 2021 10:50:31 -0700 Subject: [PATCH] Common: Fix fw-util exit mechanism for bmc update (#2438) Summary: Fw-util will throw exception string when update file size is more than 32MB. Pull Request resolved: https://github.com/facebookexternal/openbmc.quanta/pull/2438 Test Plan: 1. Upload 64 MB image to bmc. 2. Update bmc with the image. Testing: 1. upload image root@bmc-oob:~# ls -lh /tmp/ | grep F -rw-r--r-- 1 root root 64.0M Mar 29 18:48 F0C_3A04.BIN 2. update bmc root@bmc-oob:~# fw-util bmc --update bmc /tmp/F0C_3A04.BIN /tmp/F0C_3A04.BIN over size /tmp/F0C_3A04.BIN is not a valid BMC image for angelslanding Upgrade of bmc : bmc failed Reviewed By: GoldenBug fbshipit-source-id: a15a94a5da --- common/recipes-core/fw-util/files/check_image.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/recipes-core/fw-util/files/check_image.cpp b/common/recipes-core/fw-util/files/check_image.cpp index 22c660ede4a..cd62ee9f710 100644 --- a/common/recipes-core/fw-util/files/check_image.cpp +++ b/common/recipes-core/fw-util/files/check_image.cpp @@ -322,7 +322,11 @@ class Image { fsize = lseek(fd, 0, SEEK_END); if (fsize == 0) { throw "Zero size image file " + string(file); + } else if (fsize > FLASH_SIZE) { + close(fd); + throw string(file) + " over size ( > 32MB )"; } + lseek(fd, 0, SEEK_SET); unsigned char *img = (unsigned char *)calloc(FLASH_SIZE, 1); for (int bread = 0; bread < (int)fsize;) { @@ -412,7 +416,7 @@ bool BmcComponent::is_valid(string &file, bool pfr_active) if (!image.supports_machine(machine)) { return false; } - + if (pfr_active) { return true; }