You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ut...@apache.org on 2018/09/17 12:34:03 UTC

[mynewt-core] 02/03: Update flash drivers to declare erased value

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

utzig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 03e74f375ca8caf11c6dc494f4867291270b26d3
Author: Fabio Utzig <ut...@apache.org>
AuthorDate: Mon Aug 6 12:18:05 2018 -0300

    Update flash drivers to declare erased value
---
 hw/bsp/nucleo-f401re/src/hal_bsp.c                 | 3 ++-
 hw/bsp/nucleo-f413zh/src/hal_bsp.c                 | 3 ++-
 hw/bsp/olimex_stm32-e407_devboard/src/hal_bsp.c    | 3 ++-
 hw/bsp/stm32f429discovery/src/hal_bsp.c            | 3 ++-
 hw/bsp/stm32f4discovery/src/hal_bsp.c              | 3 ++-
 hw/mcu/ambiq/apollo2/src/hal_flash.c               | 3 ++-
 hw/mcu/microchip/pic32mx470f512h/src/hal_flash.c   | 3 ++-
 hw/mcu/microchip/pic32mz2048efg100/src/hal_flash.c | 3 ++-
 hw/mcu/native/src/hal_flash.c                      | 1 +
 hw/mcu/nordic/nrf51xxx/src/hal_flash.c             | 3 ++-
 hw/mcu/nordic/nrf52xxx/src/hal_flash.c             | 3 ++-
 hw/mcu/nxp/MK64F12/src/hal_flash.c                 | 3 ++-
 hw/mcu/sifive/fe310/src/hal_flash.c                | 3 ++-
 hw/mcu/stm/stm32f1xx/src/hal_flash.c               | 1 +
 hw/mcu/stm/stm32f3xx/src/hal_flash.c               | 1 +
 hw/mcu/stm/stm32f7xx/src/hal_flash.c               | 3 ++-
 hw/mcu/stm/stm32l1xx/src/hal_flash.c               | 1 +
 hw/mcu/stm/stm32l4xx/src/hal_flash.c               | 1 +
 18 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/hw/bsp/nucleo-f401re/src/hal_bsp.c b/hw/bsp/nucleo-f401re/src/hal_bsp.c
index 0aa64b7..fbc6ef2 100644
--- a/hw/bsp/nucleo-f401re/src/hal_bsp.c
+++ b/hw/bsp/nucleo-f401re/src/hal_bsp.c
@@ -60,7 +60,8 @@ const struct hal_flash stm32f4_flash_dev = {
     .hf_base_addr = 0x08000000,
     .hf_size = 512 * 1024,
     .hf_sector_cnt = NAREAS - 1,
-    .hf_align = 1
+    .hf_align = 1,
+    .hf_erased_val = 0xff,
 };
 
 #if MYNEWT_VAL(UART_0)
diff --git a/hw/bsp/nucleo-f413zh/src/hal_bsp.c b/hw/bsp/nucleo-f413zh/src/hal_bsp.c
index 66beeb4..eb2e56e 100644
--- a/hw/bsp/nucleo-f413zh/src/hal_bsp.c
+++ b/hw/bsp/nucleo-f413zh/src/hal_bsp.c
@@ -69,7 +69,8 @@ const struct hal_flash stm32f4_flash_dev = {
     .hf_base_addr = 0x08000000,
     .hf_size = 1536 * 1024,
     .hf_sector_cnt = NAREAS - 1,
-    .hf_align = 1
+    .hf_align = 1,
+    .hf_erased_val = 0xff,
 };
 
 #if MYNEWT_VAL(UART_0)
diff --git a/hw/bsp/olimex_stm32-e407_devboard/src/hal_bsp.c b/hw/bsp/olimex_stm32-e407_devboard/src/hal_bsp.c
index c290495..818e5c4 100644
--- a/hw/bsp/olimex_stm32-e407_devboard/src/hal_bsp.c
+++ b/hw/bsp/olimex_stm32-e407_devboard/src/hal_bsp.c
@@ -77,7 +77,8 @@ const struct hal_flash stm32f4_flash_dev = {
     .hf_base_addr = 0x08000000,
     .hf_size = 1024 * 1024,
     .hf_sector_cnt = NAREAS - 1,
-    .hf_align = 1
+    .hf_align = 1,
+    .hf_erased_val = 0xff,
 };
 
 #if MYNEWT_VAL(TRNG)
