From 1098c60a9d349b8c1c438bd9bf82fe383c387e02 Mon Sep 17 00:00:00 2001 From: Mary Ruthven Date: Tue, 5 Jan 2021 10:41:08 -0800 Subject: gsctool: print raw timestamp with gsctool -LM The UMA get flog script expects a raw timestamp without spaces around the colon. Output the UMA format when the machine arg is given. gsctool -aL still prints the incorrect year in the timestamp. That will get fixed in a followup CL. BUG=b:176816528 TEST=gsctool -aML outputs the old format. gsctool -aL still prints the output with timestamps. Change-Id: Ie11204260958f48485c28917c31d62d78c5b722c Signed-off-by: Mary Ruthven Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2610932 Reviewed-by: Andrey Pronin Commit-Queue: Andrey Pronin --- extra/usb_updater/gsctool.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/extra/usb_updater/gsctool.c b/extra/usb_updater/gsctool.c index c6c9efb136..4deb51ccf3 100644 --- a/extra/usb_updater/gsctool.c +++ b/extra/usb_updater/gsctool.c @@ -2545,7 +2545,8 @@ static int process_tpm_mode(struct transfer_descriptor *td, * On error retry a few times just in case flash log is locked by a concurrent * access. */ -static int process_get_flog(struct transfer_descriptor *td, uint32_t prev_stamp) +static int process_get_flog(struct transfer_descriptor *td, uint32_t prev_stamp, + bool show_machine_output) { int rv; const int max_retries = 3; @@ -2580,18 +2581,24 @@ static int process_get_flog(struct transfer_descriptor *td, uint32_t prev_stamp) return 0; memcpy(&prev_stamp, &entry.r.timestamp, sizeof(prev_stamp)); - entry_epoch = prev_stamp; - localtime_r(&entry_epoch, &loc_time); + if (show_machine_output) { + printf("%10u:%02x", prev_stamp, entry.r.type); + } else { + entry_epoch = prev_stamp; + localtime_r(&entry_epoch, &loc_time); + + if (!time_zone_reported) { + strftime(date_str, sizeof(date_str), "%Z", + &loc_time); + printf("Log time zone is %s\n", date_str); + time_zone_reported = true; + } - if (!time_zone_reported) { - strftime(date_str, sizeof(date_str), "%Z", &loc_time); - printf("Log time zone is %s\n", date_str); - time_zone_reported = true; + /* Date format is MMM DD YY HH:mm:ss */ + strftime(date_str, sizeof(date_str), "%b %d %y %T", + &loc_time); + printf("%s : %02x", date_str, entry.r.type); } - - /* Date format is MMM DD YY HH:mm:ss */ - strftime(date_str, sizeof(date_str), "%b %d %y %T", &loc_time); - printf("%s : %02x", date_str, entry.r.type); for (i = 0; i < FLASH_LOG_PAYLOAD_SIZE(entry.r.size); i++) printf(" %02x", entry.r.payload[i]); printf("\n"); @@ -3147,7 +3154,7 @@ int main(int argc, char *argv[]) exit(process_get_boot_mode(&td)); if (get_flog) - process_get_flog(&td, prev_log_entry); + process_get_flog(&td, prev_log_entry, show_machine_output); if (erase_ap_ro_hash) process_erase_ap_ro_hash(&td); -- cgit v1.2.1