diff --git a/cdba-server.c b/cdba-server.c index 4d47e1a..c737e5b 100644 --- a/cdba-server.c +++ b/cdba-server.c @@ -145,6 +145,12 @@ static void msg_fastboot_download(const void *data, size_t len) } } +static void msg_fastboot_continue(void) +{ + device_fastboot_continue(selected_device); + cdba_send(MSG_FASTBOOT_CONTINUE); +} + void cdba_send_buf(int type, size_t len, const void *buf) { struct msg msg = { @@ -228,6 +234,9 @@ static int handle_stdin(int fd, void *buf) case MSG_BOARD_INFO: device_info(username, msg->data, msg->len); break; + case MSG_FASTBOOT_CONTINUE: + msg_fastboot_continue(); + break; default: fprintf(stderr, "unk %d len %d\n", msg->type, msg->len); exit(1); diff --git a/cdba.c b/cdba.c index a16069a..681ed78 100644 --- a/cdba.c +++ b/cdba.c @@ -51,6 +51,7 @@ static bool quit; static bool fastboot_repeat; static bool fastboot_done; +static bool fastboot_continue; static int status_fd = -1; @@ -340,6 +341,22 @@ static void request_power_off(void) list_add(&work_items, &work.node); } +static void request_fastboot_continue_fn(struct work *work, int ssh_stdin) +{ + int ret; + + ret = cdba_send(ssh_stdin, MSG_FASTBOOT_CONTINUE); + if (ret < 0) + err(1, "failed to send fastboot continue request"); +} + +static void request_fastboot_continue(void) +{ + static struct work work = { request_fastboot_continue_fn }; + + list_add(&work_items, &work.node); +} + struct fastboot_download_work { struct work work; @@ -532,10 +549,14 @@ static int handle_message(struct circ_buf *buf) case MSG_FASTBOOT_PRESENT: if (*(uint8_t*)msg->data) { // printf("======================================== MSG_FASTBOOT_PRESENT(on)\n"); - if (!fastboot_done || fastboot_repeat) + if (fastboot_continue) { + request_fastboot_continue(); + fastboot_continue = false; + } else if (!fastboot_done || fastboot_repeat) { request_fastboot_files(); - else + } else { quit = true; + } } else { fastboot_done = true; // printf("======================================== MSG_FASTBOOT_PRESENT(off)\n"); @@ -557,6 +578,9 @@ static int handle_message(struct circ_buf *buf) handle_board_info(msg->data, msg->len); return -1; break; + case MSG_FASTBOOT_CONTINUE: + // printf("======================================== MSG_FASTBOOT_CONTINUE\n"); + break; default: fprintf(stderr, "unk %d len %d\n", msg->type, msg->len); return -1; @@ -585,7 +609,7 @@ static void usage(void) extern const char *__progname; fprintf(stderr, "usage: %s -b -h [-t ] " - "[-T ] boot.img\n", + "[-T ] \n", __progname); fprintf(stderr, "usage: %s -i -b -h \n", __progname); @@ -673,13 +697,15 @@ int main(int argc, char **argv) switch (verb) { case CDBA_BOOT: - if (optind >= argc || !board) + if (optind > argc || !board) usage(); fastboot_file = argv[optind]; - if (lstat(fastboot_file, &sb)) + if (!fastboot_file) + fastboot_continue = true; + else if (lstat(fastboot_file, &sb)) err(1, "unable to read \"%s\"", fastboot_file); - if (!S_ISREG(sb.st_mode) && !S_ISLNK(sb.st_mode)) + else if (!S_ISREG(sb.st_mode) && !S_ISLNK(sb.st_mode)) errx(1, "\"%s\" is not a regular file", fastboot_file); request_select_board(board); diff --git a/cdba.h b/cdba.h index 138ca7e..0264c40 100644 --- a/cdba.h +++ b/cdba.h @@ -30,6 +30,7 @@ enum { MSG_SEND_BREAK, MSG_LIST_DEVICES, MSG_BOARD_INFO, + MSG_FASTBOOT_CONTINUE, }; #endif diff --git a/device.c b/device.c index 329cf4f..9f4bcab 100644 --- a/device.c +++ b/device.c @@ -303,6 +303,11 @@ void device_fastboot_boot(struct device *device) fastboot_boot(device->fastboot); } +void device_fastboot_continue(struct device *device) +{ + fastboot_continue(device->fastboot); +} + void device_fastboot_flash_reboot(struct device *device) { fastboot_flash(device->fastboot, "boot"); diff --git a/device.h b/device.h index 600cbe5..6d431bc 100644 --- a/device.h +++ b/device.h @@ -88,6 +88,7 @@ void device_fastboot_flash_reboot(struct device *device); void device_send_break(struct device *device); void device_list_devices(const char *username); void device_info(const char *username, const void *data, size_t dlen); +void device_fastboot_continue(struct device *device); enum { DEVICE_KEY_FASTBOOT, diff --git a/fastboot.c b/fastboot.c index 53e3eaa..eec8947 100644 --- a/fastboot.c +++ b/fastboot.c @@ -490,3 +490,17 @@ int fastboot_reboot(struct fastboot *fb) return 0; } + +int fastboot_continue(struct fastboot *fb) +{ + char buf[80]; + int n; + + fastboot_write(fb, "continue", 8); + + n = fastboot_read(fb, buf, sizeof(buf)); + if (n >= 0) + fprintf(stderr, "%s\n", buf); + + return 0; +} diff --git a/fastboot.h b/fastboot.h index ffed3d4..3e5879b 100644 --- a/fastboot.h +++ b/fastboot.h @@ -17,5 +17,6 @@ int fastboot_erase(struct fastboot *fb, const char *partition); int fastboot_set_active(struct fastboot *fb, const char *active); int fastboot_flash(struct fastboot *fb, const char *partition); int fastboot_reboot(struct fastboot *fb); +int fastboot_continue(struct fastboot *fb); #endif