diff --git a/hw/bsp/stm32f429discovery/src/hal_bsp.c b/hw/bsp/stm32f429discovery/src/hal_bsp.c
index 9d8f4ea..c5a4a3c 100644
--- a/hw/bsp/stm32f429discovery/src/hal_bsp.c
+++ b/hw/bsp/stm32f429discovery/src/hal_bsp.c
@@ -78,7 +78,8 @@ const struct hal_flash stm32f4_flash_dev = {
     .hf_base_addr = 0x08000000,
     .hf_size = 2048 * 1024,
     .hf_sector_cnt = NAREAS - 1,
-    .hf_align = 1
+    .hf_align = 1,
+    .hf_erased_val = 0xff,
 };
 
 #if MYNEWT_VAL(UART_0)
diff --git a/hw/bsp/stm32f4discovery/src/hal_bsp.c b/hw/bsp/stm32f4discovery/src/hal_bsp.c
index 7e2075b..4f9d35d 100644
--- a/hw/bsp/stm32f4discovery/src/hal_bsp.c
+++ b/hw/bsp/stm32f4discovery/src/hal_bsp.c
@@ -66,7 +66,8 @@ const struct hal_flash stm32f4_flash_dev = {
     .hf_base_addr = 0x08000000,
     .hf_size = 1024 * 1024,
     .hf_sector_cnt = NAREAS - 1,
-    .hf_align = 1
+    .hf_align = 1,
+    .hf_erased_val = 0xff,
 };
 
 #if MYNEWT_VAL(UART_0)
diff --git a/hw/mcu/ambiq/apollo2/src/hal_flash.c b/hw/mcu/ambiq/apollo2/src/hal_flash.c
index bf0582b..ea050d0 100644
--- a/hw/mcu/ambiq/apollo2/src/hal_flash.c
+++ b/hw/mcu/ambiq/apollo2/src/hal_flash.c
@@ -53,7 +53,8 @@ const struct hal_flash apollo2_flash_dev = {
         .hf_base_addr = 0x00000000,
         .hf_size = 1024 * 1024,
         .hf_sector_cnt = 128,
-        .hf_align = 1
+        .hf_align = 1,
+        .hf_erased_val = 0xff,
 };
 
 static int
diff --git a/hw/mcu/microchip/pic32mx470f512h/src/hal_flash.c b/hw/mcu/microchip/pic32mx470f512h/src/hal_flash.c
index 179ef94..5197405 100644
--- a/hw/mcu/microchip/pic32mx470f512h/src/hal_flash.c
+++ b/hw/mcu/microchip/pic32mx470f512h/src/hal_flash.c
@@ -56,9 +56,10 @@ const struct hal_flash pic32mx_flash_dev = {
     .hf_base_addr = 0x1D000000,
     .hf_size = 512 * 1024,
     .hf_sector_cnt = 128,
-    .hf_align = 4      /* num bytes must be a multiple of 4 as writes can only
+    .hf_align = 4,     /* num bytes must be a multiple of 4 as writes can only
                         * be done on word boundary.
                         */
+    .hf_erased_val = 0xff,
 };
 
 static int
diff --git a/hw/mcu/microchip/pic32mz2048efg100/src/hal_flash.c b/hw/mcu/microchip/pic32mz2048efg100/src/hal_flash.c
index 78f1d1f..75f47b4 100644
--- a/hw/mcu/microchip/pic32mz2048efg100/src/hal_flash.c
+++ b/hw/mcu/microchip/pic32mz2048efg100/src/hal_flash.c
@@ -56,10 +56,11 @@ const struct hal_flash pic32mz_flash_dev = {
     .hf_base_addr = 0x1D000000,
     .hf_size = 2048 * 1024,
     .hf_sector_cnt = 128,
-    .hf_align = 4      /* num bytes must be a multiple of 4 as writes can only
+    .hf_align = 4,     /* num bytes must be a multiple of 4 as writes can only
                         * be done on word boundary. This also assumes that
                         * ECC memory is disabled (default on Wi-Fire board).
                         */
+    .hf_erased_val = 0xff,
 };
 
 static int
