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
+2 -2
View File
@@ -1201,7 +1201,7 @@ Commander::handle_command(const vehicle_command_s &cmd)
#if defined(CONFIG_BOARDCTL_RESET)
} else if ((param1 == 1) && !isArmed() && (px4_reboot_request(false, 400_ms) == 0)) {
} else if ((param1 == 1) && !isArmed() && (px4_reboot_request(REBOOT_REQUEST, 400_ms) == 0)) {
// 1: Reboot autopilot
answer_command(cmd, vehicle_command_ack_s::VEHICLE_CMD_RESULT_ACCEPTED);
@@ -1221,7 +1221,7 @@ Commander::handle_command(const vehicle_command_s &cmd)
#if defined(CONFIG_BOARDCTL_RESET)
} else if ((param1 == 3) && !isArmed() && (px4_reboot_request(true, 400_ms) == 0)) {
} else if ((param1 == 3) && !isArmed() && (px4_reboot_request(REBOOT_TO_BOOTLOADER, 400_ms) == 0)) {
// 3: Reboot autopilot and keep it in the bootloader until upgraded.
answer_command(cmd, vehicle_command_ack_s::VEHICLE_CMD_RESULT_ACCEPTED);
+1 -1
View File
@@ -177,7 +177,7 @@ void WorkerThread::threadEntry()
param_reset_specific(reset_cal, sizeof(reset_cal) / sizeof(reset_cal[0]));
_ret_value = param_save_default(true);
#if defined(CONFIG_BOARDCTL_RESET)
px4_reboot_request(false, 400_ms);
px4_reboot_request(REBOOT_REQUEST, 400_ms);
#endif // CONFIG_BOARDCTL_RESET
break;
}
+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);