This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 1d3e6510e nshlib: Add switchboot command
1d3e6510e is described below
commit 1d3e6510e6d650b1b34b5520dc1fbc8481db56cf
Author: Xiang Xiao <[email protected]>
AuthorDate: Tue Apr 4 19:59:45 2023 +0800
nshlib: Add switchboot command
switchboot <image path>
Switch to the updated or specified boot system. This command depends on
hardware support CONFIG_BOARDCTL_SWITCH_BOOT. `<image path>` point to a
partion or file which contain the firmware to boot.
Signed-off-by: Xiang Xiao <[email protected]>
---
nshlib/Kconfig | 5 +++++
nshlib/README.md | 6 ++++++
nshlib/nsh.h | 4 ++++
nshlib/nsh_command.c | 4 ++++
nshlib/nsh_syscmds.c | 18 ++++++++++++++++++
5 files changed, 37 insertions(+)
diff --git a/nshlib/Kconfig b/nshlib/Kconfig
index 1acad06f4..196af77a1 100644
--- a/nshlib/Kconfig
+++ b/nshlib/Kconfig
@@ -519,6 +519,11 @@ config NSH_DISABLE_READLINK
default DEFAULT_SMALL
depends on PSEUDOFS_SOFTLINKS
+config NSH_DISABLE_SWITCHBOOT
+ bool "Switch boot partition"
+ default DEFAULT_SMALL
+ depends on BOARDCTL_SWITCH_BOOT
+
config NSH_DISABLE_BOOT
bool "Disable boot"
default DEFAULT_SMALL
diff --git a/nshlib/README.md b/nshlib/README.md
index d5f0c0215..1dd383c51 100644
--- a/nshlib/README.md
+++ b/nshlib/README.md
@@ -1158,6 +1158,12 @@ system image.
Show target of a soft link.
+- `switchboot <image path>
+
+ Switch to the updated or specified boot system. This command depends on
+ hardware support CONFIG_BOARDCTL_SWITCH_BOOT. `<image path>` point to a
+ partion or file which contain the firmware to boot.
+
- `boot [<image path> [<header size>]]`
Boot a new firmware image. This command depends on hardware support
diff --git a/nshlib/nsh.h b/nshlib/nsh.h
index cfde18aca..e77ae9130 100644
--- a/nshlib/nsh.h
+++ b/nshlib/nsh.h
@@ -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);
#endif
+#if defined(CONFIG_BOARDCTL_SWITCH_BOOT) &&
!defined(CONFIG_NSH_DISABLE_SWITCHBOOT)
+int cmd_switchboot(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv);
+#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
diff --git a/nshlib/nsh_command.c b/nshlib/nsh_command.c
index 326091470..ffc973b44 100644
--- a/nshlib/nsh_command.c
+++ b/nshlib/nsh_command.c
@@ -529,6 +529,10 @@ static const struct cmdmap_s g_cmdmap[] =
{ "source", cmd_source, 2, 2, "<script-path>" },
#endif
+#if defined(CONFIG_BOARDCTL_SWITCH_BOOT) &&
!defined(CONFIG_NSH_DISABLE_SWITCHBOOT)
+ { "swtichboot", cmd_swtichboot, 2, 2, "<image path>" },
+#endif
+
#if !defined(CONFIG_NSH_DISABLESCRIPT) && !defined(CONFIG_NSH_DISABLE_TEST)
{ "test", cmd_test, 3, CONFIG_NSH_MAXARGUMENTS, "<expression>" },
#endif
diff --git a/nshlib/nsh_syscmds.c b/nshlib/nsh_syscmds.c
index 15fbc6ec3..406d2eac2 100644
--- a/nshlib/nsh_syscmds.c
+++ b/nshlib/nsh_syscmds.c
@@ -318,6 +318,24 @@ int cmd_poweroff(FAR struct nsh_vtbl_s *vtbl, int argc,
FAR char **argv)
}
#endif
+/****************************************************************************
+ * Name: cmd_switchboot
+ ****************************************************************************/
+
+#if defined(CONFIG_BOARDCTL_SWITCH_BOOT) &&
!defined(CONFIG_NSH_DISABLE_SWITCHBOOT)
+int cmd_switchboot(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
+{
+ if (argc != 2)
+ {
+ nsh_output(vtbl, g_fmtarginvalid, argv[0]);
+ return ERROR;
+ }
+
+ boardctl(BOARDIOC_SWITCH_BOOT, (uintptr_t)argv[1]);
+ return 0;
+}
+#endif
+
/****************************************************************************
* Name: cmd_boot
****************************************************************************/