fs: Convert NFFS partition to a generic one
The NFFS partition at the end of flash is also useful for any other file system or even the Flash Circular Buffer (FCB). Rename the partition from 'nffs_partition' to 'storage_partition' and make it depend on a new hidden Kconfig entry which the relevant users will select (such as NFFS and FCB). Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
f59a68b6d8
commit
9968cda453
18 changed files with 57 additions and 49 deletions
|
@ -56,9 +56,9 @@
|
|||
* and is used by NFFS if enabled.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_FILE_SYSTEM_NFFS)
|
||||
nffs_partition: partition@3c000 {
|
||||
label = "nffs";
|
||||
#if defined(CONFIG_FS_FLASH_MAP_STORAGE)
|
||||
storage_partition: partition@3c000 {
|
||||
label = "storage";
|
||||
reg = <0x0003c000 0x00004000>;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -69,9 +69,9 @@
|
|||
* and is used by NFFS if enabled.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_FILE_SYSTEM_NFFS)
|
||||
nffs_partition: partition@3c000 {
|
||||
label = "nffs";
|
||||
#if defined(CONFIG_FS_FLASH_MAP_STORAGE)
|
||||
storage_partition: partition@3c000 {
|
||||
label = "storage";
|
||||
reg = <0x0003c000 0x00004000>;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -46,9 +46,9 @@
|
|||
* and is used by NFFS if enabled.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_FILE_SYSTEM_NFFS)
|
||||
nffs_partition: partition@3c000 {
|
||||
label = "nffs";
|
||||
#if defined(CONFIG_FS_FLASH_MAP_STORAGE)
|
||||
storage_partition: partition@3c000 {
|
||||
label = "storage";
|
||||
reg = <0x0003c000 0x00004000>;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -59,9 +59,9 @@
|
|||
reg = <0x0003c000 0x2000>;
|
||||
};
|
||||
|
||||
#if defined(CONFIG_FILE_SYSTEM_NFFS)
|
||||
nffs_partition: partition@3e000 {
|
||||
label = "nffs";
|
||||
#if defined(CONFIG_FS_FLASH_MAP_STORAGE)
|
||||
storage_partition: partition@3e000 {
|
||||
label = "storage";
|
||||
reg = <0x0003e000 0x00002000>;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -60,9 +60,9 @@
|
|||
reg = <0x000de000 0x0001e000>;
|
||||
};
|
||||
|
||||
#if defined(CONFIG_FILE_SYSTEM_NFFS)
|
||||
nffs_partition: partition@fc000 {
|
||||
label = "nffs";
|
||||
#if defined(CONFIG_FS_FLASH_MAP_STORAGE)
|
||||
storage_partition: partition@fc000 {
|
||||
label = "storage";
|
||||
reg = <0x000fc000 0x00004000>;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -60,9 +60,9 @@
|
|||
reg = <0x00070000 0xa000>;
|
||||
};
|
||||
|
||||
#if defined(CONFIG_FILE_SYSTEM_NFFS)
|
||||
nffs_partition: partition@7a000 {
|
||||
label = "nffs";
|
||||
#if defined(CONFIG_FS_FLASH_MAP_STORAGE)
|
||||
storage_partition: partition@7a000 {
|
||||
label = "storage";
|
||||
reg = <0x0007a000 0x00006000>;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -100,9 +100,9 @@
|
|||
* will be created in this area.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_FILE_SYSTEM_NFFS)
|
||||
nffs_partition: partition@7a000 {
|
||||
label = "nffs";
|
||||
#if defined(CONFIG_FS_FLASH_MAP_STORAGE)
|
||||
storage_partition: partition@7a000 {
|
||||
label = "storage";
|
||||
reg = <0x0007a000 0x00006000>;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -53,9 +53,9 @@
|
|||
reg = <0x00070000 0xa000>;
|
||||
};
|
||||
|
||||
#if defined(CONFIG_FILE_SYSTEM_NFFS)
|
||||
nffs_partition: partition@7a000 {
|
||||
label = "nffs";
|
||||
#if defined(CONFIG_FS_FLASH_MAP_STORAGE)
|
||||
storage_partition: partition@7a000 {
|
||||
label = "storage";
|
||||
reg = <0x0007a000 0x00006000>;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -224,8 +224,8 @@ See the `MCUboot documentation`_ for more details on these partitions.
|
|||
.. _MCUboot documentation:
|
||||
https://github.com/runtimeco/mcuboot/blob/master/docs/design.md#image-slots
|
||||
|
||||
NFFS Partitions
|
||||
***************
|
||||
File System Partitions
|
||||
**********************
|
||||
|
||||
**nffs_partition**
|
||||
This is the area where NFFS expects its partition.
|
||||
**storage_partition**
|
||||
This is the area where e.g. NFFS expects its partition.
|
||||
|
|
|
@ -52,9 +52,9 @@
|
|||
reg = <0x000de000 0x0001e000>;
|
||||
};
|
||||
|
||||
#if defined(CONFIG_FILE_SYSTEM_NFFS)
|
||||
nffs_partition: partition@fc000 {
|
||||
label = "nffs";
|
||||
#if defined(CONFIG_FS_FLASH_MAP_STORAGE)
|
||||
storage_partition: partition@fc000 {
|
||||
label = "storage";
|
||||
reg = <0x000fc000 0x00004000>;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -4,6 +4,12 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
# Hidden. Automatically selected by file systems or FCB that need it
|
||||
config FS_FLASH_MAP_STORAGE
|
||||
bool
|
||||
depends on FLASH_MAP
|
||||
default n
|
||||
|
||||
menu "File Systems"
|
||||
|
||||
config FILE_SYSTEM
|
||||
|
@ -37,6 +43,7 @@ config FAT_FILESYSTEM_ELM
|
|||
config FILE_SYSTEM_NFFS
|
||||
bool "NFFS file system support"
|
||||
select FLASH_PAGE_LAYOUT
|
||||
select FS_FLASH_MAP_STORAGE
|
||||
help
|
||||
Enables NFFS file system support.
|
||||
Note: NFFS requires 1-byte unaligned access to flash thus it
|
||||
|
|
|
@ -14,5 +14,6 @@ config FCB
|
|||
prompt "Flash Circular Buffer support"
|
||||
default n
|
||||
depends on FLASH_MAP
|
||||
select FS_FLASH_MAP_STORAGE
|
||||
help
|
||||
Enable support of Flash Circular Buffer.
|
||||
|
|
|
@ -528,8 +528,8 @@ static int nffs_mount(struct fs_mount_t *mountp)
|
|||
/* Set flash descriptor fields */
|
||||
flash_desc->id = 0;
|
||||
flash_desc->sector_count = flash_get_page_count(flash_dev);
|
||||
flash_desc->area_offset = FLASH_AREA_NFFS_OFFSET;
|
||||
flash_desc->area_size = FLASH_AREA_NFFS_SIZE;
|
||||
flash_desc->area_offset = FLASH_AREA_STORAGE_OFFSET;
|
||||
flash_desc->area_size = FLASH_AREA_STORAGE_SIZE;
|
||||
|
||||
rc = nffs_misc_reset();
|
||||
if (rc) {
|
||||
|
|
|
@ -41,13 +41,13 @@ const struct flash_area default_flash_map[] = {
|
|||
.fa_size = FLASH_AREA_IMAGE_SCRATCH_SIZE,
|
||||
},
|
||||
|
||||
#ifdef CONFIG_FILE_SYSTEM_NFFS
|
||||
/* FLASH_AREA_NFFS_ */
|
||||
#ifdef CONFIG_FS_FLASH_MAP_STORAGE
|
||||
/* FLASH_AREA_STORAGE */
|
||||
{
|
||||
.fa_id = 4,
|
||||
.fa_device_id = SOC_FLASH_0_ID,
|
||||
.fa_off = FLASH_AREA_NFFS_OFFSET,
|
||||
.fa_size = FLASH_AREA_NFFS_SIZE,
|
||||
.fa_off = FLASH_AREA_STORAGE_OFFSET,
|
||||
.fa_size = FLASH_AREA_STORAGE_SIZE,
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
|
|
@ -3,8 +3,8 @@ project(NONE)
|
|||
|
||||
zephyr_compile_definitions(
|
||||
-DTEST_FLASH_OFFSET=0
|
||||
-DFLASH_AREA_NFFS_OFFSET=0
|
||||
-DFLASH_AREA_NFFS_SIZE=1048576
|
||||
-DFLASH_AREA_STORAGE_OFFSET=0
|
||||
-DFLASH_AREA_STORAGE_SIZE=1048576
|
||||
)
|
||||
|
||||
target_link_libraries(app ELMFAT)
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <zephyr/types.h>
|
||||
#include <ztest_assert.h>
|
||||
|
||||
static u8_t rambuf[FLASH_AREA_NFFS_SIZE];
|
||||
static u8_t rambuf[FLASH_AREA_STORAGE_SIZE];
|
||||
|
||||
static int test_ram_flash_init(struct device *dev)
|
||||
{
|
||||
|
@ -29,7 +29,7 @@ static int test_flash_ram_erase(struct device *dev, off_t offset, size_t len)
|
|||
off_t end_offset = offset + len;
|
||||
|
||||
zassert_true(offset >= 0, "invalid offset");
|
||||
zassert_true(offset + len <= FLASH_AREA_NFFS_SIZE,
|
||||
zassert_true(offset + len <= FLASH_AREA_STORAGE_SIZE,
|
||||
"flash address out of bounds");
|
||||
|
||||
while (offset < end_offset) {
|
||||
|
@ -45,7 +45,7 @@ static int test_flash_ram_write(struct device *dev, off_t offset,
|
|||
const void *data, size_t len)
|
||||
{
|
||||
zassert_true(offset >= 0, "invalid offset");
|
||||
zassert_true(offset + len <= FLASH_AREA_NFFS_SIZE,
|
||||
zassert_true(offset + len <= FLASH_AREA_STORAGE_SIZE,
|
||||
"flash address out of bounds");
|
||||
|
||||
memcpy(rambuf + offset, data, len);
|
||||
|
@ -57,7 +57,7 @@ static int test_flash_ram_read(struct device *dev, off_t offset, void *data,
|
|||
size_t len)
|
||||
{
|
||||
zassert_true(offset >= 0, "invalid offset");
|
||||
zassert_true(offset + len <= FLASH_AREA_NFFS_SIZE,
|
||||
zassert_true(offset + len <= FLASH_AREA_STORAGE_SIZE,
|
||||
"flash address out of bounds");
|
||||
|
||||
memcpy(data, rambuf + offset, len);
|
||||
|
|
|
@ -12,8 +12,8 @@ project(NONE)
|
|||
if(BOARD STREQUAL qemu_x86)
|
||||
zephyr_compile_definitions(
|
||||
-DTEST_FLASH_OFFSET=0
|
||||
-DFLASH_AREA_NFFS_OFFSET=0
|
||||
-DFLASH_AREA_NFFS_SIZE=1048576
|
||||
-DFLASH_AREA_STORAGE_OFFSET=0
|
||||
-DFLASH_AREA_STORAGE_SIZE=1048576
|
||||
)
|
||||
elseif(BOARD STREQUAL nrf51_pca10028)
|
||||
zephyr_compile_definitions(
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <zephyr/types.h>
|
||||
#include <ztest_assert.h>
|
||||
|
||||
static u8_t rambuf[FLASH_AREA_NFFS_SIZE];
|
||||
static u8_t rambuf[FLASH_AREA_STORAGE_SIZE];
|
||||
|
||||
static int test_ram_flash_init(struct device *dev)
|
||||
{
|
||||
|
@ -29,7 +29,7 @@ static int test_flash_ram_erase(struct device *dev, off_t offset, size_t len)
|
|||
off_t end_offset = offset + len;
|
||||
|
||||
zassert_true(offset >= 0, "invalid offset");
|
||||
zassert_true(offset + len <= FLASH_AREA_NFFS_SIZE,
|
||||
zassert_true(offset + len <= FLASH_AREA_STORAGE_SIZE,
|
||||
"flash address out of bounds");
|
||||
|
||||
while (offset < end_offset) {
|
||||
|
@ -45,7 +45,7 @@ static int test_flash_ram_write(struct device *dev, off_t offset,
|
|||
const void *data, size_t len)
|
||||
{
|
||||
zassert_true(offset >= 0, "invalid offset");
|
||||
zassert_true(offset + len <= FLASH_AREA_NFFS_SIZE,
|
||||
zassert_true(offset + len <= FLASH_AREA_STORAGE_SIZE,
|
||||
"flash address out of bounds");
|
||||
|
||||
memcpy(rambuf + offset, data, len);
|
||||
|
@ -57,7 +57,7 @@ static int test_flash_ram_read(struct device *dev, off_t offset, void *data,
|
|||
size_t len)
|
||||
{
|
||||
zassert_true(offset >= 0, "invalid offset");
|
||||
zassert_true(offset + len <= FLASH_AREA_NFFS_SIZE,
|
||||
zassert_true(offset + len <= FLASH_AREA_STORAGE_SIZE,
|
||||
"flash address out of bounds");
|
||||
|
||||
memcpy(data, rambuf + offset, len);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue