Lei YU | d19df25 | 2019-10-25 17:31:52 +0800 | [diff] [blame] | 1 | /** |
| 2 | * Copyright © 2019 IBM Corporation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Lei YU | d19df25 | 2019-10-25 17:31:52 +0800 | [diff] [blame] | 16 | #include "updater.hpp" |
| 17 | |
Faisal Awada | 5ace9fb | 2025-01-07 13:26:25 -0600 | [diff] [blame] | 18 | #include "aei_updater.hpp" |
Lei YU | e8c9cd6 | 2019-11-04 14:24:41 +0800 | [diff] [blame] | 19 | #include "pmbus.hpp" |
Lei YU | cfc040c | 2019-10-29 17:10:26 +0800 | [diff] [blame] | 20 | #include "types.hpp" |
Lei YU | 9ab6d75 | 2019-10-28 17:03:20 +0800 | [diff] [blame] | 21 | #include "utility.hpp" |
Shawn McCarney | 14572cf | 2024-11-06 12:17:57 -0600 | [diff] [blame] | 22 | #include "utils.hpp" |
Lei YU | 9ab6d75 | 2019-10-28 17:03:20 +0800 | [diff] [blame] | 23 | |
Faisal Awada | f9b426b | 2025-01-31 11:44:48 -0600 | [diff] [blame^] | 24 | #include <phosphor-logging/lg2.hpp> |
Brandon Wyman | d1bc4ce | 2019-12-13 14:20:34 -0600 | [diff] [blame] | 25 | |
Lei YU | 34fb8bd | 2019-11-07 14:24:20 +0800 | [diff] [blame] | 26 | #include <chrono> |
Lei YU | 9ab6d75 | 2019-10-28 17:03:20 +0800 | [diff] [blame] | 27 | #include <fstream> |
Lei YU | 34fb8bd | 2019-11-07 14:24:20 +0800 | [diff] [blame] | 28 | #include <thread> |
Faisal Awada | ec61bbd | 2024-11-04 08:46:20 -0600 | [diff] [blame] | 29 | #include <vector> |
Lei YU | 9ab6d75 | 2019-10-28 17:03:20 +0800 | [diff] [blame] | 30 | |
| 31 | using namespace phosphor::logging; |
| 32 | namespace util = phosphor::power::util; |
| 33 | |
Lei YU | d19df25 | 2019-10-25 17:31:52 +0800 | [diff] [blame] | 34 | namespace updater |
| 35 | { |
| 36 | |
Lei YU | 9ab6d75 | 2019-10-28 17:03:20 +0800 | [diff] [blame] | 37 | namespace internal |
| 38 | { |
| 39 | |
Faisal Awada | ec61bbd | 2024-11-04 08:46:20 -0600 | [diff] [blame] | 40 | // Define the CRC-8 polynomial (CRC-8-CCITT) |
| 41 | constexpr uint8_t CRC8_POLYNOMIAL = 0x07; |
| 42 | constexpr uint8_t CRC8_INITIAL = 0x00; |
| 43 | |
Faisal Awada | ec61bbd | 2024-11-04 08:46:20 -0600 | [diff] [blame] | 44 | // Get the appropriate Updater class instance based PSU model number |
| 45 | std::unique_ptr<updater::Updater> getClassInstance( |
| 46 | const std::string& model, const std::string& psuInventoryPath, |
| 47 | const std::string& devPath, const std::string& imageDir) |
| 48 | { |
Faisal Awada | 5ace9fb | 2025-01-07 13:26:25 -0600 | [diff] [blame] | 49 | if (model == "51E9" || model == "51DA") |
Faisal Awada | ec61bbd | 2024-11-04 08:46:20 -0600 | [diff] [blame] | 50 | { |
Faisal Awada | 5ace9fb | 2025-01-07 13:26:25 -0600 | [diff] [blame] | 51 | return std::make_unique<aeiUpdater::AeiUpdater>(psuInventoryPath, |
| 52 | devPath, imageDir); |
Faisal Awada | ec61bbd | 2024-11-04 08:46:20 -0600 | [diff] [blame] | 53 | } |
| 54 | return std::make_unique<Updater>(psuInventoryPath, devPath, imageDir); |
| 55 | } |
| 56 | |
| 57 | // Function to locate FW file with model and extension bin or hex |
| 58 | const std::string getFWFilenamePath(const std::string& directory) |
| 59 | { |
| 60 | namespace fs = std::filesystem; |
| 61 | // Get the last part of the directory name (model number) |
| 62 | std::string model = fs::path(directory).filename().string(); |
| 63 | for (const auto& entry : fs::directory_iterator(directory)) |
| 64 | { |
| 65 | if (entry.is_regular_file()) |
| 66 | { |
| 67 | std::string filename = entry.path().filename().string(); |
| 68 | |
Faisal Awada | 5ace9fb | 2025-01-07 13:26:25 -0600 | [diff] [blame] | 69 | if ((filename.rfind(model, 0) == 0) && (filename.ends_with(".bin"))) |
Faisal Awada | ec61bbd | 2024-11-04 08:46:20 -0600 | [diff] [blame] | 70 | { |
| 71 | return directory + "/" + filename; |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | return ""; |
| 76 | } |
| 77 | |
| 78 | // Compute CRC-8 checksum for a vector of bytes |
| 79 | uint8_t calculateCRC8(const std::vector<uint8_t>& data) |
| 80 | { |
| 81 | uint8_t crc = CRC8_INITIAL; |
| 82 | |
| 83 | for (const auto& byte : data) |
| 84 | { |
| 85 | crc ^= byte; |
| 86 | for (int i = 0; i < 8; ++i) |
| 87 | { |
| 88 | if (crc & 0x80) |
| 89 | crc = (crc << 1) ^ CRC8_POLYNOMIAL; |
| 90 | else |
| 91 | crc <<= 1; |
| 92 | } |
| 93 | } |
| 94 | return crc; |
| 95 | } |
| 96 | |
| 97 | // Delay execution for a specified number of milliseconds |
| 98 | void delay(const int& milliseconds) |
| 99 | { |
| 100 | std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds)); |
| 101 | } |
| 102 | |
| 103 | // Convert big endian (32 bit integer) to a vector of little endian. |
| 104 | std::vector<uint8_t> bigEndianToLittleEndian(const uint32_t bigEndianValue) |
| 105 | { |
| 106 | std::vector<uint8_t> littleEndianBytes(4); |
| 107 | |
| 108 | littleEndianBytes[3] = (bigEndianValue >> 24) & 0xFF; |
| 109 | littleEndianBytes[2] = (bigEndianValue >> 16) & 0xFF; |
| 110 | littleEndianBytes[1] = (bigEndianValue >> 8) & 0xFF; |
| 111 | littleEndianBytes[0] = bigEndianValue & 0xFF; |
| 112 | return littleEndianBytes; |
| 113 | } |
| 114 | |
| 115 | // Validate the existence and size of a firmware file. |
| 116 | bool validateFWFile(const std::string& fileName) |
| 117 | { |
| 118 | // Ensure the file exists and get the file size. |
| 119 | if (!std::filesystem::exists(fileName)) |
| 120 | { |
Faisal Awada | f9b426b | 2025-01-31 11:44:48 -0600 | [diff] [blame^] | 121 | lg2::error("Firmware file not found: {FILE}", "FILE", fileName); |
Faisal Awada | ec61bbd | 2024-11-04 08:46:20 -0600 | [diff] [blame] | 122 | return false; |
| 123 | } |
| 124 | |
| 125 | // Check the file size |
| 126 | auto fileSize = std::filesystem::file_size(fileName); |
| 127 | if (fileSize == 0) |
| 128 | { |
Faisal Awada | f9b426b | 2025-01-31 11:44:48 -0600 | [diff] [blame^] | 129 | lg2::error("Firmware {FILE} is empty", "FILE", fileName); |
Faisal Awada | ec61bbd | 2024-11-04 08:46:20 -0600 | [diff] [blame] | 130 | return false; |
| 131 | } |
| 132 | return true; |
| 133 | } |
| 134 | |
| 135 | // Open a firmware file for reading in binary mode. |
| 136 | std::unique_ptr<std::ifstream> openFirmwareFile(const std::string& fileName) |
| 137 | { |
| 138 | if (fileName.empty()) |
| 139 | { |
Faisal Awada | f9b426b | 2025-01-31 11:44:48 -0600 | [diff] [blame^] | 140 | lg2::error("Firmware file path is not provided"); |
Faisal Awada | ec61bbd | 2024-11-04 08:46:20 -0600 | [diff] [blame] | 141 | return nullptr; |
| 142 | } |
| 143 | auto inputFile = |
| 144 | std::make_unique<std::ifstream>(fileName, std::ios::binary); |
| 145 | if (!inputFile->is_open()) |
| 146 | { |
Faisal Awada | f9b426b | 2025-01-31 11:44:48 -0600 | [diff] [blame^] | 147 | lg2::error("Failed to open firmware file: {FILE}", "FILE", fileName); |
Faisal Awada | ec61bbd | 2024-11-04 08:46:20 -0600 | [diff] [blame] | 148 | return nullptr; |
| 149 | } |
| 150 | return inputFile; |
| 151 | } |
| 152 | |
| 153 | // Read firmware bytes from input stream. |
| 154 | std::vector<uint8_t> readFirmwareBytes(std::ifstream& inputFile, |
| 155 | const size_t numberOfBytesToRead) |
| 156 | { |
| 157 | std::vector<uint8_t> readDataBytes(numberOfBytesToRead, 0xFF); |
| 158 | try |
| 159 | { |
| 160 | // Enable exceptions for failbit and badbit |
| 161 | inputFile.exceptions(std::ifstream::failbit | std::ifstream::badbit); |
| 162 | inputFile.read(reinterpret_cast<char*>(readDataBytes.data()), |
| 163 | numberOfBytesToRead); |
| 164 | size_t bytesRead = inputFile.gcount(); |
| 165 | if (bytesRead != numberOfBytesToRead) |
| 166 | { |
| 167 | readDataBytes.resize(bytesRead); |
| 168 | } |
| 169 | } |
| 170 | catch (const std::ios_base::failure& e) |
| 171 | { |
Faisal Awada | f9b426b | 2025-01-31 11:44:48 -0600 | [diff] [blame^] | 172 | lg2::error("Error reading firmware: {ERROR}", "ERROR", e.what()); |
Faisal Awada | ec61bbd | 2024-11-04 08:46:20 -0600 | [diff] [blame] | 173 | readDataBytes.clear(); |
| 174 | } |
| 175 | return readDataBytes; |
| 176 | } |
| 177 | |
Lei YU | 9ab6d75 | 2019-10-28 17:03:20 +0800 | [diff] [blame] | 178 | } // namespace internal |
| 179 | |
Faisal Awada | ec61bbd | 2024-11-04 08:46:20 -0600 | [diff] [blame] | 180 | bool update(sdbusplus::bus_t& bus, const std::string& psuInventoryPath, |
| 181 | const std::string& imageDir) |
Lei YU | d19df25 | 2019-10-25 17:31:52 +0800 | [diff] [blame] | 182 | { |
Shawn McCarney | 23dee38 | 2024-11-11 18:41:49 -0600 | [diff] [blame] | 183 | auto devPath = utils::getDevicePath(bus, psuInventoryPath); |
Faisal Awada | ec61bbd | 2024-11-04 08:46:20 -0600 | [diff] [blame] | 184 | |
Lei YU | 9ab6d75 | 2019-10-28 17:03:20 +0800 | [diff] [blame] | 185 | if (devPath.empty()) |
| 186 | { |
| 187 | return false; |
| 188 | } |
| 189 | |
Faisal Awada | ec61bbd | 2024-11-04 08:46:20 -0600 | [diff] [blame] | 190 | std::filesystem::path fsPath(imageDir); |
| 191 | |
| 192 | std::unique_ptr<updater::Updater> updaterPtr = internal::getClassInstance( |
| 193 | fsPath.filename().string(), psuInventoryPath, devPath, imageDir); |
| 194 | |
| 195 | if (!updaterPtr->isReadyToUpdate()) |
Lei YU | 575ed13 | 2019-10-29 17:22:16 +0800 | [diff] [blame] | 196 | { |
Faisal Awada | f9b426b | 2025-01-31 11:44:48 -0600 | [diff] [blame^] | 197 | lg2::error("PSU not ready to update PSU = {PATH}", "PATH", |
| 198 | psuInventoryPath); |
Lei YU | 575ed13 | 2019-10-29 17:22:16 +0800 | [diff] [blame] | 199 | return false; |
| 200 | } |
| 201 | |
Faisal Awada | ec61bbd | 2024-11-04 08:46:20 -0600 | [diff] [blame] | 202 | updaterPtr->bindUnbind(false); |
| 203 | updaterPtr->createI2CDevice(); |
| 204 | int ret = updaterPtr->doUpdate(); |
| 205 | updaterPtr->bindUnbind(true); |
Lei YU | 9ab6d75 | 2019-10-28 17:03:20 +0800 | [diff] [blame] | 206 | return ret == 0; |
| 207 | } |
| 208 | |
| 209 | Updater::Updater(const std::string& psuInventoryPath, |
| 210 | const std::string& devPath, const std::string& imageDir) : |
Patrick Williams | f540219 | 2024-08-16 15:20:53 -0400 | [diff] [blame] | 211 | bus(sdbusplus::bus::new_default()), psuInventoryPath(psuInventoryPath), |
Shawn McCarney | 23dee38 | 2024-11-11 18:41:49 -0600 | [diff] [blame] | 212 | devPath(devPath), devName(utils::getDeviceName(devPath)), imageDir(imageDir) |
Lei YU | 9ab6d75 | 2019-10-28 17:03:20 +0800 | [diff] [blame] | 213 | { |
| 214 | fs::path p = fs::path(devPath) / "driver"; |
| 215 | try |
| 216 | { |
| 217 | driverPath = |
| 218 | fs::canonical(p); // Get the path that points to the driver dir |
| 219 | } |
| 220 | catch (const fs::filesystem_error& e) |
| 221 | { |
Faisal Awada | f9b426b | 2025-01-31 11:44:48 -0600 | [diff] [blame^] | 222 | lg2::error("Failed to get canonical path DEVPATH= {PATH}, ERROR= {ERR}", |
| 223 | "PATH", devPath, "ERR", e.what()); |
Lei YU | 9ab6d75 | 2019-10-28 17:03:20 +0800 | [diff] [blame] | 224 | } |
Lei YU | 9ab6d75 | 2019-10-28 17:03:20 +0800 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | // During PSU update, it needs to access the PSU i2c device directly, so it |
| 228 | // needs to unbind the driver during the update, and re-bind after it's done. |
| 229 | // After unbind, the hwmon sysfs will be gone, and the psu-monitor will report |
| 230 | // errors. So set the PSU inventory's Present property to false so that |
| 231 | // psu-monitor will not report any errors. |
| 232 | void Updater::bindUnbind(bool doBind) |
| 233 | { |
| 234 | if (!doBind) |
| 235 | { |
| 236 | // Set non-present before unbind the driver |
| 237 | setPresent(doBind); |
| 238 | } |
| 239 | auto p = driverPath; |
| 240 | p /= doBind ? "bind" : "unbind"; |
| 241 | std::ofstream out(p.string()); |
| 242 | out << devName; |
Faisal Awada | f9b426b | 2025-01-31 11:44:48 -0600 | [diff] [blame^] | 243 | if (doBind) |
| 244 | { |
| 245 | internal::delay(500); |
| 246 | } |
| 247 | out.close(); |
Lei YU | 9ab6d75 | 2019-10-28 17:03:20 +0800 | [diff] [blame] | 248 | |
| 249 | if (doBind) |
| 250 | { |
| 251 | // Set to present after bind the driver |
| 252 | setPresent(doBind); |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | void Updater::setPresent(bool present) |
| 257 | { |
| 258 | try |
| 259 | { |
| 260 | auto service = util::getService(psuInventoryPath, INVENTORY_IFACE, bus); |
| 261 | util::setProperty(INVENTORY_IFACE, PRESENT_PROP, psuInventoryPath, |
| 262 | service, bus, present); |
| 263 | } |
| 264 | catch (const std::exception& e) |
| 265 | { |
Faisal Awada | f9b426b | 2025-01-31 11:44:48 -0600 | [diff] [blame^] | 266 | lg2::error( |
| 267 | "Failed to set present property PSU= {PATH}, PRESENT= {PRESENT}", |
| 268 | "PATH", psuInventoryPath, "PRESENT", present); |
Lei YU | 9ab6d75 | 2019-10-28 17:03:20 +0800 | [diff] [blame] | 269 | } |
| 270 | } |
| 271 | |
Lei YU | 575ed13 | 2019-10-29 17:22:16 +0800 | [diff] [blame] | 272 | bool Updater::isReadyToUpdate() |
| 273 | { |
Lei YU | e8c9cd6 | 2019-11-04 14:24:41 +0800 | [diff] [blame] | 274 | using namespace phosphor::pmbus; |
| 275 | |
Lei YU | 575ed13 | 2019-10-29 17:22:16 +0800 | [diff] [blame] | 276 | // Pre-condition for updating PSU: |
| 277 | // * Host is powered off |
Lei YU | e8c9cd6 | 2019-11-04 14:24:41 +0800 | [diff] [blame] | 278 | // * At least one other PSU is present |
| 279 | // * All other PSUs that are present are having AC input and DC standby |
| 280 | // output |
| 281 | |
| 282 | if (util::isPoweredOn(bus, true)) |
Lei YU | 575ed13 | 2019-10-29 17:22:16 +0800 | [diff] [blame] | 283 | { |
Faisal Awada | f9b426b | 2025-01-31 11:44:48 -0600 | [diff] [blame^] | 284 | lg2::warning("Unable to update PSU when host is on"); |
Lei YU | 575ed13 | 2019-10-29 17:22:16 +0800 | [diff] [blame] | 285 | return false; |
| 286 | } |
Lei YU | e8c9cd6 | 2019-11-04 14:24:41 +0800 | [diff] [blame] | 287 | |
| 288 | bool hasOtherPresent = false; |
| 289 | auto paths = util::getPSUInventoryPaths(bus); |
| 290 | for (const auto& p : paths) |
| 291 | { |
| 292 | if (p == psuInventoryPath) |
| 293 | { |
| 294 | // Skip check for itself |
| 295 | continue; |
| 296 | } |
| 297 | |
| 298 | // Check PSU present |
| 299 | bool present = false; |
| 300 | try |
| 301 | { |
| 302 | auto service = util::getService(p, INVENTORY_IFACE, bus); |
| 303 | util::getProperty(INVENTORY_IFACE, PRESENT_PROP, psuInventoryPath, |
| 304 | service, bus, present); |
| 305 | } |
| 306 | catch (const std::exception& e) |
| 307 | { |
Faisal Awada | f9b426b | 2025-01-31 11:44:48 -0600 | [diff] [blame^] | 308 | lg2::error("Failed to get present property PSU={PSU}", "PSU", p); |
Lei YU | e8c9cd6 | 2019-11-04 14:24:41 +0800 | [diff] [blame] | 309 | } |
| 310 | if (!present) |
| 311 | { |
Faisal Awada | f9b426b | 2025-01-31 11:44:48 -0600 | [diff] [blame^] | 312 | lg2::warning("PSU not present PSU={PSU}", "PSU", p); |
Lei YU | e8c9cd6 | 2019-11-04 14:24:41 +0800 | [diff] [blame] | 313 | continue; |
| 314 | } |
| 315 | hasOtherPresent = true; |
| 316 | |
| 317 | // Typically the driver is still bound here, so it is possible to |
| 318 | // directly read the debugfs to get the status. |
| 319 | try |
| 320 | { |
Shawn McCarney | 23dee38 | 2024-11-11 18:41:49 -0600 | [diff] [blame] | 321 | auto path = utils::getDevicePath(bus, p); |
George Liu | b9cf0d2 | 2023-02-28 10:32:42 +0800 | [diff] [blame] | 322 | PMBus pmbus(path); |
Lei YU | e8c9cd6 | 2019-11-04 14:24:41 +0800 | [diff] [blame] | 323 | uint16_t statusWord = pmbus.read(STATUS_WORD, Type::Debug); |
| 324 | auto status0Vout = pmbus.insertPageNum(STATUS_VOUT, 0); |
| 325 | uint8_t voutStatus = pmbus.read(status0Vout, Type::Debug); |
| 326 | if ((statusWord & status_word::VOUT_FAULT) || |
| 327 | (statusWord & status_word::INPUT_FAULT_WARN) || |
| 328 | (statusWord & status_word::VIN_UV_FAULT) || |
| 329 | // For ibm-cffps PSUs, the MFR (0x80)'s OV (bit 2) and VAUX |
| 330 | // (bit 6) fault map to OV_FAULT, and UV (bit 3) fault maps to |
| 331 | // UV_FAULT in vout status. |
| 332 | (voutStatus & status_vout::UV_FAULT) || |
| 333 | (voutStatus & status_vout::OV_FAULT)) |
| 334 | { |
Faisal Awada | f9b426b | 2025-01-31 11:44:48 -0600 | [diff] [blame^] | 335 | lg2::warning( |
| 336 | "Unable to update PSU when other PSU has input/ouput fault PSU={PSU}, STATUS_WORD={STATUS}, VOUT_BYTE={VOUT}", |
| 337 | "PSU", p, "STATUS", lg2::hex, statusWord, "VOUT", lg2::hex, |
| 338 | voutStatus); |
Lei YU | e8c9cd6 | 2019-11-04 14:24:41 +0800 | [diff] [blame] | 339 | return false; |
| 340 | } |
| 341 | } |
| 342 | catch (const std::exception& ex) |
| 343 | { |
| 344 | // If error occurs on accessing the debugfs, it means something went |
| 345 | // wrong, e.g. PSU is not present, and it's not ready to update. |
Faisal Awada | f9b426b | 2025-01-31 11:44:48 -0600 | [diff] [blame^] | 346 | lg2::error("{EX}", "EX", ex.what()); |
Lei YU | e8c9cd6 | 2019-11-04 14:24:41 +0800 | [diff] [blame] | 347 | return false; |
| 348 | } |
| 349 | } |
| 350 | return hasOtherPresent; |
Lei YU | 575ed13 | 2019-10-29 17:22:16 +0800 | [diff] [blame] | 351 | } |
| 352 | |
Lei YU | 9ab6d75 | 2019-10-28 17:03:20 +0800 | [diff] [blame] | 353 | int Updater::doUpdate() |
| 354 | { |
Lei YU | 34fb8bd | 2019-11-07 14:24:20 +0800 | [diff] [blame] | 355 | using namespace std::chrono; |
Lei YU | 92e89eb | 2019-11-06 18:08:25 +0800 | [diff] [blame] | 356 | |
Lei YU | 34fb8bd | 2019-11-07 14:24:20 +0800 | [diff] [blame] | 357 | uint8_t data; |
| 358 | uint8_t unlockData[12] = {0x45, 0x43, 0x44, 0x31, 0x36, 0x30, |
| 359 | 0x33, 0x30, 0x30, 0x30, 0x34, 0x01}; |
| 360 | uint8_t bootFlag = 0x01; |
| 361 | static_assert(sizeof(unlockData) == 12); |
| 362 | |
| 363 | i2c->write(0xf0, sizeof(unlockData), unlockData); |
| 364 | printf("Unlock PSU\n"); |
| 365 | |
| 366 | std::this_thread::sleep_for(milliseconds(5)); |
| 367 | |
| 368 | i2c->write(0xf1, bootFlag); |
| 369 | printf("Set boot flag ret\n"); |
| 370 | |
| 371 | std::this_thread::sleep_for(seconds(3)); |
Lei YU | 92e89eb | 2019-11-06 18:08:25 +0800 | [diff] [blame] | 372 | |
| 373 | i2c->read(0xf1, data); |
Lei YU | 34fb8bd | 2019-11-07 14:24:20 +0800 | [diff] [blame] | 374 | printf("Read of 0x%02x, 0x%02x\n", 0xf1, data); |
Lei YU | 9ab6d75 | 2019-10-28 17:03:20 +0800 | [diff] [blame] | 375 | return 0; |
Lei YU | d19df25 | 2019-10-25 17:31:52 +0800 | [diff] [blame] | 376 | } |
| 377 | |
Lei YU | 7c2fbbb | 2019-11-06 14:56:02 +0800 | [diff] [blame] | 378 | void Updater::createI2CDevice() |
| 379 | { |
Shawn McCarney | 23dee38 | 2024-11-11 18:41:49 -0600 | [diff] [blame] | 380 | auto [id, addr] = utils::parseDeviceName(devName); |
Lei YU | 7c2fbbb | 2019-11-06 14:56:02 +0800 | [diff] [blame] | 381 | i2c = i2c::create(id, addr); |
| 382 | } |
Lei YU | d19df25 | 2019-10-25 17:31:52 +0800 | [diff] [blame] | 383 | } // namespace updater |