while (1) { uint64_t current_time = 0; poll_status = fastboot_poll();
if (1 == check_timeout) current_time = get_ticks();
/* Check if the user wanted to terminate with ^C */ if ( ((poll_status != FASTBOOT_OK) && (ctrlc())) || gflag_reboot) { printf("Fastboot ended by user\n"); continue_from_disconnect = 0; break; }
if (FASTBOOT_ERROR == poll_status) { /* Error */ printf("Fastboot error \n"); break; } elseif (FASTBOOT_DISCONNECT == poll_status) { /* break, cleanup and re-init */ printf("Fastboot disconnect detected\n"); continue_from_disconnect = 1; break; } elseif ((1 == check_timeout) && (FASTBOOT_INACTIVE == poll_status)) { /* No activity */ if (current_time >= timeout_endtime) { printf("Fastboot inactivity detected\n"); break; } } else { /* Something happened */ /* Actual works of parsing are done by rx_handler */ if (1 == check_timeout) { /* Update the timeout endtime */ timeout_endtime = current_time; timeout_endtime += timeout_ticks; } }
board_poll_status = board_fastboot_poll(); if (BOARD_FASTBOOT_DISCONNECT == board_poll_status) { printf("Fastboot disconnect detected by board action\n"); continue_from_disconnect = 0; break; } } /* while (1) */ }
/* Reset the board specific support */ fastboot_shutdown();
if (buffer_size) { /* Handle possible overflow */ unsignedint transfer_size = download_size - download_bytes;
if (buffer_size < transfer_size) transfer_size = buffer_size;
/* Save the data to the transfer buffer */ memcpy (interface.transfer_buffer + download_bytes, buffer, transfer_size);
download_bytes += transfer_size;
/* Check if transfer is done */ if (download_bytes >= download_size) { /* Reset global transfer variable, Keep download_bytes because it will be used in the next possible flashing command */ download_size = 0;
if (download_error) { /* There was an earlier error */ sprintf(response, "ERROR"); } else { /* Everything has transferred, send the OK response */ sprintf(response, "OKAY"); } fastboot_tx_status(response, strlen(response), FASTBOOT_TX_ASYNC);
printf("\ndownloading of %d bytes finished\n", download_bytes); LCD_setprogress(0);
/* Provide some feedback */ if (download_bytes && download_size && 0 == (download_bytes & (0x100000 - 1))) { /* Some feeback that the download is happening */ if (download_error) printf("X"); else printf("."); if (0 == (download_bytes % (80 * 0x100000))) printf("\n");
This is copyright.