Skip to content

Commit 385f707

Browse files
fxysunshinexiaoxiang781216
authored andcommitted
nshlib: move etc romfs mount from nsh to nuttx
This commit corresponds to apache/nuttx#11498 in nuttx. Move etc romfs mount to sched/init for compatibility with kernel/protected mode. changes: - move etc romfs mount from nsh to Nuttx, but keep the script to parse and execute. - move and rename the related CONFIG, move customized nsh_romfsimg.h to etc_romfs.c in boards, and no need declaration for romfs_img/romfs_img_len. Signed-off-by: fangxinyong <[email protected]>
1 parent c4e78cd commit 385f707

File tree

8 files changed

+15
-420
lines changed

8 files changed

+15
-420
lines changed

nshlib/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ if(CONFIG_NSH_LIBRARY)
6060
list(APPEND CSRCS nsh_vars.c)
6161
endif()
6262

63-
if(CONFIG_NSH_ROMFSETC)
64-
list(APPEND CSRCS nsh_romfsetc.c)
65-
endif()
66-
6763
if(CONFIG_NET)
6864
list(APPEND CSRCS nsh_netcmds.c)
6965

nshlib/Kconfig

Lines changed: 3 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ config NSH_LIBRARY
99
bool "NSH Library"
1010
default n
1111
select NETUTILS_NETLIB if NET
12-
select BOARDCTL if (!NSH_DISABLE_MKRD && !DISABLE_MOUNTPOINT) || NSH_ARCHINIT || NSH_ROMFSETC
12+
select BOARDCTL if (!NSH_DISABLE_MKRD && !DISABLE_MOUNTPOINT) || NSH_ARCHINIT
1313
select BOARDCTL_MKRD if !NSH_DISABLE_MKRD && !DISABLE_MOUNTPOINT
14-
select BOARDCTL_ROMDISK if NSH_ROMFSETC
1514
---help---
1615
Build the NSH support library. This is used, for example, by
1716
system/nsh in order to implement the full NuttShell (NSH).
@@ -793,29 +792,6 @@ config NSH_DISABLE_LOOPS
793792
systems where some minimal scripting is required but looping
794793
is not.
795794

796-
endif # !NSH_DISABLESCRIPT
797-
798-
config NSH_ROMFSETC
799-
bool "Support ROMFS start-up script"
800-
default n
801-
depends on FS_ROMFS
802-
---help---
803-
Mount a ROMFS filesystem at /etc and provide a system init
804-
script at /etc/init.d/rc.sysinit and a startup script
805-
at /etc/init.d/rcS. The default system init script will mount
806-
a FAT FS RAMDISK at /tmp but the logic is easily extensible.
807-
808-
if NSH_ROMFSETC
809-
810-
config NSH_CROMFSETC
811-
bool "Support CROMFS (compressed) start-up script"
812-
default n
813-
depends on FS_CROMFS
814-
---help---
815-
Mount a CROMFS filesystem at /etc and provide a compressed system
816-
init script at /etc/init.d/rc.sysinit and a startup script
817-
at /etc/init.d/rcS.
818-
819795
config NSH_ROMFSRC
820796
bool "Support ROMFS login script"
821797
default n
@@ -828,14 +804,6 @@ config NSH_ROMFSRC
828804
session. Selecting this option enables support for such a login
829805
script
830806

831-
config NSH_ROMFSMOUNTPT
832-
string "ROMFS mount point"
833-
default "/etc"
834-
---help---
835-
The default mountpoint for the ROMFS volume is /etc, but that
836-
can be changed with this setting. This must be a absolute path
837-
beginning with '/'.
838-
839807
config NSH_SYSINITSCRIPT
840808
string "Relative path to sysinit script"
841809
default "init.d/rc.sysinit"
@@ -861,106 +829,14 @@ config NSH_RCSCRIPT
861829
The default is .nshrc. This is a relative path and must not
862830
start with '/'.
863831

