Fixing the Zephyr Flash Simulator Erase Capability Bug

Today I fixed a bug in the Zephyr RTOS Flash Simulator (#100352 and #100400). The Bug The simulated flash driver incorrectly applied the no_explicit_erase capability. It was overriding the Kconfig settings with a missing Devicetree property since it used a global fallback but couldn’t accommodate boolean properties naturally. This caused even RAM-like configurations (which do not require erasing before writing) to wrongly report needing explicit erases. The Fix To resolve this issue, I submitted PR #105035 with the following targeted fixes: ...

Zephyr Flash Simulator Erase Capability Fix Plan

Flash Simulator Erase Capability Fix Plan Issues: #100352 · #100400 1. Root Cause Background The Flash Simulator driver supports two operating modes: Erase-before-write (classic Flash): set by CONFIG_FLASH_SIMULATOR_EXPLICIT_ERASE=y (default) RAM-like (no explicit erase required): set by CONFIG_FLASH_SIMULATOR_EXPLICIT_ERASE=n The Flash API uses flash_get_parameters()→caps.no_explicit_erase (a runtime boolean field) to allow code to query at runtime whether a device requires erase prior to write. The Bug File: drivers/flash/flash_simulator.c, line 556 (inside the FLASH_SIMULATOR_INIT(n) macro): // BUGGY – uses global Kconfig constant for ALL instances static const struct flash_parameters flash_parameters_##n = { .write_block_size = FLASH_SIMULATOR_PROG_UNIT(n), .erase_value = FLASH_SIMULATOR_ERASE_VALUE(n), .caps = { .no_explicit_erase = !IS_ENABLED(CONFIG_FLASH_SIMULATOR_EXPLICIT_ERASE), // ← BUG }, }; IS_ENABLED(CONFIG_FLASH_SIMULATOR_EXPLICIT_ERASE) is a compile-time global Kconfig option that applies uniformly to all instances. It does not look at per-device Devicetree properties. ...