drivers: flash: Assert implementation of Flash Page Layout
Some drivers doesn't implement flash API page layout extension which is causing the application crash once the API was calling. This patch introduce system termination for this in those drivers which doesn't implement extension. This will help to discover this problem early. It is not done by preprocessor check because it is possible to have enabled a driver which support and a driver which doesn't support this API simultaneously. Now FLASH_PAGE_LAYOUT configuration option is accessible only in case that at last one driver which implements mentioned API is enabled. Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
This commit is contained in:
parent
318436589c
commit
d095963e73
7 changed files with 44 additions and 1 deletions
|
@ -234,6 +234,13 @@ config FP_SHARING
|
|||
|
||||
endmenu
|
||||
|
||||
config FLASH_HAS_PAGE_LAYOUT
|
||||
bool
|
||||
default n
|
||||
help
|
||||
This option is enabled when the SoC flash driver supports
|
||||
retrieving the layout of flash memory pages.
|
||||
|
||||
#
|
||||
# End hidden PM feature configs
|
||||
#
|
||||
|
|
|
@ -18,7 +18,7 @@ menuconfig FLASH
|
|||
|
||||
config FLASH_PAGE_LAYOUT
|
||||
bool "API for retrieving the layout of pages"
|
||||
depends on FLASH
|
||||
depends on FLASH && FLASH_HAS_PAGE_LAYOUT
|
||||
default n
|
||||
help
|
||||
Enables API for retrieving the layout of flash memory pages.
|
||||
|
@ -127,6 +127,7 @@ config SOC_FLASH_NRF5
|
|||
bool "Nordic Semiconductor nRF5X flash driver"
|
||||
depends on FLASH && SOC_FAMILY_NRF5
|
||||
default n
|
||||
select FLASH_HAS_PAGE_LAYOUT
|
||||
help
|
||||
Enables Nordic Semiconductor nRF5X flash driver.
|
||||
|
||||
|
|
|
@ -16,6 +16,9 @@ menuconfig SOC_FLASH_STM32
|
|||
select FLASH_PAGE_LAYOUT if SOC_SERIES_STM32F0X
|
||||
select FLASH_PAGE_LAYOUT if SOC_SERIES_STM32F4X
|
||||
select FLASH_PAGE_LAYOUT if SOC_SERIES_STM32L4X
|
||||
select FLASH_HAS_PAGE_LAYOUT if SOC_SERIES_STM32F0X
|
||||
select FLASH_HAS_PAGE_LAYOUT if SOC_SERIES_STM32F4X
|
||||
select FLASH_HAS_PAGE_LAYOUT if SOC_SERIES_STM32L4X
|
||||
help
|
||||
Enable STM32F0x, STM32F3x, STM32F4x OR STM32L4x series flash driver.
|
||||
|
||||
|
|
17
drivers/flash/flash_priv.h
Normal file
17
drivers/flash/flash_priv.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef __FLASH_PRIV_H__
|
||||
#define __FLASH_PRIV_H__
|
||||
|
||||
#if defined(CONFIG_FLASH_PAGE_LAYOUT)
|
||||
static inline void flash_page_layout_not_implemented(void)
|
||||
{
|
||||
k_panic();
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -12,6 +12,7 @@
|
|||
#include <errno.h>
|
||||
#include <init.h>
|
||||
#include <soc.h>
|
||||
#include "flash_priv.h"
|
||||
|
||||
#include "fsl_common.h"
|
||||
#include "fsl_flash.h"
|
||||
|
@ -92,6 +93,10 @@ static const struct flash_driver_api flash_mcux_api = {
|
|||
.erase = flash_mcux_erase,
|
||||
.write = flash_mcux_write,
|
||||
.read = flash_mcux_read,
|
||||
#if defined(CONFIG_FLASH_PAGE_LAYOUT)
|
||||
.page_layout = (flash_api_pages_layout)
|
||||
flash_page_layout_not_implemented,
|
||||
#endif
|
||||
.write_block_size = FSL_FEATURE_FLASH_PFLASH_BLOCK_WRITE_UNIT_SIZE,
|
||||
};
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include <flash.h>
|
||||
#include <misc/util.h>
|
||||
#include "flash_priv.h"
|
||||
|
||||
#include "qm_flash.h"
|
||||
#include "qm_soc_regs.h"
|
||||
|
@ -253,6 +254,10 @@ static const struct flash_driver_api flash_qmsi_api = {
|
|||
.write = flash_qmsi_write,
|
||||
.erase = flash_qmsi_erase,
|
||||
.write_protection = flash_qmsi_write_protection,
|
||||
#if defined(CONFIG_FLASH_PAGE_LAYOUT)
|
||||
.page_layout = (flash_api_pages_layout)
|
||||
flash_page_layout_not_implemented,
|
||||
#endif
|
||||
.write_block_size = 4,
|
||||
};
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <string.h>
|
||||
#include "spi_flash_w25qxxdv_defs.h"
|
||||
#include "spi_flash_w25qxxdv.h"
|
||||
#include "flash_priv.h"
|
||||
|
||||
static inline int spi_flash_wb_id(struct device *dev)
|
||||
{
|
||||
|
@ -344,6 +345,10 @@ static const struct flash_driver_api spi_flash_api = {
|
|||
.write = spi_flash_wb_write,
|
||||
.erase = spi_flash_wb_erase,
|
||||
.write_protection = spi_flash_wb_write_protection_set,
|
||||
#if defined(CONFIG_FLASH_PAGE_LAYOUT)
|
||||
.page_layout = (flash_api_pages_layout)
|
||||
flash_page_layout_not_implemented,
|
||||
#endif
|
||||
.write_block_size = 1,
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue