diff --git a/drivers/flash/Kconfig.nor b/drivers/flash/Kconfig.nor index 23f6c2854f..c538f95324 100644 --- a/drivers/flash/Kconfig.nor +++ b/drivers/flash/Kconfig.nor @@ -29,7 +29,8 @@ config SPI_NOR_FLASH_LAYOUT_PAGE_SIZE When CONFIG_FLASH_PAGE_LAYOUT is used this driver will support that API. By default the page size corresponds to the block size (65536). Other options include the 32K-byte erase size - (32768), and the sector size (4096). + (32768), the sector size (4096), or any non-zero multiple of the + sector size. config SPI_NOR_IDLE_IN_DPD bool "Use Deep Power-Down mode when flash is not being accessed." diff --git a/drivers/flash/spi_nor.c b/drivers/flash/spi_nor.c index 96de4047f7..c83ef2b071 100644 --- a/drivers/flash/spi_nor.c +++ b/drivers/flash/spi_nor.c @@ -528,6 +528,9 @@ static int spi_nor_init(struct device *dev) /* instance 0 size in bytes */ #define INST_0_BYTES (DT_INST_0_JEDEC_SPI_NOR_SIZE / 8) +BUILD_ASSERT_MSG(SPI_NOR_IS_SECTOR_ALIGNED(CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE), + "SPI_NOR_FLASH_LAYOUT_PAGE_SIZE must be multiple of 4096"); + /* instance 0 page count */ #define LAYOUT_PAGES_COUNT (INST_0_BYTES / CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE)