1 #include "config.h"
2
3 #include "item_updater_helper.hpp"
4
5 #include "utils.hpp"
6
7 #include <thread>
8
9 namespace phosphor
10 {
11 namespace software
12 {
13 namespace updater
14 {
15
setEntry(const std::string &,uint8_t)16 void Helper::setEntry(const std::string& /* entryId */, uint8_t /* value */)
17 {
18 // Empty
19 }
20
clearEntry(const std::string &)21 void Helper::clearEntry(const std::string& /* entryId */)
22 {
23 // Empty
24 }
25
cleanup()26 void Helper::cleanup()
27 {
28 // Empty
29 }
30
factoryReset()31 void Helper::factoryReset()
32 {
33 // Mark the read-write partition for recreation upon reboot.
34 utils::execute("/sbin/fw_setenv", "rwreset", "true");
35 }
36
removeVersion(const std::string & flashId)37 void Helper::removeVersion(const std::string& flashId)
38 {
39 auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
40 SYSTEMD_INTERFACE, "StartUnit");
41 auto serviceFile = "obmc-flash-mmc-remove@" + flashId + ".service";
42 method.append(serviceFile, "replace");
43 bus.call_noreply(method);
44
45 // Wait a few seconds for the service file to finish, otherwise the BMC may
46 // start the update while the image is still being deleted.
47 constexpr auto removeWait = std::chrono::seconds(3);
48 std::this_thread::sleep_for(removeWait);
49 }
50
updateUbootVersionId(const std::string & flashId)51 void Helper::updateUbootVersionId(const std::string& flashId)
52 {
53 auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
54 SYSTEMD_INTERFACE, "StartUnit");
55 auto serviceFile = "obmc-flash-mmc-setprimary@" + flashId + ".service";
56 method.append(serviceFile, "replace");
57 bus.call_noreply(method);
58
59 // Wait a few seconds for the service file to finish, otherwise the BMC may
60 // be rebooted while pointing to a non-existent version.
61 constexpr auto setPrimaryWait = std::chrono::seconds(3);
62 std::this_thread::sleep_for(setPrimaryWait);
63 }
64
mirrorAlt()65 void Helper::mirrorAlt()
66 {
67 auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
68 SYSTEMD_INTERFACE, "StartUnit");
69 auto serviceFile = "obmc-flash-mmc-mirroruboot.service";
70 method.append(serviceFile, "replace");
71 bus.call_noreply(method);
72 }
73
74 } // namespace updater
75 } // namespace software
76 } // namespace phosphor
77