blob: 07e2b0137e6e44b86b1b5735ced581b6bff54a2a [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.
#pragma once
#include "firmware_updater_interface.hpp"
#include "host_command.hpp"
#include "mtd_util.hpp"
namespace google
{
namespace hoth
{
namespace internal
{
/** @class FirmwareMtdUpdater
* @brief Hoth firmware updater using MTD interface
*/
class FirmwareMtdUpdater : public FirmwareUpdater
{
public:
/** @brief Constructor
*
* @param[in] mtd - Reference to the MTD utility interface
* @param[in] sys - Reference to the Sys call interface
*/
FirmwareMtdUpdater(Mtd* mtd, internal::Sys* sys) : mtd(mtd), sys(sys)
{}
/** @brief Update firmware using Mtd flashCopy
* Write given firmware data to the Hoth firmware partition in EEPROM.
*
* @param[in] firmwareData - Hoth firmware image.
*/
void update(std::vector<uint8_t> firmwareData) override;
/** @brief SPI write to arbitrary address
*
* @param[in] address - SPI offset to start writing from
* @param[in] data - Data to write to the SPI EEPROM
*/
void spiWrite(uint32_t address, std::vector<uint8_t> data) override;
private:
/** @brief MTD object to access the utilitiy functions */
Mtd* mtd;
/** @brief Sys object to access sys-call functions. */
internal::Sys* sys;
};
} // namespace internal
} // namespace hoth
} // namespace google