summaryrefslogtreecommitdiff
path: root/extra/usb_updater/gsctool.c
Commit message (Collapse)AuthorAgeFilesLines
* gsctool: Parse X branding from factory config.factory-skyrim-15384.B-cr50_stabBrian Granaghan2023-05-171-1/+5
| | | | | | | | | | | | | | | | | | | BUG=b:275356839 TEST=localhost ~ # gsctool -aD --factory_config chassis_x_branded: false hw_x_compliance_version: 08 raw value: 1122334455667788 Change-Id: I8b75886d22f921671160aa62a02d9872933200e1 Signed-off-by: Brian Granaghan <granaghan@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4477485 Reviewed-by: Mary Ruthven <mruthven@chromium.org> Commit-Queue: Mary Ruthven <mruthven@chromium.org> (cherry picked from commit f430733d7accad534c1f4cbf750496c5866a22e9) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4508354 Tested-by: Wei-Shuo Su <stevesu@google.com> Auto-Submit: Wei-Shuo Su <stevesu@google.com> Commit-Queue: Chih-Yao Chuang <jasonchuang@google.com>
* gsctool: Add command to get or set factory config.Brian Granaghan2023-05-171-0/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add '--factory_config' command to get the factory config if optarg is not provided and set it if one is provided. BUG=b:275356839 TEST=localhost ~ # gsctool -a --factory_config EEDDCCBBAA998877 Failed because already set: localhost ~ # gsctool -a --factory_config 001122334455667788 Factory config failed. (7) Successful set: localhost ~ # gsctool -a --factory_config 0 localhost ~ # gsctool -a --factory_config 001122334455667788 localhost ~ # gsctool -a --factory_config 1122334455667788 Change-Id: I128e9871eb2aece3a9173c5a6e31c2ce5a4d3cd0 Signed-off-by: Brian Granaghan <granaghan@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4404231 Commit-Queue: Mary Ruthven <mruthven@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org> Tested-by: Mary Ruthven <mruthven@chromium.org> (cherry picked from commit 20ee1fabc83507d6fb5786441b22b8c4a0bfdfb9) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4507027 Auto-Submit: Wei-Shuo Su <stevesu@google.com> Commit-Queue: Chih-Yao Chuang <jasonchuang@google.com> Tested-by: Wei-Shuo Su <stevesu@google.com>
* gsctool: modify RO_A handling for DBG imagesMary Ruthven2023-03-151-5/+17
| | | | | | | | | | | BUG=b:273510573 TEST=gsctool -b dbg.bin Change-Id: I3de2687491add2d63532e028d3d62a318ce6d13a Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4342809 Reviewed-by: Andrey Pronin <apronin@chromium.org> Commit-Queue: Andrey Pronin <apronin@chromium.org>
* gsctool: reject images smaller than flash page sizeVadim Bendebury2023-03-101-3/+16
| | | | | | | | | | | | | | | | | It is impractical to use GSC images smaller than one flash page size, let's not accept them for downloading. BUG=b:272058012 TEST=get the following error trying to transfer a corrupted image: Image at offset 0x4000 too short (1024 bytes) Change-Id: Ia80e8ceaf6a5848e194000acf51824189f157ba1 Signed-off-by: Vadim Bendebury <vbendeb@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4317923 Commit-Queue: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* gsctool: Add command to get crashlogs.Brian Granaghan2023-03-091-12/+49
| | | | | | | | | | | | | | | | | | | | | Add -x <num> or --clog <num> command to fetch the crash log associated with num and dump the raw output stdout. BUG=b:265310865 TEST=gsctool -a -x 2 00000000000000000df0ad0b000000000000000000000000000000000200... 58a609000000000000000000000000000df0ad0b00000000440000000000... 000000000000000024440c00000000000000000001000000480000006801... 65720000000000009400000001000000010000008800000072763569a271... 00000018b8e20100000000000100000002000000000000000d0000000000... . . . Change-Id: I10fa3c19c31c18f1007bcc161e7ff8d2ac9e6e6c Signed-off-by: Brian Granaghan <granaghan@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4257728 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* gsctool: initialize char* pointer correctlyJett Rink2023-02-241-2/+2
| | | | | | | | | | | | | | | | | | | If gsctool is compiled more strictly, these uninitialized variables cause errors. Set the pointers to empty string like other char* variables. BUG=none TEST=make all for gsctool compiles without errors in a more strict setting Change-Id: Id65d51bcc5b81451f4235650c2cf8042986d5197 Signed-off-by: Jett Rink <jettrink@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4290237 Reviewed-by: Mary Ruthven <mruthven@chromium.org> Auto-Submit: Jett Rink <jettrink@chromium.org> Tested-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Mary Ruthven <mruthven@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* gsctool: add two new AP RO verification statusstabilize-15361.B-cr50_stabstabilize-15359.B-cr50_stabstabilize-15359.58.B-cr50_stabstabilize-15359.50.B-cr50_stabstabilize-15359.45.B-cr50_stabrelease-R112-15359.B-cr50_stabJett Rink2023-02-221-0/+6
| | | | | | | | | | | | | | | | | Add nice strings for two new AP RO verification status codes. Also make the unknown value match what is specified in ti50 (255) BUG=none TEST=make gsctool builds Change-Id: I26399640dd2cc73d7f463f38e49e5234024c24fb Signed-off-by: Jett Rink <jettrink@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4237256 Tested-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org> Auto-Submit: Jett Rink <jettrink@chromium.org>
* gsctool: Add timestamp unreliable flag for dauntless.stabilize-15317.B-cr50_stabfirmware-ti50-prepvt-15315.B-cr50_stabBrian Granaghan2023-01-091-1/+8
| | | | | | | | | | | | | | | This flag is set for logs that occur between a cold boot and AP settings the base time. These logs will start with previous_timestamp+1 and have 1<<64 set to denote that the actual base time was unknown. BUG=b:260779816 TEST=gsctool -a -L --dauntless with and without the unreliable timestamp change in firmware Change-Id: Iff87e7ca12c72b79a7b939967f266461a672ca66 Signed-off-by: Brian Granaghan <granaghan@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4143817 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* Revert "gsctool: Add timestamp unreliable flag for dauntless."Dennis Kempin2023-01-061-8/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 658729d9e338f6a970e46e69dc4c638d8ac7ccae. Reason for revert: Breaks CQ builds. See http://b/264704727 Original change's description: > gsctool: Add timestamp unreliable flag for dauntless. > > This flag is set for logs that occur between a cold boot and AP > settings the base time. These logs will start with previous_timestamp+1 > and have 1<<64 set to denote that the actual base time was unknown. > > BUG=b:260779816 > TEST=gsctool -a -L --dauntless with and without the unreliable timestamp > change in firmware > > Signed-off-by: Brian Granaghan <granaghan@google.com> > Change-Id: Iac279a948c7f34ede711c3c334ec1410b34f040c > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4112943 > Reviewed-by: Edward Hill <ecgh@chromium.org> > Reviewed-by: Mary Ruthven <mruthven@chromium.org> Bug: b:260779816 Change-Id: I9a497cc9e0f996182f7f18f93646b963d9cf5e31 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4144680 Tested-by: Dennis Kempin <denniskempin@google.com> Reviewed-by: Brian Granaghan <granaghan@google.com> Owners-Override: Dennis Kempin <denniskempin@google.com> Commit-Queue: Edward Hill <ecgh@chromium.org> Commit-Queue: Brian Granaghan <granaghan@google.com> Auto-Submit: Dennis Kempin <denniskempin@google.com> Reviewed-by: Edward Hill <ecgh@chromium.org>
* gsctool: Add timestamp unreliable flag for dauntless.Brian Granaghan2023-01-061-1/+8
| | | | | | | | | | | | | | | | This flag is set for logs that occur between a cold boot and AP settings the base time. These logs will start with previous_timestamp+1 and have 1<<64 set to denote that the actual base time was unknown. BUG=b:260779816 TEST=gsctool -a -L --dauntless with and without the unreliable timestamp change in firmware Signed-off-by: Brian Granaghan <granaghan@google.com> Change-Id: Iac279a948c7f34ede711c3c334ec1410b34f040c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4112943 Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* gsctool: Add a command to perform a GSC resetstabilize-15301.B-cr50_stabstabilize-15300.B-cr50_stabMatt Vertescher2022-12-201-1/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | To help with AP RO verification testing, it would be convenient to expose a `gsctool` command rather than point users at a cryptic `trunks_send --raw` command. This patch adds a new `--reboot` flag with an optional reset timeout parameter in milliseconds that sends the TPMV reset immediate message to the GSC. BUG=b:261857287 TEST=Ran the new command against the latest Ti50 ``` $ gsctool -D --reboot ... $ gsctool -D --reboot 1000 ... $ gsctool -D --reboot 1001 Error 1 sending immediate reset command ``` Signed-off-by: Matt Vertescher <mvertescher@google.com> Change-Id: I5c101f37579e37b5ee7dc9241b6fbff07cff6947 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4114560 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* gsctool: support setting CCD capabilitiesstabilize-15251.B-cr50_stabstabilize-15245.B-cr50_stabVadim Bendebury2022-11-141-8/+174
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is necessary to allow the user to set certain capabilities using gsctool. Which exactly capabilities can be set and to which values is determined by the policies enforced by the chip, gsctool should provide a generic way of setting any existing capability to any legal value. The 'AllowUnverifiedRo' capability stands out, because it might require the operator's physical presence confirmation, similar to the 'ccd open' case. A new vendor subcommand is being added to pass desired capability and value to Ti50, as three byte payload the version, the capability and the value. Version and value are mapped by Ti50 into the appropriate enums. All available capability names can be seen in the output of 'gsctool -D -I', the accepted values are 'Default', 'IfOpened', and 'Always'. The new functionality is achieved by allowing the 'I' command line option to accept an optional argument, a string in the form of '<capability name>:<desired value>', where both parts of the string can be abbreviated and will be accepted case insensitive unless the abbreviation is ambiguous. Since this option is supported only by Ti50, gsctool will enforce the default Ti50 USB device ID when running this command over USB and in case of errors will remind the user that the setting capabilities is not supported on Cr50. BUG=b:257253538 TEST=tried running the command on Ti50 implementing support of the new vendor subcommand. # Attempt to set when CCD is locked $ gsctool -D -I | grep State State: Locked $ gsctool -I UartGscRxAPTx:always finding_device 18d1:504a Found device. found interface 3 endpoint 4, chunk_len 64 READY ------- Got error 7(NotAllowed) # Attempt to set to the current value when CCD is open $ gsctool -D -I | grep State State: Opened $ gsctool -I UartGscRxAPTx:always finding_device 18d1:504a Found device. found interface 3 endpoint 4, chunk_len 64 READY ------- # attempt to use ambiguous capability name $ gsctool -I UartGscRx:always finding_device 18d1:504a Found device. found interface 3 endpoint 4, chunk_len 64 READY ------- Ambiguous capability name # Attempt to use incorrect value abbreviation $ gsctool -I UartGscRxAPTx:x finding_device 18d1:504a Found device. found interface 3 endpoint 4, chunk_len 64 READY ------- Unsupported capability value # Various attempts to set AllowUnverifiedRo. Transitions from # default -> ifOpened -> Always require PP, transitions in the # opposite direction do not. $ gsctool -I allow:d finding_device 18d1:504a Found device. found interface 3 endpoint 4, chunk_len 64 READY ------- $ gsctool -I allow:if finding_device 18d1:504a Found device. found interface 3 endpoint 4, chunk_len 64 READY ------- Another press will be required! Press PP button now! Press PP button now! Press PP button now! Press PP button now! Press PP button now! Press PP button now! Press PP button now! PP Done! $ gsctool -I allow:a finding_device 18d1:504a Found device. found interface 3 endpoint 4, chunk_len 64 READY ------- Another press will be required! Press PP button now! Press PP button now! Press PP button now! Press PP button now! Press PP button now! Press PP button now! PP Done! $ gsctool -I allow:d finding_device 18d1:504a Found device. found interface 3 endpoint 4, chunk_len 64 READY ------- $ - also validated that misformatted capability/value combinations are rejected as expected: $ gsctool -I xyz: finding_device 18d1:504a Found device. found interface 3 endpoint 4, chunk_len 64 READY ------- Misformatted capability parameter: xyz: $ gsctool -I :xyz finding_device 18d1:504a Found device. found interface 3 endpoint 4, chunk_len 64 READY ------- Misformatted capability parameter: :xyz $ gsctool -I xyz finding_device 18d1:504a Found device. found interface 3 endpoint 4, chunk_len 64 READY ------- Misformatted capability parameter: xyz $ gsctool -I x:yz finding_device 18d1:504a Found device. found interface 3 endpoint 4, chunk_len 64 READY ------- Unknown capability name - tried setting capabilities when running on Brya, observed expected error messages. Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Change-Id: I803440501d0e3af3c2a645b52b42970b54695701 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4010705 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* gsctool: Add AP RO verify write protect descriptors config commandMatt Vertescher2022-11-111-0/+235
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds the ability to get and set the AP RO verification write protect descriptors registers from `gsctool` by adding a new `-E` command flag with an optional argument. BUG=b:250972056 TEST=Running gsctool locally to set and get the write protect descriptors to verify communication and handlers are working properly: $ gsctool -D -E ... not provisioned $ gsctool -D -E "0xff 0xf" ... expected values: 1: ff & 0f $ gsctool -D -E "ff 0f f" ... Invalid the write protect descriptors hex string length $ gsctool -D -E "ff f 0x00 ff" ... $ gsctool -D -E ... expected values: 1: ff & 0f, 2: 00 & ff $ gsctool -D -E "0xff 0xf 0x00 0xff 0xf0 f0" ... $ gsctool -D -E ... expected values: 1: ff & 0f, 2: 00 & ff, 3: f0 & f0 Signed-off-by: Matt Vertescher <mvertescher@google.com> Change-Id: I0d7cc6a98d6cf442592a1b9b81ef1c86193dd068 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3983416 Reviewed-by: Mary Ruthven <mruthven@chromium.org> Tested-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* gsctool: fix misleading error messagestabilize-15236.66.B-cr50_stabrelease-R109-15237.B-cr50_stabrelease-R109-15236.B-cr50_stabVadim Bendebury2022-11-081-2/+1
| | | | | | | | | | | | | | | | | | | | | | The getopt_long() library function returns '?' (decimal 63) in case there is a command line parameter with required value, but there is no value in the command line. gsctool is printing "could not find long opt table index for 63" in this case, which is misleading. This patch changes error message to make sense. BUG=none TEST=before this change running './gsctool -D -R' results in "could not find long opt table index for 63" after this change error message is "Command line error, parameter argument missing" Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Change-Id: I5b1a8fda62a7edd673ea1181efb73108677b77d1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4010704 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* gsctool: Add AP RO verify SPI read/write addressing config mode commandMatt Vertescher2022-11-071-0/+148
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds the ability to get and set the AP RO verification SPI read/write addressing mode configuration setting from `gsctool` by adding a new `-C` command flag with an optional argument. BUG=b:250972056 TEST=Running gsctool locally to set and get the SPI addressing mode to verify communication and handlers are working properly: $ gsctool -D -C 3byte ... $ gsctool -D -C ... 3byte $ gsctool -D -C 4byte ... $ gsctool -D -C ... 4byte Change-Id: I2ad4af65615310cf1477adfda7df1bfdf0e0a914 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3966474 Tested-by: Matt Vertescher <mvertescher@google.com> Reviewed-by: Alyssa Haroldsen <kupiakos@google.com> Auto-Submit: Matt Vertescher <mvertescher@google.com> Commit-Queue: Matt Vertescher <mvertescher@google.com> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* gsctool: add support for AP RO Verification V2 statusJett Rink2022-11-031-0/+39
| | | | | | | | | | | | | | | | | | Implement AP RO Verification V2 status that ti50 will send via the same TPM Vendor command: VENDOR_CC_GET_AP_RO_STATUS See ti50 impl in chrome-internal:5070449 BUG=b:256892104 TEST=manually verified all V2 return values from ti50 Change-Id: I95c071046054075c045d8e698946dc81e55c64dd Signed-off-by: Jett Rink <jettrink@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3999806 Tested-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* gsctool: adjust CCD info v1 capabilities representationstabilize-15117.86.B-cr50_stabstabilize-15117.48.B-cr50_stabstabilize-15117.111.B-cr50_stabrelease-R107-15117.B-cr50_stabVadim Bendebury2022-09-141-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The gsctool utility expects the 64 capabilities values to be represented as two u32 quantities in big endian format, where each two bits represent current and default states for various capabilities. Ti50 represents the same values as single u64 little endian values. This patch modifies the cpabilities values to match expectations in case ccd_info structure is of version 1. BUG=b:244750201 TEST=capalbilities display on the Ti50 console and in gsctool output are the same in both cases when CCD is opened and locked: localhost # ./gsctool -a -I State: Opened Password: None Flags: 000000 Capabilities, current and default: UartGscRxAPTx Y Always UartGscTxAPRx Y Always UartGscRxECTx Y Always UartGscTxECRx Y IfOpened UartGscRxFpmcuTx Y Always UartGscTxFpmcuRx Y IfOpened FlashAP Y IfOpened FlashEC Y IfOpened OverrideWP Y IfOpened RebootECAP Y IfOpened GscFullConsole Y IfOpened UnlockNoReboot Y Always UnlockNoShortPP Y Always OpenNoTPMWipe Y IfOpened OpenNoLongPP Y IfOpened RemoveBatteryBypassPP Y Always I2C Y IfOpened FlashRead Y Always OpenNoDevMode Y Always OpenFromUSB Y Always OverrideBatt Y IfOpened BootUnverifiedRo Y Default CCD caps bitmap: 0x3fffff Capabilities are default. localhost # ./gsctool -a -I State: Locked Password: None Flags: 000000 Capabilities, current and default: UartGscRxAPTx Y Always UartGscTxAPRx Y Always UartGscRxECTx Y Always UartGscTxECRx - IfOpened UartGscRxFpmcuTx Y Always UartGscTxFpmcuRx - IfOpened FlashAP - IfOpened FlashEC - IfOpened OverrideWP - IfOpened RebootECAP - IfOpened GscFullConsole - IfOpened UnlockNoReboot Y Always UnlockNoShortPP Y Always OpenNoTPMWipe - IfOpened OpenNoLongPP - IfOpened RemoveBatteryBypassPP Y Always I2C - IfOpened FlashRead Y Always OpenNoDevMode Y Always OpenFromUSB Y Always OverrideBatt - IfOpened BootUnverifiedRo - Default CCD caps bitmap: 0xe9817 Capabilities are default. Signed-off-by: Vadim Bendebury <vbendeb@google.com> Change-Id: I41e0ea22265cdb5aaaff33be4ba79030e402ee1b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3895514 Reviewed-by: Mary Ruthven <mruthven@chromium.org> Commit-Queue: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* gsctool: Size TPM update request packets to fit the max block size.Sam McNally2022-09-141-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | tpm_send_pkt() uses a static buffer sized to MAX_BUF_SIZE. When updating via the TPM interface transfer_section() calls tpm_send_pkt() with a data size bounded by SIGNED_TRANSFER_SIZE. tpm_send_pkt() copies the data into its static buffer, with a 20 byte offset to leave space for the header. MAX_BUF_SIZE is 500 and SIGNED_TRANSFER_SIZE is 1024, so this overflows by 544 bytes. The build options for gsctool have recently changed to adopt the fortified version of memcpy, which now detects this buffer overflow. Split MAX_BUF_SIZE into MAX_RX_BUF_SIZE and MAX_TX_BUF_SIZE, increasing MAX_TX_BUF_SIZE to fit update packets. BUG=b:246212506 TEST=gsctool -a /opt/google/ti50/firmware/ti50.bin.prepvt succeeds make buildall -j Change-Id: I5180d8ec72a03feaeba9226c9c2f2faad29ae38a Signed-off-by: Sam McNally <sammc@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3893949 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* gsctool: support CCD info variationsVadim Bendebury2022-09-131-7/+198
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Cr50 and Ti50 generate different CCD Info reports, as the set of CCD capabilities is different on these two devices. To help addressing this problem a recent change was introduced in the Ti50 code to generate a versioned CCD Info report. This will allow the gsctool utility to address future modification of the CCD info report structure. The 'legacy' Cr50 report still does not have a header, and will be considered by gsctool 'version 0'. The Ti50 CCD Info report header version is set to 1. This patch consolidates processing of both report versions by gsctool. The set of CCD capabilities, their names and default states have been copied from Ti50 codebase and modified for code style manually, which is extremely error prone, this process will have to be automated, unfortunately there is no direct code sharing between the trees. BUG=b:244750201 TEST=on a Cr50 device for CCD in 'opened' and 'locked' states: - verified that 'gsctool -a -I' outputs for the old and new versions of gsctool are identical. On a Ti50 device, for CCD in 'opened' and 'locked' states: - verified that output of the new version 'gsctool -a -I' matches output of `ccd` ran on Ti50 console. Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Change-Id: I47592e7b74c76cf130199161baf0ae7c88056b2a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3877672 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* gsctool: cosmetic changes to pacify pre-upload checksVadim Bendebury2022-09-091-3/+3
| | | | | | | | | | | | | | | | The 'All right reserved' line is not needed in the header any more. Also fixing compiler warning about potentially unassigned variable uses. Those warnings are false positives, but it is better to keep the compiler happy. BUG=none TEST=none Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Change-Id: If9f4baaad2c837101ca3d69e85e9998bef194fc4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3887969 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* gsctool: fix compilation problemsVadim Bendebury2022-09-071-6/+10
| | | | | | | | | | | | | | | | | | | | | It turns out that due to a bug in ./Makefile gsctool is always compiled with -O0. Fixing the make file bug highlighted a bug in gsctool code where a return value of getline() was left unchecked. This patch fixes the gsctool compilation problem. BUG=b:245028043 TEST=Verified that gsctool now builds successfully with -O3. Verified that attempts to set password are properly failed when entered passwords are of different length and succeed otherwise. Change-Id: I8a3f337f3d40ff14a23162fab796b5b02f6cc664 Signed-off-by: Vadim Bendebury <vbendeb@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3876011 Tested-by: Vadim Bendebury <vbendeb@chromium.org> Commit-Queue: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org> Reviewed-by: Brian Norris <briannorris@chromium.org>
* apro: add new return codes (take two)Mary Ruthven2022-08-181-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add new ap_ro_integrity_check return codes. The existing AP_RO_PASS (1) return code doesn't verify the GBB. Rename it to AP_RO_PASS_UNVERIFIED_GBB. Shimless RMA should only treat AP_RO_PASS (6) as a pass. Nothing returns this right now. This CL also adds AP_RO_IN_PROGRESS(7). AP_RO_IN_PROGRESS is used if AP RO verification is ongoing. AP_RO_FAIL_CLEARED will be used in a followup CL. old: 1 - AP_RO_PASS new: 1 - AP_RO_PASS_UNVERIFIED_GBB ... 6 - AP_RO_PASS 7 - AP_RO_IN_PROGRESS This saves 8 bytes since it also shortens a print message. The remaining space changes from 5804 to 5812 bytes. BUG=b:234497234 TEST=make buildall -j; make -C extra/usb_updater/ gsctool Change-Id: I9f8b45f5564d453cbb4386b318b65d977d8b3f73 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3828596 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* Revert "apro: add new return codes"stabilize-15054.98.B-cr50_stabstabilize-15054.26.B-cr50_stabstabilize-15054.115.B-cr50_stabrelease-R106-15054.B-cr50_stabJudy Hsiao2022-08-121-12/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit c1f5a5481f1121e2f408055f04906205b779dc91. Reason for revert: b:242249503 ``` gsctool.c:2382:2: error: duplicate case value 2382 | case AP_RO_UNSUPPORTED_NOT_TRIGGERED: | ^~~~ gsctool.c:2373:2: note: previously used here 2373 | case AP_RO_UNSUPPORTED_NOT_TRIGGERED: | ^~~~ ``` Original change's description: > apro: add new return codes > > Add new ap_ro_integrity_check return codes. The existing AP_RO_PASS (2) > return code doesn't verify the GBB. Rename it to > AP_RO_PASS_UNVERIFIED_GBB. Shimless RMA should only treat > AP_RO_PASS (7) as a pass. Nothing returns this right now. > This CL also adds AP_RO_FAIL_CLEARED(8) and AP_RO_IN_PROGRESS(9). > AP_RO_IN_PROGRESS is used if AP RO verification is ongoing. > AP_RO_FAIL_CLEARED will be used in a followup CL. > > old: > 2 - AP_RO_PASS > > new: > 2 - AP_RO_PASS_UNVERIFIED_GBB > ... > 7 - AP_RO_PASS > 8 - AP_RO_FAIL_CLEARED > 9 - AP_RO_IN_PROGRESS > > This saves 8 bytes since it also shortens a print message. The remaining > space changes from 5804 to 5812 bytes. > > BUG=b:234497234 > TEST=make buildall -j > > Change-Id: I8d19a411c2534236c9defa82291872420c19a15b > Signed-off-by: Mary Ruthven <mruthven@chromium.org> > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3805819 > Reviewed-by: Andrey Pronin <apronin@chromium.org> > Commit-Queue: Andrey Pronin <apronin@chromium.org> Bug=b:234497234, b:242249503 Change-Id: I63ebc6a1343410e3b2a5ab0684a8a533553ec1ec Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3826713 Reviewed-by: Andrey Pronin <apronin@chromium.org> Auto-Submit: Judy Hsiao <judyhsiao@google.com> Tested-by: Judy Hsiao <judyhsiao@google.com> Owners-Override: Judy Hsiao <judyhsiao@google.com> Reviewed-by: Mary Ruthven <mruthven@chromium.org> Commit-Queue: Andrey Pronin <apronin@chromium.org> Commit-Queue: Mary Ruthven <mruthven@chromium.org>
* apro: add new return codesMary Ruthven2022-08-111-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add new ap_ro_integrity_check return codes. The existing AP_RO_PASS (2) return code doesn't verify the GBB. Rename it to AP_RO_PASS_UNVERIFIED_GBB. Shimless RMA should only treat AP_RO_PASS (7) as a pass. Nothing returns this right now. This CL also adds AP_RO_FAIL_CLEARED(8) and AP_RO_IN_PROGRESS(9). AP_RO_IN_PROGRESS is used if AP RO verification is ongoing. AP_RO_FAIL_CLEARED will be used in a followup CL. old: 2 - AP_RO_PASS new: 2 - AP_RO_PASS_UNVERIFIED_GBB ... 7 - AP_RO_PASS 8 - AP_RO_FAIL_CLEARED 9 - AP_RO_IN_PROGRESS This saves 8 bytes since it also shortens a print message. The remaining space changes from 5804 to 5812 bytes. BUG=b:234497234 TEST=make buildall -j Change-Id: I8d19a411c2534236c9defa82291872420c19a15b Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3805819 Reviewed-by: Andrey Pronin <apronin@chromium.org> Commit-Queue: Andrey Pronin <apronin@chromium.org>
* gsctool: clean up and restore compilation outside chrootstabilize-14964.B-cr50_stabfirmware-chameleon-14947.B-cr50_stabfirmware-14947.B-cr50_stabVadim Bendebury2022-06-161-2/+3
| | | | | | | | | | | | | | | | The new compiler version does not like mixing up arrays and pointers, BRANCH=none BUG=none TEST=compilation succeeds inside and outside chroot, gsctool updates succeed with Ti50 Signed-off-by: Vadim Bendebury <vbendeb@google.com> Change-Id: Ia507d27315bf601450a7d9b45cf20f98f4833a05 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3710276 Commit-Queue: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* gsctool: block ti50 upgrade without going through 0.0.15Jett Rink2022-05-231-3/+33
| | | | | | | | | | | | | | | | | | | | We need to ensure that versions before 0.0.15 upgrade to 0.0.15 before going to 0.0.16 or later. Otherwise, the first page of the new RW is erased when upgrading RO and we need to rescue. BUG=none TEST=locally changed must have version to 0.22.0 and played around with different versions on my brya. Worked as expected around version 0.22.0 Change-Id: I79b41fb86c22aa37163264815faef9558370d702 Signed-off-by: Jett Rink <jettrink@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3658243 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Vadim Bendebury <vbendeb@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Auto-Submit: Jett Rink <jettrink@chromium.org>
* gsctool: Support flog on H1D3C.stabilize-14771.B-cr50_stabBrian Granaghan2022-04-291-21/+82
| | | | | | | | | | | | BUG=b:219038720 TEST=gsctool -aL Change-Id: I1c0b417e61dcb6460345c2fcf8d43952ebbf65d3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3573469 Commit-Queue: Brian Granaghan <granaghan@google.com> Tested-by: Brian Granaghan <granaghan@google.com> Reviewed-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* gsctool: update apro boot cmd to support triggering ro verifyMary Ruthven2022-04-151-3/+26
| | | | | | | | | | | | | | | | | | | gsctool is running out of short opts. This change replaces get_apro_boot_status to make it more flexible. We can add future ap ro vendor commands to this arg. Replace --get_apro_boot_status with '--apro_boot' to get the AP RO verification status. Add '--apro_boot start' to trigger AP RO verify. BUG=b:195693537 TEST=run 'gsctool -aB start' to trigger verification on hatch. Use 'gsctool -aB' to check the status. Change-Id: I7c8cb73dca8309a5cf61981f7e3154dc85e4590d Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3587153 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
* Revert "gsctool: Support flog on H1D3C."stabilize-14682.B-cr50_stabMorg2022-04-061-75/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 6a90601b84302253f1f2572b948ca2dce69cc17c. Reason for revert: Currently breaking CQ Original change's description: > gsctool: Support flog on H1D3C. > > BUG=b:219038720 > TEST=gsctool -D -L > > Change-Id: I606d1a5958de4a94be402f6520836504f5b8c6c3 > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3561468 > Reviewed-by: Jett Rink <jettrink@chromium.org> > Reviewed-by: Mary Ruthven <mruthven@chromium.org> > Commit-Queue: Brian Granaghan <granaghan@google.com> > Tested-by: Brian Granaghan <granaghan@google.com> BUG=b:228247766 Change-Id: I03eba9b17190909e475938808892ca3747376811 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3572266 Reviewed-by: Brian Granaghan <granaghan@google.com> Tested-by: Morg <morg@chromium.org> Owners-Override: Morg <morg@chromium.org> Auto-Submit: Morg <morg@chromium.org> Commit-Queue: Brian Granaghan <granaghan@google.com> Reviewed-by: Anton Romanov <romanton@google.com>
* gsctool: Support flog on H1D3C.Brian Granaghan2022-04-051-21/+75
| | | | | | | | | | | | BUG=b:219038720 TEST=gsctool -D -L Change-Id: I606d1a5958de4a94be402f6520836504f5b8c6c3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3561468 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org> Commit-Queue: Brian Granaghan <granaghan@google.com> Tested-by: Brian Granaghan <granaghan@google.com>
* Revert "gsctool: add support for USER_PRES vc"stabilize-voshyr-14637.B-cr50_stabstabilize-14633.B-cr50_stabstabilize-14616.B-cr50_stabstabilize-14589.B-cr50_stabstabilize-14588.98.B-cr50_stabstabilize-14588.14.B-cr50_stabstabilize-14588.123.B-cr50_stabrelease-R101-14588.B-cr50_stabfactory-guybrush-14600.B-cr50_stabBrian Norris2022-03-141-65/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit d4b3156ccadb281842b22bb3bd2ad41ab1da5c9b. Reason for revert: new warnings/errors cause build failures b/224575372 Original change's description: > gsctool: add support for USER_PRES vc > > Add support for sending and interpreting the user_pres vendor command. > > BUG=b:208504127 > TEST=none > > Change-Id: I7e20f448011ffb2a15ae352a4c1e49b72afa015d > Signed-off-by: Mary Ruthven <mruthven@chromium.org> > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3495864 > Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Bug: b:208504127, b:224575372 Change-Id: I4a6c8813da5c4ed31ac6adcb410d6869ca7ec9ec Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3523383 Owners-Override: Brian Norris <briannorris@chromium.org> Auto-Submit: Brian Norris <briannorris@chromium.org> Commit-Queue: Brian Norris <briannorris@chromium.org> Tested-by: Brian Norris <briannorris@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org> Commit-Queue: Mary Ruthven <mruthven@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@google.com> Commit-Queue: Abhishek Pandit-Subedi <abhishekpandit@google.com>
* gsctool: add support for USER_PRES vcMary Ruthven2022-03-141-1/+65
| | | | | | | | | | | | Add support for sending and interpreting the user_pres vendor command. BUG=b:208504127 TEST=none Change-Id: I7e20f448011ffb2a15ae352a4c1e49b72afa015d Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3495864 Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org>
* gsctool: search on 2KB boundary instead of 16KB boundary for headerJett Rink2022-03-081-5/+5
| | | | | | | | | | | | | | | | | | | We relaxed the RW header alignment search in RO to be on the 2KB boundary instead of 16KB. This gives us more room if RO grows. ti50 already supports this. Also 2KB is the lowest is would every go since that is a hardware page boundary. BUG=b:217564005 TEST=see that gsctool can upgrade with an image that isn't align on 16KB boundary but it aligned on 2KB boundary. Change-Id: I0b05de6191d566a01b629d09d95f3d214282e454 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3508830 Reviewed-by: Mary Ruthven <mruthven@chromium.org> Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org>
* ap_ro_status: report the button status if verification is unsupportedMary Ruthven2021-10-151-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Shimless RMA needs to know if the button combo triggered AP RO verification even if AP RO verification isn't supported. This change adds two new responses AP_RO_UNSUPPORTED_TRIGGERED(5) and AP_RO_UNSUPPORTED_NOT_TRIGGERED(4) to tell if the button combo was pressed on a board that doesn't support AP RO verification. The old AP_RO_UNSUPPORTED value, 3, isn't returned by cr50 anymore. AP_RO_PASS(1) and AP_RO_FAIL(2) are still used. They both mean the combo was triggered. AP_RO_NOT_RUN(0) is still used. It still means the combo wasn't triggered. Summary of the states - pressed - AP_RO_PASS(1), AP_RO_FAIL(2), AP_RO_UNSUPPORTED_TRIGGERED(5) - not pressed - AP_RO_NOT_RUN(0) and AP_RO_UNSUPPORTED_NOT_TRIGGERED(4) - unknown - AP_RO_UNSUPPORTED_UNKNOWN(3) BUG=b:181000999 TEST=use gsctool to get the AP RO verification status on cr50 images with the new and old version of the get AP RO status vendor command. Change-Id: Ib2b33e69a4d4165fc2c13437a919b8f2a83c1bba Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3213112 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
* gsctool: add new get ap ro hash errorsMary Ruthven2021-06-181-2/+8
| | | | | | | | | | BUG=b:185783841 TEST=none Change-Id: I4c9a43efd2d3c5e77a681b8b10054a07df99df96 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2953866 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* gsctool: add support for getting AP RO boot statusMary Ruthven2021-06-181-0/+52
| | | | | | | | | | | | Add support for running the VENDOR_CC_GET_AP_RO_STATUS vendor command. BUG=b:182594555 TEST=gsctool -aB prints the AP RO verification status Change-Id: If14073894441657746a84cff8f778fd57a126625 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2951963 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* gsctool: add --dauntless flag and default to havenstabilize-14029.B-cr50_stabJett Rink2021-06-101-1/+13
| | | | | | | | | | | | | | | | | | For commands that do not take in an image, we cannot tell if we are communicating with a haven or dauntless chip automatically. Add a way to specify if we are communicating with a dauntless chip. Default to haven if the optional --dauntless flag is not present BUG=b:190659004 TEST=execute `gsctool -I` on haven chip and see success TEST=execute `gsctool -I --dauntless` on haven chip and see failure that it cannot find device with dauntless VID:PID Change-Id: Ia92422846d283eba5b27cfaa130c782f13af90ca Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2952837 Commit-Queue: Mary Ruthven <mruthven@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* gsctool: use dauntless vid:pid as default for d2 imagesJett Rink2021-03-231-12/+12
| | | | | | | | | | | | | | | | If a dauntless image is passed in on the command line, then default the vid:pid to daunltess's vid:pid if it wasn't specified on the command line. BUG=none TEST=upgraded d2 image without specifying -d option TEST=upgraded cr50 image without specifying -d option Change-Id: I8387d9d27432f6911df03e16249e91bd44b5558b Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2782361 Commit-Queue: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* cleanup: remove unnecessary image size paddingJett Rink2021-02-191-4/+2
| | | | | | | | | | | | | | | | For dauntless images, we say that the image goes to the next 16KB aligned address, but this will get reduce anyway since we don't send the 0xFFs as the end of the transfer. Removing this just reduces unnecessary complexity BUG=none TEST=update firmware on D2 TEST=update firmware on H1 (should be no change) Change-Id: I03ce12b85138b9200a8e48ad441221d3aa3f1609 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2706038 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* gsctool: use SHA256 digest for D2 instead of SHA1Jett Rink2021-02-191-19/+60
| | | | | | | | | | | | | | | Since Dauntless does not support SHA1, we need to send a SHA256 digest prefix for each firmware update packet. Haven should be unaffected by this change as it will still use SHA1 BUG=b:179683616 TEST=Verify D2 using SHA256 for validation works TEST=Verify H1 using SHA1 still works Change-Id: I4627d3d4d90e0bbe0dae78d4bb29852fad1a3149 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2702316 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* gsctool: drop logic for non-background supportJett Rink2021-02-191-37/+10
| | | | | | | | | | | | | | | | | | | We won't encounter H1 older than 0.0.22, and all dauntless will support background update support The alpha firmware drop (b:180042261) contains support for VENDOR_CC_TURN_UPDATE_ON in addition to VENDOR_CC_IMMEDIATE_RESET. Use VENDOR_CC_TURN_UPDATE_ON as the default. BUG=b:162244909,b:172465629 TEST=Upgrade firmware with alpha firmware before and after this change TEST=verify that Cr50 upgrade works as well Change-Id: Ibaf1d867dd4135f0041aa53273515e4228508cc3 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2702315 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* usb_updater: gsctool: fix buffer truncation warn/errorAdrian Ratiu2021-01-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GCC starting with v7 introduced a new warning triggered by the snprintf calls which fails the build due to having -Werror on. CrOS is upgrading GCC 4.9 -> 10.2. The fix here is to increase the buffer size a bit so the entire max string content can fit into the buffer, thus not triggering GCC's bounds checks. gsctool.c: In function 'process_erase_ap_ro_hash': gsctool.c:1540:37: error: ', size ' directive output truncated writing 7 bytes into a region of size between 0 and 2 [-Werror=format-truncation=] 1540 | "misconfigured response, rc=%d, size %zd", | ~~^~~~~ gsctool.c:1540:5: note: using the range [-..., ...] for directive argument 1540 | "misconfigured response, rc=%d, size %zd", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gsctool.c:1539:3: note: 'snprintf' output between 37 and 66 bytes into a destination of size 30 1539 | snprintf(error_details, sizeof(error_details), | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1540 | "misconfigured response, rc=%d, size %zd", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1541 | rv, response_size); | ~~~~~~~~~~~~~~~~~~ gsctool.c:1534:38: error: ', response ' directive output truncated writing 11 bytes into a region of size between 0 and 9 [-Werror=format-truncation=] 1534 | "Unexpected error rc %d, response %d", | ~~~~~~~~~^~ gsctool.c:1533:4: note: 'snprintf' output between 34 and 46 bytes into a destination of size 30 1533 | snprintf(error_details, sizeof(error_details), | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1534 | "Unexpected error rc %d, response %d", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1535 | rv, response); | ~~~~~~~~~~~~~ cc1: all warnings being treated as errors BUG=chromium:1169162 TEST=Local builds using GCC 10.2.0. Change-Id: Ib66eb6a877c52a8bd6e82a7e76d040ff927ec691 Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2645125 Tested-by: Adrian Ratiu <adrian.ratiu@collabora.corp-partner.google.com> Commit-Queue: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* coil: replace coil terms in gsctoolMary Ruthven2021-01-061-1/+1
| | | | | | | | | | BUG=b:175244613 TEST=make buildall -j Change-Id: I59278215bfc40886b213442918c07fcdbe9bbfe7 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2613452 Reviewed-by: Namyoon Woo <namyoon@chromium.org>
* gsctool: add ti50 image supportJett Rink2021-01-061-62/+214
| | | | | | | | | | | | | | | | | | Based on the input image, we determine if this is a CR50 image or a Dauntless image. The magic lets us determine which type of image it is. For D2 images, we scan for the RW header instead of using hard coded offsets as this will allow us to change where the RW is located (if RO contracts or expands). BUG=b:172465629 TEST=sent image to D2 from gsctool via CCD TEST=flash new H1 image to volteer using to slot B Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I7554c978a9ba83b423fbaf43c62f9f0d6711d071 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2585926 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* gsctool: print raw timestamp with gsctool -LMMary Ruthven2021-01-051-12/+19
| | | | | | | | | | | | | | | | | | 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 <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2610932 Reviewed-by: Andrey Pronin <apronin@chromium.org> Commit-Queue: Andrey Pronin <apronin@chromium.org>
* gsctool: add support for GET_AP_RO_HASH vendor commandMary Ruthven2020-11-181-0/+50
| | | | | | | | | | | | Add the gsctool support for the GET_AP_RO_HASH vendor command BUG=b:168634745 TEST=gsctool -aA Change-Id: I9c14446fbea22e428ca920341a8c1618b82722a3 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2547198 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* gsctool: add option to erase AP RO hashVadim Bendebury2020-05-291-3/+55
| | | | | | | | | | | | | | | | | | | The new option triggers sending the VENDOR_CC_SEED_AP_RO_CHECK vendor command with the empty payload. The Cr50 response indicates if the erase succeeded or there were problems (either board ID space not erased, or flash erase operation failed). BUG=b:153764696 TEST=verified successful erase of the AP RO flash space on devices with empty board ID space, and failure to erase in case board ID space is programmed with the appropriate error message. Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Change-Id: I4b7c981323771b73a837e766bd5e94e3824e8e00 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2204976 Reviewed-by: Namyoon Woo <namyoon@chromium.org>
* gsctool: print sensible date when listing flash log contentsVadim Bendebury2020-05-111-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | Displaying epoch values in the flash log entries does not help the end user to synchronize the flash log events with other logs generated on the device. This patch changes the log output format to display the device time zone in the first line and then all present log entries with timestamp in 'dd:mm:yy hh:mm:ss' format. BUG=b:153764696 TEST=ran the new gsctool image on a Chrome OS device: $ gsctool -a -L Log time zone is PST Dec 31 69 16:00:01 : 00 May 06 20 21:20:41 : 09 01 ... May 08 20 12:09:21 : 09 00 May 08 20 12:09:22 : 09 03 May 08 20 12:09:23 : 09 06 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Change-Id: I3fca12e1679fbdd9e0e168606014e84c89c42402 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2191282 Reviewed-by: Namyoon Woo <namyoon@chromium.org>
* gsctool: supprot enabling write protection (WP)Vadim Bendebury2020-04-141-13/+39
| | | | | | | | | | | | | | | | This patch makes use of the modification of the vendor command VENDOR_CC_WP, which allows to enable WP. BUG=b:153881773 TEST=verified that attempts to enable WP when running the unmodified Cr50 image fail with error message "Early Cr50 versions do not support setting WP", and that the updated Cr50 image allows to enable WP using 'gsctool -a -w enable' Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Change-Id: Ie28c1c9b171dd6ea2e3edc0ae624f953cb4fa4fe Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2149526 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* gsctool: get the current system boot modeNamyoon Woo2020-03-061-2/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | gsctool -g or --getbootmode can get the current system boot mode. BUG=b:141578322 BRANCH=cr50 TEST=ran on helios. $ ./extra/usb_updater/gsctool --getbootmode finding_device 18d1:5014 Found device. found interface 3 endpoint 4, chunk_len 64 READY ------- Boot mode = 0x00: NORMAL $ ./extra/usb_updater/gsctool -g finding_device 18d1:5014 Found device. found interface 3 endpoint 4, chunk_len 64 READY ------- Getting boot mode Boot mode = 0x00: NORMAL Change-Id: Id024ac94fb08b680bd5e190bc7eeb2de301b70a2 Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2058128 Reviewed-by: Mary Ruthven <mruthven@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>