nshlib: Add boot command
boot [<image path> [<header size>]] Boot a new firmware image. This command depends on hardware support CONFIG_BOARDCTL_BOOT_IMAGE. <image path> may point to a partion or file which contain the firmware to boot. The optional, numeric argument <header size> may be useful for skipping metadata information preprended to the firmware image. Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
c694d8d90f
commit
4f7dd7be7c
@ -519,6 +519,11 @@ config NSH_DISABLE_READLINK
|
|||||||
default DEFAULT_SMALL
|
default DEFAULT_SMALL
|
||||||
depends on PSEUDOFS_SOFTLINKS
|
depends on PSEUDOFS_SOFTLINKS
|
||||||
|
|
||||||
|
config NSH_DISABLE_BOOT
|
||||||
|
bool "Disable boot"
|
||||||
|
default DEFAULT_SMALL
|
||||||
|
depends on BOARDCTL_BOOT_IMAGE
|
||||||
|
|
||||||
config NSH_DISABLE_REBOOT
|
config NSH_DISABLE_REBOOT
|
||||||
bool "Disable reboot"
|
bool "Disable reboot"
|
||||||
default DEFAULT_SMALL
|
default DEFAULT_SMALL
|
||||||
|
@ -1158,6 +1158,14 @@ system image.
|
|||||||
|
|
||||||
Show target of a soft link.
|
Show target of a soft link.
|
||||||
|
|
||||||
|
- `boot [<image path> [<header size>]]`
|
||||||
|
|
||||||
|
Boot a new firmware image. This command depends on hardware support
|
||||||
|
CONFIG_BOARDCTL_BOOT_IMAGE. `<image path>` may point to a partion or file
|
||||||
|
which contain the firmware to boot. The optional, numeric argument
|
||||||
|
`<header size>` may be useful for skipping metadata information preprended
|
||||||
|
to the firmware image.
|
||||||
|
|
||||||
- `reboot [<n>]`
|
- `reboot [<n>]`
|
||||||
|
|
||||||
Reset and reboot the system immediately. This command depends on hardware
|
Reset and reboot the system immediately. This command depends on hardware
|
||||||
|
@ -1149,6 +1149,10 @@ int cmd_irqinfo(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv);
|
|||||||
int cmd_pmconfig(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv);
|
int cmd_pmconfig(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_BOARDCTL_BOOT_IMAGE) && !defined(CONFIG_NSH_DISABLE_BOOT)
|
||||||
|
int cmd_boot(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_BOARDCTL_RESET) && !defined(CONFIG_NSH_DISABLE_REBOOT)
|
#if defined(CONFIG_BOARDCTL_RESET) && !defined(CONFIG_NSH_DISABLE_REBOOT)
|
||||||
int cmd_reboot(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv);
|
int cmd_reboot(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv);
|
||||||
#endif
|
#endif
|
||||||
|
@ -129,6 +129,10 @@ static const struct cmdmap_s g_cmdmap[] =
|
|||||||
{ "basename", cmd_basename, 2, 3, "<path> [<suffix>]" },
|
{ "basename", cmd_basename, 2, 3, "<path> [<suffix>]" },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_BOARDCTL_BOOT_IMAGE) && !defined(CONFIG_NSH_DISABLE_BOOT)
|
||||||
|
{ "boot", cmd_boot, 1, 3, "[<image path> [<header size>]]" },
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(CONFIG_NSH_DISABLESCRIPT) && !defined(CONFIG_NSH_DISABLE_LOOPS)
|
#if !defined(CONFIG_NSH_DISABLESCRIPT) && !defined(CONFIG_NSH_DISABLE_LOOPS)
|
||||||
{ "break", cmd_break, 1, 1, NULL },
|
{ "break", cmd_break, 1, 1, NULL },
|
||||||
#endif
|
#endif
|
||||||
|
@ -165,7 +165,7 @@ int cmd_shutdown(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* boardctl() will not return in any case. It if does, it means that
|
/* boardctl() will not return in any case. It if does, it means that
|
||||||
* there was a problem with the shutdown/resaet operation.
|
* there was a problem with the shutdown/reset operation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
nsh_error(vtbl, g_fmtcmdfailed, argv[0], "boardctl", NSH_ERRNO);
|
nsh_error(vtbl, g_fmtcmdfailed, argv[0], "boardctl", NSH_ERRNO);
|
||||||
@ -318,6 +318,52 @@ int cmd_poweroff(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: cmd_boot
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if defined(CONFIG_BOARDCTL_BOOT_IMAGE) && !defined(CONFIG_NSH_DISABLE_BOOT)
|
||||||
|
int cmd_boot(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
|
||||||
|
{
|
||||||
|
struct boardioc_boot_info_s info;
|
||||||
|
|
||||||
|
memset(&info, 0, sizeof(info));
|
||||||
|
|
||||||
|
/* Invoke the BOARDIOC_BOOT_IMAGE board control to reset the board. If
|
||||||
|
* the board_boot_image() function returns, then it was not possible to
|
||||||
|
* boot the image due to some constraints.
|
||||||
|
*/
|
||||||
|
|
||||||
|
switch (argc)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
info.header_size = strtoul(argv[2], NULL, 0);
|
||||||
|
|
||||||
|
/* Go through */
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
info.path = argv[1];
|
||||||
|
|
||||||
|
/* Go through */
|
||||||
|
|
||||||
|
case 0:
|
||||||
|
|
||||||
|
/* Nothing to do */
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
boardctl(BOARDIOC_BOOT_IMAGE, (uintptr_t)&info);
|
||||||
|
|
||||||
|
/* boardctl() will not return in this case. It if does, it means that
|
||||||
|
* there was a problem with the boot operation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
nsh_error(vtbl, g_fmtcmdfailed, argv[0], "boardctl", NSH_ERRNO);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: cmd_reboot
|
* Name: cmd_reboot
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user