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 | |
Isaac Kurth | 7eebeaa | 2021-06-15 13:25:30 -0500 | [diff] [blame] | 5 | #include "utils.hpp" |
| 6 | |
Adriana Kobylak | 3412435 | 2020-05-22 09:40:40 -0500 | [diff] [blame] | 7 | #include <thread> |
| 8 | |
Adriana Kobylak | 86013f3 | 2020-05-13 12:12:38 -0500 | [diff] [blame] | 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 | { |
Isaac Kurth | 7eebeaa | 2021-06-15 13:25:30 -0500 | [diff] [blame] | 33 | // Mark the read-write partition for recreation upon reboot. |
| 34 | utils::execute("/sbin/fw_setenv", "rwreset", "true"); |
Adriana Kobylak | 86013f3 | 2020-05-13 12:12:38 -0500 | [diff] [blame] | 35 | } |
| 36 | |
Adriana Kobylak | 25773a7 | 2022-01-21 15:24:48 +0000 | [diff] [blame] | 37 | void Helper::removeVersion(const std::string& flashId) |
Adriana Kobylak | 86013f3 | 2020-05-13 12:12:38 -0500 | [diff] [blame] | 38 | { |
Adriana Kobylak | 70f5bc0 | 2020-05-13 14:08:14 -0500 | [diff] [blame] | 39 | auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH, |
| 40 | SYSTEMD_INTERFACE, "StartUnit"); |
Adriana Kobylak | 25773a7 | 2022-01-21 15:24:48 +0000 | [diff] [blame] | 41 | auto serviceFile = "obmc-flash-mmc-remove@" + flashId + ".service"; |
Adriana Kobylak | 70f5bc0 | 2020-05-13 14:08:14 -0500 | [diff] [blame] | 42 | method.append(serviceFile, "replace"); |
| 43 | bus.call_noreply(method); |
Adriana Kobylak | c31943e | 2020-07-29 12:41:59 -0500 | [diff] [blame] | 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); |
Adriana Kobylak | 86013f3 | 2020-05-13 12:12:38 -0500 | [diff] [blame] | 49 | } |
| 50 | |
Adriana Kobylak | 25773a7 | 2022-01-21 15:24:48 +0000 | [diff] [blame] | 51 | void Helper::updateUbootVersionId(const std::string& flashId) |
Adriana Kobylak | 86013f3 | 2020-05-13 12:12:38 -0500 | [diff] [blame] | 52 | { |
Adriana Kobylak | 3412435 | 2020-05-22 09:40:40 -0500 | [diff] [blame] | 53 | auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH, |
| 54 | SYSTEMD_INTERFACE, "StartUnit"); |
Adriana Kobylak | 25773a7 | 2022-01-21 15:24:48 +0000 | [diff] [blame] | 55 | auto serviceFile = "obmc-flash-mmc-setprimary@" + flashId + ".service"; |
Adriana Kobylak | 3412435 | 2020-05-22 09:40:40 -0500 | [diff] [blame] | 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); |
Adriana Kobylak | 86013f3 | 2020-05-13 12:12:38 -0500 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | void Helper::mirrorAlt() |
| 66 | { |
| 67 | // Empty |
| 68 | } |
| 69 | |
| 70 | } // namespace updater |
| 71 | } // namespace software |
| 72 | } // namespace phosphor |