blob: fef776dfd38c859029c663d34fdf4ac9e135fe63 [file] [log] [blame]
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "firmware_mtd_updater.hpp"
#include "payload_update_interface.hpp"
#include <stdplus/print.hpp>
#include <xyz/openbmc_project/Control/Hoth/error.hpp>
namespace google
{
namespace hoth
{
namespace internal
{
namespace
{
using sdbusplus::error::xyz::openbmc_project::control::hoth::FirmwareFailure;
constexpr char updatePartition[] = "hoth-update";
} // namespace
void FirmwareMtdUpdater::update(std::vector<uint8_t> firmwareData)
{
if (mtd == nullptr)
{
stdplus::print(stderr, "Firmware MTD update is not implemented\n");
throw FirmwareFailure();
}
std::string updateDevice = mtd->findPartition(updatePartition);
mtd->flashCopy(sys, firmwareData, updateDevice);
}
void FirmwareMtdUpdater::spiWrite([[maybe_unused]] uint32_t address,
[[maybe_unused]] std::vector<uint8_t> data)
{
stdplus::print(stderr,
"SpiWrite method is not applicable to FirmwareMtdUpdater\n");
throw FirmwareFailure();
}
} // namespace internal
} // namespace hoth
} // namespace google