From 45c144ba134835b0a66bdcb7dd40114c7b6a8249 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 30 Apr 2013 15:54:02 -0600 Subject: Add configuration and example to test MTD partitions --- apps/ChangeLog.txt | 2 + apps/examples/Kconfig | 3 +- apps/examples/Make.defs | 4 + apps/examples/README.txt | 27 +++ apps/examples/mtdpart/.gitignore | 11 + apps/examples/mtdpart/Kconfig | 46 +++++ apps/examples/mtdpart/Makefile | 96 +++++++++ apps/examples/mtdpart/mtdpart_main.c | 379 +++++++++++++++++++++++++++++++++++ apps/examples/nxffs/Kconfig | 58 ++++++ apps/examples/nxffs/nxffs_main.c | 11 +- 10 files changed, 628 insertions(+), 9 deletions(-) create mode 100644 apps/examples/mtdpart/.gitignore create mode 100644 apps/examples/mtdpart/Kconfig create mode 100755 apps/examples/mtdpart/Makefile create mode 100644 apps/examples/mtdpart/mtdpart_main.c (limited to 'apps') diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index 0749237ef..4676d8b8e 100644 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -534,3 +534,5 @@ Petit (2014-4-24). 6.28 2013-xx-xx Gregory Nutt + + * apps/examples/mtdpart: Provides a simple test of MTD partitions. diff --git a/apps/examples/Kconfig b/apps/examples/Kconfig index ec0a97dd4..cf70ae53e 100644 --- a/apps/examples/Kconfig +++ b/apps/examples/Kconfig @@ -21,8 +21,9 @@ source "$APPSDIR/examples/keypadtest/Kconfig" source "$APPSDIR/examples/igmp/Kconfig" source "$APPSDIR/examples/lcdrw/Kconfig" source "$APPSDIR/examples/mm/Kconfig" -source "$APPSDIR/examples/mount/Kconfig" source "$APPSDIR/examples/modbus/Kconfig" +source "$APPSDIR/examples/mount/Kconfig" +source "$APPSDIR/examples/mtdpart/Kconfig" source "$APPSDIR/examples/nettest/Kconfig" source "$APPSDIR/examples/nsh/Kconfig" source "$APPSDIR/examples/null/Kconfig" diff --git a/apps/examples/Make.defs b/apps/examples/Make.defs index 68d4d4340..4026edcbd 100644 --- a/apps/examples/Make.defs +++ b/apps/examples/Make.defs @@ -118,6 +118,10 @@ ifeq ($(CONFIG_EXAMPLES_MOUNT),y) CONFIGURED_APPS += examples/mount endif +ifeq ($(CONFIG_EXAMPLES_MTDPART),y) +CONFIGURED_APPS += examples/mtdpart +endif + ifeq ($(CONFIG_EXAMPLES_NETTEST),y) CONFIGURED_APPS += examples/nettest endif diff --git a/apps/examples/README.txt b/apps/examples/README.txt index 3c6fd7029..cd6701e9c 100644 --- a/apps/examples/README.txt +++ b/apps/examples/README.txt @@ -671,6 +671,33 @@ examples/mount when CONFIG_EXAMPLES_MOUNT_DEVNAME is not defined. The default is zero (meaning that "/dev/ram0" will be used). +examples/mtdpart +^^^^^^^^^^^^^^^^ + + This examples provides a simple test of MTD partition logic. + + * CONFIG_EXAMPLES_MTDPART - Enables the MTD partition test example + * CONFIG_EXAMPLES_MTDPART_ARCHINIT - The default is to use the RAM MTD + device at drivers/mtd/rammtd.c. But an architecture-specific MTD driver + can be used instead by defining CONFIG_EXAMPLES_MTDPART_ARCHINIT. In + this case, the initialization logic will call mtdpart_archinitialize() + to obtain the MTD driver instance. + * CONFIG_EXAMPLES_MTDPART_NPARTITIONS - This setting provides the number + of partitions to test. The test will divide the reported size of the + MTD device into equal-sized sub-regions for each test partition. Default: + 3 + + When CONFIG_EXAMPLES_MTDPART_ARCHINIT is not defined, this test will use + the RAM MTD device at drivers/mtd/rammtd.c to simulate FLASH. The size of + the allocated RAM drive will be: CONFIG_EXMPLES_RAMMTD_ERASESIZE * + CONFIG_EXAMPLES_MTDPART_NEBLOCKS + + * CONFIG_EXAMPLES_MTDPART_ERASESIZE - This value gives the size of one + erase block in the MTD RAM device. This must exactly match the default + configuration in drivers/mtd/rammtd.c! + * CONFIG_EXAMPLES_MTDPART_NEBLOCKS - This value gives the nubmer of erase + blocks in MTD RAM device. + examples/nettest ^^^^^^^^^^^^^^^^ diff --git a/apps/examples/mtdpart/.gitignore b/apps/examples/mtdpart/.gitignore new file mode 100644 index 000000000..106e96227 --- /dev/null +++ b/apps/examples/mtdpart/.gitignore @@ -0,0 +1,11 @@ +Make.dep +.depend +.built +*.swp +*.asm +*.rel +*.lst +*.sym +*.adb +*.lib +*.src diff --git a/apps/examples/mtdpart/Kconfig b/apps/examples/mtdpart/Kconfig new file mode 100644 index 000000000..363b6091f --- /dev/null +++ b/apps/examples/mtdpart/Kconfig @@ -0,0 +1,46 @@ +# +# For a description of the syntax of this configuration file, +# see misc/tools/kconfig-language.txt. +# + +config EXAMPLES_MTDPART + bool "MTD partition test" + default n + ---help--- + Enable the MTD partition test example + +if EXAMPLES_MTDPART + +config EXAMPLES_MTDPART_ARCHINIT + bool "Architecture-specific initialization" + default n + ---help--- + The default is to use the RAM MTD device at drivers/mtd/rammtd.c. + But an architecture-specific MTD driver can be used instead by + defining EXAMPLES_MTDPART_ARCHINIT. In this case, the + initialization logic will call mtdpart_archinitialize() to obtain + the MTD driver instance. + +config EXAMPLES_MTDPART_NEBLOCKS + int "Number of erase blocks (simulated)" + default 32 + depends on !EXAMPLES_MTDPART_ARCHINIT + ---help--- + When EXAMPLES_MTDPART_ARCHINIT is not defined, this test will use + the RAM MTD device at drivers/mtd/rammtd.c to simulate FLASH. In + this case, this value must be provided to give the nubmer of erase + blocks in MTD RAM device. + + The size of the allocated RAM drive will be: + + EXAMPLES_MTDPART_ERASESIZE * EXAMPLES_MTDPART_NEBLOCKS + +config EXAMPLES_MTDPART_NPARTITIONS + int "Number of partitions" + default 3 + ---help--- + This setting provides the number of partitions to test. The + test will divide the reported size of the MTD device into equal- + sized sub-regions for each test partition. + +endif diff --git a/apps/examples/mtdpart/Makefile b/apps/examples/mtdpart/Makefile new file mode 100755 index 000000000..56f9afa84 --- /dev/null +++ b/apps/examples/mtdpart/Makefile @@ -0,0 +1,96 @@ +############################################################################ +# apps/examples/mtdpart/Makefile +# +# Copyright (C) 2013 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +-include $(TOPDIR)/.config +-include $(TOPDIR)/Make.defs +include $(APPDIR)/Make.defs + +# Hello, World! Example + +ASRCS = +CSRCS = mtdpart_main.c + +AOBJS = $(ASRCS:.S=$(OBJEXT)) +COBJS = $(CSRCS:.c=$(OBJEXT)) + +SRCS = $(ASRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) + +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else +ifeq ($(WINTOOL),y) + BIN = ..\\..\\libapps$(LIBEXT) +else + BIN = ../../libapps$(LIBEXT) +endif +endif + +ROOTDEPPATH = --dep-path . + +# Common build + +VPATH = + +all: .built +.PHONY: clean depend distclean + +$(AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(COBJS): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +.built: $(OBJS) + $(call ARCHIVE, $(BIN), $(OBJS)) + @touch .built + +context: + +.depend: Makefile $(SRCS) + @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep + @touch $@ + +depend: .depend + +clean: + $(call DELFILE, .built) + $(call CLEAN) + +distclean: clean + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) + +-include Make.dep diff --git a/apps/examples/mtdpart/mtdpart_main.c b/apps/examples/mtdpart/mtdpart_main.c new file mode 100644 index 000000000..9b22aaf13 --- /dev/null +++ b/apps/examples/mtdpart/mtdpart_main.c @@ -0,0 +1,379 @@ +/**************************************************************************** + * examples/mtdpart/mtdpart_main.c + * + * Copyright (C) 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +/**************************************************************************** + * Definitions + ****************************************************************************/ +/* Configuration ************************************************************/ +/* Make sure that support for MTD partitions is enabled */ + +#ifndef CONFIG_MTD_PARTITION +# error "CONFIG_MTD_PARTITION is required" +#endif + +/* The default is to use the RAM MTD device at drivers/mtd/rammtd.c. But + * an architecture-specific MTD driver can be used instead by defining + * CONFIG_EXAMPLES_MTDPART_ARCHINIT. In this case, the initialization logic + * will call mtdpart_archinitialize() to obtain the MTD driver instance. + */ + +#ifndef CONFIG_EXAMPLES_MTDPART_ARCHINIT + +/* Make sure that the RAM MTD driver is enabled */ + +# ifndef CONFIG_RAMMTD +# error "CONFIG_RAMMTD is required without CONFIG_EXAMPLES_MTDPART_ARCHINIT" +# endif + +/* This must exactly match the default configuration in drivers/mtd/rammtd.c */ + +# ifndef CONFIG_RAMMTD_ERASESIZE +# define CONFIG_RAMMTD_ERASESIZE 4096 +# endif + +/* Given the ERASESIZE, CONFIG_EXAMPLES_MTDPART_NEBLOCKS will determine the + * size of the RAM allocation needed. + */ + +# ifndef CONFIG_EXAMPLES_MTDPART_NEBLOCKS +# define CONFIG_EXAMPLES_MTDPART_NEBLOCKS (32) +# endif + +# undef MTDPART_BUFSIZE +# define MTDPART_BUFSIZE \ + (CONFIG_RAMMTD_ERASESIZE * CONFIG_EXAMPLES_MTDPART_NEBLOCKS) + +#endif + +#ifdef CONFIG_EXAMPLES_MTDPART_NPARTITIONS +# define CONFIG_EXAMPLES_MTDPART_NPARTITIONS 3 +#endif + +/* Debug ********************************************************************/ +#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_FS) +# define message syslog +# define msgflush() +#else +# define message printf +# define msgflush() fflush(stdout); +#endif + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct mtdpart_filedesc_s +{ + FAR char *name; + bool deleted; + size_t len; + uint32_t crc; +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ +/* Pre-allocated simulated flash */ + +#ifndef CONFIG_EXAMPLES_MTDPART_ARCHINIT +static uint8_t g_simflash[MTDPART_BUFSIZE]; +#endif + +/**************************************************************************** + * External Functions + ****************************************************************************/ + +#ifdef CONFIG_EXAMPLES_MTDPART_ARCHINIT +extern FAR struct mtd_dev_s *mtdpart_archinitialize(void); +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: mtdpart_main + ****************************************************************************/ + +int mtdpart_main(int argc, char *argv[]) +{ + FAR struct mtd_dev_s *master; + FAR struct mtd_dev_s *part[CONFIG_EXAMPLES_MTDPART_NPARTITIONS]; + FAR struct mtd_geometry_s geo; + FAR uint32_t *buffer; + char blockname[32]; + char charname[32]; + ssize_t nbytes; + off_t nblocks; + off_t offset; + off_t check; + unsigned int blkpererase; + int fd; + int i; + int j; + int k; + int ret; + + /* Create and initialize a RAM MTD FLASH driver instance */ + +#ifdef CONFIG_EXAMPLES_MTDPART_ARCHINIT + master = mtdpart_archinitialize(); +#else + master = rammtd_initialize(g_simflash, MTDPART_BUFSIZE); +#endif + if (!master) + { + message("ERROR: Failed to create RAM MTD instance\n"); + msgflush(); + exit(1); + } + + /* Initialize to provide an FTL block driver on the MTD FLASH interface. + * + * NOTE: We could just skip all of this FTL and BCH stuff. We could + * instead just use the MTD drivers bwrite and bread to perform this + * test. Creating the character drivers, however, makes this test more + * interesting. + */ + + ret = ftl_initialize(0, master); + if (ret < 0) + { + message("ERROR: ftl_initialize /dev/mtdblock0 failed: %d\n", ret); + msgflush(); + exit(2); + } + + /* Now create a character device on the block device */ + + ret = bchdev_register("/dev/mtdblock0", "/dev/mtd0", false); + if (ret < 0) + { + message("ERROR: bchdev_register /dev/mtd0 failed: %d\n", ret); + msgflush(); + exit(3); + } + + /* Get the geometry of the FLASH device */ + + ret = master->ioctl(master, MTDIOC_GEOMETRY, (unsigned long)((uintptr_t)&geo)); + if (ret < 0) + { + fdbg("ERROR: mtd->ioctl failed: %d\n", ret); + exit(3); + } + + message("Flash Geometry:\n"); + message(" blocksize: %uld\n", (unsigned long)geo.blocksize); + message(" erasesize: %uld\n", (unsigned long)geo.erasesize); + message(" neraseblocks: %uld\n", (unsigned long)geo.neraseblocks); + + /* Determine the size of each partition */ + + blkpererase = geo.erasesize / geo.blocksize; + nblocks = geo.neraseblocks * blkpererase / CONFIG_EXAMPLES_MTDPART_NPARTITIONS; + + /* Now create MTD FLASH partitions */ + + for (offset = 0, i = 1; + i <= CONFIG_EXAMPLES_MTDPART_NPARTITIONS; + offset += nblocks, i++) + { + /* Create the partition */ + + part[i] = mtd_partition(master, offset, nblocks); + if (!part[i]) + { + message("ERROR: mtd_partition failed. offset=%uld nblocks=%uld\n", + (unsigned long)offset, (unsigned long)nblocks); + msgflush(); + exit(4); + } + + /* Initialize to provide an FTL block driver on the MTD FLASH interface */ + + snprintf(blockname, 32, "/dev/mtdblock%d", i); + snprintf(charname, 32, "/dev/mtd%d", i); + + ret = ftl_initialize(i, part[i]); + if (ret < 0) + { + message("ERROR: ftl_initialize %s failed: %d\n", blockname, ret); + msgflush(); + exit(5); + } + + /* Now create a character device on the block device */ + + ret = bchdev_register(blockname, charname, false); + if (ret < 0) + { + message("ERROR: bchdev_register %s failed: %d\n", charname, ret); + msgflush(); + exit(6); + } + } + + /* Allocate a buffer */ + + buffer = (FAR uint32_t *)malloc(geo.blocksize); + if (!buffer) + { + message("ERROR: failed to allocate a sector buffer\n"); + msgflush(); + exit(7); + } + + /* Open the master MTD FLASH character driver for writing */ + + fd = open("/dev/mtd0", O_WRONLY); + if (fd < 0) + { + message("ERROR: open /dev/mtd0 failed: %d\n", errno); + msgflush(); + exit(8); + } + + /* Now write the offset into every block */ + + offset = 0; + for (i = 0; i < geo.neraseblocks; i++) + { + for (j = 0; j < blkpererase; j++) + { + /* Fill the block with the offset */ + + for (k = 0; k < geo.blocksize / sizeof(uint32_t); k++) + { + buffer[k] = offset; + offset += 4; + } + + /* And write it using the character driver */ + + nbytes = write(fd, buffer, geo.blocksize); + if (nbytes < 0) + { + message("ERROR: write to /dev/mtd0 failed: %d\n", errno); + msgflush(); + exit(9); + } + } + } + + close(fd); + + /* Now read each partition */ + + for (offset = 0, i = 1; + i <= CONFIG_EXAMPLES_MTDPART_NPARTITIONS; + offset += nblocks, i++) + { + /* Open the master MTD partition character driver for writing */ + + snprintf(charname, 32, "/dev/mtd%d", i); + fd = open(charname, O_RDONLY); + if (fd < 0) + { + message("ERROR: open %s failed: %d\n", charname, errno); + msgflush(); + exit(10); + } + + /* Now verify the offset in every block */ + + check = offset; + for (i = 0; i < nblocks; i++) + { + for (j = 0; j < blkpererase; j++) + { + /* Read the next block into memory */ + + nbytes = read(fd, buffer, geo.blocksize); + if (nbytes < 0) + { + message("ERROR: read from %s failed: %d\n", charname, errno); + msgflush(); + exit(11); + } + + /* Verfy the offsets in the block */ + + check = offset; + for (k = 0; k < geo.blocksize / sizeof(uint32_t); k++) + { + if (buffer[k] != check) + { + message("ERROR: Bad offset %uld, expected %uld\n", + buffer[k], check); + msgflush(); + exit(12); + } + + check += 4; + } + } + } + + close(fd); + } + + /* And exit without bothering to clean up */ + + msgflush(); + return 0; +} + diff --git a/apps/examples/nxffs/Kconfig b/apps/examples/nxffs/Kconfig index 074ace872..57c55787c 100644 --- a/apps/examples/nxffs/Kconfig +++ b/apps/examples/nxffs/Kconfig @@ -10,4 +10,62 @@ config EXAMPLES_NXFFS Enable the NXFFS file system example if EXAMPLES_NXFFS + +config EXAMPLES_NXFFS_ARCHINIT + bool "Architecture-specific initialization" + default n + ---help--- + The default is to use the RAM MTD device at drivers/mtd/rammtd.c. + But an architecture-specific MTD driver can be used instead by + defining EXAMPLES_NXFFS_ARCHINIT. In this case, the + initialization logic will call mtdpart_archinitialize() to obtain + the MTD driver instance. + +config EXAMPLES_NXFFS_NEBLOCKS + int "Number of erase blocks (simulated)" + default 32 + depends on !EXAMPLES_NXFFS_ARCHINIT + ---help--- + When EXAMPLES_NXFFS_ARCHINIT is not defined, this test will use + the RAM MTD device at drivers/mtd/rammtd.c to simulate FLASH. In + this case, this value must be provided to give the nubmer of erase + blocks in MTD RAM device. + + The size of the allocated RAM drive will be: + + RAMMTD_ERASESIZE * EXAMPLES_NXFFS_NEBLOCKS + +config EXAMPLES_NXFFS_MAXNAME + int "Max name size" + default 128 + range 1 255 + ---help--- + Determines the maximum size of names used in the filesystem + + config EXAMPLES_NXFFS_MAXFILE + int "Max file size" + default 8192 + ---help--- + Determines the maximum size of a file + +config EXAMPLES_NXFFS_MAXIO + int "Max I/O" + default 347 + +config EXAMPLES_NXFFS_MAXOPEN + int "Max open files" + default 512 + +config EXAMPLES_NXFFS_MOUNTPT + string "NXFFS mountpoint" + default "/mnt/nxffs" + +config EXAMPLES_NXFFS_NLOOPS + int "Number of test loops" + default 100 + +config EXAMPLES_NXFFS_VERBOSE + bool "Verbose output" + default n + endif diff --git a/apps/examples/nxffs/nxffs_main.c b/apps/examples/nxffs/nxffs_main.c index 8bb5cd1fe..23b02cc16 100644 --- a/apps/examples/nxffs/nxffs_main.c +++ b/apps/examples/nxffs/nxffs_main.c @@ -69,10 +69,6 @@ /* This must exactly match the default configuration in drivers/mtd/rammtd.c */ -# ifndef CONFIG_RAMMTD_BLOCKSIZE -# define CONFIG_RAMMTD_BLOCKSIZE 512 -# endif - # ifndef CONFIG_RAMMTD_ERASESIZE # define CONFIG_RAMMTD_ERASESIZE 4096 # endif @@ -81,8 +77,7 @@ # define CONFIG_EXAMPLES_NXFFS_NEBLOCKS (32) # endif -# undef CONFIG_EXAMPLES_NXFFS_BUFSIZE -# define CONFIG_EXAMPLES_NXFFS_BUFSIZE \ +# define EXAMPLES_NXFFS_BUFSIZE \ (CONFIG_RAMMTD_ERASESIZE * CONFIG_EXAMPLES_NXFFS_NEBLOCKS) #endif @@ -145,7 +140,7 @@ struct nxffs_filedesc_s /* Pre-allocated simulated flash */ #ifndef CONFIG_EXAMPLES_NXFFS_ARCHINIT -static uint8_t g_simflash[CONFIG_EXAMPLES_NXFFS_BUFSIZE]; +static uint8_t g_simflash[EXAMPLES_NXFFS_BUFSIZE]; #endif static uint8_t g_fileimage[CONFIG_EXAMPLES_NXFFS_MAXFILE]; @@ -807,7 +802,7 @@ int nxffs_main(int argc, char *argv[]) #ifdef CONFIG_EXAMPLES_NXFFS_ARCHINIT mtd = nxffs_archinitialize(); #else - mtd = rammtd_initialize(g_simflash, CONFIG_EXAMPLES_NXFFS_BUFSIZE); + mtd = rammtd_initialize(g_simflash, EXAMPLES_NXFFS_BUFSIZE); #endif if (!mtd) { -- cgit v1.2.3