You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by da...@apache.org on 2021/03/03 21:48:26 UTC

[incubator-nuttx] branch master updated (f9d20ea -> c8d4a4c)

This is an automated email from the ASF dual-hosted git repository.

davids5 pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.


    from f9d20ea  sigdeliver: fix system block when kill signal to idle in SMP
     new 0aa78cc  mtd/progmem: Let MTD_PROGMEM depend on ARCH_HAVE_PROGMEM
     new c8d4a4c  mtd/progmem: Add up_progmem_read callback guarded by ARCH_HAVE_PROGMEM_READ

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 arch/Kconfig              |  5 +++++
 drivers/mtd/Kconfig       |  1 +
 drivers/mtd/mtd_progmem.c | 23 +++++++++++++++++++----
 include/nuttx/progmem.h   | 33 +++++++++++++++++++++++++++++++++
 4 files changed, 58 insertions(+), 4 deletions(-)


[incubator-nuttx] 01/02: mtd/progmem: Let MTD_PROGMEM depend on ARCH_HAVE_PROGMEM

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davids5 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 0aa78ccc814bacc4e7167329433d878e906ceab0
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Mon Mar 1 23:02:18 2021 +0800

    mtd/progmem: Let MTD_PROGMEM depend on ARCH_HAVE_PROGMEM
    
    and remove the reference of CONFIG_ARCH_HAVE_PROGMEM from code
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
    Change-Id: I89a73f138d54718ee8bc9345958675d7a2a34ba8
---
 drivers/mtd/Kconfig       | 1 +
 drivers/mtd/mtd_progmem.c | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
index 027689e..986f740 100644
--- a/drivers/mtd/Kconfig
+++ b/drivers/mtd/Kconfig
@@ -130,6 +130,7 @@ endif # MTD_READAHEAD
 config MTD_PROGMEM
 	bool "Enable on-chip program FLASH MTD device"
 	default n
+	depends on ARCH_HAVE_PROGMEM
 	---help---
 		Enable to support an MTD device that supports the on-chip FLASH
 		using the interfaces defined in include/nuttx/progmem.  Those
diff --git a/drivers/mtd/mtd_progmem.c b/drivers/mtd/mtd_progmem.c
index 8308a7f..ab722ab 100644
--- a/drivers/mtd/mtd_progmem.c
+++ b/drivers/mtd/mtd_progmem.c
@@ -49,7 +49,7 @@
 #include <nuttx/fs/ioctl.h>
 #include <nuttx/mtd/mtd.h>
 
-#ifdef CONFIG_ARCH_HAVE_PROGMEM
+#ifdef CONFIG_MTD_PROGMEM
 
 /****************************************************************************
  * Private Types
@@ -422,4 +422,4 @@ FAR struct mtd_dev_s *progmem_initialize(void)
   return (FAR struct mtd_dev_s *)priv;
 }
 
-#endif /* CONFIG_ARCH_HAVE_PROGMEM */
+#endif /* CONFIG_MTD_PROGMEM */


[incubator-nuttx] 02/02: mtd/progmem: Add up_progmem_read callback guarded by ARCH_HAVE_PROGMEM_READ

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davids5 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit c8d4a4c76a424ffb1115ad0dc669a8d8a9ca82f4
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Mon Mar 1 22:59:14 2021 +0800

    mtd/progmem: Add up_progmem_read callback guarded by ARCH_HAVE_PROGMEM_READ
    
    since sometime platform code need do some special action during memcpy
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
    Change-Id: Id108ef4232376feab3e37e9b3aee9a7927a03bd4
---
 arch/Kconfig              |  5 +++++
 drivers/mtd/mtd_progmem.c | 19 +++++++++++++++++--
 include/nuttx/progmem.h   | 33 +++++++++++++++++++++++++++++++++
 3 files changed, 55 insertions(+), 2 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index a0fa940..c66100a 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -303,6 +303,11 @@ config ARCH_HAVE_PROGMEM
 	bool
 	default n
 
+config ARCH_HAVE_PROGMEM_READ
+	bool
+	default n
+	depends on ARCH_HAVE_PROGMEM
+
 config ARCH_HAVE_RESET
 	bool
 	default n
