Improve fastboot verbose output.
Move some verbose messages so they're only output with -v.
Remove some misleading verbose messages altogether (such as "wiping
userdata...").
Properly log all the commands sent and responses received. Example:
$ fastboot -v flashall
...
Sending sparse 'system' 2/2 (443712 KB)
fastboot: verbose: sending command "download:1b1500d0"
fastboot: verbose: received DATA 1b1500d0
fastboot: verbose: sending data (1024 bytes)
fastboot: verbose: sending data (165596160 bytes)
fastboot: verbose: sending data (1024 bytes)
fastboot: verbose: sending data (267762688 bytes)
fastboot: verbose: sending data (1024 bytes)
fastboot: verbose: sending data (20978688 bytes)
fastboot: verbose: sending data (1024 bytes)
fastboot: verbose: sending data (7168 bytes)
fastboot: verbose: sending data (1024 bytes)
fastboot: verbose: sending data (3072 bytes)
fastboot: verbose: sending data (1024 bytes)
fastboot: verbose: sending data (3072 bytes)
fastboot: verbose: sending data (1024 bytes)
fastboot: verbose: sending data (3072 bytes)
fastboot: verbose: sending data (208 bytes)
fastboot: verbose: received OKAY
OKAY [ 13.871s]
Writing sparse 'system' 2/2
fastboot: verbose: sending command "flash:system"
fastboot: verbose: received OKAY
OKAY [ 3.228s]
Rebooting
fastboot: verbose: sending command "reboot"
fastboot: verbose: received OKAY
Finished. Total time: 36.939s
Bug: http://b/30953083
Bug: http://b/74444116
Test: `fastboot -v flashall`
Change-Id: I2cca198daa062fd1fb732218343263803b111e38
diff --git a/fastboot/protocol.cpp b/fastboot/protocol.cpp
index c239861..133a2d0 100644
--- a/fastboot/protocol.cpp
+++ b/fastboot/protocol.cpp
@@ -75,18 +75,21 @@
}
if (!memcmp(status, "INFO", 4)) {
- fprintf(stderr,"(bootloader) %s\n", status + 4);
+ verbose("received INFO %s", status + 4);
+ fprintf(stderr, "(bootloader) %s\n", status + 4);
continue;
}
if (!memcmp(status, "OKAY", 4)) {
+ verbose("received OKAY %s", status + 4);
if (response) {
- strcpy(response, (char*) status + 4);
+ strcpy(response, status + 4);
}
return 0;
}
if (!memcmp(status, "FAIL", 4)) {
+ verbose("received FAIL %s", status + 4);
if (r > 4) {
g_error = android::base::StringPrintf("remote: %s", status + 4);
} else {
@@ -96,6 +99,7 @@
}
if (!memcmp(status, "DATA", 4) && size > 0){
+ verbose("received DATA %s", status + 4);
uint32_t dsize = strtol(status + 4, 0, 16);
if (dsize > size) {
g_error = android::base::StringPrintf("data size too large (%d)", dsize);
@@ -105,6 +109,7 @@
return dsize;
}
+ verbose("received unknown status code \"%4.4s\"", status);
g_error = "unknown status code";
transport->Close();
break;
@@ -124,6 +129,8 @@
response[0] = 0;
}
+ verbose("sending command \"%s\"", cmd.c_str());
+
if (transport->Write(cmd.c_str(), cmd.size()) != static_cast<int>(cmd.size())) {
g_error = android::base::StringPrintf("command write failed (%s)", strerror(errno));
transport->Close();
@@ -134,6 +141,8 @@
}
static int64_t _command_write_data(Transport* transport, const void* data, uint32_t size) {
+ verbose("sending data (%" PRIu32 " bytes)", size);
+
int64_t r = transport->Write(data, size);
if (r < 0) {
g_error = android::base::StringPrintf("data write failure (%s)", strerror(errno));
@@ -149,6 +158,8 @@
}
static int64_t _command_read_data(Transport* transport, void* data, uint32_t size) {
+ verbose("reading data (%" PRIu32 " bytes)", size);
+
int64_t r = transport->Read(data, size);
if (r < 0) {
g_error = android::base::StringPrintf("data read failure (%s)", strerror(errno));