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