You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2018/03/14 18:49:46 UTC

[mynewt-mcumgr] 03/03: [zephyr] Use new VFS API for file system init.

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

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

commit ad556b30243f53ef51caf3199c26e114bc7d39ad
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Wed Mar 14 11:49:14 2018 -0700

    [zephyr] Use new VFS API for file system init.
---
 samples/smp_svr/zephyr/src/main.c | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/samples/smp_svr/zephyr/src/main.c b/samples/smp_svr/zephyr/src/main.c
index 5dfc540..bfb325a 100644
--- a/samples/smp_svr/zephyr/src/main.c
+++ b/samples/smp_svr/zephyr/src/main.c
@@ -16,6 +16,8 @@
 #include <mgmt/buf.h>
 
 #ifdef CONFIG_MCUMGR_CMD_FS_MGMT
+#include <device.h>
+#include <fs.h>
 #include "fs_mgmt/fs_mgmt.h"
 #endif
 #ifdef CONFIG_MCUMGR_CMD_OS_MGMT
@@ -44,6 +46,16 @@ STATS_NAME_END(smp_svr_stats);
 /* Define an instance of the stats group. */
 STATS_SECT_DECL(smp_svr_stats) smp_svr_stats;
 
+#ifdef CONFIG_MCUMGR_CMD_FS_MGMT
+static struct nffs_flash_desc flash_desc;
+
+static struct fs_mount_t nffs_mnt = {
+	.type = FS_NFFS,
+	.mnt_point = "/nffs",
+	.fs_data = &flash_desc,
+};
+#endif
+
 static const struct bt_data ad[] = {
 	BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
 	BT_DATA_BYTES(BT_DATA_UUID128_ALL,
@@ -105,14 +117,28 @@ static void bt_ready(int err)
 
 void main(void)
 {
-    int rc;
+	struct device *flash_dev;
+	int rc;
 
 	rc = STATS_INIT_AND_REG(smp_svr_stats, STATS_SIZE_32, "smp_svr_stats");
 	assert(rc == 0);
 
 	/* Register the built-in mcumgr command handlers. */
 #ifdef CONFIG_MCUMGR_CMD_FS_MGMT
-    fs_mgmt_register_group();
+	flash_dev = device_get_binding(CONFIG_FS_NFFS_FLASH_DEV_NAME);
+	if (!flash_dev) {
+        printk("Error getting NFFS flash device binding\n");
+	} else {
+		/* set backend storage dev */
+		nffs_mnt.storage_dev = flash_dev;
+
+		rc = fs_mount(&nffs_mnt);
+		if (rc < 0) {
+			printk("Error mounting nffs [%d]\n", rc);
+		}
+	}
+
+	fs_mgmt_register_group();
 #endif
 #ifdef CONFIG_MCUMGR_CMD_OS_MGMT
 	os_mgmt_register_group();

-- 
To stop receiving notification emails like this one, please contact
ccollins@apache.org.