Update command in CLI

This commit is contained in:
whowechina 2023-11-05 11:59:52 +08:00
parent 6c3ac34040
commit 1eafa6a21a
2 changed files with 10 additions and 1 deletions

Binary file not shown.

View File

@ -6,6 +6,7 @@
#include "pico/stdio.h"
#include "pico/stdlib.h"
#include "pico/bootrom.h"
#include "cli.h"
#include "save.h"
@ -87,6 +88,13 @@ static void handle_fps(int argc, char *argv[])
printf("FPS: core 0: %d, core 1: %d\n", fps[0], fps[1]);
}
static void handle_update(int argc, char *argv[])
{
printf("Boot into update mode.\n");
fflush(stdout);
sleep_ms(100);
reset_usb_boot(0, 2);
}
int cli_extract_non_neg_int(const char *param, int len)
{
if (len == 0) {
@ -94,7 +102,7 @@ int cli_extract_non_neg_int(const char *param, int len)
}
int result = 0;
for (int i = 0; i < len; i++) {
if (!isdigit(param[i])) {
if (!isdigit((uint8_t)param[i])) {
return -1;
}
result = result * 10 + param[i] - '0';
@ -181,4 +189,5 @@ void cli_init(const char *prompt, const char *logo)
cli_register("?", handle_help, "Display this help message.");
cli_register("fps", handle_fps, "Display FPS.");
cli_register("update", handle_update, "Update firmware.");
}