diff --git a/hw/mcu/native/src/hal_flash.c b/hw/mcu/native/src/hal_flash.c
index 9513432..e3dde50 100644
--- a/hw/mcu/native/src/hal_flash.c
+++ b/hw/mcu/native/src/hal_flash.c
@@ -81,6 +81,7 @@ const struct hal_flash native_flash_dev = {
     .hf_size = 1024 * 1024,
     .hf_sector_cnt = FLASH_NUM_AREAS,
     .hf_align = MYNEWT_VAL(MCU_FLASH_MIN_WRITE_SIZE),
+    .hf_erased_val = 0xff,
 };
 
 static void
diff --git a/hw/mcu/nordic/nrf51xxx/src/hal_flash.c b/hw/mcu/nordic/nrf51xxx/src/hal_flash.c
index dc52da8..6ac0cee 100644
--- a/hw/mcu/nordic/nrf51xxx/src/hal_flash.c
+++ b/hw/mcu/nordic/nrf51xxx/src/hal_flash.c
@@ -50,7 +50,8 @@ const struct hal_flash nrf51_flash_dev = {
     .hf_base_addr = 0x00000000,
     .hf_size = 256 * 1024,	/* XXX read from factory info? */
     .hf_sector_cnt = 256,	/* XXX read from factory info? */
-    .hf_align = 1
+    .hf_align = 1,
+    .hf_erased_val = 0xff,
 };
 
 #define NRF51_FLASH_READY() (NRF_NVMC->READY == NVMC_READY_READY_Ready)
diff --git a/hw/mcu/nordic/nrf52xxx/src/hal_flash.c b/hw/mcu/nordic/nrf52xxx/src/hal_flash.c
index 50edd54..e42a540 100644
--- a/hw/mcu/nordic/nrf52xxx/src/hal_flash.c
+++ b/hw/mcu/nordic/nrf52xxx/src/hal_flash.c
@@ -49,7 +49,8 @@ const struct hal_flash nrf52k_flash_dev = {
     .hf_base_addr = 0x00000000,
     .hf_size = 1024 * 1024,	/* XXX read from factory info? */
     .hf_sector_cnt = 256,	/* XXX read from factory info? */
-    .hf_align = 1
+    .hf_align = 1,
+    .hf_erased_val = 0xff,
 };
 #elif defined(NRF52810_XXAA)
 const struct hal_flash nrf52k_flash_dev = {
diff --git a/hw/mcu/nxp/MK64F12/src/hal_flash.c b/hw/mcu/nxp/MK64F12/src/hal_flash.c
index 083dc29..b2ba1c6 100644
--- a/hw/mcu/nxp/MK64F12/src/hal_flash.c
+++ b/hw/mcu/nxp/MK64F12/src/hal_flash.c
@@ -61,7 +61,8 @@ static flash_config_t mk64f12_config;
 struct hal_flash mk64f12_flash_dev = {
     /* Most items are set after FLASH_Init() */
     .hf_itf = &mk64f12_flash_funcs,
-    .hf_align = MK64F12_FLASH_ALIGN
+    .hf_align = MK64F12_FLASH_ALIGN,
+    .hf_erased_val = 0xff,
 };
 
 static int
diff --git a/hw/mcu/sifive/fe310/src/hal_flash.c b/hw/mcu/sifive/fe310/src/hal_flash.c
index 2591c91..68cc7c8 100644
--- a/hw/mcu/sifive/fe310/src/hal_flash.c
+++ b/hw/mcu/sifive/fe310/src/hal_flash.c
@@ -50,7 +50,8 @@ const struct hal_flash fe310_flash_dev = {
     .hf_base_addr = 0x20000000,
     .hf_size = 8 * 1024 * 1024,  /* XXX read from factory info? */
     .hf_sector_cnt = 4096,       /* XXX read from factory info? */
-    .hf_align = 1
+    .hf_align = 1,
+    .hf_erased_val = 0xff,
 };
 
 #define FLASH_CMD_READ_STATUS_REGISTER 0x05
diff --git a/hw/mcu/stm/stm32f1xx/src/hal_flash.c b/hw/mcu/stm/stm32f1xx/src/hal_flash.c
index 4c63e18..78a29ba 100644
--- a/hw/mcu/stm/stm32f1xx/src/hal_flash.c
+++ b/hw/mcu/stm/stm32f1xx/src/hal_flash.c
@@ -50,6 +50,7 @@ const struct hal_flash stm32f1_flash_dev = {
     .hf_size = _FLASH_SIZE,
     .hf_sector_cnt = _FLASH_SIZE / _FLASH_SECTOR_SIZE,
     .hf_align = 2,
+    .hf_erased_val = 0xff,
 };
 
 static int
diff --git a/hw/mcu/stm/stm32f3xx/src/hal_flash.c b/hw/mcu/stm/stm32f3xx/src/hal_flash.c
index 4c8c144..98d8fe8 100644
--- a/hw/mcu/stm/stm32f3xx/src/hal_flash.c
+++ b/hw/mcu/stm/stm32f3xx/src/hal_flash.c
@@ -127,6 +127,7 @@ stm32f3_flash_dev()
         stm32f3_flash_dev_.hf_size = HAL_FLASH_SIZE;
         stm32f3_flash_dev_.hf_sector_cnt = HAL_FLASH_SIZE / HAL_FLASH_SECTOR_SIZE;
         stm32f3_flash_dev_.hf_align = 2;
+        stm32f3_flash_dev_.hf_erased_val = 0xff;
     }
     return &stm32f3_flash_dev_;
 }
