mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 03:45:50 +08:00
Add an optional byte-oriented write method to the MTD interface
This commit is contained in:
@@ -4653,3 +4653,6 @@
|
|||||||
* configs/sim/mkroe-stm32f4: Support for the MikroElektronika
|
* configs/sim/mkroe-stm32f4: Support for the MikroElektronika
|
||||||
Mikromedia for STM32F4 development board (from Ken Petit, 2013-4-30).
|
Mikromedia for STM32F4 development board (from Ken Petit, 2013-4-30).
|
||||||
* fs/smartfs: Add Ken Pettits SMART FS (2013-4-30).
|
* fs/smartfs: Add Ken Pettits SMART FS (2013-4-30).
|
||||||
|
* include/nuttx/mtd.h and most MTD drivers: Add support for
|
||||||
|
(optional) method to perform byte oriented writes if so configured
|
||||||
|
(2013-5-1)
|
||||||
@@ -3192,12 +3192,21 @@ extern void up_ledoff(int led);
|
|||||||
</ul>
|
</ul>
|
||||||
<p>
|
<p>
|
||||||
Some devices may support byte oriented reads (optional).
|
Some devices may support byte oriented reads (optional).
|
||||||
Most MTD devices are inherently block oriented so byte-oriented writing is not supported.
|
Most MTD devices are inherently block oriented so byte-oriented accesses are not supported.
|
||||||
It is recommended that low-level drivers not support read() if it requires buffering.
|
It is recommended that low-level drivers not support read() if it requires buffering.
|
||||||
</p>
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
<p><code>ssize_t (*read)(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes, FAR uint8_t *buffer);</code></p>
|
<p><code>ssize_t (*read)(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes, FAR uint8_t *buffer);</code></p>
|
||||||
</ul>
|
</ul>
|
||||||
|
<p>
|
||||||
|
Some devices may also support byte oriented writes (optional).
|
||||||
|
Most MTD devices are inherently block oriented so byte-oriented accesses are not supported.
|
||||||
|
It is recommended that low-level drivers not support read() if it requires buffering.
|
||||||
|
This interface is only available if <code>CONFIG_MTD_BYTE_WRITE</code> is defined.
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<p><code>ssize_t (*write)(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes, FAR const uint8_t *buffer);</code></p>
|
||||||
|
</ul>
|
||||||
<p>
|
<p>
|
||||||
Support other, less frequently used commands:
|
Support other, less frequently used commands:
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
+16
-3
@@ -3,6 +3,8 @@
|
|||||||
# see misc/tools/kconfig-language.txt.
|
# see misc/tools/kconfig-language.txt.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
comment "MTD Configuration"
|
||||||
|
|
||||||
config MTD_PARTITION
|
config MTD_PARTITION
|
||||||
bool "Support MTD partitions"
|
bool "Support MTD partitions"
|
||||||
default n
|
default n
|
||||||
@@ -24,6 +26,17 @@ config MTD_PARTITION
|
|||||||
managing the sub-region of flash beginning at 'offset' (in blocks)
|
managing the sub-region of flash beginning at 'offset' (in blocks)
|
||||||
and of size 'nblocks' on the device specified by 'mtd'.
|
and of size 'nblocks' on the device specified by 'mtd'.
|
||||||
|
|
||||||
|
config MTD_BYTE_WRITE
|
||||||
|
bool "Byte write"
|
||||||
|
default n
|
||||||
|
---help---
|
||||||
|
Some devices (such as the EON EN25F80) support writing an arbitrary
|
||||||
|
number of bytes to FLASH. This setting enables MTD interfaces to
|
||||||
|
support such writes. The SMART file system can take advantage of
|
||||||
|
this option if it is enabled.
|
||||||
|
|
||||||
|
comment "MTD Device Drivers"
|
||||||
|
|
||||||
config RAMMTD
|
config RAMMTD
|
||||||
bool "RAM-based MTD driver"
|
bool "RAM-based MTD driver"
|
||||||
default n
|
default n
|
||||||
@@ -132,9 +145,9 @@ config MP25P_SUBSECTOR_ERASE
|
|||||||
bool "Sub-Sector Erase"
|
bool "Sub-Sector Erase"
|
||||||
default n
|
default n
|
||||||
---help---
|
---help---
|
||||||
Some devices (the EON EN25F80) support a smaller erase block size (4K vs 64K).
|
Some devices (such as the EON EN25F80) support a smaller erase block
|
||||||
This option enables support for sub-sector erase. The SMART file system can
|
size (4K vs 64K). This option enables support for sub-sector erase.
|
||||||
take advantage of this option if it is enabled.
|
The SMART file system can take advantage of this option if it is enabled.
|
||||||
|
|
||||||
config MP25P_BYTEWRITE
|
config MP25P_BYTEWRITE
|
||||||
bool "Enable ByteWrite ioctl support"
|
bool "Enable ByteWrite ioctl support"
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
* Derived from drivers/mtd/m25px.c
|
* Derived from drivers/mtd/m25px.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009-2011 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2009-2011, 2013 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -365,7 +365,7 @@ static int at24c_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MTDIOC_BULKERASE:
|
case MTDIOC_BULKERASE:
|
||||||
ret=at24c_eraseall(priv);
|
ret = at24c_eraseall(priv);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MTDIOC_XIPBASE:
|
case MTDIOC_XIPBASE:
|
||||||
@@ -413,6 +413,10 @@ FAR struct mtd_dev_s *at24c_initialize(FAR struct i2c_dev_s *dev)
|
|||||||
priv->pagesize = AT24XX_PAGESIZE;
|
priv->pagesize = AT24XX_PAGESIZE;
|
||||||
priv->npages = AT24XX_NPAGES;
|
priv->npages = AT24XX_NPAGES;
|
||||||
|
|
||||||
|
/* NOTE since the pre-allocated device structure lies in .bss, any
|
||||||
|
* unsupported methods should have been nullified.
|
||||||
|
*/
|
||||||
|
|
||||||
priv->mtd.erase = at24c_erase;
|
priv->mtd.erase = at24c_erase;
|
||||||
priv->mtd.bread = at24c_bread;
|
priv->mtd.bread = at24c_bread;
|
||||||
priv->mtd.bwrite = at24c_bwrite;
|
priv->mtd.bwrite = at24c_bwrite;
|
||||||
|
|||||||
+5
-3
@@ -2,7 +2,7 @@
|
|||||||
* drivers/mtd/at25.c
|
* drivers/mtd/at25.c
|
||||||
* Driver for SPI-based AT25DF321 (32Mbit) flash.
|
* Driver for SPI-based AT25DF321 (32Mbit) flash.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009-2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2009-2013 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
* Petteri Aimonen <jpa@nx.mail.kapsi.fi>
|
* Petteri Aimonen <jpa@nx.mail.kapsi.fi>
|
||||||
*
|
*
|
||||||
@@ -664,10 +664,12 @@ FAR struct mtd_dev_s *at25_initialize(FAR struct spi_dev_s *dev)
|
|||||||
* to be extended to handle multiple FLASH parts on the same SPI bus.
|
* to be extended to handle multiple FLASH parts on the same SPI bus.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
priv = (FAR struct at25_dev_s *)kmalloc(sizeof(struct at25_dev_s));
|
priv = (FAR struct at25_dev_s *)kzalloc(sizeof(struct at25_dev_s));
|
||||||
if (priv)
|
if (priv)
|
||||||
{
|
{
|
||||||
/* Initialize the allocated structure */
|
/* Initialize the allocated structure (unsupported methods were
|
||||||
|
* nullified by kzalloc).
|
||||||
|
*/
|
||||||
|
|
||||||
priv->mtd.erase = at25_erase;
|
priv->mtd.erase = at25_erase;
|
||||||
priv->mtd.bread = at25_bread;
|
priv->mtd.bread = at25_bread;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* drivers/mtd/at45db.c
|
* drivers/mtd/at45db.c
|
||||||
* Driver for SPI-based AT45DB161D (16Mbit)
|
* Driver for SPI-based AT45DB161D (16Mbit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010-2011 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2010-2011, 2013 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -827,10 +827,12 @@ FAR struct mtd_dev_s *at45db_initialize(FAR struct spi_dev_s *spi)
|
|||||||
* to be extended to handle multiple FLASH parts on the same SPI bus.
|
* to be extended to handle multiple FLASH parts on the same SPI bus.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
priv = (FAR struct at45db_dev_s *)kmalloc(sizeof(struct at45db_dev_s));
|
priv = (FAR struct at45db_dev_s *)kzalloc(sizeof(struct at45db_dev_s));
|
||||||
if (priv)
|
if (priv)
|
||||||
{
|
{
|
||||||
/* Initialize the allocated structure */
|
/* Initialize the allocated structure. (unsupported methods were
|
||||||
|
* nullified by kzalloc).
|
||||||
|
*/
|
||||||
|
|
||||||
priv->mtd.erase = at45db_erase;
|
priv->mtd.erase = at45db_erase;
|
||||||
priv->mtd.bread = at45db_bread;
|
priv->mtd.bread = at45db_bread;
|
||||||
|
|||||||
+4
-2
@@ -995,10 +995,12 @@ FAR struct mtd_dev_s *m25p_initialize(FAR struct spi_dev_s *dev)
|
|||||||
* to be extended to handle multiple FLASH parts on the same SPI bus.
|
* to be extended to handle multiple FLASH parts on the same SPI bus.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
priv = (FAR struct m25p_dev_s *)kmalloc(sizeof(struct m25p_dev_s));
|
priv = (FAR struct m25p_dev_s *)kzalloc(sizeof(struct m25p_dev_s));
|
||||||
if (priv)
|
if (priv)
|
||||||
{
|
{
|
||||||
/* Initialize the allocated structure */
|
/* Initialize the allocated structure. (unsupported methods were
|
||||||
|
* nullified by kzalloc).
|
||||||
|
*/
|
||||||
|
|
||||||
priv->mtd.erase = m25p_erase;
|
priv->mtd.erase = m25p_erase;
|
||||||
priv->mtd.bread = m25p_bread;
|
priv->mtd.bread = m25p_bread;
|
||||||
|
|||||||
@@ -395,14 +395,16 @@ FAR struct mtd_dev_s *mtd_partition(FAR struct mtd_dev_s *mtd, off_t firstblock,
|
|||||||
|
|
||||||
/* Allocate a partition device structure */
|
/* Allocate a partition device structure */
|
||||||
|
|
||||||
part = (FAR struct mtd_partition_s *)malloc(sizeof(struct mtd_partition_s));
|
part = (FAR struct mtd_partition_s *)kzalloc(sizeof(struct mtd_partition_s));
|
||||||
if (!part)
|
if (!part)
|
||||||
{
|
{
|
||||||
fdbg("ERROR: Failed to allocate memory for the partition device\n");
|
fdbg("ERROR: Failed to allocate memory for the partition device\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the partition device structure */
|
/* Initialize the partition device structure. (unsupported methods were
|
||||||
|
* nullified by kzalloc).
|
||||||
|
*/
|
||||||
|
|
||||||
part->child.erase = part_erase;
|
part->child.erase = part_erase;
|
||||||
part->child.bread = part_bread;
|
part->child.bread = part_bread;
|
||||||
|
|||||||
@@ -429,7 +429,7 @@ FAR struct mtd_dev_s *rammtd_initialize(FAR uint8_t *start, size_t size)
|
|||||||
|
|
||||||
/* Create an instance of the RAM MTD device state structure */
|
/* Create an instance of the RAM MTD device state structure */
|
||||||
|
|
||||||
priv = (FAR struct ram_dev_s *)kmalloc(sizeof(struct ram_dev_s));
|
priv = (FAR struct ram_dev_s *)kzalloc(sizeof(struct ram_dev_s));
|
||||||
if (!priv)
|
if (!priv)
|
||||||
{
|
{
|
||||||
fdbg("Failed to allocate the RAM MTD state structure\n");
|
fdbg("Failed to allocate the RAM MTD state structure\n");
|
||||||
@@ -445,7 +445,9 @@ FAR struct mtd_dev_s *rammtd_initialize(FAR uint8_t *start, size_t size)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perform initialization as necessary */
|
/* Perform initialization as necessary. (unsupported methods were
|
||||||
|
* nullified by kzalloc).
|
||||||
|
*/
|
||||||
|
|
||||||
priv->mtd.erase = ram_erase;
|
priv->mtd.erase = ram_erase;
|
||||||
priv->mtd.bread = ram_bread;
|
priv->mtd.bread = ram_bread;
|
||||||
|
|||||||
@@ -660,10 +660,12 @@ FAR struct mtd_dev_s *ramtron_initialize(FAR struct spi_dev_s *dev)
|
|||||||
* to be extended to handle multiple FLASH parts on the same SPI bus.
|
* to be extended to handle multiple FLASH parts on the same SPI bus.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
priv = (FAR struct ramtron_dev_s *)kmalloc(sizeof(struct ramtron_dev_s));
|
priv = (FAR struct ramtron_dev_s *)kzalloc(sizeof(struct ramtron_dev_s));
|
||||||
if (priv)
|
if (priv)
|
||||||
{
|
{
|
||||||
/* Initialize the allocated structure */
|
/* Initialize the allocated structure. (unsupported methods were
|
||||||
|
* nullified by kzalloc).
|
||||||
|
*/
|
||||||
|
|
||||||
priv->mtd.erase = ramtron_erase;
|
priv->mtd.erase = ramtron_erase;
|
||||||
priv->mtd.bread = ramtron_bread;
|
priv->mtd.bread = ramtron_bread;
|
||||||
|
|||||||
+30
-1
@@ -79,6 +79,10 @@ static ssize_t skel_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t n
|
|||||||
FAR const uint8_t *buf);
|
FAR const uint8_t *buf);
|
||||||
static ssize_t skel_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes,
|
static ssize_t skel_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes,
|
||||||
FAR uint8_t *buffer);
|
FAR uint8_t *buffer);
|
||||||
|
#ifdef CONFIG_MTD_BYTE_WRITE
|
||||||
|
static ssize_t skel_write(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes,
|
||||||
|
FAR const uint8_t *buffer);
|
||||||
|
#endif
|
||||||
static int skel_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg);
|
static int skel_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -88,7 +92,15 @@ static int skel_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg);
|
|||||||
|
|
||||||
static struct skel_dev_s g_skeldev =
|
static struct skel_dev_s g_skeldev =
|
||||||
{
|
{
|
||||||
{ skel_erase, skel_rbead, skel_bwrite, skel_read, skel_ioctl },
|
{ skel_erase,
|
||||||
|
skel_rbead,
|
||||||
|
skel_bwrite,
|
||||||
|
skel_read,
|
||||||
|
#ifdef CONFIG_MTD_BYTE_WRITE
|
||||||
|
skel_write,
|
||||||
|
#endif
|
||||||
|
skel_ioctl
|
||||||
|
},
|
||||||
/* Initialization of any other implementation specific data goes here */
|
/* Initialization of any other implementation specific data goes here */
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -202,6 +214,23 @@ static ssize_t skel_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: skel_write
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Some FLASH parts have the ability to write an arbitrary number of
|
||||||
|
* bytes to an arbitrary offset on the device.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_MTD_BYTE_WRITE
|
||||||
|
static ssize_t skel_write(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes,
|
||||||
|
FAR const uint8_t *buffer)
|
||||||
|
{
|
||||||
|
return -ENOSYS;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: skel_ioctl
|
* Name: skel_ioctl
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
+4
-2
@@ -2,7 +2,7 @@
|
|||||||
* drivers/mtd/sst25.c
|
* drivers/mtd/sst25.c
|
||||||
* Driver for SPI-based SST25 FLASH.
|
* Driver for SPI-based SST25 FLASH.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -1195,7 +1195,9 @@ FAR struct mtd_dev_s *sst25_initialize(FAR struct spi_dev_s *dev)
|
|||||||
priv = (FAR struct sst25_dev_s *)kzalloc(sizeof(struct sst25_dev_s));
|
priv = (FAR struct sst25_dev_s *)kzalloc(sizeof(struct sst25_dev_s));
|
||||||
if (priv)
|
if (priv)
|
||||||
{
|
{
|
||||||
/* Initialize the allocated structure */
|
/* Initialize the allocated structure. (unsupported methods were
|
||||||
|
* nullified by kzalloc).
|
||||||
|
*/
|
||||||
|
|
||||||
priv->mtd.erase = sst25_erase;
|
priv->mtd.erase = sst25_erase;
|
||||||
priv->mtd.bread = sst25_bread;
|
priv->mtd.bread = sst25_bread;
|
||||||
|
|||||||
@@ -201,7 +201,10 @@ static struct sst39vf_dev_s g_sst39vf =
|
|||||||
sst39vf_bread, /* bread method */
|
sst39vf_bread, /* bread method */
|
||||||
sst39vf_bwrite, /* bwrte method */
|
sst39vf_bwrite, /* bwrte method */
|
||||||
sst39vf_read, /* read method */
|
sst39vf_read, /* read method */
|
||||||
sst39vf_ioctl /* write method */
|
#ifdef CONFIG_MTD_BYTE_WRITE
|
||||||
|
NULL, /* write method */
|
||||||
|
#endif
|
||||||
|
sst39vf_ioctl /* ioctl method */
|
||||||
},
|
},
|
||||||
NULL /* Chip */
|
NULL /* Chip */
|
||||||
};
|
};
|
||||||
|
|||||||
+4
-2
@@ -2,7 +2,7 @@
|
|||||||
* drivers/mtd/w25.c
|
* drivers/mtd/w25.c
|
||||||
* Driver for SPI-based W25x16, x32, and x64 and W25q16, q32, q64, and q128 FLASH
|
* Driver for SPI-based W25x16, x32, and x64 and W25q16, q32, q64, and q128 FLASH
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -1124,7 +1124,9 @@ FAR struct mtd_dev_s *w25_initialize(FAR struct spi_dev_s *spi)
|
|||||||
priv = (FAR struct w25_dev_s *)kzalloc(sizeof(struct w25_dev_s));
|
priv = (FAR struct w25_dev_s *)kzalloc(sizeof(struct w25_dev_s));
|
||||||
if (priv)
|
if (priv)
|
||||||
{
|
{
|
||||||
/* Initialize the allocated structure */
|
/* Initialize the allocated structure (unsupported methods were
|
||||||
|
* nullified by kzalloc).
|
||||||
|
*/
|
||||||
|
|
||||||
priv->mtd.erase = w25_erase;
|
priv->mtd.erase = w25_erase;
|
||||||
priv->mtd.bread = w25_bread;
|
priv->mtd.bread = w25_bread;
|
||||||
|
|||||||
+16
-6
@@ -52,11 +52,12 @@
|
|||||||
|
|
||||||
/* Macros to hide implementation */
|
/* Macros to hide implementation */
|
||||||
|
|
||||||
#define MTD_ERASE(d,s,n) ((d)->erase ? (d)->erase(d,s,n) : (-ENOSYS))
|
#define MTD_ERASE(d,s,n) ((d)->erase ? (d)->erase(d,s,n) : (-ENOSYS))
|
||||||
#define MTD_BREAD(d,s,n,b) ((d)->bread ? (d)->bread(d,s,n,b) : (-ENOSYS))
|
#define MTD_BREAD(d,s,n,b) ((d)->bread ? (d)->bread(d,s,n,b) : (-ENOSYS))
|
||||||
#define MTD_READ(d,s,n,b) ((d)->read ? (d)->read(d,s,n,b) : (-ENOSYS))
|
#define MTD_BWRITE(d,s,n,b)((d)->bwrite ? (d)->bwrite(d,s,n,b) : (-ENOSYS))
|
||||||
#define MTD_BWRITE(d,s,n,b)((d)->bwrite ? (d)->bwrite(d,s,n,b) : (-ENOSYS))
|
#define MTD_READ(d,s,n,b) ((d)->read ? (d)->read(d,s,n,b) : (-ENOSYS))
|
||||||
#define MTD_IOCTL(d,c,a) ((d)->ioctl ? (d)->ioctl(d,c,a) : (-ENOSYS))
|
#define MTD_WRITE(d,s,n,b) ((d)->write ? (d)->write(d,s,n,b) : (-ENOSYS))
|
||||||
|
#define MTD_IOCTL(d,c,a) ((d)->ioctl ? (d)->ioctl(d,c,a) : (-ENOSYS))
|
||||||
|
|
||||||
/* If any of the low-level device drivers declare they want sub-sector erase
|
/* If any of the low-level device drivers declare they want sub-sector erase
|
||||||
* support, then define MTD_SUBSECTOR_ERASE.
|
* support, then define MTD_SUBSECTOR_ERASE.
|
||||||
@@ -108,7 +109,12 @@ struct mtd_dev_s
|
|||||||
{
|
{
|
||||||
/* The following methods operate on the MTD: */
|
/* The following methods operate on the MTD: */
|
||||||
|
|
||||||
/* Erase the specified erase blocks (units are erase blocks) */
|
/* Erase the specified erase blocks (units are erase blocks). Semantic
|
||||||
|
* Clarification: Here, we are not referring to the erase block according
|
||||||
|
* to the FLASH data sheet. Rather, we are referring to the *smallest*
|
||||||
|
* eraseable part of the FLASH which may have a name like a page or sector
|
||||||
|
* or subsector.
|
||||||
|
*/
|
||||||
|
|
||||||
int (*erase)(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks);
|
int (*erase)(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks);
|
||||||
|
|
||||||
@@ -127,6 +133,10 @@ struct mtd_dev_s
|
|||||||
|
|
||||||
ssize_t (*read)(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes,
|
ssize_t (*read)(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes,
|
||||||
FAR uint8_t *buffer);
|
FAR uint8_t *buffer);
|
||||||
|
#ifdef CONFIG_MTD_BYTE_WRITE
|
||||||
|
ssize_t (*write)(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes,
|
||||||
|
FAR const uint8_t *buffer);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Support other, less frequently used commands:
|
/* Support other, less frequently used commands:
|
||||||
* - MTDIOC_GEOMETRY: Get MTD geometry
|
* - MTDIOC_GEOMETRY: Get MTD geometry
|
||||||
|
|||||||
+3
-1
@@ -208,6 +208,7 @@ int main(int argc, char **argv, char **envp)
|
|||||||
printf("# undef CONFIG_FS_FAT\n");
|
printf("# undef CONFIG_FS_FAT\n");
|
||||||
printf("# undef CONFIG_FS_ROMFS\n");
|
printf("# undef CONFIG_FS_ROMFS\n");
|
||||||
printf("# undef CONFIG_FS_NXFFS\n");
|
printf("# undef CONFIG_FS_NXFFS\n");
|
||||||
|
printf("# undef CONFIG_FS_SMARTFS\n");
|
||||||
printf("# undef CONFIG_FS_BINFS\n");
|
printf("# undef CONFIG_FS_BINFS\n");
|
||||||
printf("# undef CONFIG_NFS\n");
|
printf("# undef CONFIG_NFS\n");
|
||||||
printf("#endif\n\n");
|
printf("#endif\n\n");
|
||||||
@@ -215,7 +216,8 @@ int main(int argc, char **argv, char **envp)
|
|||||||
printf("#undef CONFIG_FS_READABLE\n");
|
printf("#undef CONFIG_FS_READABLE\n");
|
||||||
printf("#undef CONFIG_FS_WRITABLE\n");
|
printf("#undef CONFIG_FS_WRITABLE\n");
|
||||||
printf("#if defined(CONFIG_FS_FAT) || defined(CONFIG_FS_ROMFS) || defined(CONFIG_USBMSC) || \\\n");
|
printf("#if defined(CONFIG_FS_FAT) || defined(CONFIG_FS_ROMFS) || defined(CONFIG_USBMSC) || \\\n");
|
||||||
printf(" defined(CONFIG_FS_NXFFS) || defined(CONFIG_FS_BINFS) || defined(CONFIG_NFS)\n");
|
printf(" defined(CONFIG_FS_NXFFS) || defined(CONFIG_FS_SMARTFS) || defined(CONFIG_FS_BINFS) || \\\n");
|
||||||
|
printf(" defined(CONFIG_NFS)\n");
|
||||||
printf("# define CONFIG_FS_READABLE 1\n");
|
printf("# define CONFIG_FS_READABLE 1\n");
|
||||||
printf("#endif\n\n");
|
printf("#endif\n\n");
|
||||||
printf("#if defined(CONFIG_FS_FAT) || defined(CONFIG_USBMSC) || defined(CONFIG_FS_NXFFS) || \\\n");
|
printf("#if defined(CONFIG_FS_FAT) || defined(CONFIG_USBMSC) || defined(CONFIG_FS_NXFFS) || \\\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user