864-
config NSH_ROMFSDEVNO
865-
int "ROMFS block device minor number"
866-
default 0
867-
---help---
868-
This is the minor number of the ROMFS block device. The default is
869-
'0' corresponding to /dev/ram0.
870-
871-
config NSH_ROMFSSECTSIZE
872-
int "ROMFS sector size"
873-
default 64
874-
---help---
875-
This is the sector size to use with the ROMFS volume. Since the
876-
default volume is very small, this defaults to 64 but should be
877-
increased if the ROMFS volume were to be become large. Any value
878-
selected must be a power of 2.
879-
880-
choice
881-
prompt "ROMFS header location"
882-
default NSH_DEFAULTROMFS
883-
884-
config NSH_DEFAULTROMFS
885-
bool "Default ROMFS header path"
886-
---help---
887-
Selects the default header located in the source directory of the
888-
NSH library.
889-
890-
config NSH_ARCHROMFS
891-
bool "Architecture-specific ROMFS path"
892-
---help---
893-
Enable this option to provide an architecture-specific ROMFS
894-
header at arch/<boardname>/nsh_romfsimg.h. Note that this header
895-
will be linked (or copied) from nuttx/boards/<arch>/<chip>/<board>/include
896-
and should be stored at that location in the nuttx boards/
897-
sub-directory.
898-
899-
config NSH_CUSTOMROMFS
900-
bool "Custom ROMFS header path"
901-
---help---
902-
Enable this option to provide a custom ROMFS header. The path to
903-
the header file can be specified in the option "Custom ROMFS header
904-
file".
905-
906-
endchoice
907-
908-
if NSH_CUSTOMROMFS
909-
910-
config NSH_CUSTOMROMFS_HEADER
911-
string "Custom ROMFS header file path"
912-
default ""
913-
---help---
914-
Specifies the path to the custom ROMFS header file. This must be
915-
either a full path or a path relative to one of the include file
916-
search paths provided in your CFLAGS.
917-
918-
endif #NSH_CUSTOMROMFS
919-
920-
config NSH_FATDEVNO
921-
int "FAT block device minor number"
922-
default 1
923-
depends on FS_FAT
924-
---help---
925-
When the default rcS file used when NSH_ROMFSETC is selected, it
926-
will mount a FAT FS under /tmp. This is the minor number of the FAT
927-
FS block device. The default is '1' corresponding to /dev/ram1.
928-
929-
config NSH_FATSECTSIZE
930-
int "FAT sector size"
931-
default 512
932-
depends on FS_FAT
933-
---help---
934-
When the default rcS file used when NSH_ROMFSETC is selected, it
935-
will mount a FAT FS under /tmp. This is the sector size use with the
936-
FAT FS. Default is 512.
937-
938-
config NSH_FATNSECTORS
939-
int "FAT number of sectors"
940-
default 1024
941-
depends on FS_FAT
942-
---help---
943-
When the default rcS file used when NSH_ROMFSETC is selected, it
944-
will mount a FAT FS under /tmp. This is the number of sectors to use
945-
with the FAT FS. Default is 1024. The amount of memory used by the
946-
FAT FS will be NSH_FATSECTSIZE * NSH_FATNSECTORS bytes.
947-
948-
config NSH_FATMOUNTPT
949-
string "FAT mount point"
950-
default "/tmp"
951-
depends on FS_FAT
952-
---help---
953-
When the default rcS file used when NSH_ROMFSETC is selected, it
954-
will mount a FAT FS under /tmp. This is the location where the FAT
955-
FS will be mounted. Default is "/tmp".
956-
957832
config NSH_SCRIPT_REDIRECT_PATH
958833
string "rcS redirect output"
959834
default ""
960835
---help---
961836
This option can redirect rcS output.such as /dev/log or other.
962837

963-
endif # NSH_ROMFSETC
838+
endif # !NSH_DISABLESCRIPT
839+
964840
endmenu # Scripting Support
965841

966842
menu "Console Configuration"

nshlib/Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ ifeq ($(CONFIG_NSH_VARS),y)
4545
CSRCS += nsh_vars.c
4646
endif
4747

48-
ifeq ($(CONFIG_NSH_ROMFSETC),y)
49-
CSRCS += nsh_romfsetc.c
50-
endif
51-
5248
ifeq ($(CONFIG_NET),y)
5349
CSRCS += nsh_netcmds.c
5450

nshlib/nsh.h

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -287,20 +287,7 @@
287287

288288
/* Verify support for ROMFS /etc directory support options */
289289

290-
#ifdef CONFIG_NSH_ROMFSETC
291-
# ifdef CONFIG_DISABLE_MOUNTPOINT
292-
# error "Mountpoint support is disabled"
293-
# undef CONFIG_NSH_ROMFSETC
294-
# endif
295-
296-
# ifndef CONFIG_FS_ROMFS
297-
# error "ROMFS support not enabled"
298-
# undef CONFIG_NSH_ROMFSETC
299-
# endif
300-
301-
# ifndef CONFIG_NSH_ROMFSMOUNTPT
302-
# define CONFIG_NSH_ROMFSMOUNTPT "/etc"
303-
# endif
290+
#ifdef CONFIG_ETC_ROMFS
304291

305292
# ifndef CONFIG_NSH_SYSINITSCRIPT
306293
# define CONFIG_NSH_SYSINITSCRIPT "init.d/rc.sysinit"
@@ -311,41 +298,25 @@
311298
# endif
312299

313300
# undef NSH_SYSINITPATH
314-
# define NSH_SYSINITPATH CONFIG_NSH_ROMFSMOUNTPT "/" CONFIG_NSH_SYSINITSCRIPT
301+
# define NSH_SYSINITPATH CONFIG_ETC_ROMFSMOUNTPT "/" CONFIG_NSH_SYSINITSCRIPT
315302

316303
# undef NSH_INITPATH
317-
# define NSH_INITPATH CONFIG_NSH_ROMFSMOUNTPT "/" CONFIG_NSH_INITSCRIPT
304+
# define NSH_INITPATH CONFIG_ETC_ROMFSMOUNTPT "/" CONFIG_NSH_INITSCRIPT
318305