diff --git a/hw/mcu/stm/stm32f7xx/src/hal_flash.c b/hw/mcu/stm/stm32f7xx/src/hal_flash.c
index 720cad3..017c722 100644
--- a/hw/mcu/stm/stm32f7xx/src/hal_flash.c
+++ b/hw/mcu/stm/stm32f7xx/src/hal_flash.c
@@ -66,7 +66,8 @@ const struct hal_flash stm32f7_flash_dev = {
     .hf_base_addr = 0x08000000,
     .hf_size = 2 * 1024 * 1024,
     .hf_sector_cnt = STM32F7_FLASH_NUM_AREAS - 1,
-    .hf_align = 1
+    .hf_align = 1,
+    .hf_erased_val = 0xff,
 };
 
 static int
diff --git a/hw/mcu/stm/stm32l1xx/src/hal_flash.c b/hw/mcu/stm/stm32l1xx/src/hal_flash.c
index 4a4dfc6..d0b6af6 100644
--- a/hw/mcu/stm/stm32l1xx/src/hal_flash.c
+++ b/hw/mcu/stm/stm32l1xx/src/hal_flash.c
@@ -52,6 +52,7 @@ const struct hal_flash stm32l1_flash_dev = {
     .hf_size = _FLASH_SIZE,
     .hf_sector_cnt = _FLASH_SIZE / _FLASH_SECTOR_SIZE,
     .hf_align = MYNEWT_VAL(MCU_FLASH_MIN_WRITE_SIZE),
+    .hf_erased_val = 0,
 };
 
 static int
diff --git a/hw/mcu/stm/stm32l4xx/src/hal_flash.c b/hw/mcu/stm/stm32l4xx/src/hal_flash.c
index bbe5a42..07d2745 100644
--- a/hw/mcu/stm/stm32l4xx/src/hal_flash.c
+++ b/hw/mcu/stm/stm32l4xx/src/hal_flash.c
@@ -51,6 +51,7 @@ const struct hal_flash stm32l4_flash_dev = {
     .hf_size = _FLASH_SIZE,
     .hf_sector_cnt = _FLASH_SIZE / _FLASH_SECTOR_SIZE,
     .hf_align = 8,
+    .hf_erased_val = 0xff,
 };
 
 static int