emubd: Added optional nor-masking emulation

This adds NOR-style masking emulation to emubd when erase_value is set
to -2:

  erase     => 0xff
  prog 0xf0 => 0xf0
  prog 0xcc => 0xc0

We do _not_ rely on this property in littlefs, and so this feature will
probably go unused in our tests, but it's useful for running other
filesystems (SPIFFS) on top of emubd.

It may be a bit of a scope violation to merge this into littlefs's core
repo, but it's useful to centralize emubd's features somewhere...
This commit is contained in:
Christopher Haster
2025-08-06 13:30:14 -05:00
parent 6a57258558
commit 92af5de3ca
2 changed files with 71 additions and 22 deletions
+3 -1
View File
@@ -67,7 +67,9 @@ typedef int64_t lfs3_emubd_ssleep_t;
// emubd config, this is required for testing
struct lfs3_emubd_cfg {
// 8-bit erase value to use for simulating erases. -1 simulates a noop
// erase, which is faster than simulating a fixed erase value.
// erase, which is faster than simulating a fixed erase value. -2 emulates
// nor-masking, which is useful for testing other filesystems (littlefs
// does _not_ rely on this!).
int32_t erase_value;
// Number of erase cycles before a block becomes "bad". The exact behavior