diff --git a/ChangeLog.txt b/ChangeLog.txt index 64b2464cd..d354fdc4e 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1327,3 +1327,6 @@ * The apps/ directory has been removed from the NuttX GIT repository and now stands alone in its own repository (2015-06-27). * apps/examples/poll: Fix a few bit-rot compilation errors (2015-07-01). + * apps/nshlib: NSH will now support an (optional) shutdown command if + the board provides the option CONFIG_BOARD_POWEROFF (2015-07-04). + diff --git a/nshlib/Kconfig b/nshlib/Kconfig index a1c2e5c3f..55d8097e6 100644 --- a/nshlib/Kconfig +++ b/nshlib/Kconfig @@ -332,6 +332,11 @@ config NSH_DISABLE_SH bool "Disable sh" default n +config CONFIG_NSH_DISABLE_SHUTDOWN + bool "Disable sh" + default n + depends on BOARDCTL_POWEROFF + config NSH_DISABLE_SLEEP bool "Disable sleep" default n diff --git a/nshlib/Makefile b/nshlib/Makefile index 69f2f0a18..4d2d6a8ca 100644 --- a/nshlib/Makefile +++ b/nshlib/Makefile @@ -42,7 +42,7 @@ include $(APPDIR)/Make.defs ASRCS = CSRCS = nsh_init.c nsh_parse.c nsh_console.c nsh_script.c CSRCS += nsh_command.c nsh_fscmds.c nsh_ddcmd.c nsh_proccmds.c nsh_mmcmds.c -CSRCS += nsh_timcmds.c nsh_envcmds.c nsh_dbgcmds.c +CSRCS += nsh_timcmds.c nsh_envcmds.c nsh_syscmds.c nsh_dbgcmds.c ifeq ($(CONFIG_NFILE_STREAMS),0) CSRCS += nsh_stdsession.c diff --git a/nshlib/README.txt b/nshlib/README.txt index 275f15185..479efbc0b 100644 --- a/nshlib/README.txt +++ b/nshlib/README.txt @@ -884,6 +884,11 @@ o sh Execute the sequence of NSH commands in the file referred to by . +o shutdown + + Shutdown and power off the system immediately. This command depends on + hardware support to power down the system. + o sleep Pause execution (sleep) of seconds. @@ -990,6 +995,7 @@ Command Dependencies on Configuration Settings rmdir (((!CONFIG_DISABLE_MOUNTPOINT && CONFIG_FS_WRITABLE) || !CONFIG_DISABLE_PSEUDOFS_OPERATIONS) && CONFIG_NFILE_DESCRIPTORS > 0) set !CONFIG_DISABLE_ENVIRON sh CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0 && !CONFIG_NSH_DISABLESCRIPT + shutdown CONFIG_BOARDCTL_POWEROFF sleep !CONFIG_DISABLE_SIGNALS test !CONFIG_NSH_DISABLESCRIPT umount !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_READABLE @@ -1028,10 +1034,10 @@ also allow it to squeeze into very small memory footprints. CONFIG_NSH_DISABLE_MV, CONFIG_NSH_DISABLE_NFSMOUNT, CONFIG_NSH_DISABLE_PS, CONFIG_NSH_DISABLE_PING, CONFIG_NSH_DISABLE_PING6, CONFIG_NSH_DISABLE_PUT, CONFIG_NSH_DISABLE_PWD, CONFIG_NSH_DISABLE_RM, CONFIG_NSH_DISABLE_RMDIR, - CONFIG_NSH_DISABLE_SET, CONFIG_NSH_DISABLE_SH, CONFIG_NSH_DISABLE_SLEEP, - CONFIG_NSH_DISABLE_TEST, CONFIG_NSH_DISABLE_UMOUNT, CONFIG_NSH_DISABLE_UNSET, - CONFIG_NSH_DISABLE_URLDECODE, CONFIG_NSH_DISABLE_URLENCODE, CONFIG_NSH_DISABLE_USLEEP, - CONFIG_NSH_DISABLE_WGET, CONFIG_NSH_DISABLE_XD + CONFIG_NSH_DISABLE_SET, CONFIG_NSH_DISABLE_SH, CONFIG_NSH_DISABLE_SHUTDOWN, + CONFIG_NSH_DISABLE_SLEEP, CONFIG_NSH_DISABLE_TEST, CONFIG_NSH_DISABLE_UMOUNT, + CONFIG_NSH_DISABLE_UNSET, CONFIG_NSH_DISABLE_URLDECODE, CONFIG_NSH_DISABLE_URLENCODE, + CONFIG_NSH_DISABLE_USLEEP, CONFIG_NSH_DISABLE_WGET, CONFIG_NSH_DISABLE_XD Verbose help output can be suppressed by defining CONFIG_NSH_HELP_TERSE. In that case, the help command is still available but will be slightly smaller. diff --git a/nshlib/nsh.h b/nshlib/nsh.h index 91f7ca325..c43fd7a4f 100644 --- a/nshlib/nsh.h +++ b/nshlib/nsh.h @@ -988,6 +988,10 @@ void nsh_usbtrace(void); # endif #endif /* CONFIG_NET */ +#if defined(CONFIG_BOARDCTL_POWEROFF) && !defined(CONFIG_NSH_DISABLE_SHUTDOWN) + int cmd_shutdown(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +#endif + #ifndef CONFIG_DISABLE_ENVIRON # ifndef CONFIG_NSH_DISABLE_SET int cmd_set(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); diff --git a/nshlib/nsh_command.c b/nshlib/nsh_command.c index edc858e09..8a7b9cd7a 100644 --- a/nshlib/nsh_command.c +++ b/nshlib/nsh_command.c @@ -369,6 +369,10 @@ static const struct cmdmap_s g_cmdmap[] = # endif #endif +#if defined(CONFIG_BOARDCTL_POWEROFF) && !defined(CONFIG_NSH_DISABLE_SHUTDOWN) + { "shutdown", cmd_shutdown, 1, 1, NULL }, +#endif + #ifndef CONFIG_DISABLE_SIGNALS # ifndef CONFIG_NSH_DISABLE_SLEEP { "sleep", cmd_sleep, 2, 2, "" },