63 int writeProtectPinRange_ = 0)
199 std::span<const bool> writeProtectSectors,
202 std::span<const bool> writeProtectSectors,
216 [[nodiscard]] uint8_t
read(
size_t address);
217 [[nodiscard]] uint8_t
peek(
size_t address)
const;
218 void write(
size_t address, uint8_t value);
221 template<
typename Archive>
222 void serialize(Archive& ar,
unsigned version);
231 template<
typename Archive>
232 void serialize(Archive& ar,
unsigned version);
249 AmdFlash(
const std::string& name,
const ValidatedChip& chip,
250 const Rom* rom, std::span<const bool> writeProtectSectors,
253 [[nodiscard]]
size_t getSectorIndex(
size_t address)
const;
254 [[nodiscard]] Sector& getSector(
size_t address) {
return sectors[getSectorIndex(address)]; };
255 [[nodiscard]]
const Sector& getSector(
size_t address)
const {
return sectors[getSectorIndex(address)]; };
258 [[nodiscard]] uint16_t peekAutoSelect(
size_t address, uint16_t undefined = 0xFFFF)
const;
259 [[nodiscard]] uint16_t peekCFI(
size_t address)
const;
261 void setState(
State newState);
262 [[nodiscard]]
bool checkCommandReset();
263 [[nodiscard]]
bool checkCommandLongReset();
264 [[nodiscard]]
bool checkCommandCFIQuery();
265 [[nodiscard]]
bool checkCommandCFIExit();
266 [[nodiscard]]
bool checkCommandStatusRead();
267 [[nodiscard]]
bool checkCommandStatusClear();
268 [[nodiscard]]
bool checkCommandEraseSector();
269 [[nodiscard]]
bool checkCommandEraseChip();
270 [[nodiscard]]
bool checkCommandProgramHelper(
size_t numBytes, std::span<const uint8_t> cmdSeq);
271 [[nodiscard]]
bool checkCommandProgram();
272 [[nodiscard]]
bool checkCommandDoubleByteProgram();
273 [[nodiscard]]
bool checkCommandQuadrupleByteProgram();
274 [[nodiscard]]
bool checkCommandBufferProgram();
275 [[nodiscard]]
bool checkCommandAutoSelect();
276 [[nodiscard]]
bool checkCommandContinuityCheck();
277 [[nodiscard]]
bool partialMatch(std::span<const uint8_t> dataSeq)
const;
279 [[nodiscard]]
bool isWritable(
const Sector& sector)
const;
286 std::unique_ptr<SRAM> ram;
288 std::vector<Sector> sectors;
291 uint8_t status = 0x80;
292 bool vppWpPinLow =
false;
296namespace AmdFlashChip
304 .autoSelect{.manufacturer = AMD, .device{0xA4}, .extraCode = 0x01},
305 .geometry{DeviceInterface::x8, {{8, 0x10000}}},
310 .autoSelect{.manufacturer = AMD, .device{0xAD}},
311 .geometry{DeviceInterface::x8, {{32, 0x10000}}},
316 .autoSelect{.manufacturer = STM, .device{0x5B}},
317 .geometry{DeviceInterface::x8x16, {{1, 0x4000}, {2, 0x2000}, {1, 0x8000}, {15, 0x10000}}},
320 .systemInterface{{0x27, 0x36, 0x00, 0x00}, {16, 1, 1024, 1}, {16, 1, 8, 1}},
321 .primaryAlgorithm{{1, 0}, 0, 0, 2, 1, 1, 4, 0, 0, 0},
327 .autoSelect{.manufacturer = STM, .device{0x10, 0x00}, .extraCode = 0x0008, .undefined = 0, .oddZero =
true, .readMask = 0x7F},
328 .geometry{DeviceInterface::x8x16, {{8, 0x2000}, {127, 0x10000}}, 2},
329 .program{.fastCommand =
true, .bufferCommand =
true, .shortAbortReset =
true, .pageSize = 32},
331 .command =
true, .withManufacturerDevice =
true, .commandMask = 0xFFF, .readMask = 0xFF,
332 .systemInterface{{0x27, 0x36, 0xB5, 0xC5}, {16, 1, 1024, 1}, {16, 1, 8, 1}},
333 .primaryAlgorithm{{1, 3}, 0, 0, 2, 4, 1, 4, 0, 0, 1, {0xB5, 0xC5}, 0x02, 1},
339 .autoSelect{.manufacturer = AMD, .device{0x10, 0x00}, .extraCode = 0xFF0A, .readMask = 0x0F},
340 .geometry{DeviceInterface::x8x16, {{8, 0x2000}, {127, 0x10000}}, 2},
341 .program{.bufferCommand =
true, .pageSize = 256},
343 .command =
true, .withAutoSelect =
true, .exitCommand =
true, .commandMask = 0xFF, .readMask = 0x7F,
344 .systemInterface{{0x27, 0x36, 0x00, 0x00}, {256, 256, 512, 65536}, {8, 8, 2, 1}},
345 .primaryAlgorithm{{1, 3}, 0, 8, 2, 1, 0, 8, 0, 0, 2, {0xB5, 0xC5}, 0x02, 1},
347 .misc {.statusCommand =
true, .continuityCommand =
true},