Enable flash - #434
Conversation
|
build_prs #434 vivoblueos/external#27 |
|
Job is started, see https://github.com/vivoblueos/kernel/actions/runs/28585965485. |
|
❌ Job failed. Failed jobs: build_and_check_boards (failure), see https://github.com/vivoblueos/kernel/actions/runs/28585965485. |
|
build_prs #434 vivoblueos/external#27 |
|
Job is started, see https://github.com/vivoblueos/kernel/actions/runs/28586350982. |
|
✅ All jobs completed successfully, see https://github.com/vivoblueos/kernel/actions/runs/28586350982. |
|
There was a problem hiding this comment.
We need to confirm whether these commands are specific to the W25Q80 or are generic (common to other flash chips).
There was a problem hiding this comment.
These command codes are JEDEC 25-series SPI NOR Flash standard commands, not specific to the W25Q80. The file header is marked with //! JEDEC 25-series SPI NOR Flash command layer., consistent with the Winbond W25Q80 datasheet, and also applicable to chips conforming to the same standard, such as W25Q64 / W25Q128.
Refer to the Linux kernel include/linux/mtd/spi-nor.h: https://raw.githubusercontent.com/torvalds/linux/master/include/linux/mtd/spi-nor.h
DescriptionThis commit enables driving an SPI NOR flash on ESP32-C3 and registers it as a block device through the device-discovery mainline ( Registration pathThe flash block device is no longer registered directly by
Review feedback
Configuration
Verification
NoteThe stack size on the ESP32C3 is currently insufficient; executing |
|
build_prs |
|
Job is started, see https://github.com/vivoblueos/kernel/actions/runs/29995152327. |
|
❌ Job failed. Failed jobs: check_format (failure), build_and_check_boards (failure), see https://github.com/vivoblueos/kernel/actions/runs/29995152327. |
|
build_prs |
|
Job is started, see https://github.com/vivoblueos/kernel/actions/runs/29996977500. |
|
❌ Job failed. Failed jobs: build_and_check_boards (failure), see https://github.com/vivoblueos/kernel/actions/runs/29996977500. |
|
build_prs |
|
Job is started, see https://github.com/vivoblueos/kernel/actions/runs/30012795185. |
|
❌ Job failed. Failed jobs: build_and_check_boards (failure), see https://github.com/vivoblueos/kernel/actions/runs/30012795185. |
esp32 qemu has no external W25Q64 on GPSPI2
|
build_prs |
|
Job is started, see https://github.com/vivoblueos/kernel/actions/runs/30062768436. |
|
❌ Job failed. Failed jobs: build_and_check_boards (failure), see https://github.com/vivoblueos/kernel/actions/runs/30062768436. |
|
build_prs |
|
Job is started, see https://github.com/vivoblueos/kernel/actions/runs/30064196924. |
|
Job is started, see https://github.com/vivoblueos/kernel/actions/runs/30434038782. |
|
✅ All jobs completed successfully, see https://github.com/vivoblueos/kernel/actions/runs/30434038782. |
|
build_prs |
|
Job is started, see https://github.com/vivoblueos/kernel/actions/runs/30521709572. |
|
❌ Job failed. Failed jobs: build_and_check_boards (failure), see https://github.com/vivoblueos/kernel/actions/runs/30521709572. |
|
build_prs |
|
Job is started, see https://github.com/vivoblueos/kernel/actions/runs/30522989755. |
|
✅ All jobs completed successfully, see https://github.com/vivoblueos/kernel/actions/runs/30522989755. |
| const FLASH_SECTOR_SIZE: u16 = 512; | ||
| const FLASH_ERASE_SIZE: usize = 4096; | ||
| const PAGES_PER_ERASE_BLOCK: usize = FLASH_ERASE_SIZE / 256; | ||
| const MAX_24BIT_CAPACITY: u64 = 0x0100_0000; |
There was a problem hiding this comment.
These parameters can be defined in config file with different flash types.
| .transaction(&mut [Operation::Write(&[0x9F]), Operation::Read(&mut id_buf)]) | ||
| .map_err(spi_err_to_flash)?; | ||
| let jedec_id = (id_buf[0] as u32) << 16 | (id_buf[1] as u32) << 8 | (id_buf[2] as u32); | ||
| if jedec_id == 0 || jedec_id == 0x00FF_FFFF { |
There was a problem hiding this comment.
It is not recommended to use too many magic-words. use "#defined PARAMETER_MEANING 0x0000xxxx"
|
Description This change keeps SPI NOR flash, block-device support, and FATFS enabled by default on ESP32-C3 while allowing ESP32 QEMU to boot without an external SPI flash device, and hardens the SPI bus so that multiple devices sharing one peripheral cannot interleave commands on ESP32-C3 where Bus and SPI transaction locking The bus model is borrowed from PR #442 — one shared
Performance: uncontended, each transaction adds one Erase cache: single slot → two-slot LRU The flash driver previously cached one erase block at a time: struct EraseCacheSlot {
erase_block_id: Option<usize>,
data: Vec<u8>,
dirty: bool,
last_used: u64,
}
cache: [EraseCacheSlot; ERASE_CACHE_SLOTS], // ERASE_CACHE_SLOTS = 2
use_counter: u64,
Two slots let a workload that alternates between two erase blocks (FAT metadata, directory + file data) keep both resident instead of thrashing; Flash geometry from Kconfig Flash geometry is no longer hard-coded.
BlockSpi full-duplex read
Robustness changes
Initialization path (unchanged from enable-flash)
VFS behavior (unchanged from enable-flash)
Configuration
The ESP32-C3 debug and release defconfigs keep Verification New unit tests added in this change:
The full kernel test suite ( Note The optional-device path currently does not print an early warning when the external flash is absent. Before the scheduler starts, both normal logging and LCD PR 439 also uses SPI2 and assigns GPIO5 as LCD DC, while the external flash uses GPIO5 as Flash CS; merging both features requires explicit SPI bus ownership and GPIO assignment handling, not just resolving the Git function-name conflict. The extra |
|
build_prs |
|
Job is started, see https://github.com/vivoblueos/kernel/actions/runs/31146224844. |
|
❌ Job failed. Failed jobs: build_and_check_boards (failure), see https://github.com/vivoblueos/kernel/actions/runs/31146224844. |
|
build_prs |
|
Job is started, see https://github.com/vivoblueos/kernel/actions/runs/31156036205. |
|
❌ Job failed. Failed jobs: build_and_check_boards (failure), see https://github.com/vivoblueos/kernel/actions/runs/31156036205. |
|
build_prs |
|
Job is started, see https://github.com/vivoblueos/kernel/actions/runs/31156811434. |
|
❌ Job failed. Failed jobs: build_and_check_boards (failure), see https://github.com/vivoblueos/kernel/actions/runs/31156811434. |
|
build_prs |
|
Job is started, see https://github.com/vivoblueos/kernel/actions/runs/31158667377. |
|
✅ All jobs completed successfully, see https://github.com/vivoblueos/kernel/actions/runs/31158667377. |
|
build_prs |
|
Job is started, see https://github.com/vivoblueos/kernel/actions/runs/31168310846. |
|
❌ Job failed. Failed jobs: build_and_check_boards (failure), see https://github.com/vivoblueos/kernel/actions/runs/31168310846. |
Enable to read and write nor-flash. It has been verified by connecting W25Q64 in ESP32C3. Note:
CS : GPIO5,
DI : GPIO9,
DO : GPIO10,
CLK : GPIO8.