62 int writeProtectPinRange_ = 0)
198 std::span<const bool> writeProtectSectors,
201 std::span<const bool> writeProtectSectors,
215 [[nodiscard]] uint8_t
read(
size_t address);
216 [[nodiscard]] uint8_t
peek(
size_t address)
const;
217 void write(
size_t address, uint8_t value);
220 template<
typename Archive>
221 void serialize(Archive& ar,
unsigned version);
230 template<
typename Archive>
231 void serialize(Archive& ar,
unsigned version);
248 AmdFlash(
const std::string& name,
const ValidatedChip& chip,
249 const Rom* rom, std::span<const bool> writeProtectSectors,
252 [[nodiscard]]
size_t getSectorIndex(
size_t address)
const;
253 [[nodiscard]] Sector& getSector(
size_t address) {
return sectors[getSectorIndex(address)]; };
254 [[nodiscard]]
const Sector& getSector(
size_t address)
const {
return sectors[getSectorIndex(address)]; };
257 [[nodiscard]] uint16_t peekAutoSelect(
size_t address, uint16_t undefined = 0xFFFF)
const;
258 [[nodiscard]] uint16_t peekCFI(
size_t address)
const;
260 void setState(
State newState);
261 [[nodiscard]]
bool checkCommandReset();
262 [[nodiscard]]
bool checkCommandLongReset();
263 [[nodiscard]]
bool checkCommandCFIQuery();
264 [[nodiscard]]
bool checkCommandCFIExit();
265 [[nodiscard]]
bool checkCommandStatusRead();
266 [[nodiscard]]
bool checkCommandStatusClear();
267 [[nodiscard]]
bool checkCommandEraseSector();
268 [[nodiscard]]
bool checkCommandEraseChip();
269 [[nodiscard]]
bool checkCommandProgramHelper(
size_t numBytes, std::span<const uint8_t> cmdSeq);
270 [[nodiscard]]
bool checkCommandProgram();
271 [[nodiscard]]
bool checkCommandDoubleByteProgram();
272 [[nodiscard]]
bool checkCommandQuadrupleByteProgram();
273 [[nodiscard]]
bool checkCommandBufferProgram();
274 [[nodiscard]]
bool checkCommandAutoSelect();
275 [[nodiscard]]
bool checkCommandContinuityCheck();
276 [[nodiscard]]
bool partialMatch(std::span<const uint8_t> dataSeq)
const;
278 [[nodiscard]]
bool isWritable(
const Sector& sector)
const;
285 std::unique_ptr<SRAM> ram;
287 std::vector<Sector> sectors;
290 uint8_t status = 0x80;
291 bool vppWpPinLow =
false;
295namespace AmdFlashChip
303 .autoSelect{.manufacturer = AMD, .device{0xA4}, .extraCode = 0x01},
304 .geometry{DeviceInterface::x8, {{8, 0x10000}}},
309 .autoSelect{.manufacturer = AMD, .device{0xAD}},
310 .geometry{DeviceInterface::x8, {{32, 0x10000}}},
315 .autoSelect{.manufacturer = STM, .device{0x5B}},
316 .geometry{DeviceInterface::x8x16, {{1, 0x4000}, {2, 0x2000}, {1, 0x8000}, {15, 0x10000}}},
319 .systemInterface{{0x27, 0x36, 0x00, 0x00}, {16, 1, 1024, 1}, {16, 1, 8, 1}},
320 .primaryAlgorithm{{1, 0}, 0, 0, 2, 1, 1, 4, 0, 0, 0},
326 .autoSelect{.manufacturer = STM, .device{0x10, 0x00}, .extraCode = 0x0008, .undefined = 0, .oddZero =
true, .readMask = 0x7F},
327 .geometry{DeviceInterface::x8x16, {{8, 0x2000}, {127, 0x10000}}, 2},
328 .program{.fastCommand =
true, .bufferCommand =
true, .shortAbortReset =
true, .pageSize = 32},
330 .command =
true, .withManufacturerDevice =
true, .commandMask = 0xFFF, .readMask = 0xFF,
331 .systemInterface{{0x27, 0x36, 0xB5, 0xC5}, {16, 1, 1024, 1}, {16, 1, 8, 1}},
332 .primaryAlgorithm{{1, 3}, 0, 0, 2, 4, 1, 4, 0, 0, 1, {0xB5, 0xC5}, 0x02, 1},
338 .autoSelect{.manufacturer = AMD, .device{0x10, 0x00}, .extraCode = 0xFF0A, .readMask = 0x0F},
339 .geometry{DeviceInterface::x8x16, {{8, 0x2000}, {127, 0x10000}}, 2},
340 .program{.bufferCommand =
true, .pageSize = 256},
342 .command =
true, .withAutoSelect =
true, .exitCommand =
true, .commandMask = 0xFF, .readMask = 0x7F,
343 .systemInterface{{0x27, 0x36, 0x00, 0x00}, {256, 256, 512, 65536}, {8, 8, 2, 1}},
344 .primaryAlgorithm{{1, 3}, 0, 8, 2, 1, 0, 8, 0, 0, 2, {0xB5, 0xC5}, 0x02, 1},
346 .misc {.statusCommand =
true, .continuityCommand =
true},