reboot: Add reboot to ISP option

This commit is contained in:
Peter van der Perk
2024-01-04 11:17:16 -05:00
committed by Daniel Agar
parent 8ba18a78af
commit 84093a07a2
13 changed files with 56 additions and 19 deletions
+1 -1
View File
@@ -375,7 +375,7 @@ write_reboot:
sleep(1);
px4_reboot_request(false);
px4_reboot_request(REBOOT_REQUEST);
while (1) { px4_usleep(1); } // this command should not return on success
+15 -4
View File
@@ -44,6 +44,7 @@
#include <px4_platform_common/module.h>
#include <px4_platform_common/shutdown.h>
#include <string.h>
#include <board_config.h>
static void print_usage()
{
@@ -51,6 +52,9 @@ static void print_usage()
PRINT_MODULE_USAGE_NAME_SIMPLE("reboot", "command");
PRINT_MODULE_USAGE_PARAM_FLAG('b', "Reboot into bootloader", true);
#ifdef BOARD_HAS_ISP_BOOTLOADER
PRINT_MODULE_USAGE_PARAM_FLAG('i', "Reboot into ISP (1st stage bootloader)", true);
#endif
PRINT_MODULE_USAGE_ARG("lock|unlock", "Take/release the shutdown lock (for testing)", true);
}
@@ -58,17 +62,24 @@ static void print_usage()
extern "C" __EXPORT int reboot_main(int argc, char *argv[])
{
int ch;
bool to_bootloader = false;
reboot_request_t request = REBOOT_REQUEST;
int myoptind = 1;
const char *myoptarg = nullptr;
while ((ch = px4_getopt(argc, argv, "b", &myoptind, &myoptarg)) != -1) {
while ((ch = px4_getopt(argc, argv, "bi", &myoptind, &myoptarg)) != -1) {
switch (ch) {
case 'b':
to_bootloader = true;
request = REBOOT_TO_BOOTLOADER;
break;
#ifdef BOARD_HAS_ISP_BOOTLOADER
case 'i':
request = REBOOT_TO_ISP;
break;
#endif
default:
print_usage();
return 1;
@@ -98,7 +109,7 @@ extern "C" __EXPORT int reboot_main(int argc, char *argv[])
return ret;
}
int ret = px4_reboot_request(to_bootloader);
int ret = px4_reboot_request(request);
if (ret < 0) {
PX4_ERR("reboot failed (%i)", ret);