You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2015/11/24 01:54:50 UTC

[5/5] incubator-mynewt-larva git commit: Clear flash status before attempting write. Otherwise it'll fail before even attempting write. Don't error in init if flash is already unlocked.

Clear flash status before attempting write. Otherwise it'll fail
before even attempting write.
Don't error in init if flash is already unlocked.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/c4017193
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/c4017193
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/c4017193

Branch: refs/heads/master
Commit: c4017193c1b08f057c51bb0e5fce6a4bd2d5a776
Parents: 8de028f
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Mon Nov 23 16:51:18 2015 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Nov 23 16:51:18 2015 -0800

----------------------------------------------------------------------
 hw/mcu/stm/stm32f4xx/src/hal_flash.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/c4017193/hw/mcu/stm/stm32f4xx/src/hal_flash.c
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f4xx/src/hal_flash.c b/hw/mcu/stm/stm32f4xx/src/hal_flash.c
index b2922e7..ba93941 100644
--- a/hw/mcu/stm/stm32f4xx/src/hal_flash.c
+++ b/hw/mcu/stm/stm32f4xx/src/hal_flash.c
@@ -74,6 +74,11 @@ stm32f4_flash_write(uint32_t address, const void *src, uint32_t num_bytes)
     int rc;
 
     sptr = src;
+    /*
+     * Clear status of previous operation.
+     */
+    __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | \
+      FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR| FLASH_FLAG_PGSERR);
     for (i = 0; i < num_bytes; i++) {
         rc = HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, address, sptr[i]);
         if (rc != 0) {
@@ -110,12 +115,6 @@ stm32f4_flash_erase_sector(uint32_t sector_address)
 static int
 stm32f4_flash_init(void)
 {
-    int rc;
-
-    rc = HAL_FLASH_Unlock();
-    if (rc != 0) {
-        return -1;
-    }
-
+    HAL_FLASH_Unlock();
     return 0;
 }