From 94388feaf11a1aaca22311138b1060db592aa669 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Mon, 4 Mar 2019 10:21:31 -0800 Subject: gsctool: make sure programmed image size is properly aligned Flash driver of the g chip requires that the size of the programmed area is evenly divisible by 4. This patch makes sure that gsctool complies with this requirement. BRANCH=none BUG=b:127295653 TEST=without this patch attempts to update Cr50 to an image built from ToT fails, with this patch the same image programs just fine. Change-Id: I064d22130a56e9e703f728bc898fd5de82d365d4 Signed-off-by: Vadim Bendebury Reviewed-on: https://chromium-review.googlesource.com/1499657 Reviewed-by: Namyoon Woo Reviewed-by: Andrey Pronin --- extra/usb_updater/gsctool.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/extra/usb_updater/gsctool.c b/extra/usb_updater/gsctool.c index e24306cbc2..996ac42749 100644 --- a/extra/usb_updater/gsctool.c +++ b/extra/usb_updater/gsctool.c @@ -720,6 +720,12 @@ static void transfer_section(struct transfer_descriptor *td, while (data_len && (data_ptr[data_len - 1] == 0xff)) data_len--; + /* + * Make sure total size is 4 bytes aligned, this is required for + * successful flashing. + */ + data_len = (data_len + 3) & ~3; + printf("sending 0x%zx bytes to %#x\n", data_len, section_addr); while (data_len) { size_t payload_size; -- cgit v1.2.1