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. ...