bios: enable configure flashrom tool
Since flashrom can handle cases which the flat write is unable to do,
allow for flashrom to be configured as the tool for writing.
Tested: image is written as expected
```
May 28 15:29:23 s8030-bmc-30303035c0c1 phosphor-bios-software-update[20409]: flashrom v1.2.1 on Linux 6.6.86-c94132b-dirty-875bc16-00427-g875bc16d66f8 (armv6l)
May 28 15:29:23 s8030-bmc-30303035c0c1 phosphor-bios-software-update[20409]: flashrom is free software, get the source code at https://flashrom.org
May 28 15:29:23 s8030-bmc-30303035c0c1 phosphor-bios-software-update[20409]: Using clock_gettime for delay loops (clk_id: 1, resolution: 1ns).
May 28 15:29:23 s8030-bmc-30303035c0c1 phosphor-bios-software-update[20409]: Opened /dev/mtd6 successfully
May 28 15:29:23 s8030-bmc-30303035c0c1 phosphor-bios-software-update[20409]: Found Programmer flash chip "Opaque flash chip" (32768 kB, Programmer-specific) on linux_mtd.
May 28 15:29:22 s8030-bmc-30303035c0c1 phosphor-bios-software-update[20341]: [flashrom] running flashrom -p linux_mtd:dev=6 -w /tmp/spi-device-image-9551.bin
May 28 15:29:46 s8030-bmc-30303035c0c1 phosphor-bios-software-update[20409]: Reading old flash chip contents... done.
May 28 15:33:42 s8030-bmc-30303035c0c1 phosphor-bios-software-update[20409]: Erasing and writing flash chip... Erase/write done.
May 28 15:35:08 s8030-bmc-30303035c0c1 phosphor-bios-software-update[20409]: Verifying flash... VERIFIED.
root@s8030-bmc-30303035c0c1:~# cmp -l /tmp/mtd6_dump.bin /tmp/8030V401.ROM
root@s8030-bmc-30303035c0c1:~# echo $?
0
```
Change-Id: I16c561231c2fa040d951c78dd0a76c28560c98d8
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/bios/bios_software_manager.cpp b/bios/bios_software_manager.cpp
index 163c827..3f4099a 100644
--- a/bios/bios_software_manager.cpp
+++ b/bios/bios_software_manager.cpp
@@ -47,6 +47,13 @@
co_return false;
}
+ enum FlashTool tool = flashToolNone;
+
+ if (config.configType == "IntelSPIFlash")
+ {
+ tool = flashToolFlashrom;
+ }
+
const std::string configIfaceMux = configIface + ".MuxOutputs";
std::vector<std::string> names;
@@ -74,7 +81,6 @@
}
enum FlashLayout layout = flashLayoutFlat;
- enum FlashTool tool = flashToolNone;
debug("SPI device: {INDEX1}:{INDEX2}", "INDEX1", spiControllerIndex.value(),
"INDEX2", spiDeviceIndex.value());
diff --git a/bios/spi_device.cpp b/bios/spi_device.cpp
index e6917b5..fbf6fe9 100644
--- a/bios/spi_device.cpp
+++ b/bios/spi_device.cpp
@@ -407,7 +407,20 @@
co_return 1;
}
- std::string cmd = "flashrom -p linux_mtd:dev=" + devPath.value();
+ size_t devNum = 0;
+
+ try
+ {
+ devNum = std::stoi(devPath.value().substr(8));
+ }
+ catch (std::exception& e)
+ {
+ error("could not parse mtd device number from {STR}: {ERROR}", "STR",
+ devPath.value(), "ERROR", e);
+ co_return 1;
+ }
+
+ std::string cmd = "flashrom -p linux_mtd:dev=" + std::to_string(devNum);
if (layout == flashLayoutFlat)
{