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/19 01:12:16 UTC
[03/14] incubator-mynewt-larva git commit: Add NFFS area identifier
to flash map. Add flash_area_to_nffs_desc(),
which returns flash region in a format suitable for NFFS APIs.
Add NFFS area identifier to flash map.
Add flash_area_to_nffs_desc(), which returns flash region in a
format suitable for NFFS APIs.
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/d942da38
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/d942da38
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/d942da38
Branch: refs/heads/master
Commit: d942da384909ca03c101f7ed7878cf371c7be9b4
Parents: bd60282
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Nov 18 15:43:00 2015 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Nov 18 15:43:00 2015 -0800
----------------------------------------------------------------------
hw/bsp/native/src/os_bsp.c | 6 ++++
hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c | 5 +++
libs/nffs/egg.yml | 7 ++--
libs/util/egg.yml | 11 +++---
libs/util/include/util/flash_map.h | 7 ++++
libs/util/src/flash_map.c | 38 +++++++++++++++++++++
6 files changed, 67 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/d942da38/hw/bsp/native/src/os_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/native/src/os_bsp.c b/hw/bsp/native/src/os_bsp.c
index a632c86..cc414da 100644
--- a/hw/bsp/native/src/os_bsp.c
+++ b/hw/bsp/native/src/os_bsp.c
@@ -36,7 +36,13 @@ static struct flash_area bsp_flash_areas[] = {
.fa_flash_id = 0,
.fa_off = 0x000e0000,
.fa_size = (128 * 1024)
+ },
+ [FLASH_AREA_NFFS] = {
+ .fa_flash_id = 0,
+ .fa_off = 0x00008000,
+ .fa_size = (32 * 1024)
}
+
};
void os_bsp_init(void)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/d942da38/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c b/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c
index 353061d..72f3385 100644
--- a/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c
+++ b/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c
@@ -40,6 +40,11 @@ static struct flash_area bsp_flash_areas[] = {
.fa_flash_id = 0,
.fa_off = 0x080e0000,
.fa_size = (128 * 1024)
+ },
+ [FLASH_AREA_NFFS] = {
+ .fa_flash_id = 0,
+ .fa_off = 0x08008000,
+ .fa_size = (32 * 1024)
}
};
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/d942da38/libs/nffs/egg.yml
----------------------------------------------------------------------
diff --git a/libs/nffs/egg.yml b/libs/nffs/egg.yml
index cbedd96..0ad83d8 100644
--- a/libs/nffs/egg.yml
+++ b/libs/nffs/egg.yml
@@ -1,6 +1,7 @@
egg.name: libs/nffs
-egg.vers: 0.1
-egg.deps:
- - libs/os
+egg.vers: 0.1
+egg.identities: NFFS
+egg.deps:
+ - libs/os
- libs/testutil
- hw/hal
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/d942da38/libs/util/egg.yml
----------------------------------------------------------------------
diff --git a/libs/util/egg.yml b/libs/util/egg.yml
index 2891aa3..3faef1b 100644
--- a/libs/util/egg.yml
+++ b/libs/util/egg.yml
@@ -1,10 +1,13 @@
-egg.name: libs/util
+egg.name: libs/util
egg.vers: 0.1
egg.deps:
- hw/hal
- libs/os
- libs/testutil
egg.deps.SHELL:
- - libs/console/full
- - libs/shell
-egg.cflags.SHELL: -DSHELL_PRESENT
+ - libs/console/full
+ - libs/shell
+egg.cflags.SHELL: -DSHELL_PRESENT
+egg.deps.NFFS:
+ - libs/nffs
+egg.cflags.NFFS: -DNFFS_PRESENT
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/d942da38/libs/util/include/util/flash_map.h
----------------------------------------------------------------------
diff --git a/libs/util/include/util/flash_map.h b/libs/util/include/util/flash_map.h
index d0b7aec..3b77c86 100644
--- a/libs/util/include/util/flash_map.h
+++ b/libs/util/include/util/flash_map.h
@@ -50,6 +50,7 @@ struct flash_area {
#define FLASH_AREA_IMAGE_0 1
#define FLASH_AREA_IMAGE_1 2
#define FLASH_AREA_IMAGE_SCRATCH 3
+#define FLASH_AREA_NFFS 4
/*
* Initializes flash map. Memory will be referenced by flash_map code
@@ -78,4 +79,10 @@ int flash_area_erase(const struct flash_area *, uint32_t off, uint32_t len);
*/
int flash_area_to_sectors(int idx, int *cnt, struct flash_area *ret);
+/*
+ * Given flash map index, return sector info in NFFS area desc format.
+ */
+struct nffs_area_desc;
+int flash_area_to_nffs_desc(int idx, int *cnt, struct nffs_area_desc *nad);
+
#endif /* H_UTIL_FLASH_MAP_ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/d942da38/libs/util/src/flash_map.c
----------------------------------------------------------------------
diff --git a/libs/util/src/flash_map.c b/libs/util/src/flash_map.c
index eb70a0f..b035b78 100644
--- a/libs/util/src/flash_map.c
+++ b/libs/util/src/flash_map.c
@@ -13,9 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <string.h>
#include <hal/hal_flash.h>
#include <hal/hal_flash_int.h>
+#ifdef NFFS_PRESENT
+#include <nffs/nffs.h>
+#endif
#include "util/flash_map.h"
static const struct flash_area *flash_map;
@@ -76,6 +80,40 @@ flash_area_to_sectors(int idx, int *cnt, struct flash_area *ret)
return 0;
}
+#ifdef NFFS_PRESENT
+int
+flash_area_to_nffs_desc(int idx, int *cnt, struct nffs_area_desc *nad)
+{
+ int i;
+ struct hal_flash *hf;
+ const struct flash_area *fa;
+
+ if (!flash_map || idx >= flash_map_entries) {
+ return -1;
+ }
+ *cnt = 0;
+ fa = &flash_map[idx];
+
+ hf = bsp_flash_dev(fa->fa_flash_id);
+ for (i = 0; i < hf->hf_sector_cnt; i++) {
+ if (hf->hf_sectors[i] >= fa->fa_off &&
+ hf->hf_sectors[i] < fa->fa_off + fa->fa_size) {
+ if (nad) {
+ nad->nad_flash_id = fa->fa_flash_id;
+ nad->nad_offset = hf->hf_sectors[i];
+ nad->nad_length = hal_flash_sector_size(hf, i);
+ nad++;
+ }
+ *cnt = *cnt + 1;
+ }
+ }
+ if (nad) {
+ memset(nad, 0, sizeof(*nad));
+ }
+ return 0;
+}
+#endif /* NFFS_PRESENT */
+
int
flash_area_read(const struct flash_area *fa, uint32_t off, void *dst,
uint32_t len)