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 2016/02/02 03:26:17 UTC

[2/3] incubator-mynewt-larva git commit: Add flash_map, internal flash to NRF52 BSP.

Add flash_map, internal flash to NRF52 BSP.


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/f8cd4145
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/f8cd4145
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/f8cd4145

Branch: refs/heads/master
Commit: f8cd4145aa751efabdbfc539d3a06f7f537826ad
Parents: fe944eb
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Mon Feb 1 18:24:32 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Feb 1 18:24:32 2016 -0800

----------------------------------------------------------------------
 hw/bsp/nrf52pdk/include/bsp/bsp.h              |  2 +
 hw/bsp/nrf52pdk/src/hal_bsp.c                  | 16 ++++++-
 hw/bsp/nrf52pdk/src/os_bsp.c                   | 50 +++++++++++++++++++++
 hw/mcu/nordic/nrf52xxx/include/mcu/nrf52_hal.h |  3 ++
 4 files changed, 70 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f8cd4145/hw/bsp/nrf52pdk/include/bsp/bsp.h
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52pdk/include/bsp/bsp.h b/hw/bsp/nrf52pdk/include/bsp/bsp.h
index 9708b6b..0987c69 100644
--- a/hw/bsp/nrf52pdk/include/bsp/bsp.h
+++ b/hw/bsp/nrf52pdk/include/bsp/bsp.h
@@ -35,6 +35,8 @@ extern "C" {
 /* UART info */
 #define CONSOLE_UART    0
 
+int bsp_imgr_current_slot(void);
+
 #ifdef __cplusplus
 }
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f8cd4145/hw/bsp/nrf52pdk/src/hal_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52pdk/src/hal_bsp.c b/hw/bsp/nrf52pdk/src/hal_bsp.c
index a016232..e722515 100644
--- a/hw/bsp/nrf52pdk/src/hal_bsp.c
+++ b/hw/bsp/nrf52pdk/src/hal_bsp.c
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 #include <stdint.h>
+#include <stddef.h>
 #include "mcu/nrf52_hal.h"
 
 static const struct nrf52_uart_cfg uart_cfg = {
@@ -23,7 +24,20 @@ static const struct nrf52_uart_cfg uart_cfg = {
     .suc_pin_cts = 7
 };
 
-const struct nrf52_uart_cfg *bsp_uart_config(void)
+const struct nrf52_uart_cfg *
+bsp_uart_config(void)
 {
     return &uart_cfg;
 }
+
+const struct hal_flash *
+bsp_flash_dev(uint8_t id)
+{
+    /*
+     * Internal flash mapped to id 0.
+     */
+    if (id != 0) {
+        return NULL;
+    }
+    return &nrf52k_flash_dev;
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f8cd4145/hw/bsp/nrf52pdk/src/os_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52pdk/src/os_bsp.c b/hw/bsp/nrf52pdk/src/os_bsp.c
index 833cfb9..71b93a3 100644
--- a/hw/bsp/nrf52pdk/src/os_bsp.c
+++ b/hw/bsp/nrf52pdk/src/os_bsp.c
@@ -13,9 +13,56 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+#include <hal/flash_map.h>
+
+static struct flash_area bsp_flash_areas[] = {
+#if 0
+    [FLASH_AREA_BOOTLOADER] = {
+        .fa_flash_id = 0,       /* internal flash */
+        .fa_off = 0x08000000,   /* beginning */
+        .fa_size = (32 * 1024)
+    },
+#endif
+    /* 2 * 16K and 1*64K sectors here */
+    [FLASH_AREA_IMAGE_0] = {
+        .fa_flash_id = 0,
+        .fa_off = 0x00000000,
+        .fa_size = (232 * 1024)
+    },
+    [FLASH_AREA_IMAGE_1] = {
+        .fa_flash_id = 0,
+        .fa_off = 0x00042000,
+        .fa_size = (232 * 1024)
+    },
+    [FLASH_AREA_IMAGE_SCRATCH] = {
+        .fa_flash_id = 0,
+        .fa_off = 0x0007c000,
+        .fa_size = (4 * 1024)
+    },
+    [FLASH_AREA_NFFS] = {
+        .fa_flash_id = 0,
+        .fa_off = 0x0007d000,
+        .fa_size = (12 * 1024)
+    }
+};
+
 void *_sbrk(int incr);
 void _close(int fd);
 
+/*
+ * Returns the flash map slot where the currently active image is located.
+ * If executing from internal flash from fixed location, that slot would
+ * be easy to find.
+ * If images are in external flash, and copied to RAM for execution, then
+ * this routine would have to figure out which one of those slots is being
+ * used.
+ */
+int
+bsp_imgr_current_slot(void)
+{
+    return FLASH_AREA_IMAGE_0;
+}
+
 void
 os_bsp_init(void)
 {
@@ -24,4 +71,7 @@ os_bsp_init(void)
      */
     _sbrk(0);
     _close(0);
+
+    flash_area_init(bsp_flash_areas,
+      sizeof(bsp_flash_areas) / sizeof(bsp_flash_areas[0]));
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f8cd4145/hw/mcu/nordic/nrf52xxx/include/mcu/nrf52_hal.h
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf52xxx/include/mcu/nrf52_hal.h b/hw/mcu/nordic/nrf52xxx/include/mcu/nrf52_hal.h
index afd584b..2dc7d77 100755
--- a/hw/mcu/nordic/nrf52xxx/include/mcu/nrf52_hal.h
+++ b/hw/mcu/nordic/nrf52xxx/include/mcu/nrf52_hal.h
@@ -43,6 +43,9 @@ struct nrf52_uart_cfg {
 };
 const struct nrf52_uart_cfg *bsp_uart_config(void);
 
+struct hal_flash;
+extern const struct hal_flash nrf52k_flash_dev;
+
 #ifdef __cplusplus
 }
 #endif