fw update: spi device code updater
This code updater is for updating spi flash devices.
It can for example update the host firmware on different server boards
and has following features:
- power down the host before update
- set mux gpios to access spi flash
- (very limited) communication with ME (Management Engine)
- use flashrom to utilize fw with IFD (Intel Flash Descriptor)
- otherwise directly write to the flash chip.
The behavior of this code updater can be configured via EM.
Tested: on Tyan S5549 Board
Change-Id: I27803b7fded71af2364c2f55fad841a410603dec
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/test/bios-spi/test_bios_spi.cpp b/test/bios-spi/test_bios_spi.cpp
new file mode 100644
index 0000000..aea6ebc
--- /dev/null
+++ b/test/bios-spi/test_bios_spi.cpp
@@ -0,0 +1,43 @@
+#include "bios-spi/spi_device.hpp"
+#include "spi_device_code_updater.hpp"
+
+#include <phosphor-logging/lg2.hpp>
+#include <sdbusplus/asio/connection.hpp>
+#include <sdbusplus/asio/object_server.hpp>
+#include <sdbusplus/async.hpp>
+#include <sdbusplus/server.hpp>
+#include <xyz/openbmc_project/Association/Definitions/server.hpp>
+#include <xyz/openbmc_project/Software/Update/server.hpp>
+
+#include <iostream>
+#include <memory>
+
+int main()
+{
+ sdbusplus::async::context ctx;
+
+ try
+ {
+ SPIDeviceCodeUpdater spidcu(ctx, true, false);
+ uint32_t vendorIANA = 0x0000a015;
+ std::string compatible = "com.testvendor.testcomponent";
+ SPIDeviceCodeUpdater* cu = &spidcu;
+ std::vector<std::string> gpioNames;
+ std::vector<uint8_t> gpioValues;
+
+ DeviceConfig config(vendorIANA, compatible, "SPIFlash", "HostSPI");
+
+ auto sd = std::make_unique<SPIDevice>(
+ ctx, "1e630000.spi", true, true, gpioNames, gpioValues, config, cu,
+ true, true, false);
+
+ spidcu.devices.insert(std::move(sd));
+ }
+ catch (std::exception& e)
+ {
+ std::cerr << e.what() << std::endl;
+ return 1;
+ }
+
+ return 0;
+}