mirror of
https://github.com/apache/nuttx-apps.git
synced 2025-10-16 22:38:41 +08:00
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:

committed by
Petro Karashchenko

parent
c694d8d90f
commit
4f7dd7be7c
@@ -165,7 +165,7 @@ int cmd_shutdown(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
|
||||
#endif
|
||||
|
||||
/* 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);
|
||||
@@ -318,6 +318,52 @@ int cmd_poweroff(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
|
||||
}
|
||||
#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
|
||||
****************************************************************************/
|
||||
|
Reference in New Issue
Block a user