summaryrefslogtreecommitdiff
path: root/extra
Commit message (Collapse)AuthorAgeFilesLines
* extra: usb_updater: include config.hGwendal Grignou2017-07-282-3/+2
| | | | | | | | | | | | | | | | | | | | board.h and config-chip.h should only be called from config.h, otherwise some #define may not be set properly. BUG=chromium:746471 BRANCH=none TEST=Found a bug while compiling OTP changes (c/580289/) (https://luci-milo.appspot.com/buildbot/chromiumos.tryserver/ no_vmtest_pre_cq/81548) The size of the serial number string is set in config.h when CONFIG_USB_SERIALNO is needed. Compile with ec-utils with cr50_onboard USE flag set. Change-Id: I5a2306bd0dc1dea29265226f2986829b768cfb61 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/581887 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* usb_updater: fix transposed symbolic board ID representationVadim Bendebury2017-07-111-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>
* usb_updater: display board ID information from RW headersVadim Bendebury2017-07-101-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>
* hammer: prepare and update the trackpad firmwareChun-Ta Lin2017-06-221-22/+168
| | | | | | | | | | | | | | | Implement the necessary bits for updating the trackpad firmware over I2C, primarily following the protocol from open source driver. BRANCH=none BUG=b:35587174 TEST=Manually update firmware and confirmed reported FW version changed. Change-Id: Ice5098269803f524de0b6a853f5a98f28382a7fb Reviewed-on: https://chromium-review.googlesource.com/532765 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Chun-ta Lin <itspeter@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* usb_updater: allow symbolic Board IDsVadim Bendebury2017-06-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>
* hammer: initial commit for trackpad firmware updaterChun-Ta Lin2017-06-092-0/+426
| | | | | | | | | | | | | | | Tool to update the trackpad firmware over USB. Primarily borrowed from extra/usb_console/usb_console.c BRANCH=none BUG=b:35587174 TEST=Manually executed with hammer Change-Id: Icad951d2478a3e231f293e11fb461eaae20e5042 Reviewed-on: https://chromium-review.googlesource.com/525192 Commit-Ready: Chun-ta Lin <itspeter@chromium.org> Tested-by: Chun-ta Lin <itspeter@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* Cr50: usb_updater: add commands to get/set board idVadim Bendebury2017-06-071-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>
* cr50: usb_updater: do not send setup request unless necessaryVadim Bendebury2017-06-061-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>
* cr50: usb_updater: add proper vendor command processingVadim Bendebury2017-06-061-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>
* usb_updater: add usb_updater2 to gitignoreVadim Bendebury2017-05-311-0/+1
| | | | | | | | | | | | | | | The newly generated file is now showing up in 'git status' output, let's hide it. BRANCH=none BUG=none TEST='git status' output is now clean even after running 'make -C extra/usb_updater'. Change-Id: I6f7e93b303cfff89ec8ae7b3a74286a743e9c27e Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/517677 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* usb_updater: when communicating over tpm treat upgrades differentlyVadim Bendebury2017-05-311-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>
* tigertool: update pyusb callsNick Sanders2017-05-251-2/+2
| | | | | | | | | | | | | | | Update pyusb calling format to match chroot version. BRANCH=None BUG=b:35849284 TEST=flash, control tigertail successfully Change-Id: I27f34d63c8ddc09c903dcc1da39d18e7dbf15710 Reviewed-on: https://chromium-review.googlesource.com/511668 Commit-Ready: Nick Sanders <nsanders@chromium.org> Tested-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* usb_updater2: USB updater for common code ECNicolas Boichat2017-05-212-9/+980
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is copied chip/g version as of commit 0e5497db6, plus the following uncommited usb_update patch (CL:458469): a0176a1cc usb_updater: Flush all data from endpoint before trying to update On top of that, a good number of common-code specific modifications are added: new extra commands, new first_response_pdu format, use of FMAP. BRANCH=none BUG=b:35587170 TEST=usb_updater binary identical before and after this change. TEST=make BOARD=hammer -j && \ ( cd extra/usb_updater && make && \ time sudo ./usb_updater2 ../../build/hammer/ec.bin ) TEST=cd extra/usb_updater; make # Jump to RW sudo ./usb_updater2 -j sleep 0.5 # Update RO, then reboot sudo ./usb_updater2 ../../build/hammer/ec.bin sleep 0.5 # Update RW (first tell RO to not jump to RW) sudo ./usb_updater2 -s sudo ./usb_updater2 ../../build/hammer/ec.bin TEST=cd extra/usb_updater; make # Tell RW to jump back to RO sudo ./usb_updater2 -w sleep 0.5 # Update RW, then reboot sudo ./usb_updater2 -s sudo ./usb_updater2 ../../build/hammer/ec.bin TEST=usb_updater2 can update hammer, and read its version, rollback version and key version. Change-Id: I09da894d83e2b4d6c2e46cab301522c27fa0160c Reviewed-on: https://chromium-review.googlesource.com/458468 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Nick Sanders <nsanders@chromium.org>
* tigertail: tigertool command line apiNick Sanders2017-05-169-0/+1020
| | | | | | | | | | | | | | | This tool allows an easy commandline interface to set the USB-C mux position, as well as init and reboot. BRANCH=None BUG=b:35849284 TEST=flash, control tigertail successfully Change-Id: I8d60c215fee04de158c22edca5377c3c6cd48cf0 Reviewed-on: https://chromium-review.googlesource.com/493617 Commit-Ready: Nick Sanders <nsanders@chromium.org> Tested-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* usb_updater: do not filter out dev cr50 versionsVadim Bendebury2017-05-021-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>
* usb_updater: post a reset during upstart on old versionsMary Ruthven2017-04-071-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>
* usb_updater: /dev/tmp0 -> /dev/tpm0Brian Norris2017-04-061-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>
* usb_updater: only run send_done on usb transfersMary Ruthven2017-04-061-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>
* usb_updater: fix --fwverstabilize-9430.BMary Ruthven2017-04-031-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>
* usb_updater: fix -b optionMary Ruthven2017-03-311-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>
* usb_updater: separate image updates and resets, add restore image optionVadim Bendebury2017-03-221-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>
* usb_updater: stop supporting protocol versions below 5Vadim Bendebury2017-03-211-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>
* usb_updater: fix command line options descriptionVadim Bendebury2017-03-021-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>
* usb_updater: change command line option from --spi to --systemdevVadim Bendebury2017-02-281-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>
* g: usb_updater: fix option description and add post_resetVadim Bendebury2017-02-261-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>
* g: rate limit firmware updatesVadim Bendebury2017-02-221-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Revert "servo_v4: Remove PSTATE to create more space in RO"Nick Sanders2016-12-291-1/+2
| | | | | | | | | | This reverts commit 7ed9a96cd7247e66d60464bb7737c139d71e7395. Change-Id: Ifb3c31d04c8ff10c6186370c98ab127295b0f117 Reviewed-on: https://chromium-review.googlesource.com/422478 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Scott Collyer <scollyer@chromium.org>
* servo_v4: Remove PSTATE to create more space in ROScott2016-12-201-2/+1
| | | | | | | | | | | | | | | | | | | When including USB PD support, the image won't fit in the default RO size of 0xf000, but does fit in the 0x10000 RW. This change removes PSTATE and increases the RO to 0x10000. BRANCH=none BUG=chrome-os-partner:61170 TEST=manual Verfied the image still builds and can run after updating via util/flash_ec and via /usb_updater/fw_update.py -b servo_v4.json Change-Id: I8f60bb1f107060e26390e6c8292a3add58703c0d Signed-off-by: Scott <scollyer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/422450 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
* usb_updater: initialize corrupt_inactive_rw before using itVadim Bendebury2016-12-201-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>
* usb_updater: add command to corrupt rwMary Ruthven2016-12-161-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>
* sweetberry: add power logging toolNick Sanders2016-12-1610-0/+803
| | | | | | | | | | | | | | powerlog.py can access sweetberry and log power data. Also included are marlin and kevin example board configs. BUG=chromium:608039 TEST=log power data BRANCH=None Change-Id: I0f868d95d17d86522dca045a227a824563f93cd0 Signed-off-by: Nick Sanders <nsanders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/413293 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* usb_updater: close connection when no data is transferredVadim Bendebury2016-12-011-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>
* usb_updater: protocol version 6 (vendor commands over usb)Vadim Bendebury2016-11-281-18/+141
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* usb_updater: improve debugabilityVadim Bendebury2016-11-281-1/+8
| | | | | | | | | | | | | | | | | | 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>
* usb_updater: use proper TPM command code for vendor commandsVadim Bendebury2016-11-281-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>
* tpm: move extension and vendor command definitions into own fileVadim Bendebury2016-11-281-9/+8
| | | | | | | | | | | | | | | 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>
* usb_updater: unify normal and error messagesVadim Bendebury2016-11-281-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>
* usb_updater: use same endian conversion functionsVadim Bendebury2016-11-281-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>
* extra/usb_gpio: fix misspelled variable nameMartin Roth2016-11-151-9/+9
| | | | | | | | | | | | | This should be 'transferred'. BUG=None BRANCH=None TEST=make buildall passes Change-Id: I40c3c456256eb1d4ae553545497566afae929e32 Signed-off-by: Martin Roth <martinroth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/403422 Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
* usb_serial: add python consoleNick Sanders2016-11-081-0/+287
| | | | | | | | | | | | | | | console.py can access a Google USB serial endpoint specified by vid:pid and serial number BUG=chromium:608039 TEST=open console to send and receive text. BRANCH=None Change-Id: I735692b7031d73506be2745a2cd5225bfcefd396 Reviewed-on: https://chromium-review.googlesource.com/405030 Commit-Ready: Nick Sanders <nsanders@chromium.org> Tested-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Kevin Cheng <kevcheng@chromium.org>
* usb_update: increase read timout for fw_update.pyNick Sanders2016-11-011-1/+1
| | | | | | | | | | | | | | | sweetberry takes a bit longer to erase flash and seems to be timing out. This fix gets sweetberry to update reliably. BUG=chromium:608039 TEST=update sweetberry firmware BRANCH=None Change-Id: I9a0cbeae3b7ce0e4b87840fe8bf24bb2e10777e9 Reviewed-on: https://chromium-review.googlesource.com/404710 Commit-Ready: Nick Sanders <nsanders@chromium.org> Tested-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* extra/usb_updater: don't use uninitialize variablesAaron Durbin2016-10-271-1/+1
| | | | | | | | | | | | | | | The 'transferred_sections' variable wasn't initialized in all paths. Fix that. BUG=chrome-os-partner:58794 BRANCH=None TEST=Built. Change-Id: If82ef1274d6a931e0cd193f276f34bfcac1fb1c7 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/404548 Tested-by: Matthias Kaehlcke <mka@chromium.org> Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
* usb_updater: report running H1 firmwareAaron Durbin2016-10-271-22/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | Add a command line option which allows to retrieve version currently running on the cr50 device. BRANCH=none BUG=chrome-os-partner:58794 TEST=run the following command: $ sudo ./extra/usb_updater/usb_updater -f open_device 18d1:5014 found interface 4 endpoint 5, chunk_len 64 READY ------- start Target running protocol version 5 Offsets: backup RO at 0, backup RW at 0x4000 Keyids: RO 0x3716ee6b, RW 0xb93d6539 Current versions: RO 0.0.9 RW 0.0.8 Change-Id: Ia34f455d3ca826a24992adf123a07865dccb1d57 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/400418 Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* usb_updater: add command to reset CR50 when updating over SPIVadim Bendebury2016-10-081-7/+20
| | | | | | | | | | | | | | | | | | | | The new extension command is used to request device reset after a successful update when communicating over SPI. tpm_send_pkt() is being refactored to allow passing of different extension commands. BRANCH=none BUG=chrome-os-partner:58226 TEST=verified that the system gets reset and the new image version kicks in on both gru (over SPI) and reef (over USB). Change-Id: I02f3ef76fc4b4ee1e52dedb9cb538e072638257a Signed-off-by: Vadim Bendebury <vbendeb@google.com> Reviewed-on: https://chromium-review.googlesource.com/395629 Commit-Ready: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* g: Upgrade protocol returns the keyid for RO/RWBill Richardson2016-10-071-11/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The keyid field of struct SignedHeader is what distinguishes prod keys from dev keys. This may be useful someday, so let's have the update protocol return those values for the active RO and RW images. Bump the UPGRADE_PROTOCOL_VERSION accordingly. Note: This doesn't enforce any keyid matches, it just returns the current values as part of the initial upgrade handshake in case we want to know. BUG=chrome-os-partner:57956 BRANCH=none TEST=make buildall; try on Gru Make sure that Cr50 can be freely updated and downgraded between firmwares that speak either v4 or v5 of the protocol, by using the v5-aware usb_updater tool. And of course, make sure that v5 images report their keyids. Duh. Change-Id: If2cc0d4023dca2078b9398fd899618dc2cd409b9 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/394732 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* usb_updater: always reboot cr50 in the end of the updatestabilize-8872.70.Bstabilize-8872.6.Bstabilize-8872.40.Bstabilize-8872.15.Brelease-R55-8872.BVadim Bendebury2016-10-061-2/+2
| | | | | | | | | | | | | | | | | | | With the recent modification of the tpm reset processing the only way to get the cr50 restart is to reset it internally. Make sure that usb_updater triggers the cr50 reset in the end of the update. BRANCH=none BUG=none TEST=with the corresponding init script changes the update on reef happens as expected. Change-Id: Ib49b81c4ef6d12d0b877a8a63493cf4d6d5aaeb0 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/394255 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* usb_updater: add missing help message sectionVadim Bendebury2016-10-061-0/+2
| | | | | | | | | | | | | | | The previously added '-b' command line option was left out from the help message. This patch fixes it. BRANCH=none BUG=none TEST=verified that -b command line option description is included in the help message. Change-Id: I71117a8653ae5094fd0bf3909c8715d6ec25259d Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/394254 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* sweetberry: add usb fw updateNick Sanders2016-09-021-0/+14
| | | | | | | | | | | | | | | Port USB firmware update to stm32f4 dwc usb from st usb. This includes usb dwc usb stream inplementation, generic endpoint interfaces, and the sweetberry test case. BUG=chromium:608039 TEST=usb update works BRANCH=None Change-Id: Ia26e4f7e990ee64991468799c99b036f5f32190f Signed-off-by: Nick Sanders <nsanders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/377520 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* usb_updater: option to report image versionsVadim Bendebury2016-08-261-2/+35
| | | | | | | | | | | | | | | | | | It is sometimes necessary to find out headers' version of a cr50 binary blob. This patch adds this ability. BRANCH=none BUG=none TEST=build the new tool image and try it: $ ./extra/usb_updater/usb_updater -b /build/kevin-tpm2/opt/google/cr50/firmware/cr50.bin read 524288(0x80000) bytes from /build/kevin-tpm2/opt/google/cr50/firmware/cr50.bin RO_A:0.0.8 RW_A:0.0.4 RO_B:0.0.8 RW_B:0.0.4 $ Change-Id: I367ca94346484410f785fb56a941c8558ab57634 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/374085 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* usb_updater: move to protocol version 4Vadim Bendebury2016-08-261-61/+279
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Trying to use usb_updater in the upstart script made its shortcomings very obvious: it is difficult to tell if the cr50 needs to have both RO and RW updated, and if so - if it is even capable of updating RW. Also, it is not clear that the target should erase its backup sections as soon as it receives the transfer originating PDU. It is not known in advance if the host has a newer RW section, of if the host is even going to transfer the RO section. These issues are addressed by version 4 of the image transfer protocol. The target now reports versions of its currently active RO and RW sections back to the host. The host compares versions running on the target with the versions retrieved from the image prepared for the update and decides which sections, if any, need to be transferred. The host also takes into account protocol version currently running by the target's RW: versions below 3 do not allow RO updates. In the development environment USB transfer ends with the target reset. This is not desirable when the update is happening on a Chromebook running production code. Also, in the development environment there could exist multiple versions of the image with the same signer header version fields, with only difference in the timestamp. We want to be able to update using these images in development environment, but in production we want to rely to the header version fields. These two mode (dev versus production) are now controlled by the -u/--upstart command line flag. The updater now can return four different exit values: - 0 means that the update was not required, the device is already running the current code. - 1 means update was completed, the target must be reset for the update to kick in. - 2 means that the RW transfer was completed, but the RO transfer could bot be attempted, because the target is running an early protocol version and is not capable of the RO updates. This exit value is the indicator that the utility needs to be run again after target restated, so that the new RW version can accept an RO update. - 3 means the update failed due to some internal error. BRANCH=none BUG=chrome-os-partner:49954 TEST=updates of targets running earlier protocol version still work fine. Change-Id: Ia56f63072eaf88dcdefebf621b7341535748c7d7 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/374759 Reviewed-by: Bill Richardson <wfrichar@chromium.org>