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/12/07 21:06:14 UTC

[1/2] incubator-mynewt-larva git commit: Fix issues with generating a flash image with subdirectories in it. Use bigger write size thereby using less memory from NFFS.

Repository: incubator-mynewt-larva
Updated Branches:
  refs/heads/master b2066eaf6 -> 8adaa514b


Fix issues with generating a flash image with subdirectories in it.
Use bigger write size thereby using less memory from NFFS.


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

Branch: refs/heads/master
Commit: 5d3c6d7aae2d1add7ac909cbd8286b0f47f3831e
Parents: b2066ea
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Mon Dec 7 11:57:16 2015 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Dec 7 11:57:16 2015 -0800

----------------------------------------------------------------------
 project/ffs2native/src/main.c | 42 +++++++++++++++++++++++++++++---------
 1 file changed, 32 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/5d3c6d7a/project/ffs2native/src/main.c
----------------------------------------------------------------------
diff --git a/project/ffs2native/src/main.c b/project/ffs2native/src/main.c
index 395103a..b2fecd5 100644
--- a/project/ffs2native/src/main.c
+++ b/project/ffs2native/src/main.c
@@ -87,7 +87,7 @@ print_inode_entry(struct nffs_inode_entry *inode_entry, int indent)
 
     name[inode.ni_filename_len] = '\0';
 
-    printf("%*s%s\n", indent, "", name);
+    printf("%*s%s\n", indent, "", name[0] == '\0' ? "/" : name);
 }
 
 static void
@@ -107,16 +107,18 @@ process_inode_entry(struct nffs_inode_entry *inode_entry, int indent)
 static void
 printfs(void)
 {
+    printf("\n\nNFFS contents:\n");
     process_inode_entry(nffs_root_dir, 0);
 }
 
-void
+static int
 copy_in_file(char *src, char *dst)
 {
     struct fs_file *nf;
     FILE *fp;
     int rc;
-    char data[32];
+    char data[2048];
+    int ret = 0;
 
     rc = fs_open(dst, FS_ACCESS_WRITE, &nf);
     assert(rc == 0);
@@ -128,10 +130,15 @@ copy_in_file(char *src, char *dst)
     }
     while ((rc = fread(data, 1, sizeof(data), fp))) {
         rc = fs_write(nf, data, rc);
-        assert(rc == 0);
+        if (rc) {
+            ret = rc;
+            break;
+        }
     }
     rc = fs_close(nf);
     assert(rc == 0);
+    fclose(fp);
+    return ret;
 }
 
 void
@@ -149,15 +156,30 @@ copy_in_directory(const char *src, const char *dst)
         usage(1);
     }
     while ((entry = readdir(dr))) {
-            snprintf(src_name, sizeof(src_name), "%s/%s", src, entry->d_name);
-            snprintf(dst_name, sizeof(dst_name), "%s/%s", dst, entry->d_name);
+        snprintf(src_name, sizeof(src_name), "%s/%s", src, entry->d_name);
+        snprintf(dst_name, sizeof(dst_name), "%s/%s", dst, entry->d_name);
         if (entry->d_type == DT_DIR &&
-          !strcmp(entry->d_name, ".") && !strcmp(entry->d_name, "..")) {
-            copy_in_directory(src_name, dst_name);
+          strcmp(entry->d_name, ".") && strcmp(entry->d_name, "..")) {
             rc = fs_mkdir(dst_name);
+            copy_in_directory(src_name, dst_name);
             assert(rc == 0);
         } else if (entry->d_type == DT_REG) {
-            copy_in_file(src_name, dst_name);
+            printf("Copying %s\n", dst_name);
+            rc = copy_in_file(src_name, dst_name);
+            if (rc) {
+                printf("  error code %d ", rc);
+                switch (rc) {
+                case FS_ENOMEM:
+                    printf("out of memory\n");
+                    break;
+                case FS_EFULL:
+                    printf("disk is full\n");
+                    break;
+                default:
+                    printf("\n");
+                }
+                break;
+            }
         } else {
             printf("Skipping %s\n", src_name);
         }
@@ -222,7 +244,7 @@ main(int argc, char **argv)
          */
         rc = nffs_format(area_descs);
         assert(rc == 0);
-        copy_in_directory(copy_in_dir, "/");
+        copy_in_directory(copy_in_dir, "");
     } else {
         rc = nffs_detect(area_descs);
         if (rc) {


[2/2] incubator-mynewt-larva git commit: Now the NFFS array size has to be initialized before calling flash_area_to_nffs_desc().

Posted by ma...@apache.org.
Now the NFFS array size has to be initialized before calling
flash_area_to_nffs_desc().


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

Branch: refs/heads/master
Commit: 8adaa514b52b50c56b1647b02707bef5ee9f9198
Parents: 5d3c6d7
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Mon Dec 7 12:05:29 2015 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Dec 7 12:05:29 2015 -0800

----------------------------------------------------------------------
 project/luatest/src/main.c | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/8adaa514/project/luatest/src/main.c
----------------------------------------------------------------------
diff --git a/project/luatest/src/main.c b/project/luatest/src/main.c
index e31075b..733bc4f 100755
--- a/project/luatest/src/main.c
+++ b/project/luatest/src/main.c
@@ -100,6 +100,7 @@ main(int argc, char **argv)
 
     nffs_init();
 
+    cnt = NFFS_AREA_MAX;
     rc = flash_area_to_nffs_desc(FLASH_AREA_NFFS, &cnt, descs);
     assert(rc == 0);