mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
Before accessing the sst26 flash, the "Global Unlock" command must me executed, which I do in the sst26 driver.
BUT. re-reading the datasheet, the WREN instruction is required to enable the execution of this command. This was not done. I have no idea how the driver currently works except by chance. The writes should never happen at all, the flash is half-enabled!
This commit is contained in:
committed by
Gregory Nutt
parent
96edfdb4c7
commit
0d41a1cd42
+25
-2
@@ -245,6 +245,7 @@ static inline void sst26_unlock(FAR struct spi_dev_s *dev);
|
||||
static inline int sst26_readid(struct sst26_dev_s *priv);
|
||||
static void sst26_waitwritecomplete(struct sst26_dev_s *priv);
|
||||
static void sst26_writeenable(struct sst26_dev_s *priv);
|
||||
static void sst26_writedisable(struct sst26_dev_s *priv);
|
||||
static void sst26_globalunlock(struct sst26_dev_s *priv);
|
||||
static inline void sst26_sectorerase(struct sst26_dev_s *priv, off_t offset, uint8_t type);
|
||||
static inline int sst26_chiperase(struct sst26_dev_s *priv);
|
||||
@@ -427,7 +428,7 @@ static void sst26_globalunlock(struct sst26_dev_s *priv)
|
||||
|
||||
SPI_SELECT(priv->dev, SPIDEV_FLASH, true);
|
||||
|
||||
/* Send "Write Enable (WREN)" command */
|
||||
/* Send "Global Unlock (ULBPR)" command */
|
||||
|
||||
(void)SPI_SEND(priv->dev, SST26_ULBPR);
|
||||
|
||||
@@ -459,6 +460,27 @@ static void sst26_writeenable(struct sst26_dev_s *priv)
|
||||
sstinfo("Enabled\n");
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
* Name: sst26_writedisable
|
||||
************************************************************************************/
|
||||
|
||||
static void sst26_writedisable(struct sst26_dev_s *priv)
|
||||
{
|
||||
/* Select this FLASH part */
|
||||
|
||||
SPI_SELECT(priv->dev, SPIDEV_FLASH, true);
|
||||
|
||||
/* Send "Write Disable (WRDI)" command */
|
||||
|
||||
(void)SPI_SEND(priv->dev, SST26_WRDI);
|
||||
|
||||
/* Deselect the FLASH */
|
||||
|
||||
SPI_SELECT(priv->dev, SPIDEV_FLASH, false);
|
||||
|
||||
sstinfo("Disabled\n");
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
* Name: sst26_sectorerase (4k)
|
||||
************************************************************************************/
|
||||
@@ -939,8 +961,9 @@ FAR struct mtd_dev_s *sst26_initialize_spi(FAR struct spi_dev_s *dev)
|
||||
else
|
||||
{
|
||||
/* Make sure that the FLASH is unprotected so that we can write into it */
|
||||
|
||||
sst26_writeenable(priv);
|
||||
sst26_globalunlock(priv);
|
||||
sst26_writedisable(priv);
|
||||
|
||||
#ifdef CONFIG_MTD_REGISTRATION
|
||||
/* Register the MTD with the procfs system if enabled */
|
||||
|
||||
Reference in New Issue
Block a user