319306
# ifdef CONFIG_NSH_ROMFSRC
320307
# ifndef CONFIG_NSH_RCSCRIPT
321308
# define CONFIG_NSH_RCSCRIPT ".nshrc"
322309
# endif
323310

324311
# undef NSH_RCPATH
325-
# define NSH_RCPATH CONFIG_NSH_ROMFSMOUNTPT "/" CONFIG_NSH_RCSCRIPT
326-
# endif
327-
328-
# ifndef CONFIG_NSH_ROMFSDEVNO
329-
# define CONFIG_NSH_ROMFSDEVNO 0
312+
# define NSH_RCPATH CONFIG_ETC_ROMFSMOUNTPT "/" CONFIG_NSH_RCSCRIPT
330313
# endif
331314

332-
# ifndef CONFIG_NSH_ROMFSSECTSIZE
333-
# define CONFIG_NSH_ROMFSSECTSIZE 64
334-
# endif
335-
336-
# define NSECTORS(b) (((b)+CONFIG_NSH_ROMFSSECTSIZE-1)/CONFIG_NSH_ROMFSSECTSIZE)
337-
# define STR_RAMDEVNO(m) #m
338-
# define MKMOUNT_DEVNAME(m) "/dev/ram" STR_RAMDEVNO(m)
339-
# define MOUNT_DEVNAME MKMOUNT_DEVNAME(CONFIG_NSH_ROMFSDEVNO)
340-
341315
#else
342316

343317
# undef CONFIG_NSH_ROMFSRC
344-
# undef CONFIG_NSH_ROMFSMOUNTPT
345318
# undef CONFIG_NSH_INITSCRIPT
346319
# undef CONFIG_NSH_RCSCRIPT
347-
# undef CONFIG_NSH_ROMFSDEVNO
348-
# undef CONFIG_NSH_ROMFSSECTSIZE
349320

350321
#endif
351322

@@ -804,12 +775,6 @@ extern "C"
804775

805776
/* Initialization */
806777

807-
#ifdef CONFIG_NSH_ROMFSETC
808-
int nsh_romfsetc(void);
809-
#else
810-
# define nsh_romfsetc() (-ENOSYS)
811-
#endif
812-
813778
#ifdef HAVE_USB_CONSOLE
814779
int nsh_usbconsole(void);
815780
#else
@@ -826,7 +791,7 @@ void nsh_aliasfree(FAR struct nsh_vtbl_s *vtbl,
826791
#ifndef CONFIG_NSH_DISABLESCRIPT
827792
int nsh_script(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
828793
FAR const char *path, bool log);
829-
#ifdef CONFIG_NSH_ROMFSETC
794+
#ifdef CONFIG_ETC_ROMFS
830795
int nsh_sysinitscript(FAR struct nsh_vtbl_s *vtbl);
831796
int nsh_initscript(FAR struct nsh_vtbl_s *vtbl);
832797
#ifdef CONFIG_NSH_ROMFSRC

nshlib/nsh_init.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ void nsh_initialize(void)
106106
#if defined (CONFIG_NSH_SYMTAB)
107107
struct boardioc_symtab_s symdesc;
108108
#endif
109-
#if defined(CONFIG_NSH_ROMFSETC) && !defined(CONFIG_NSH_DISABLESCRIPT)
109+
#if defined(CONFIG_ETC_ROMFS) && !defined(CONFIG_NSH_DISABLESCRIPT)
110110
FAR struct console_stdio_s *pstate;
111111
#endif
112112

@@ -122,10 +122,6 @@ void nsh_initialize(void)
122122
# endif
123123
#endif
124124

125-
/* Mount the /etc filesystem */
126-
127-
(void)nsh_romfsetc();
128-
129125
#ifdef CONFIG_NSH_USBDEV_TRACE
130126
/* Initialize any USB tracing options that were requested */
131127

@@ -147,7 +143,7 @@ void nsh_initialize(void)
147143
boardctl(BOARDIOC_INIT, 0);
148144
#endif
149145

150-
#if defined(CONFIG_NSH_ROMFSETC) && !defined(CONFIG_NSH_DISABLESCRIPT)
146+
#if defined(CONFIG_ETC_ROMFS) && !defined(CONFIG_NSH_DISABLESCRIPT)
151147
pstate = nsh_newconsole(false);
152148

153149
/* Execute the system init script */
@@ -167,7 +163,7 @@ void nsh_initialize(void)
167163
boardctl(BOARDIOC_FINALINIT, 0);
168164
#endif
169165

170-
#if defined(CONFIG_NSH_ROMFSETC) && !defined(CONFIG_NSH_DISABLESCRIPT)
166+
#if defined(CONFIG_ETC_ROMFS) && !defined(CONFIG_NSH_DISABLESCRIPT)
171167
/* Execute the start-up script */
172168

173169
nsh_initscript(&pstate->cn_vtbl);

0 commit comments

Comments
 (0)