Skip to content

Commit 73ebf16

Browse files
committed
samples: drivers: spi_flash: Use valid addresses/sizes for dual-flash
When a board contains two identical flash memories configured in parallel dual-flash mode, the actual sector size is twice the sector size of a single flash memory. So, assuming 4-KiB sectors for each flash memory, any erase operation must be 8-KiB aligned. This commit updates the start offset and sector size in the spi_flash sample to be properly aligned when a dual-flash configuration is used. At the moment, this is only supported for STM32-based boards and QSPI flash memories. Signed-off-by: Thomas Altenbach <[email protected]>
1 parent cb9f19a commit 73ebf16

File tree

1 file changed

+4
-0
lines changed
  • samples/drivers/spi_flash/src

1 file changed

+4
-0
lines changed

samples/drivers/spi_flash/src/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@
2323
#define SPI_FLASH_TEST_REGION_OFFSET 0x7F000
2424
#elif defined(CONFIG_BOARD_EK_RA8M1) || defined(CONFIG_BOARD_EK_RA8D1)
2525
#define SPI_FLASH_TEST_REGION_OFFSET 0x40000
26+
#elif DT_HAS_COMPAT_STATUS_OKAY(st_stm32_qspi_nor) && DT_PROP(DT_NODELABEL(quadspi), dual_flash)
27+
#define SPI_FLASH_TEST_REGION_OFFSET 0xfe000
2628
#else
2729
#define SPI_FLASH_TEST_REGION_OFFSET 0xff000
2830
#endif
2931
#if defined(CONFIG_BOARD_EK_RA8M1) || defined(CONFIG_BOARD_EK_RA8D1)
3032
#define SPI_FLASH_SECTOR_SIZE 262144
33+
#elif DT_HAS_COMPAT_STATUS_OKAY(st_stm32_qspi_nor) && DT_PROP(DT_NODELABEL(quadspi), dual_flash)
34+
#define SPI_FLASH_SECTOR_SIZE 8192
3135
#else
3236
#define SPI_FLASH_SECTOR_SIZE 4096
3337
#endif

0 commit comments

Comments
 (0)