summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Clear OWNERS for factory/firmware branchfactory-gru-9017.BBrian Norris2021-09-102-10/+1
| | | | | | | | | | | | BUG=none TEST=none Change-Id: I0f03f432ada1064ffba9595be78ca7ab4d25ecd1 Signed-off-by: Brian Norris <briannorris@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3155059 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Owners-Override: Jora Jacobi <jora@google.com> Tested-by: Jack Rosenthal <jrosenth@chromium.org>
* usb_updater: fix transposed symbolic board ID representationVadim Bendebury2017-09-091-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | When usb_udpater reads board ID information from a binary blob, in case the ID field can be represented as a 4 character ASCII string the updater transposes the characters, resulting in a reversed string printed. Fix the transposition to verify that the result is printed properly. BRANCH=none BUG=b:63597142 TEST=ran the following commands: $ make BOARD=cr50 $ CR50_BOARD_ID='TEST:ff00:ff00' H1_DEVIDS='0x0169c181 0x04656742' \ ./util/signer/bs $ ./extra/usb_updater/usb_updater -b build/cr50/ec.bin read 524288(0x80000) bytes from build/cr50/ec.bin RO_A:4919.0.0 RW_A:0.0.21[TEST:0000ff00:0000ff00] RO_B:-1.-1.-1 ... Change-Id: I852cf9505d6b8b9e7133ca1008be1b22081a9d88 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/567681 Reviewed-by: Mary Ruthven <mruthven@chromium.org> (cherry picked from commit a9c26a97ef3910e4a12434519be6b29763475f8b) Reviewed-on: https://chromium-review.googlesource.com/658355 Reviewed-by: Philip Chen <philipchen@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
* usb_updater: display board ID information from RW headersVadim Bendebury2017-09-091-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds code to interpret the contents of the Cr50 image's RW headers board ID fields. Board ID fields are added to the RW and RW_B version strings, as a three field colon separated value. The actual board ID is likely to be a 4 symbol ASCII string, if it is, the 4 ASCII characters are displayed. If it is not - the 8 character hex value is printed. The rest of the fields are displayed as 8 characters hex values. BRANCH=none BUG=b:62294740 TEST=tried the new option on various Cr50 images: $ ./extra/usb_updater/usb_updater -b build/cr50/ec.bin read 524288(0x80000) bytes from build/cr50/ec.bin RO_A:4919.0.0 RW_A:0.0.21[00000000:00000000:00000000] ... $ ./extra/usb_updater/usb_updater -b cr50.bin.dev read 524288(0x80000) bytes from cr50.bin.dev RO_A:0.0.10 RW_A:0.0.21[XXXR:00000004:00000001]... Change-Id: I5a92a600d24e4a7d6d615f256b5979414e883d77 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/562919 Reviewed-by: Randall Spangler <rspangler@chromium.org> (cherry picked from commit f50e0086e61aed2b722bd37c188e7e2204735f32) Reviewed-on: https://chromium-review.googlesource.com/658354 Reviewed-by: Philip Chen <philipchen@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
* usb_updater: allow symbolic Board IDsVadim Bendebury2017-09-091-10/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When specifying board ID to program, it is convenient to be able to specify the ID as a string, as reported by the RLZ stored in the VPD. With this patch the first component of the board_id command line option is considered a string if it is no longer than 4 bytes. BRANCH=cr50 BUG=b:35587387,b:35587053 TEST=ran the following commands (interleaved with erasing INFO1 on the target): localhost ~ # usb_updater -s -i Board ID space: ffffffff:ffffffff:ffffffff localhost ~ # usb_updater -s -i ABCD localhost ~ # usb_updater -s -i Board ID space: 41424344:bebdbcbb:0000ff00 localhost ~ # usb_updater -s -i Board ID space: ffffffff:ffffffff:ffffffff localhost ~ # usb_updater -s -i 0x41424344:0x1234 localhost ~ # usb_updater -s -i Board ID space: 41424344:bebdbcbb:00001234 localhost ~ # usb_updater -s -i Board ID space: ffffffff:ffffffff:ffffffff localhost ~ # usb_updater -s -i ABCD:0x1234 localhost ~ # usb_updater -s -i Board ID space: 41424344:bebdbcbb:00001234 Change-Id: Ied8b240d60ea50f6fc8633f919ce4bc81ac17727 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/528440 Reviewed-by: Randall Spangler <rspangler@chromium.org> (cherry picked from commit bdbb45b14acf4af6acef045272c845204adc77e3) Reviewed-on: https://chromium-review.googlesource.com/658353 Reviewed-by: Philip Chen <philipchen@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
* Cr50: usb_updater: add commands to get/set board idVadim Bendebury2017-09-081-3/+131
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch enhances the Cr50 usb_updater to allow to get and set Board ID value saved in the Cr50's INFO1 space using the earlier introduced dedicated vendor commands. Getting or Setting the board ID does not require establishing a connection with the Cr50, the new option is --board_id/-i. When specified without a parameter, the new option will cause the Board ID to be read. When specified with a parameter, the board ID value will be set. The parameter includes one or two values in a single string, the values separated by a colon. The first value is a 4 byte board ID, and the second value is the flags field. The default flags field is set to 0xff00. BRANCH=cr50 BUG=b:35587387,b:35587053 TEST=verified that it is possible to get and set the board ID value using usb_updater, both over USB and TPM. verified that it is not possible to set a new board ID value is the INFO1 space has been already programmed. verified that it is not possible to set a board ID value which would not allow the currently running image to start (even though there is no run time check yet). Change-Id: Ief175d8b2ef3177db13fa86f831914088d9447b0 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/525096 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> (cherry picked from commit 25fb7bb3e54b8e68d3e03119a521cfac0a6bb5cb) Reviewed-on: https://chromium-review.googlesource.com/658352 Reviewed-by: Philip Chen <philipchen@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
* cr50: Add console and TPM vendor commands to get/set board IDPhilip Chen2017-09-086-3/+349
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds vendor and console commands to read and write the board ID space in the INFO1 block. Current image's board ID settings are saved in the image header by the latest codesigner. Board ID write attempts are rejected if the board ID space is already initialized, or if the currently running image will not be allowed to run with the new board ID space settings. Error codes are returned to the caller as a single byte value. Successful read command returns 12 bytes of the board ID space contents. The console command always allows to read the board ID value, and allows to write it if the image was built with debug enabled. Conflicts: chip/g/flash_info.h BUG=b:35586335 BRANCH=cr50 TEST=as follows: - verified that board ID can be read by any image and set by debug images. - with the upcoming patches verified the ability to set and read board ID values using vendor commands. Change-Id: I35a3e2db92175a29de8011172b80091065b27414 Signed-off-by: Philip Chen <philipchen@google.com> Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/522234 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org> (cherry picked from commit ee545922389739b39cc0ac7e0f0d1dd8c2c67607) Reviewed-on: https://chromium-review.googlesource.com/658351 Reviewed-by: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org>
* cr50: usb_updater: do not send setup request unless necessaryVadim Bendebury2017-09-081-21/+26
| | | | | | | | | | | | | | | | | | | | | | | | | There are only two usb_updater actions which require establishing a connection with the Cr50: transferring the firmware image during update and reporting the version of the running image (because the version is reported when the connection is established). This patch refactors usb_updater code to establish the connection only when necessary. BRANCH=cr50 BUG=b:35587387,b:35587053 TEST=verified that 'usb_updater -c' succeeds both issued over USB and TPM Change-Id: I6a0c82eb440c092263d4802f124f458f148a8ab5 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/525095 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> (cherry picked from commit 885c02a92d35607bf410e27f27c0b35e67827cf5) Reviewed-on: https://chromium-review.googlesource.com/658350 Reviewed-by: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org>
* cr50: usb_updater: add proper vendor command processingVadim Bendebury2017-09-081-39/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | So far vendor command processing has been a second class citizen in the Cr50 usb_updater: return codes were mostly ignored even when using TPM, when using USB there was no way to communicate return codes at all. This patch refactors the source code to use a single function to process vendor commands over both USB and TPM, adding proper passing of the result codes back to the caller in both cases, retrieving the return code from the response header when using TPM and from the first byte of the response payload when using USB. BRANCH=cr50 BUG=b:35587387,b:35587053 TEST=verified that it is possible to update rw13, rw18 and rw20 both over TPM and USB, which indicates that vendor commands are properly handled. Change-Id: I837e17b29d3b025fbca5b1ef49463cfb1729fe6c Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/525094 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> (cherry picked from commit b06942187e7025d1334bcd8d0ffa95b225c19179) Reviewed-on: https://chromium-review.googlesource.com/658349 Reviewed-by: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org>
* usb_updater: when communicating over tpm treat upgrades differentlyVadim Bendebury2017-09-081-13/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | All extension and vendor commands' payloads need to be passed to the processing functions the same way, whether they arrive over /dev/tpm0 or over USB. The upgrade PDUs sent over USB need to include two additional fields which are stripped off by the reassembly layer on the Cr50. This patch makes sure that none of other than EXTENSION_FW_UPGRADE commands sent over /dev/tpm0 by usb_updater have the extra encapsulation. BRANCH=cr50 BUG=b:62106898 TEST=verified that updates work the same way over TPM and USB (which includes sending the 'turn_update_on' commands. Before this patch the turn_update_on command sent by usb_updater over TPM was not processed properly (the timeout value was wrong). Change-Id: I3f4ab7330037f6eb1ce8bac7c63faa5d7c309c94 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/517416 Reviewed-by: Andrey Pronin <apronin@chromium.org> (cherry picked from commit bd0f74a6f49cd3dcbed81738e376a8b05868b4f5) Reviewed-on: https://chromium-review.googlesource.com/658348 Reviewed-by: Philip Chen <philipchen@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
* usb_updater: do not filter out dev cr50 versionsVadim Bendebury2017-09-081-12/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The usb_updater code comparing versions to decide which one is newer filters out values in excess of 1000 to not consider dev build versions to be newer than the released versions. In fact this logic is flawed: with node locked RO it is possible to build dev (self signed) version, which can run on the device, and this version should take over the released version, if it is currently present on the device. If the RO is not node locked, the dev RW version will not verify, so it is safe to download it to the chip, it would be ignored. BRANCH=cr50 BUG=none TEST=with this patch applied it is possible to update self signed versions running on H1 (the updater considers them newer than 0.0.18 and sends the chip the vendor command to enable the downloaded image after download completes). Change-Id: Ibb5761e4bb24fcc7dee5cc10b2f26af7a8e9aa2e Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/492087 Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org> (cherry picked from commit 32eebe3c5f12c1963bf9bc921839de1168cd7396) Reviewed-on: https://chromium-review.googlesource.com/658347 Reviewed-by: Philip Chen <philipchen@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
* usb_updater: post a reset during upstart on old versionsMary Ruthven2017-09-081-4/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If Cr50 does not have support for invalidating the RW header and restoring it, then upstart should still post a reset. This changes usb_updater to post a restart during upstart if the RW minor version is less than 19. BUG=none BRANCH=cr50 TEST=manual Copy new usb_updater onto the DUT. run 'sync' Build two cr50 debug images one with 0.0.19 and one with 0.1.12 verify update process works test_that $DUT_IP -b $BOARD firmware_Cr50Update --args="old_release_image=$PATH_TO_PROD_13 release_image=$PATH_TO_PROD_18 dev_image=$DBG_IMAGE_19" Build a firmware image with https://review.coreboot.org/#/c/18946/3 test_that $DUT_IP -b $BOARD firmware_Cr50Update --args="old_release_image=$PATH_TO_PROD_18 release_image=$DBG_IMAGE_19 dev_image=$DBG_IMAGE_1_12" Change-Id: I811977de26999b1d26bd2d4126b88b1c55a93931 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/470326 Reviewed-by: Aaron Durbin <adurbin@chromium.org> (cherry picked from commit bcc4e087a13727755482b13b44f1ab7bfd361beb) Reviewed-on: https://chromium-review.googlesource.com/658346 Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
* usb_updater: /dev/tmp0 -> /dev/tpm0Brian Norris2017-09-081-1/+1
| | | | | | | | | | | | | | | | | | That's a typo. BUG=none TEST=none BRANCH=none Change-Id: I4577a746c113b6c1d2c6745975272532909c8a8a Signed-off-by: Brian Norris <briannorris@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/470507 Reviewed-by: Andrey Pronin <apronin@chromium.org> (cherry picked from commit 6277174bff831f7fae8958dfdab131893cc43dcc) Reviewed-on: https://chromium-review.googlesource.com/658345 Reviewed-by: Philip Chen <philipchen@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
* usb_updater: only run send_done on usb transfersMary Ruthven2017-09-081-1/+2
| | | | | | | | | | | | | | | | | | | | show_fw_ver runs send_done on both usb and tpm transfers. This changes usb_update, so it will only run send_done on usb transfers BUG=none BRANCH=cr50 TEST=copy to dut. stop trunksd. Run 'usb_updater -f -s && usb_updater -f && usb_updater -f' Change-Id: I3a09c003ae41a4651c9961092552d7807656a68a Reviewed-on: https://chromium-review.googlesource.com/470169 Commit-Ready: Mary Ruthven <mruthven@chromium.org> Tested-by: Mary Ruthven <mruthven@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org> (cherry picked from commit 56e3c669e829993683199514b78d2497784d3766) Reviewed-on: https://chromium-review.googlesource.com/658344 Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
* usb_updater: fix --fwverMary Ruthven2017-09-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change adds a send_done call at the end of show_fw_ver. With this change Cr50 will set the state to rx_idle after every usb_update -f call. Cr50 cannot process any vendor commands unless the updater state is idle. After a vendor command is sent cr50 wont set the state to idle unless it receives a send_done call. It will also reset the state if it sees that it has been more than 5 seconds since the last transfer. In the current state you cannot use usb_updater -f back to back because usb_updater doesn't call send_done through the -f path. If you wait 5 seconds between calls, then it will work. If the call fails and you keep retrying waiting less than 5 seconds between calls, then it will fail forever. The last transfer time will get reset with each call and Cr50 will never reach the timeout to reset the usb_update state to idle. BUG=none BRANCH=cr50 TEST=run 'sudo ./usb_updater -f && sudo ./usb_updater -f'. Verify both calls succeed. Change-Id: I5daca8e03ece840288abb61e02a528a9af0ada30 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/465491 Reviewed-by: Aaron Durbin <adurbin@chromium.org> (cherry picked from commit e69a10388476c963c52d99967d15362a5ce44064) Reviewed-on: https://chromium-review.googlesource.com/658343 Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
* usb_updater: fix -b optionMary Ruthven2017-09-081-1/+1
| | | | | | | | | | | | | | | | | | | We want the -b option to be parsed the same way as the -u option, because usb_updater should handle reading the file the same way. This changes binver hasarg to be 0, so that it doesn't eat the filename. BUG=none BRANCH=cr50 TEST=usb_updater --binver $IMAGE Change-Id: I0b868bc5d316e5fb42fc34bc746bbee868d20630 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/465490 Reviewed-by: Aaron Durbin <adurbin@chromium.org> (cherry picked from commit 24fd8060fd27f0306d5d3f91faa09d28ed892772) Reviewed-on: https://chromium-review.googlesource.com/658342 Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
* usb_updater: separate image updates and resets, add restore image optionVadim Bendebury2017-09-081-62/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With the upcoming availability of the downloaded header corruption, there needs to be a mechanism for usb_updater to restore the corrupted header, so that the downloaded code can run right away. This patch separates image download and reset functionality. Download happens as before, and the UPGRADE_DONE PDU is sent immediately once image transfer completes. This puts the receive state machine into the idle state and allows to send other commands. The reset function is different for the target supporting protocol versions 5 and above. The only command version 5 recognizes is the indirect reboot command (the UPGRADE_DONE PDU sent the second time in a row). For protocol version 6 and above the reset could be immediate or posted, and for targets running RW version 19 or above the command to restore the corrupted header is required. When running on the target the command to restore the corrupted header would be generated by the AP firmware on the reboot. BRANCH=cr50 BUG=b:35580805 TEST=with the next patch of the series applied observed the corrupted header properly restored and the device rebooted. Change-Id: If87c12fe8578cd6f1b4beed6d113471356f6b6c2 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/457677 Reviewed-by: Aaron Durbin <adurbin@chromium.org> (cherry picked from commit 218f65dda650e775b9e28e5dee9704f6511e8a28) Reviewed-on: https://chromium-review.googlesource.com/658341 Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
* cr50: add vendor command to restore corrupted headerVadim Bendebury2017-09-084-5/+194
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The upcoming move of the Cr50 firmware update to the background requires postponing the activation of the newly uploaded Cr50 image to a later point in time, when the AP is ready to switch to start using the new Cr50 image. The suggested way of achieving it is as follows: when downloading the new image, the current Cr50 code modifies the header's 'image_size' field, setting its top bit to 1. This both makes the size invalid and guarantees that the new image would not verify on the following Cr50 restarts. When the AP is ready to switch to running the new Cr50 image, it will send a vendor command, which would trigger the currently running Cr50 image to restore the other image's size field. This vendor command would also communicate the timeout for the Cr50 to wait before rebooting, if there has been at least one header (ro or rw) restored. Rebooting the Cr50 would trigger rebooting the AP, resulting in the entire system running the updated firmware. Response sent to the AP will indicate if there has been a header restored and the reboot is indeed upcoming, this would allow the AP to quiesce the state of the device to handle the reboot gracefully. Conflicts: common/extension.c include/tpm_vendor_cmds.h BRANCH=cr50 BUG=b:35580805 TEST=with the rest of the patches applied observed the system properly after the new header version was restored. Change-Id: Ia1edee67b6aa8f458810d5dc2931477cfaab1566 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/457676 Reviewed-by: Aaron Durbin <adurbin@chromium.org> (cherry picked from commit dc66986d0a7fd182ddcafbee00045a25709edcb4) Reviewed-on: https://chromium-review.googlesource.com/658340 Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
* usb_updater: stop supporting protocol versions below 5Vadim Bendebury2017-09-081-107/+47
| | | | | | | | | | | | | | | | | | | | | | | There are no early H1 chips left in circulation, all released chips (starting with RW 0.0.10) support update protocol version 5. This patch drops all technical debt associated with supporting earlier protocol versions. BRANCH=cr50 BUG=b:35580805 TEST=downgraded an H1 test board to ro 0.0.8 rw 0.0.9. Updated it to the latest image (ro 0.0.10 rw 0.0.18). Change-Id: I28c9b0c597122c7aa602a88fb56f9c7bf04b9984 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/457500 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org> (cherry picked from commit bd30d3f2cd5a0fb90ec72ed7ea47b3f29d114c7f) Reviewed-on: https://chromium-review.googlesource.com/658339 Reviewed-by: Philip Chen <philipchen@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
* usb_updater: fix command line options descriptionVadim Bendebury2017-03-071-1/+2
| | | | | | | | | | | | | | | | | | | | | | The -b command line option should not be described as requiring a parameter, as the binary file is given to most of invocations of usb_updater. Also adding the missing -p command line option description. BRANCH=none BUG=none TEST='usb_updater -b <file name>' does not fail any more Change-Id: I6ceefa8c4dda841db63177d6134a611600a43078 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/448956 Reviewed-by: Aaron Durbin <adurbin@chromium.org> (cherry picked from commit ee1ccf4fbe7edf9817cb1d64043dbbdc926b9be2) Reviewed-on: https://chromium-review.googlesource.com/451042 Reviewed-by: Youcheng Syu <youcheng@google.com> Commit-Queue: Youcheng Syu <youcheng@google.com> Tested-by: Youcheng Syu <youcheng@google.com>
* usb_updater: change command line option from --spi to --systemdevVadim Bendebury2017-03-071-19/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The command line option to trigger communicating with the cr50 over /dev/tpm0 has been set to 'spi' originally, as SPI was the interface to communicate with the TPM on first devices using cr50. This is not technically correct, as many devices use i2c for this purpose. Let's rename the command line option from 'spi' to 'dev' and correct names and comments to reflect this too. BRANCH=none BUG=none TEST=ran on a reef device: localhost tmp # ./usb_updater -f --systemdev Could not open TPM: Device or resource busy localhost tmp # initctl stop trunksd trunksd stop/waiting localhost tmp # ./usb_updater -f --systemdev start target running protocol version 6 offsets: backup RO at 0x40000, backup RW at 0x4000 keyids: RO 0xaa66150f, RW 0xb93d6539 Current versions: RO 0.0.10 RW 0.0.16 localhost tmp # ./usb_updater -f -s start target running protocol version 6 offsets: backup RO at 0x40000, backup RW at 0x4000 keyids: RO 0xaa66150f, RW 0xb93d6539 Current versions: RO 0.0.10 RW 0.0.16 Change-Id: Ifbdd3618209ad9930e0678cf50e82a789ae5e2cd Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/447781 Reviewed-by: Aaron Durbin <adurbin@chromium.org> (cherry picked from commit 6ceabb07e3ee571437cba34360701b73e83f5516) Reviewed-on: https://chromium-review.googlesource.com/451041 Reviewed-by: Youcheng Syu <youcheng@google.com> Commit-Queue: Youcheng Syu <youcheng@google.com> Tested-by: Youcheng Syu <youcheng@google.com>
* g: usb_updater: fix option description and add post_resetVadim Bendebury2017-03-071-13/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new option allows the operator to explicitly request the post reset reboot instead of immediate reboot (which is now ignored by production cr50 images). Also sort option descriptions and move the colons where they belong (after command line arguments requiring additional parameters), BRANCH=none BUG=none TEST=running usb_updater with -b or -d without extra parameter causes the return error code and the help message printed. running $ ./extra/usb_updater/usb_updater -p build/cr50/ec.bin results in a proper image transfer, with the following reboot of the chromeos device triggering cr50 reset and the new downloaded image running. Change-Id: I64328973a2dfac1b78262f1ffacd677e52956d27 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/446939 Reviewed-by: Aaron Durbin <adurbin@chromium.org> (cherry picked from commit 31cfc63b80ea8f5b778e6c3f568f325a6064244a) Reviewed-on: https://chromium-review.googlesource.com/451040 Reviewed-by: Youcheng Syu <youcheng@google.com> Commit-Queue: Youcheng Syu <youcheng@google.com> Tested-by: Youcheng Syu <youcheng@google.com>
* g: rate limit firmware updatesVadim Bendebury2017-03-074-5/+147
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduces a delay between accepted cr50 firmware upload attempts. The next attempt to write into the same or lower address in flash would be accepted no sooner than in 60 seconds after the previous attempt. This would prevent a rogue user from wearing the flash by repeated uploads to the same address. This limitation is not imposed by dev images (those compiled with CR50_DEV=1). BRANCH=none BUG=chrome-os-partner:63098 TEST=verified that attempts to update soon after the previous update result in the following error message issued by usb_updater: sending 0x2d8b8 bytes to 0x4000 Error: status 0x9 Modified usb_updater to send one random pdu twice. Observed the same error message. Change-Id: Idca55ad091d09daaddd0a4cad5b1f871af1ede93 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/445496 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/451197 Reviewed-by: Youcheng Syu <youcheng@google.com> Commit-Queue: Youcheng Syu <youcheng@google.com> Tested-by: Youcheng Syu <youcheng@google.com>
* usb_updater: initialize corrupt_inactive_rw before using itVadim Bendebury2017-02-071-1/+4
| | | | | | | | | | | | | | | | | | | | | | | The earlier change introduced the uninitialized variable bug, which was not caught by the compiler. Let's make sure the variable is always initialized, and also let's add a message informing the user that the binary image is ignored when -f or -c command line options are given. BRANCH=none BUG=chrome-os-partner:55667 TEST=there is no accidental attempts to erase the inactive firmware any more. The message is printed when the binary image is ignored. Change-Id: If67841fa3933e7c2df772348ed5308ff722a6e3a Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/421498 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/439099 Reviewed-by: Youcheng Syu <youcheng@google.com> Commit-Queue: Youcheng Syu <youcheng@google.com> Tested-by: Youcheng Syu <youcheng@google.com>
* usb_updater: add command to corrupt rwMary Ruthven2017-02-071-3/+33
| | | | | | | | | | | | | | | | | | | This change adds a option to use the vendor command VENDOR_CC_INVALIDATE_INACTIVE_RW to invalidate the inactive rw image. BUG=chrome-os-partner:55667 BRANCH=none TEST=run 'usb_updater -c' use the cr50 console to verify the inactive rw image version is 'Error' Change-Id: Id460f7ac9f20146902da7596613bee566f473dd2 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/421141 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/439098 Reviewed-by: Youcheng Syu <youcheng@google.com> Commit-Queue: Youcheng Syu <youcheng@google.com> Tested-by: Youcheng Syu <youcheng@google.com>
* cr50: add vendor command to invalidate inactive rwMary Ruthven2017-02-072-0/+54
| | | | | | | | | | | | | | | | | | | | | | | | This adds a vendor command to invalidate the old rw. It should be used when the tpm has been validated. BUG=chrome-os-partner:55667 BRANCH=none TEST=manual run the vendor command run 'ver' on the cr50 console and verify the inactive RW version is Error reboot cr50 10 times and make sure there is no rollback. Change-Id: Ibec3dde77d6b1ab921e43613d54638b7318f3f57 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/420407 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/439097 Reviewed-by: Youcheng Syu <youcheng@google.com> Commit-Queue: Youcheng Syu <youcheng@google.com> Tested-by: Youcheng Syu <youcheng@google.com>
* usb_updater: close connection when no data is transferredVadim Bendebury2017-02-071-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | When usb_updater is invoked with the '-f' option and without specifying the binary file to transmit, the cr50 still enters the data transfer mode, even though the host is not transferring anything. As a result cr50 stays in the 'rx_outside_block' state until timeout expires. Another usb_updater invocation fails if attempted before timeout expiration. The UPGRADE_DONE PDU sent by the host causes the state machine to switch to the idle state immediately. BRANCH=none BUG=none TEST=ran the following commands: usb_updater -f && usb_updater -f the second invocation used to fail before this change, now it succeeds. Change-Id: Iceafeb30de6011975fbf47dabc7c6c494177c0f7 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/415554 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/439096 Reviewed-by: Youcheng Syu <youcheng@google.com> Commit-Queue: Youcheng Syu <youcheng@google.com> Tested-by: Youcheng Syu <youcheng@google.com>
* usb_updater: protocol version 6 (vendor commands over usb)Vadim Bendebury2017-02-073-32/+206
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduces version 6 of the cr50 USB update protocol. This version allows to multiplex TPM vendor and extension commands over the same USB endpoint which is used for firmware updates. When channeling TPM vendor commands the USB update frame looks as follows: 4 bytes 4 bytes 4 bytes 2 bytes variable size +-----------+--------------+---------------+-----------+------~~~-------+ + total size| block digest | EXT_CMD | Vend. sub.| data | +-----------+--------------+---------------+-----------+------~~~-------+ Where 'Vend. sub' is the vendor subcommand, and data field is subcommand dependent. The target tells between update PDUs and encapsulated vendor subcommands by looking at the EXT_CMD value - it is set to 0xbaccd00a and as such is guaranteed not to be a valid update PDU destination address. In the previous protocol versions target reset was requested by the host sending a 4 byte PDU after the target receives the UPGRADE_DONE message and moves the state machine to the 'awaiting_reset' state. With the ability to transfer vendor commands, there is no need for the target to have a special state for reset. The host can send the posted or immediate reboot request using the appropriate vendor command. As a result the 'awaiting_reset' state has been removed, the target accepts vendor commands only when state machine is in the rx_idle state. Vendor command response size is not fixed, it is subcommand dependent. In the current implementation the total size of the vendor command PDU can not exceed 64 bytes, as there is no reassembly on the target side. For backwards compatibility in case the target is running protocol version earlier than 6, the 4 byte PDU is still sent to the target after UPGRADE_DONE is sent. BRANCH=none BUG=chrome-os-partner:60013 TEST=tested updates on Reef and Gru, observed that it is possible to update earlier versions of firmware, and that it is possible to request immediate and posted reset (depending on the presence of the -u flag in the usb_updater invocation). Change-Id: I6ea9e9f742c96b8ab0670e9cec87a83cd47bb20e Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/414948 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/439095 Reviewed-by: Youcheng Syu <youcheng@google.com> Commit-Queue: Youcheng Syu <youcheng@google.com> Tested-by: Youcheng Syu <youcheng@google.com>
* usb_updater: improve debugabilityVadim Bendebury2017-02-073-1/+11
| | | | | | | | | | | | | | | | | | | | | | When usb update errors happen it helps a lot to be able to see the actual error code returned by the target and where the error was generated. This patch adds a few printouts to help with debugging. BRANCH=none BUG=none TEST=observed proper error messages generated while debugging introduction of extension/vendor commands transfer over USB. Change-Id: I06c77e7467f7f9547704c88c4b673866fb2e6032 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/414947 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/439094 Reviewed-by: Youcheng Syu <youcheng@google.com> Commit-Queue: Youcheng Syu <youcheng@google.com> Tested-by: Youcheng Syu <youcheng@google.com>
* usb_updater: use proper TPM command code for vendor commandsVadim Bendebury2017-02-071-1/+4
| | | | | | | | | | | | | | | | | | | | | Until extension commands using incompatible TPM command code are phased out, the function sending vendor/extension commands to the TPM needs to be aware of the subcommand code and use the matching TPM command code. BRANCH=none BUG=chrome-os-partner:60013 TEST=with the rest of the patches applied both posted and immediate reset commands operate on Gru as expected. Change-Id: I8977df22e4c2fadfd3427c0b4f70035f7f532e00 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/414946 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/439093 Reviewed-by: Youcheng Syu <youcheng@google.com> Commit-Queue: Youcheng Syu <youcheng@google.com> Tested-by: Youcheng Syu <youcheng@google.com>
* tpm: move extension and vendor command definitions into own fileVadim Bendebury2017-02-073-74/+91
| | | | | | | | | | | | | | | | | | | Let's make sure that both embedded and host side use the same command definitions. To avoid host compilation problems move the definitions into a separate file. BRANCH=none BUG=none TEST=compilation still works. Change-Id: Id0d85a51aebabed0637965b3b19d7ed42c46e75e Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/414945 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/439092 Reviewed-by: Youcheng Syu <youcheng@google.com> Commit-Queue: Youcheng Syu <youcheng@google.com> Tested-by: Youcheng Syu <youcheng@google.com>
* g: update: expose USB PDU verification functionVadim Bendebury2017-02-072-12/+26
| | | | | | | | | | | | | | | | | | | | | Some upcoming changes will introduce transfer of vendor and extension commands over the usb updater endpoint. This patch exposes a function which allows to verify integrity of received USB PDUs. BRANCH=none BUG=chrome-os-partner:60013 TEST=no functional changes, usb_updater still works fine. Change-Id: I8d9e6746ef0dfbb17bba618410514ca047a59a45 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/414441 Reviewed-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/439091 Reviewed-by: Youcheng Syu <youcheng@google.com> Commit-Queue: Youcheng Syu <youcheng@google.com> Tested-by: Youcheng Syu <youcheng@google.com>
* usb_updater: unify normal and error messagesVadim Bendebury2017-02-071-9/+9
| | | | | | | | | | | | | | | | | | | Just for consistency sake, make all normal messages generated by the utility in the course of firmware update start with lower case letters and all error messages start with upper case letters. BRANCH=none BUG=none TEST=make buildall -j still succeeds Change-Id: Ifb0bd8dec4c2bb5cbbb2c93b1918fc699c2f33dd Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/414944 Reviewed-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/439090 Reviewed-by: Youcheng Syu <youcheng@google.com> Commit-Queue: Youcheng Syu <youcheng@google.com> Tested-by: Youcheng Syu <youcheng@google.com>
* usb_updater: use same endian conversion functionsVadim Bendebury2017-02-071-5/+5
| | | | | | | | | | | | | | | | | | | This is just a clean up patch, unifying all cases where endian conversions are used in the usb updater source code. BRANCH=none BUG=none TEST=usb update of cr50 is still possible on gru (which uses the code being changed). Change-Id: I362e9762493854b4fdbb9ec15c2cb363003f258a Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/414443 Reviewed-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/439089 Reviewed-by: Youcheng Syu <youcheng@google.com> Commit-Queue: Youcheng Syu <youcheng@google.com> Tested-by: Youcheng Syu <youcheng@google.com>
* ec: Improve efficiency of host command dispatcherSam Hurst2016-11-2310-133/+175
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use binary search in host command lookup dispatcher BUG=chrome-os-partner:570895 TEST=manual testing on kevin - Kevin boots - ectool hello make buildall -j Verify *.smap hcmds section is sorted: 100bca94 R __hcmds 100bca94 R __host_cmd_0x0000 100bcaa0 R __host_cmd_0x0001 100bcaac R __host_cmd_0x0002 100bcab8 R __host_cmd_0x0003 100bcac4 R __host_cmd_0x0004 100bcad0 R __host_cmd_0x0005 100bcadc R __host_cmd_0x0006 100bcae8 R __host_cmd_0x0007 100bcaf4 R __host_cmd_0x0008 100bcb00 R __host_cmd_0x0009 100bcb0c R __host_cmd_0x000a 100bcb18 R __host_cmd_0x000b 100bcb24 R __host_cmd_0x000d 100bcb30 R __host_cmd_0x0010 100bcb3c R __host_cmd_0x0011 100bcb48 R __host_cmd_0x0012 100bcb54 R __host_cmd_0x0013 100bcb60 R __host_cmd_0x0015 100bcb6c R __host_cmd_0x0016 100bcb78 R __host_cmd_0x0017 100bcb84 R __host_cmd_0x0025 100bcb90 R __host_cmd_0x0026 100bcb9c R __host_cmd_0x0029 100bcba8 R __host_cmd_0x002a 100bcbb4 R __host_cmd_0x002b 100bcbc0 R __host_cmd_0x002c 100bcbcc R __host_cmd_0x0044 100bcbd8 R __host_cmd_0x0045 100bcbe4 R __host_cmd_0x0046 100bcbf0 R __host_cmd_0x0047 100bcbfc R __host_cmd_0x0061 100bcc08 R __host_cmd_0x0062 100bcc14 R __host_cmd_0x0064 100bcc20 R __host_cmd_0x0065 100bcc2c R __host_cmd_0x0067 100bcc38 R __host_cmd_0x0087 100bcc44 R __host_cmd_0x008c 100bcc50 R __host_cmd_0x008d 100bcc5c R __host_cmd_0x008f 100bcc68 R __host_cmd_0x0092 100bcc74 R __host_cmd_0x0093 100bcc80 R __host_cmd_0x0096 100bcc8c R __host_cmd_0x0097 100bcc98 R __host_cmd_0x0098 100bcca4 R __host_cmd_0x0099 100bccb0 R __host_cmd_0x009e 100bccbc R __host_cmd_0x00a0 100bccc8 R __host_cmd_0x00a1 100bccd4 R __host_cmd_0x00a8 100bcce0 R __host_cmd_0x00a9 100bccec R __host_cmd_0x00b6 100bccf8 R __host_cmd_0x00b7 100bcd04 R __host_cmd_0x00d2 100bcd10 R __host_cmd_0x00d3 100bcd1c R __host_cmd_0x00db 100bcd28 R __host_cmd_0x0101 100bcd34 R __host_cmd_0x0102 100bcd40 R __host_cmd_0x0103 100bcd4c R __host_cmd_0x0104 100bcd58 R __host_cmd_0x0110 100bcd64 R __host_cmd_0x0111 100bcd70 R __host_cmd_0x0112 100bcd7c R __host_cmd_0x0113 100bcd88 R __host_cmd_0x0114 100bcd94 R __host_cmd_0x0115 100bcda0 R __host_cmd_0x0116 100bcdac R __host_cmd_0x0117 100bcdb8 R __host_cmd_0x0118 100bcdc4 R __host_cmd_0x011a 100bcdd0 R __evt_src_EC_MKBP_EVENT_KEY_MATRIX 100bcdd0 R __hcmds_end BRANCH=none Change-Id: Ideb9951b318763f71915e2c4e5052f4b4bfab173 Reviewed-on: https://chromium-review.googlesource.com/405528 Commit-Ready: Sam Hurst <shurst@google.com> Tested-by: Sam Hurst <shurst@google.com> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Reef: Enable interrupt for BMI160Daisuke Nojiri2016-11-224-3/+8
| | | | | | | | | | | | | | This patch enables an interrupt handler for BMI160. This will improve response time of the motion sense task. BUG=None BRANCH=none TEST=Install and run AIDA64 from Playstore. Wiggle Reef DVT. Verify 'CrosEC Gyroscope' readings change. Change-Id: Ie8dacb51795fa194840817d833cc6356beb01c8f Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/413079
* hammer: Add support for USB HID touchpadNicolas Boichat2016-11-221-2/+5
| | | | | | | | | | | | | | Add another endpoint, to be driven by the USB HID touchpad driver. BRANCH=none BUG=chrome-os-partner:59083 TEST=make BOARD=hammer -j && util/flash_ec --board=hammer Change-Id: I0fd62ceb233aa13e0af61f6ee6a0c0c9fc1c4b52 Reviewed-on: https://chromium-review.googlesource.com/410961 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* driver/touchpad_elan: Report events to USB HID touchpadNicolas Boichat2016-11-221-24/+47
| | | | | | | | | | | | | | Pass reported events to the USB HID touchpad driver. BRANCH=none BUG=chrome-os-partner:59083 TEST=make BOARD=hammer -j && util/flash_ec --board=hammer Change-Id: I234be1a1db8526e615acdd13c5d4dae40be5bdff Reviewed-on: https://chromium-review.googlesource.com/410960 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* chip/stm32/usb_hid: Add USB HID touchpad driverNicolas Boichat2016-11-224-0/+385
| | | | | | | | | | | | | | | This describes a 5-finger touchpad. The physical/logical dimensions of the trackpad are hardcoded for the time being. BRANCH=none BUG=chrome-os-partner:59083 TEST=make BOARD=hammer -j && util/flash_ec --board=hammer Change-Id: I04a0833a28c013395974104ebdd6fcb29e5d6680 Reviewed-on: https://chromium-review.googlesource.com/407742 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* chip/stm32/usb: Allow interface handler to reply with more than 64 bytesNicolas Boichat2016-11-223-14/+69
| | | | | | | | | | | | | | | | For example, when a HID descriptor is longer than 64 bytes, we need to split it in multiple packets. BRANCH=none BUG=chrome-os-partner:59083 TEST=make buildall -j TEST=make BOARD=hammer -j && util/flash_ec --board=hammer Change-Id: I25a05eabaf9413e332fe3cd70695a0d53639713d Reviewed-on: https://chromium-review.googlesource.com/409316 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Fix EC build for latest llvm for elm boardManoj Gupta2016-11-221-0/+2
| | | | | | | | | | | | | | | | | | | | Mark host command structures as aligned for elm board. Without marking as aligned, llvm was correctly complaining about taking address of packed member. util/ectool.c:1158 error: taking address of packed member 'size' of class or structure 'ec_params_usb_pd_fw_update' may result in an unaligned pointer value [-Werror,-Waddress-of-packed-member] BRANCH=none BUG=chromium:665240 TEST=Builds now Change-Id: Ic4a2e81f6af8ef2a906d6ac7aca87ea6d00fe318 Reviewed-on: https://chromium-review.googlesource.com/413108 Commit-Ready: Manoj Gupta <manojgupta@chromium.org> Tested-by: Manoj Gupta <manojgupta@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
* Reef: Disable keyboard and trackpad in tablet modeDaisuke Nojiri2016-11-223-18/+32
| | | | | | | | | | | | | | | | | | | | | | | | | Enabling/Dislabling keyboard and touchpad is required to prevent EC from waking up the system from S3 in tablet mode. This change disables the keyboard and the trackpad when the lid goes beyond 180 degree. Keyboard and touchpad are also enabled/disabled by the tablet switch. When the lid reaches 360 position, keyboard and touchpad are disabled. And they stay disabled as long as the lid stays at 360 position. This prevents keyboard and touchpad from turning on by the (faulty) lid angle calculation. BUG=chrome-os-partner:58792 BRANCH=none TEST=Keyboard and trackpad are disabled when the lid goes beyond 180 and re-enabled when it's smaller than 180. Keyboard and trackpad are disabled when the lid goes to 360 degree and the system doesn't wake up by a keypress. Change-Id: I48c04bd576f457a899dfdf9b4718d73b59419cbe Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/411395
* hammer: Add keyscan taskNicolas Boichat2016-11-224-1/+34
| | | | | | | | | | | | | | | This scans the keyboard matrix, and reports events. Pin layout is temporary. BRANCH=none BUG=chrome-os-partner:59083 TEST=make BOARD=hammer -j && util/flash_ec --board=hammer Change-Id: Ifec7d1bd0223d4653c40b36e068d5d082d16284f Reviewed-on: https://chromium-review.googlesource.com/411607 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* chip/stm32/usb_hid_keyboard: Add functions for keyscanNicolas Boichat2016-11-222-54/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | This first cleans up the code: - Define report as a structure. - Fix USB interval from 40 ms to 32 ms (Linux kernel complains otherwise). Then, this removes the old set_keyboard_report interface, and replaces it by the interface used by the keyboard scanner (i.e. keyboard_state_changed and keyboard_clear_buffer). This also means we need a keycode table to translate from row/column to USB HID keycode. BRANCH=none BUG=chrome-os-partner:59083 TEST=make buildall -j TEST=make BOARD=hammer -j && util/flash_ec --board=hammer With evtest and "hid 0-7" in console, check that key are reported correctly. Change-Id: I5d526db1568c29c7f28fc5e962e213e44303cc16 Reviewed-on: https://chromium-review.googlesource.com/411571 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* g: do not consider valid headers with the 'magic' field corruptedVadim Bendebury2016-11-221-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When cr50 rollback happens, the newer header's magic field is set to zero to prevent it from ever running again. Take this into consideration when displaying versions of the inactive RW image. BRANCH=none BUG=none TEST=loaded two versions of the new code on a cr50 and then modified the fallback counter to force it to boot the older version and reboot a Reef. Once Reef fully boots to chrome os examine CR50 version report: Before: > vers ... RW_A: 0.0.9/DEV/cr50_v1.1.5654-2228b76+ RW_B: * 0.0.11/DEV/cr50_v1.1.5654-2228b76+ ... After: > vers ... RW_A: * 0.0.9/DEV/cr50_v1.1.5654-2228b76+ RW_B: Error Change-Id: I2a9ee13117a0bc91710226cd733c5c484c6d0595 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/413089 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* electro/reef: Configure the battery parameters for electro & reefVijay Hiremath2016-11-221-25/+138
| | | | | | | | | | | | | | | | | Electro & Reef use the same board files but have different batteries hence configure the respective battery parameters for these boards. BUG=chrome-os-partner:59876 BRANCH=none TEST=Manually tested on Reef. Boot with/without/battery works. cut-off and boot from cut-off works. Change-Id: I0e4684987133d6bcd9cabab5c5a1ce5b6c5684d2 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/411353 Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com> Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* npcx: hwtimer: Add consecutive reading for ITCNT32Mulin Chao2016-11-221-5/+15
| | | | | | | | | | | | | | | | | | | | The mux for selecting source clock of ITIM will introduce a delay and have a chance to make ITIM's source clock and core clock are asynchronous. We need consecutive reading for ITCNT32 no matter source clock is APB2 or 32k. Modified sources: 1. hwtimer.c: Add consecutive reading for ITCNT32 BRANCH=none BUG=chrome-os-partner:34346,chrome-os-partner:59240 TEST=No time stamp symptoms occur on wheatley for 30 hours. Change-Id: I8b54e93b320e3ea74fc3d6ea13f0d178f9c449cd Signed-off-by: Mulin Chao <mlchao@nuvoton.com> Reviewed-on: https://chromium-review.googlesource.com/412505 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
* ISH: set toolchain in core/minute-iali feng2016-11-211-3/+3
| | | | | | | | | | | | | | | | | | | When "make buildall" has board which uses core/minute-ia, CROSS_COMPILE?=i686-pc-linux-gnu- doesn't get set unless CROSS_COMPILE is not defined; however, it's defined before this line, and wrong toolchain is used. Remove "?" to set correct CROSS_COMPILE. BUG=none BRANCH=none TEST='make buildall -j' passed Change-Id: Ied4a9f93a4d44714c012d3a3e50e4a34f41a7c1f Signed-off-by: li feng <li1.feng@intel.com> Reviewed-on: https://chromium-review.googlesource.com/410402 Commit-Ready: Li1 Feng <li1.feng@intel.com> Tested-by: Li1 Feng <li1.feng@intel.com> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* driver: bmi160: Remove unnecessary delayGwendal Grignou2016-11-212-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | Rereading the specification, remove delays when not needed: - When we move the sensor out of suspend, we need to wait before using it (BMI160 spec: 2.11.38 Register (0x7E) CMD) When we do a softreset, we need just need to wait 300us for the sensor to go in suspend, we will wait only when we change the rate and enable the sensor. - The timeout at fifo flush is not needed, it was added for debugging. - Remove unnecessary printf when initializing the magnetometer. BUG=chrome-os-partner:59188 BRANCH=glados, reef, strago TEST=On reef, check the EC boot faster: time spend initializing the sensors decreased from 240ms to 133ms Change-Id: Ia80232da42aa705df819a4988da483a344ffcbb4 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/411964 Commit-Ready: David Hendricks <dhendrix@chromium.org> Tested-by: David Hendricks <dhendrix@chromium.org> Reviewed-by: David Hendricks <dhendrix@chromium.org>
* Reef: Swap Volume Up and Down GPIOsDaisuke Nojiri2016-11-211-3/+8
| | | | | | | | | | | | | | | The button closer to the hinge is assigned to volume down and the one closer to the user is assigned to volume up. This change swaps the GPIO assignments to fix the UX. BUG=chrome-os-partner:60057 BRANCH=none TEST=Verified the one closer to the hinge increases the volume and the one closer to the user descreases the volume. Change-Id: I3e716da288839c3f5be608fb2d63f277bbde1bc7 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/412981
* cr50: remove the pull down on uart2 txMary Ruthven2016-11-212-3/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | The pulldown on diob5 is used to detect when servo is detached. It is unnecessary during deep sleep and when the EC console is active because servo detection is disabled. Having the pull-down enabled during these times can increase power consumption. This change disables the pulldown when the EC console and deep sleep are enabled. It also disables the diob5 input during deep sleep. BUG=chrome-os-partner:60020 BRANCH=none TEST=manual Disconnect servo Use the suzyq consoles to turn off the AP. Enable deep sleep. Measure the power consumed by vddiob and make sure it is around 0.3mW when the EC is in hibernate and when it is not. Change-Id: I8a653c28800cfbeeb1b4b8598d166846124c6b53 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/412940 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>