21 lines
include/flash_verifier.h
Declares FlashVerifier and the binary-safe verify contract.
// FlashVerifier: validates flash page writes by comparing source data with readback.
#pragma once
#include <cstddef>
 
// Compares a written flash block against its post-write readback.
// Used by the bootloader after every page program operation.
class FlashVerifier {
public:
  FlashVerifier() = default;
 
  // Compares a written flash page with the data read back from the target address.
  // The data blocks are treated as raw binary and may contain arbitrary byte values
  // including embedded null (0x00) bytes anywhere in the payload.
  // Parameters:
  //   written  - data supplied to the flash program operation
  //   readback - data read back from flash immediately after programming
  //   length   - number of bytes in both written and readback
  // Returns: true if every byte in [0, length) matches; false if any byte differs,
  //          including bytes that follow an embedded null
  bool verify(const char* written, const char* readback, std::size_t length) const;
};