You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/05/17 12:13:59 UTC
[incubator-nuttx-apps] branch master updated: Apps Issue
#246:Replace romdisk_register() with boardctl(BOARDIOC_ROMDISK) files
changed: examples/nxflat/nxflat_main.c examples/thttpd/thttpd_main.c
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new ab41d23 Apps Issue #246:Replace romdisk_register() with boardctl(BOARDIOC_ROMDISK) files changed: examples/nxflat/nxflat_main.c examples/thttpd/thttpd_main.c
ab41d23 is described below
commit ab41d23d7c1d89ae59aa550aa0755adb5c9e7bea
Author: Tanushree Baindur <ta...@gmail.com>
AuthorDate: Thu May 13 23:37:30 2021 -0500
Apps Issue #246:Replace romdisk_register() with boardctl(BOARDIOC_ROMDISK)
files changed: examples/nxflat/nxflat_main.c
examples/thttpd/thttpd_main.c
examples/thttpd: Fix error: unused variable 'desc'
---
examples/nxflat/nxflat_main.c | 15 +++++++++++----
examples/thttpd/thttpd_main.c | 20 +++++++++++++++++---
2 files changed, 28 insertions(+), 7 deletions(-)
diff --git a/examples/nxflat/nxflat_main.c b/examples/nxflat/nxflat_main.c
index a853b6b..791e60e 100644
--- a/examples/nxflat/nxflat_main.c
+++ b/examples/nxflat/nxflat_main.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * examples/nxflat/nxflat_main.c
+ * apps/examples/nxflat/nxflat_main.c
*
* Copyright (C) 2009, 2011, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gn...@nuttx.org>
@@ -41,6 +41,7 @@
#include <nuttx/compiler.h>
#include <sys/mount.h>
+#include <sys/boardctl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -153,12 +154,18 @@ int main(int argc, FAR char *argv[])
FAR char *args[1];
int ret;
int i;
+ struct boardioc_romdisk_s desc;
/* Create a ROM disk for the ROMFS filesystem */
message("Registering romdisk\n");
- ret = romdisk_register(0, (FAR uint8_t *)romfs_img,
- NSECTORS(romfs_img_len), SECTORSIZE);
+
+ desc.minor = 0; /* Minor device number of the ROM disk. */
+ desc.nsectors = NSECTORS(romfs_img_len); /* The number of sectors in the ROM disk */
+ desc.sectsize = SECTORSIZE; /* The size of one sector in bytes */
+ desc.image = (FAR uint8_t *)romfs_img; /* File system image */
+
+ ret = boardctl(BOARDIOC_ROMDISK, (uintptr_t)&desc);
if (ret < 0)
{
errmsg("ERROR: romdisk_register failed: %d\n", ret);
@@ -173,7 +180,7 @@ int main(int argc, FAR char *argv[])
ret = mount(ROMFSDEV, MOUNTPT, "romfs", MS_RDONLY, NULL);
if (ret < 0)
{
- errmsg("ERROR: mount(%s,%s,romfs) failed: %s\n",
+ errmsg("ERROR: mount(%s,%s,romfs) failed: %d\n",
ROMFSDEV, MOUNTPT, errno);
}
diff --git a/examples/thttpd/thttpd_main.c b/examples/thttpd/thttpd_main.c
index 1b4dff3..d350084 100644
--- a/examples/thttpd/thttpd_main.c
+++ b/examples/thttpd/thttpd_main.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * examples/thttpd/thttpd_main.c
+ * apps/examples/thttpd/thttpd_main.c
*
* Copyright (C) 2009-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gn...@nuttx.org>
@@ -59,6 +59,10 @@
#include <nuttx/drivers/ramdisk.h>
+#ifdef CONFIG_THTTPD_NXFLAT
+# include <sys/boardctl.h>
+#endif
+
#ifdef CONFIG_THTTPD_BINFS
# include <nuttx/fs/unionfs.h>
#endif
@@ -204,6 +208,9 @@ int main(int argc, FAR char *argv[])
#endif
char *thttpd_argv = "thttpd";
int ret;
+#ifdef CONFIG_THTTPD_NXFLAT
+ struct boardioc_romdisk_s desc;
+#endif
/* Configure SLIP */
@@ -252,12 +259,18 @@ int main(int argc, FAR char *argv[])
netlib_ifup("eth0");
+#ifdef CONFIG_THTTPD_NXFLAT
/* Create a ROM disk for the ROMFS filesystem */
printf("Registering romdisk\n");
- ret = romdisk_register(0, (uint8_t *)romfs_img, NSECTORS(romfs_img_len),
- SECTORSIZE);
+ desc.minor = 0; /* Minor device number of the ROM disk. */
+ desc.nsectors = NSECTORS(romfs_img_len); /* The number of sectors in the ROM disk */
+ desc.sectsize = SECTORSIZE; /* The size of one sector in bytes */
+ desc.image = (FAR uint8_t *)romfs_img; /* File system image */
+
+ ret = boardctl(BOARDIOC_ROMDISK, (uintptr_t)&desc);
+
if (ret < 0)
{
printf("ERROR: romdisk_register failed: %d\n", ret);
@@ -275,6 +288,7 @@ int main(int argc, FAR char *argv[])
printf("ERROR: mount(%s,%s,romfs) failed: %d\n",
ROMFSDEV, ROMFS_MOUNTPT, errno);
}
+#endif
#ifdef CONFIG_THTTPD_BINFS
/* Mount the BINFS file system */