diff --git a/drivers/mtd/mtd_progmem.c b/drivers/mtd/mtd_progmem.c
index ab722ab..cb489f3 100644
--- a/drivers/mtd/mtd_progmem.c
+++ b/drivers/mtd/mtd_progmem.c
@@ -200,6 +200,13 @@ static ssize_t progmem_bread(FAR struct mtd_dev_s *dev, off_t startblock,
                              size_t nblocks, FAR uint8_t *buffer)
 {
   FAR struct progmem_dev_s *priv = (FAR struct progmem_dev_s *)dev;
+#ifdef CONFIG_ARCH_HAVE_PROGMEM_READ
+  ssize_t result;
+
+  result = up_progmem_read(up_progmem_getaddress(startblock), buffer,
+                           nblocks << priv->blkshift);
+  return result < 0 ? result : nblocks;
+#else
   FAR const uint8_t *src;
 
   /* Read the specified blocks into the provided user buffer and return
@@ -210,6 +217,7 @@ static ssize_t progmem_bread(FAR struct mtd_dev_s *dev, off_t startblock,
   src = (FAR const uint8_t *)up_progmem_getaddress(startblock);
   memcpy(buffer, src, nblocks << priv->blkshift);
   return nblocks;
+#endif
 }
 
 /****************************************************************************
@@ -248,19 +256,26 @@ static ssize_t progmem_read(FAR struct mtd_dev_s *dev, off_t offset,
                             size_t nbytes, FAR uint8_t *buffer)
 {
   FAR struct progmem_dev_s *priv = (FAR struct progmem_dev_s *)dev;
+  off_t startblock = offset >> priv->blkshift;
+#ifdef CONFIG_ARCH_HAVE_PROGMEM_READ
+  ssize_t result;
+
+  result = up_progmem_read(up_progmem_getaddress(startblock) +
+           (offset & ((1 << priv->blkshift) - 1)), buffer, nbytes);
+  return result < 0 ? result : nbytes;
+#else
   FAR const uint8_t *src;
-  off_t startblock;
 
   /* Read the specified bytes into the provided user buffer and return
    * status (The positive, number of bytes actually read or a negated
    * errno)
    */
 
-  startblock = offset >> priv->blkshift;
   src = (FAR const uint8_t *)up_progmem_getaddress(startblock) +
                              (offset & ((1 << priv->blkshift) - 1));
   memcpy(buffer, src, nbytes);
   return nbytes;
+#endif
 }
 
 /****************************************************************************
diff --git a/include/nuttx/progmem.h b/include/nuttx/progmem.h
index 0a7f99c..7aa55bf 100644
--- a/include/nuttx/progmem.h
+++ b/include/nuttx/progmem.h
@@ -216,6 +216,39 @@ ssize_t up_progmem_ispageerased(size_t page);
 
 ssize_t up_progmem_write(size_t addr, FAR const void *buf, size_t count);
 
+/****************************************************************************
+ * Name: up_progmem_read
+ *
+ * Description:
+ *   Read data at given address
+ *
+ *   Note: this function is not limited to single page and nor it requires
+ *   the address be aligned inside the page boundaries.
+ *
+ * Input Parameters:
+ *   addr  - Address with or without flash offset
+ *           (absolute or aligned to page0)
+ *   buf   - Pointer to buffer
+ *   count - Number of bytes to read
+ *
+ * Returned Value:
+ *   Bytes read or negative value on error.  The following errors are
+ *   reported (errno is not set!)
+ *
+ *     EINVAL: If count is not aligned with the flash boundaries (i.e.
+ *             some MCU's require per half-word or even word access)
+ *     EFAULT: On invalid address
+ *     EIO:    On unsuccessful read
+ *     EACCES: Insufficient permissions (read/write protected)
+ *     EPERM:  If operation is not permitted due to some other constraints
+ *             (i.e. some internal block is not running etc.)
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ARCH_HAVE_PROGMEM_READ
+ssize_t up_progmem_read(size_t addr, FAR void *buf, size_t count);
+#endif
+
 #undef EXTERN
 #if defined(__cplusplus)
 }