The NSH shutdown command now supports the --reset option, if available in hardware
This commit is contained in:
parent
fa9e1812f8
commit
a2a1530694
@ -1328,7 +1328,9 @@
|
||||
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).
|
||||
the board provides the option CONFIG_BOARDCTL_POWEROFF. The command can
|
||||
also be used to reset the system if CONFIG_BOARDCTL_RESET=y.
|
||||
(2015-07-04).
|
||||
* apps/system/poweroff: Remove the system poweroff command. This is
|
||||
replaced with the NSH shutdown commandi (2015-07-02).
|
||||
|
||||
|
@ -884,10 +884,11 @@ o sh <script-path>
|
||||
Execute the sequence of NSH commands in the file referred
|
||||
to by <script-path>.
|
||||
|
||||
o shutdown
|
||||
o shutdown [--reset]
|
||||
|
||||
Shutdown and power off the system immediately. This command depends on
|
||||
hardware support to power down the system.
|
||||
Shutdown and power off the system or, optionally, reset the system
|
||||
immediately. This command depends on hardware support to power down or
|
||||
reset the system; one, both, or neither behavior may be supported.
|
||||
|
||||
o sleep <sec>
|
||||
|
||||
@ -995,7 +996,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
|
||||
shutdown CONFIG_BOARDCTL_POWEROFF || CONFIG_BOARDCTL_RESET
|
||||
sleep !CONFIG_DISABLE_SIGNALS
|
||||
test !CONFIG_NSH_DISABLESCRIPT
|
||||
umount !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_READABLE
|
||||
|
@ -988,7 +988,8 @@ void nsh_usbtrace(void);
|
||||
# endif
|
||||
#endif /* CONFIG_NET */
|
||||
|
||||
#if defined(CONFIG_BOARDCTL_POWEROFF) && !defined(CONFIG_NSH_DISABLE_SHUTDOWN)
|
||||
#if (defined(CONFIG_BOARDCTL_POWEROFF) || defined(CONFIG_BOARDCTL_RESET)) && \
|
||||
!defined(CONFIG_NSH_DISABLE_SHUTDOWN)
|
||||
int cmd_shutdown(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
#endif
|
||||
|
||||
|
@ -369,8 +369,14 @@ static const struct cmdmap_s g_cmdmap[] =
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BOARDCTL_POWEROFF) && !defined(CONFIG_NSH_DISABLE_SHUTDOWN)
|
||||
#ifndef CONFIG_NSH_DISABLE_SHUTDOWN
|
||||
#if defined(CONFIG_BOARDCTL_POWEROFF) && defined(CONFIG_BOARDCTL_RESET)
|
||||
{ "shutdown", cmd_shutdown, 1, 2, "[--reset]" },
|
||||
#elif defined(CONFIG_BOARDCTL_POWEROFF)
|
||||
{ "shutdown", cmd_shutdown, 1, 1, NULL },
|
||||
#elif defined(CONFIG_BOARDCTL_RESET)
|
||||
{ "shutdown", cmd_shutdown, 2, 2, "--reset" },
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_DISABLE_SIGNALS
|
||||
|
@ -78,17 +78,78 @@
|
||||
* Name: cmd_shutdown
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_BOARDCTL_POWEROFF) && !defined(CONFIG_NSH_DISABLE_SHUTDOWN)
|
||||
#if (defined(CONFIG_BOARDCTL_POWEROFF) || defined(CONFIG_BOARDCTL_RESET)) && \
|
||||
!defined(CONFIG_NSH_DISABLE_SHUTDOWN)
|
||||
|
||||
int cmd_shutdown(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
/* Invoide the BOARDIOC_POWEROFF board control to shutdown the board
|
||||
* If board_power_off function returns, then it was not possible to power-off the
|
||||
* board due to some constraints.
|
||||
#if defined(CONFIG_BOARDCTL_POWEROFF) && defined(CONFIG_BOARDCTL_RESET)
|
||||
/* If both shutdown and reset are supported, then a single option may
|
||||
* be provided to select the reset behavior (--reset). We know here
|
||||
* that argc is either 1 or 2.
|
||||
*/
|
||||
|
||||
if (argc == 2)
|
||||
{
|
||||
/* Verify that the single argument is --reset */
|
||||
|
||||
if (strcmp(argv[1], "--reset") != 0)
|
||||
{
|
||||
nsh_output(vtbl, g_fmtarginvalid, argv[0]);
|
||||
return ERROR
|
||||
}
|
||||
|
||||
/* Invoke the BOARDIOC_RESET board control to reset the board. If
|
||||
* the board_reset() function returns, then it was not possible to
|
||||
* reset the board due to some constraints.
|
||||
*/
|
||||
|
||||
(void)boardctl(BOARDIOC_RESET, EXIT_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Invoke the BOARDIOC_POWEROFF board control to shutdown the board.
|
||||
* If the board_power_off function returns, then it was not possible
|
||||
* to power-off the* board due to some constraints.
|
||||
*/
|
||||
|
||||
(void)boardctl(BOARDIOC_POWEROFF, EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
#elif defined(CONFIG_BOARDCTL_RESET)
|
||||
/* Only reset behavior is supported and we already know that exactly one
|
||||
* argument has been provided.
|
||||
*/
|
||||
|
||||
/* Verify that the single argument is --reset */
|
||||
|
||||
if (strcmp(argv[1], "--reset") != 0)
|
||||
{
|
||||
nsh_output(vtbl, g_fmtarginvalid, argv[0]);
|
||||
return ERROR
|
||||
}
|
||||
|
||||
/* Invoke the BOARDIOC_RESET board control to reset the board. If
|
||||
* the board_reset() function returns, then it was not possible to
|
||||
* reset the board due to some constraints.
|
||||
*/
|
||||
|
||||
(void)boardctl(BOARDIOC_RESET, EXIT_SUCCESS);
|
||||
|
||||
#else
|
||||
/* Only the reset behavior is supported and we already know that there is
|
||||
* no argument to the command.
|
||||
*/
|
||||
|
||||
/* Invoke the BOARDIOC_POWEROFF board control to shutdown the board. If
|
||||
* the board_power_off function returns, then it was not possible to power-
|
||||
* off the board due to some constraints.
|
||||
*/
|
||||
|
||||
(void)boardctl(BOARDIOC_POWEROFF, EXIT_SUCCESS);
|
||||
#endif
|
||||
|
||||
/* boarctl() will not return in this case. It if does, it means that
|
||||
/* boarctl() will not return in any case. It if does, it means that
|
||||
* there was a problem with the shutdown operaion.
|
||||
*/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user