You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ry...@apache.org on 2019/02/27 11:52:54 UTC
[mynewt-core] branch master updated: spiflash: Improve erase sectors
This is an automated email from the ASF dual-hosted git repository.
rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new 711d976 spiflash: Improve erase sectors
new 085e45c Merge pull request #1664 from rymanluk/spiflash_fix
711d976 is described below
commit 711d9767efb6c7c7ac6429637eec0d35a8bd8194
Author: Ćukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Wed Feb 27 11:11:32 2019 +0100
spiflash: Improve erase sectors
Each flash has known time which is needed to erase sector.
Having this in mind we can wait a bit before reading status after sector
erase.
Note: This could be done smarter along with adjusting longest time which
might be needed. For now we choose some "default" value
---
hw/drivers/flash/spiflash/src/spiflash.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/hw/drivers/flash/spiflash/src/spiflash.c b/hw/drivers/flash/spiflash/src/spiflash.c
index 8e28612..5e05616 100644
--- a/hw/drivers/flash/spiflash/src/spiflash.c
+++ b/hw/drivers/flash/spiflash/src/spiflash.c
@@ -876,6 +876,8 @@ spiflash_wait_ready(struct spiflash_dev *dev, uint32_t timeout_ms)
spiflash_lock(dev);
while (!spiflash_device_ready(dev)) {
+ /* If not ready let's give it 10ms */
+ os_time_delay(os_time_ms_to_ticks32(10));
if (os_time_get() > exp_time) {
rc = -1;
goto err;
@@ -1033,6 +1035,11 @@ spiflash_erase_sector(const struct hal_flash *hal_flash_dev,
spiflash_cs_deactivate(dev);
#endif
+ /* Usually erase sector takes around 40ms, let's wait here that time.
+ * TODO: Do it configurable per flash.
+ */
+ os_time_delay(os_time_ms_to_ticks32(40));
+
spiflash_wait_ready(dev, 100);
err:
spiflash_unlock(dev);