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 
16 void Helper::setEntry(const std::string& /* entryId */, uint8_t /* value */)
17 {
18     // Empty
19 }
20 
21 void Helper::clearEntry(const std::string& /* entryId */)
22 {
23     // Empty
24 }
25 
26 void Helper::cleanup()
27 {
28     // Empty
29 }
30 
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 
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 
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 
65 void Helper::mirrorAlt()
66 {
67     // Empty
68 }
69 
70 } // namespace updater
71 } // namespace software
72 } // namespace phosphor
73