You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2020/01/09 12:38:41 UTC

[incubator-nuttx] 04/07: drivers: mtd: smart: SPI-Flash recovery from the initial error state

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

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

commit 14c58b0f8c9f1fce8a61b26c98b36ddbb88ede51
Author: Alin Jerpelea <al...@sony.com>
AuthorDate: Tue May 15 06:52:16 2018 +0900

    drivers: mtd: smart: SPI-Flash recovery from the initial error state
    
    The FLASH may be not erased in the initial delivery state.
    Just in case for the recovery of this fatal situation,
    after once erasing the sector, return the sector as a free sector.
---
 drivers/mtd/smart.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/mtd/smart.c b/drivers/mtd/smart.c
index 406c793..d5cd676 100644
--- a/drivers/mtd/smart.c
+++ b/drivers/mtd/smart.c
@@ -3780,6 +3780,21 @@ retry:
           dev->lastallocblock = allocblock;
           break;
         }
+      else
+        {
+          /* The FLASH may be not erased in the initial delivery state.
+           * Just in case for the recovery of this fatal situation,
+           * after once erasing the sector, return the sector as a free sector.
+           */
+
+          if (1 == dev->availsectperblk)
+            {
+              MTD_ERASE(dev->mtd, allocblock, 1);
+              physicalsector = i;
+              dev->lastallocblock = allocblock;
+              break;
+            }
+        }
     }
 
   if (physicalsector == 0xffff)