Skip to content

Commit

Permalink
Common: Fix fw-util exit mechanism for bmc update (#2438)
Browse files Browse the repository at this point in the history
Summary:
Fw-util will throw exception string when update file size is more than 32MB.

Pull Request resolved: facebookexternal/openbmc.quanta#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
  • Loading branch information
amithash authored and facebook-github-bot committed Apr 6, 2021
1 parent a0fd123 commit f137c9a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion common/recipes-core/fw-util/files/check_image.cpp
Expand Up @@ -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;) {
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit f137c9a

Please sign in to comment.