summaryrefslogtreecommitdiffstats
path: root/tools/updater.hpp
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2018-08-08 09:43:33 -0700
committerPatrick Venture <venture@google.com>2018-09-18 12:08:31 -0700
commit7dc4670d4be4884e0c6486ca4f0e799116935096 (patch)
tree703c321fc90da65d9333785ead9d145e9142d600 /tools/updater.hpp
parente39f2b3a9a19b8e788a7225a0d291716325b77ee (diff)
downloadphosphor-ipmi-flash-7dc4670d4be4884e0c6486ca4f0e799116935096.tar.gz
phosphor-ipmi-flash-7dc4670d4be4884e0c6486ca4f0e799116935096.zip
tools: starting burn_my_bmc host utility
burn_my_bmc is a host-run utility that in cooperation with the phosphor-ipmi-flash library, attempts to send a BMC firmware image and signature file to the BMC and trigger verification of said image. The program's current design and use were tailored towards the legacy OpenBMC image and not UBI. Therefore, changes to support the UBI process will get addressed as it all takes shape. The overall process is: 1) Attempts to send firmware image over an interface. 2) Attempts to send signature file contents over an interface*. 3) Triggers a verification step. 4) Reboots the BMC**. * The only interface in the initial version here is the blocktransfer interface. It's technically also possibly KCS. It's sending the data over the same communications channel as the normal IPMI packets. A later patchset will enable sending the data bytes over an LPC memory region or the PCI P2A region. ** The 4th step is done by a separate call to the 'reboot' command. The 'reboot' and 'ping' commands will come in a later patchset. Change-Id: I62d725274e56c55ca414fa6c2a3eab6c500066ed Signed-off-by: Patrick Venture <venture@google.com>
Diffstat (limited to 'tools/updater.hpp')
-rw-r--r--tools/updater.hpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/tools/updater.hpp b/tools/updater.hpp
new file mode 100644
index 0000000..561e6c7
--- /dev/null
+++ b/tools/updater.hpp
@@ -0,0 +1,53 @@
+#pragma once
+
+#include "interface.hpp"
+#include "updatehelper.hpp"
+
+#include <fstream>
+#include <memory>
+#include <string>
+
+class UploadManager
+{
+ public:
+ UploadManager(std::ifstream&& image, std::ifstream&& hash,
+ int32_t imageSize, int32_t hashSize,
+ UpdateHelperInterface* helper, DataInterface* dintf) :
+ imageStream(std::move(image)),
+ hashStream(std::move(hash)), imageSize(imageSize), hashSize(hashSize),
+ helper(helper), dintf(dintf)
+ {
+ }
+
+ /**
+ * Instantiate an UploadManager if the parameters check out.
+ *
+ * @param[in] image - path to the firmware image.
+ * @param[in] hash - path to the image's hash.
+ * @param[in] helper - pointer to an UpdateHelperInterface.
+ * @param[in] dintf - pointer to the data interface to use.
+ * @return UploadManager if valid or nullptr if invalid.
+ */
+ static std::unique_ptr<UploadManager>
+ BuildUploadMgr(const std::string& image, const std::string& hash,
+ UpdateHelperInterface* helper, DataInterface* dintf);
+
+ /**
+ * Try to update the BMC flash image over IPMI through BT.
+ */
+ void UpdateBMC();
+
+ private:
+ std::ifstream imageStream;
+ std::ifstream hashStream;
+ int32_t imageSize;
+ int32_t hashSize;
+ UpdateHelperInterface* helper;
+ DataInterface* dintf;
+};
+
+// Main entry point for the update command.
+// Update uploads and verifies the image.
+// throws exception on errors.
+void UpdaterMain(const std::string& interface, const std::string& image,
+ const std::string& signature);
OpenPOWER on IntegriCloud