summaryrefslogtreecommitdiff
path: root/extra
Commit message (Collapse)AuthorAgeFilesLines
* rma_reset: fix ignored return value errorMary Ruthven2018-03-271-1/+6
| | | | | | | | | | | | | | | | | | | | | | | The fread return value was ignored in rma_reset.c. This caused clang compilation to fail. This change checks the return value. BUG=none BRANCH=none TEST=clang compilation no longer fails Change-Id: I710b367008b2e17a94c875ea3eae92bcc75546b0 Signed-off-by: Mary Ruthven <mruthven@google.com> Reviewed-on: https://chromium-review.googlesource.com/976555 Commit-Ready: Mary Ruthven <mruthven@chromium.org> Tested-by: Mary Ruthven <mruthven@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/982327 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Commit-Queue: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Trybot-Ready: Furquan Shaikh <furquan@chromium.org>
* rma_reset: update Makefile to use different compiliersMary Ruthven2018-03-271-5/+6
| | | | | | | | | | | | | | | | | | BUG=none BRANCH=none TEST=compile for bob and reef. make sure it runs on both Change-Id: I30004c9794c9619698889fecbf8746778ebbb48c Signed-off-by: Mary Ruthven <mruthven@google.com> Reviewed-on: https://chromium-review.googlesource.com/976554 Commit-Ready: Mary Ruthven <mruthven@chromium.org> Tested-by: Mary Ruthven <mruthven@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/982326 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Commit-Queue: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Trybot-Ready: Furquan Shaikh <furquan@chromium.org>
* stack_analyzer: Add new syntax for function pointer arraysNicolas Boichat2018-03-193-14/+187
| | | | | | | | | | | | | | | | Makes it far simpler to support hooks, console commands, host commands. BRANCH=poppy,fizz BUG=chromium:648840 TEST=Add new array annotation, run stack_analyzer Change-Id: I8ed074ba5534661ed59f4f713bb4ba194e712f4e Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/966042 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit 0cbb4b6f9dc71f6c6d90fd628f466bb61bae9dca) Reviewed-on: https://chromium-review.googlesource.com/969721
* gsctool: require exactly two hash sections for every boardVadim Bendebury2018-03-162-42/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The same Chrome OS device could have not only several released firmware images, but also several variations of the GBB contents. Any permutation of these two sets is possible, but both areas must match, as modified GBB is no smaller problem than modified code or RO data. With this patch the verifier will continue looking for board sections in the descriptors database until the entire database has been scanned. Only finding exactly two sections, and each section providing proper matches will qualify the check as 'pass'. BRANCH=none BUG=none TEST=verified that both single and dual section descriptions are processed properly, and that matching 1 and 3 sections triggers a return error. Change-Id: I181655192246ce245c43e6ce7ba4768ac5c9e51a Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/951864 Reviewed-by: Andrey Pronin <apronin@chromium.org> (cherry picked from commit ccbba8f968ac4bf77c7c8ed665ab96a587f65ff8) Reviewed-on: https://chromium-review.googlesource.com/965431 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Commit-Queue: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Trybot-Ready: Furquan Shaikh <furquan@chromium.org>
* cr50: fix hash database parser to reject misformatted offsets/sizesVadim Bendebury2018-03-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Section offsets and sizes are hex numbers which should not be longer than 8 characters. BRANCH=none BUG=b:73668125 TEST=descriptions which miss the size field are properly reported now. Before the utility would just terminate with an error without a message. Change-Id: I9bc461b5f848b80e464fecc9b40dcf0ea213c9a7 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/949311 Reviewed-by: Randall Spangler <rspangler@chromium.org> (cherry picked from commit 1dfe3193e7110888268c98e1e9339e79b0ee5025) Reviewed-on: https://chromium-review.googlesource.com/963738 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Commit-Queue: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Trybot-Ready: Furquan Shaikh <furquan@chromium.org>
* rma_reset: add server side responseMary Ruthven2018-03-101-6/+61
| | | | | | | | | | | | | | | | | | | | Add support for generating the authcode from cr50's challenge. BUG=b:74019846 BRANCH=none TEST=create a cr50 image with test keys. Verify that the output from rma_reset -c opens cr50. Change-Id: I85a209e55dc23daa118e0071e868878b6fbfcb69 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/945419 Reviewed-by: Randall Spangler <rspangler@chromium.org> (cherry picked from commit 52c3a72b736eab4344d3eb10079af06fa05ac2b4) Reviewed-on: https://chromium-review.googlesource.com/957922 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Commit-Queue: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Trybot-Ready: Furquan Shaikh <furquan@chromium.org>
* gsctool: add open box RMA optionVadim Bendebury2018-03-034-6/+376
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch enhances the gsctool utility to allow to verify RO sections of the target AP and EC flash memory. The only command line parameter required for the new option ('O') is the file name of the target descriptors database, containing memory description sections for one or more Chrome OS devices. Memory description sections are of two types (both types could be referring AP or EC memory): - hash descriptor, this section includes the address range of the memory and one or more hash values for the contents of that address range. Multiple hashes are needed in case when the same device has mnore than one RO firmware releases in circulation. - dump descriptor, this is a request for this utility to display on the console the contents of the certain area of flash memory on the target. When this utility starts the process, the target might request that the operator confirms physical presence, in this case the utility keeps prompting the operator to press the physical presence button until DUT is satisfied, BRANCH=none BUG=b:73668125 TEST=created a descriptor database for a Robo device feeding it with values retrieved on the device by locally running spihash command on the device. Then ran this utility to verify successful hash and dump retrievals, comparing dump values with values obtained through Cr50 console directly. Created additional dummy hash variants and verified that the utility succeeds only if all matches happen at the same variant index in different hash sections. Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/933545 Reviewed-by: Mary Ruthven <mruthven@chromium.org> (cherry picked from commit d57e5eb3128774732e3b3fe40c0f939d9aaeff1a) Change-Id: I54d551b400d2d9e3a6cac41c755ddc85b05806ff Reviewed-on: https://chromium-review.googlesource.com/947428 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Commit-Queue: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Trybot-Ready: Furquan Shaikh <furquan@chromium.org>
* gsctool: move common objects and definitions into a .h fileVadim Bendebury2018-03-032-74/+126
| | | | | | | | | | | | | | | | | | | | | | | | | This is a lateral move allowing to share some data structures and functions previously limited to the gsctool.c scope. This will allow adding new functionality in a separate .c file, and further refactor gsctool.c which little by little became quite unwieldy. BRANCH=none BUG=b:73668125 TEST=gsctool utility still works for uploading Cr50 images. Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/933543 Reviewed-by: Randall Spangler <rspangler@chromium.org> (cherry picked from commit 52b93ce19d00c9a6507c630501904b845a1b6486) Change-Id: I2271a941959427e3045e62e4ec9d186c03454321 Reviewed-on: https://chromium-review.googlesource.com/947427 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Commit-Queue: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Trybot-Ready: Furquan Shaikh <furquan@chromium.org>
* gsctool: add RO descriptor parserVadim Bendebury2018-03-035-2/+528
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds code which would parse the RO hash/dump descriptor file including a database listing expected values of hashes for various ranges of target SPI flash devices, or areas which need to be printed out (hex dumped) for operator inspection. Lines starting with '#' are completely ignored. The rest of the logical lines could actually split into multiple text lines in the file, so to separate one logical line from another at least one empty line is required. Hash descriptor database file consists of sections for various Chrome OS boards. Each board description section starts with a logical line of 4 characters which is the board ID (the same as the board's RLZ code). Each board description section includes variable number of range descriptor entries, each entry being a logical line, potentially split into multiple text lines. Each entry consists of semicolon separated fields: {a|e|g}:{h|d}:base_addr:size[:value[:value[:value...]]]] Where - the first sindgle character field defines the way the range is accessed: a - AP flash e - EC flash g - EC flash requiring gang programming mode - the second single character field defines the range type h - Cr50 returns the hash of the range d - Cr50 returns actual contents of the range (hex dump) - the third and and forth fields are base address and size of the range - ranges of type 'h' include one or more values for the hash of the range, each hash is a 64 byte hex string. Ranges of type 'd' do not include any data. All values are expressed in hex. The parser API provides functions to open the passed in hash descriptor file and find there the section for a particular board, a function to advance to the next entry in the board's section, and a function to close the file when board entries scanning is completed. When scanning the entries, the parser verifies their sanity, i.e. conformance with the above described format, that all hashes are of the right size, that there are no hashes attached to 'dump' entries and there is at least one hash attached to the 'hash' entries, and that there are no invalid characters in the hashes and address range definitions. The parser is not yet used by the gsctool, but when the new module is compiled stand alone with -DTEST_PARSER passed to the compiler, it becomes an executable which can be given the test hash database (the new file, sample_descriptor) to interpret and report success or failure. BRANCH=none BUG=chromium:812880 TEST=ran the following commands: $ gcc -DTEST_PARSER desc_parser.c -o dp $ ./dp sample_descriptor Section 1, rv 0 Section 2, rv 0 Section 3, rv 0 Unexpected data in section 4 Section 4, rv -22 Invalid hash 1 size 0 in section 5 Section 5, rv -22 Invalid hash 1 size 0 in section 6 Section 6, rv -22 Invalid hash 1 size 63 in section 7 Section 7, rv -22 Invalid hash 1 size 65 in section 8 Section 8, rv -22 Invalid hash 1 value in section 9 Section 9, rv -22 Unexpected number of variants in section 10 Section 10, rv -22 Invalid hex value 10x in section 11 Section 11, rv -22 Section 12, rv -61 $ Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/923419 Reviewed-by: Andrey Pronin <apronin@chromium.org> (cherry picked from commit 9a6de75ebf220effe1e428f4e253178f36360ec1) Change-Id: I37fcf22306ee9d085bfceb3fbad267b4d3de6535 Reviewed-on: https://chromium-review.googlesource.com/947426 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Commit-Queue: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Trybot-Ready: Furquan Shaikh <furquan@chromium.org>
* gsctool: refactor PP polling into a functionVadim Bendebury2018-03-031-42/+61
| | | | | | | | | | | | | | | | | | | | | | | Both CCD and SPI_HASH commands need to enforce physical presence. This patch separates PP polling into a function which can be used by both commands. BRANCH=none BUG=b:73668125 TEST=verified that running 'gsctool -a -o' on a Robo device still allows to unlock CCD with PP enforced. Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/930567 Reviewed-by: Randall Spangler <rspangler@chromium.org> (cherry picked from commit 1850d5908a348e31d61b2816f6f086fd4d3596de) Change-Id: I6fd988eafc6096260a0260f369eda139bcd1c44c Reviewed-on: https://chromium-review.googlesource.com/947419 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Commit-Queue: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Trybot-Ready: Furquan Shaikh <furquan@chromium.org>
* cr50: use single __packed definitionVadim Bendebury2018-02-222-6/+1
| | | | | | | | | | | | | | | | | | | Various parts of Cr50 code and Cr50 related utilities duplicate definition of __packed available in include/common.h. Let's use the same definition everywhere. BRANCH=cr50, cr50-mp BUG=none TEST=make buildall succeeds verified that linker generated map files for Cr50 RW are the same before and after this change. built and used gsctoo and rma_reset Change-Id: Ib91f9bbad1f6822b347f32b393630f592df80d60 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/931929 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* gsctool: fix Board ID retrieval functionVadim Bendebury2018-02-211-8/+6
| | | | | | | | | | | | | | | | | | The function used to read or write Board ID value, when invoked for reading, reports the value on the console, but does not save the read value in the passed in structure. Let's always save it in the structure so that the caller of this function has access to the retrieved value. BRANCH=none BUG=chromium:812880 TEST=verified that 'gsctool -i' still operates as expected. Change-Id: I9bc713386758ca6701e6b853e042652e2f392871 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/925692 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* gsctool: allow multiple source filesVadim Bendebury2018-02-212-3/+14
| | | | | | | | | | | | | | | | | | | | | | | With the upcoming extensions it would be beneficial to be able to keep gsctool functionality spread among multiple source files. The current Makefile is also not generating proper dependencies, which was fine when gsctool utility was first introduced, but is not adequate any more, and would be even more noticeable when more source files are added. In preparation let's just convert the build scheme into separately compiling .c files, generating .d files while at it, and then linking the .o files together in a separate link operation. BRANCH=none BUG=chromium:812880 TEST=verified that gsctool still builds fine and allows to update Cr50 image. Change-Id: I537bbe6bf76ac71e8d30040b276b78513d390bbf Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/923418 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* gsctool: add options to control ccdVadim Bendebury2018-01-121-10/+133
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The user needs to be able to unlock/open/lock CCD in addition to setting the CCD password. This patch adds command line options for these three CCD subcommands. They all are communicated to the TPM using the same vendor command. 'open' and 'unlock' subcommands could require the user to enter the password. This is indicated by the appropriate vendor command return code. If return code of 'open' or 'unlock' subcommand indicates the need for physical presence, the utility starts polling the Cr50 prompting the user to press the power button when the chip expects it. Some input parameters sanity checks are added to make sure that the user does not request mutually exclusive actions. BRANCH=none BUG=b:62537474 TEST=verified that CCD can be unlocked and opend with and without password, with and without PP required. Change-Id: Iea229a220e9f3d2f5d07cebdaebcb9b297939310 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/861209 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* gsctool: allow password handling function to run on different subcommandsVadim Bendebury2018-01-121-6/+15
| | | | | | | | | | | | | | | | | | | | | With the upcoming addition of ability to manage CCD using gsctool, it is necessary to send user password in several CC_CCD subcommands. This patch modifies the password handler to allow the user to specify the subcommand code to use. VENDOR_RC_IN_PROGRESS is added to the list of acceptable return codes, as this is what could be returned in response to 'ccd unlock' or 'ccd open'. BRANCH=none BUG=b:62537474 TEST=verified that password still could be set and cleared from the CLI and gsctool Change-Id: Ic58f344a728897fb535cd9b7bedd47d28b30f5f8 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/861207 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* ccd: prepare for handling crucial CCD commands through TPM task contextVadim Bendebury2018-01-101-4/+6
| | | | | | | | | | | | | | | | | | | | We want CCD commands lock, open, password, and unlock (at least to start with) to be available over both CLI and through crosh (i.e. coming over /dev/tpm0). Let's allocate a TPM vendor command for handling all CCD subcommands, and move to this new framework the 'ccd password' command, which already is available over vendor command. BRANCH=cr50 BUG=b:62537474 TEST=verified that 'ccd password' still works both over Suzy-Q CLI and using gsctool on the target. Change-Id: I2d06230b762f47af7e580b188a587bc5678ca169 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/853280 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* gsctool: use full path when invoking trunks_sendVadim Bendebury2018-01-051-1/+1
| | | | | | | | | | | | | | | | | | The gsctool utility sometimes is used in environments where path to trunks_send is not set. As a result 'gsctool -t' invocations fail. Let's make sure PATH includes /usr/sbin before trunsk_send is invoked. BRANCH=none BUG=none TEST=verified that gsctool invocations in crosh started in a tab and in a linux shell ran under user 'chronos' do not fail. Change-Id: Ib8af365dc5707cfec19acda9aa0228d33eb4573f Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/851266 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org>
* gsctool: Add option '--any' to auto-detect -s/-t availability.Hung-Te Lin2018-01-051-6/+23
| | | | | | | | | | | | | | | | | | | | | | | For partners and developers, it's usually better to have a single simple instruction to invoke commands. Currently gsctool needs either -s (if /dev/tpm is not locked) or -t (if trunksd is running) and partners have to either try both commands (-s or -t) or read the error messages and try to figure out which option to use. For example, see the extra logic in CL:831787. Instead of putting the check everywhere in scripting, it seems easier and more convenient to have a simple switch - "--any (-a)" that automatically selects between -s and -t. BUG=b:70184153 TEST=gsctool -f -a; stop trunksd; gsctool -f -a Change-Id: Ie1590b0b8fef882178465ceee64a7150eda6b0dd Reviewed-on: https://chromium-review.googlesource.com/851612 Commit-Ready: Hung-Te Lin <hungte@chromium.org> Tested-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* usb_updater2: Increase touchpad debug buffer length to 50 bytes.Nicolas Boichat2017-12-141-2/+2
| | | | | | | | | | | | | | | We would like to use all 64-bytes of the buffer as parameter to UPDATE_EXTRA_CMD_TOUCHPAD_DEBUG (12 bytes for update_frame_header, 2 bytes for the extra command type, leaving 50 bytes of payload). BRANCH=none BUG=b:63993891 TEST=./usb_updater2 -g 00 -d 18d1:502b Change-Id: I023aa760f1a4cf9cacf9262a758cba1120d4f380 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/780372 Reviewed-by: Chun-ta Lin <itspeter@chromium.org>
* sweetberry: add microsecond to sweetberry timestampMengqi Guo2017-12-071-1/+1
| | | | | | | | | | | | | | | | | | This CL adds microsecond to sweetberry timestamp, for more accuracy in timing sweetberry runs. This CL is part of the effort to start sweetberry measurements while running power autotests. BRANCH=None BUG=b:68956240 TEST=./powerlog.py -b xxx.board -c xxx.scenario \ --save_stats_json [directory to store it] Change-Id: I68c40d5be6d684205b49428c4e5cb6e69af6dfdf Signed-off-by: Mengqi Guo <mqg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/812502 Reviewed-by: Puthikorn Voravootivat <puthik@chromium.org>
* i2c: support large reading in i2c_xfer()Chun-Ta Lin2017-12-071-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There might be more than one place that will use very similar codes in CL:542716 (usb_i2c.c). To avoid unnecessary duplication of code, we fold the logic into i2c_xfer(). With config enabled (illustrated in this CL), i2c_xfer() will support large reading. An early prototype of potential usage is demostrated in CL:781300. BRANCH=none TEST=For CONFIG_I2C_XFER_LARGE_READ: With proprietary software on slave: ./touchpad_updater -d TEST=For usb_i2c regression: ./touchpad_updater still works (where the reading is less than 255) TEST=For generic EC regression test: On poppy EC (With CONFIG_I2C_XFER_LARGE_READ defined) (1) Prevent override of update /usr/share/vboot/bin/set_gbb_flags.sh 0xa39 (2) flashrom -p ec -w ec_binary_contains_this_CL.bin (3) ectool reboot_ec cold (4) "ectool version" verified that both RO/RW/Build info is local. (5) Test with a type-C DP dongle on DELL 2408WFP. (6) Plug-in type-C charger and external display still works. (7) Confirmed that battery is charging. (7) "ectool battery" reads same data (for fixed field) as before. (8) "ectool usbpdpower", confirmed charger info displayed as before. (9) "ectool usbpd 0", confirmed content exactly as before. (10) For Gyro. Verify under Arc++ Using App: com.gamma.bubblelevel, works the same as before. (11) For Accelerometers. Verify under Arc++ Using App: com.innoventions.sensorkinetics, small movement's charts looks as expected. TEST=For generic EC regression test: On Caroline EC (Without CONFIG_I2C_XFER_LARGE_READ defined). Details in CL:810332 BUG=b:63993891 Change-Id: I654868945fa535e784800177d54eb2d9803f5249 Signed-off-by: Chun-Ta Lin <itspeter@google.com> Reviewed-on: https://chromium-review.googlesource.com/788479 Commit-Ready: Chun-ta Lin <itspeter@chromium.org> Tested-by: Chun-ta Lin <itspeter@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* servo_updater: add version checksNick Sanders2017-12-063-8/+84
| | | | | | | | | | | | | | This adds a check for the current and new versions, and will not update if they are matched. BUG=b:69016431 BRANCH=None TEST=sudo ./servo_updater.py -b servo_micro Change-Id: I3462099a086278dc1589609d76facf11a64bd3bc Signed-off-by: Nick Sanders <nsanders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/804716 Reviewed-by: Wai-Hong Tam <waihong@google.com>
* sweetberry: print MEAN in json formatMengqi Guo2017-12-054-13/+75
| | | | | | | | | | | | | | | | | | | | | | | | This CL adds the flag --save_stats_json which prints the MEAN of sweetberry readings into json format. Corresponding unit test has been added too. Printing just the MEAN in json format makes it easier to read it back in power_telemetry_logger, which uploads the stats to the dashboard. This CL is part of the effort to start sweetberry measurements while running power autotests. BRANCH=None BUG=b:68956240 TEST=./powerlog.py -b xxx.board -c xxx.scenario \ --save_stats_json [directory to store it] python -m unittest -v stats_manager_unittest Change-Id: I8274bcac21175f6c53184ced79b6ffe5e7d7a72a Signed-off-by: Mengqi Guo <mqg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/807636 Reviewed-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Puthikorn Voravootivat <puthik@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org>
* gsctool: fix error processing logicVadim Bendebury2017-12-011-1/+1
| | | | | | | | | | | | | | The error processing logic is reversed, which results in missing error values when errors actually happen. BRANCH=none BUG=none TEST=verified that errors values are now reported properly. Change-Id: I282920d35e978a704e8c2728a8aa71a5f1da9a00 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/802994 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* servo_updater: add better default argsNick Sanders2017-11-281-5/+55
| | | | | | | | | | | | | | | | Let servo_updater look for configs and firmwares in the default installed locations. BUG=b:69016431 BRANCH=None TEST=sudo servo_updater -b servo_v4 Change-Id: I069b96044ce17992e41a8fc66931477823eef986 Signed-off-by: Nick Sanders <nsanders@google.com> Reviewed-on: https://chromium-review.googlesource.com/792603 Commit-Ready: Nick Sanders <nsanders@chromium.org> Tested-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Wai-Hong Tam <waihong@google.com>
* gsctool: add option to disable RMA modeVadim Bendebury2017-11-281-3/+15
| | | | | | | | | | | | | | | | The --rma_auth command line option is being extended to treat the auth_code of value of 'disable' as a user request to cancel CCD RMA mode on the device. BRANCH=none BUG=b:68213540 TEST=verified that passing '-f disable' to gsctool causes CCD state on the Cr50 changed to 'Locked' Change-Id: I8764e0207977a6290d3d10dc4678f98631be0360 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/784354 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* hammer: enable large block reading on usb i2c passthru.Chun-Ta Lin2017-11-241-15/+58
| | | | | | | | | | | | | | | | | | | | | | | | Originally, i2c passthru is limited to use I2C_XFER_SINGLE flag where it can only read at most 255 bytes at a time. For application that requires larger i2c bus reading, we change the flag setting and the command protocol. TEST=old ./touchpad_updater still works (previous protocol) TEST=new ./touchpad_updater can get more than 500 bytes per transaction TEST=Debug message only print when -d assigned. ./touchpad_updater -d TEST=Manually change #define CONFIG_USB_I2C_MAX_READ_COUNT (1024 - 6) to #define CONFIG_USB_I2C_MAX_READ_COUNT (1024 - 4) and trigger POWER_OF_TWO assertion. BRANCH=none BUG=b:35587174, b:63993891 Change-Id: Id75b11ea49ba89bab8e18af24d47219030c778c5 Signed-off-by: Chun-Ta Lin <itspeter@google.com> Reviewed-on: https://chromium-review.googlesource.com/542716 Commit-Ready: Chun-ta Lin <itspeter@chromium.org> Tested-by: Chun-ta Lin <itspeter@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* gsctool: clean up error processingVadim Bendebury2017-11-211-14/+31
| | | | | | | | | | | | | | | | | | The gsctool utility is inconsistent in using stdio channels when reporting errors. All error messages should go into stderr. Also, to avoid confusion, this patch makes options -s and -t mutually exclusive. BRANCH=none BUG=b:68213540 TEST=verified that passing both -t and -s command line options causes an error. Change-Id: Ieb50cf08314aa37594964ef4bbfa4a850741da2f Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/784353 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* servo: add usb_console to chrootNick Sanders2017-11-161-3/+14
| | | | | | | | | | | | | | add usb_console, console.py to chroot install. This tool allows directly accessing the usb console of servo v4, servo micro, cr50, etc. BUG=b:69016431 BRANCH=None TEST=usb_console -d 18d1:501b Change-Id: If9d5d49cf31d785ea9a7cec0a4eeeb34abae9cd1 Signed-off-by: Nick Sanders <nsanders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/773400
* servo_updater: allow differing console enpointsNick Sanders2017-11-153-4/+8
| | | | | | | | | | | | | | | servo_micro has the console on intf 3, while servo_v4 has it's console on intf 0. Abstract this into the config file rather than hardcoding. BUG=b:37513705 BRANCH=None TEST=update servo_micro Signed-off-by: Nick Sanders <nsanders@chromium.org> Change-Id: I0090a0d081e001e62ffa7235eebbd6131ea00dcf Reviewed-on: https://chromium-review.googlesource.com/769794 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* usb_updater2: Add support for touchpad debugging featureNicolas Boichat2017-11-141-16/+61
| | | | | | | | | | | | | | Add support for touchpad debugging in usb_updater2, allowing an arbitrary parameter to be passed. BRANCH=none BUG=b:63993891 TEST=./usb_updater2 -g 00 -d 18d1:502b Change-Id: I1242e3bab9dc69ec3a92dd158c85606211e40f21 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/763575 Reviewed-by: Chun-ta Lin <itspeter@chromium.org>
* sweetberry: save to specified directoryMengqi Guo2017-11-092-46/+105
| | | | | | | | | | | | | | | | | | | | | | This CL modifies the 2 flags --save_stats and --save_raw_data so that they can take arguments to save the corresponding file into directories that we specify. It also provides a new flag --no_print_raw_data to suppress printing sweetberry readings in real time. This CL is part of the effort to start sweetberry measurements while running power autotests. BRANCH=None BUG=b:68956240 TEST=./powerlog.py -b xxx.board -c xxx.scenario \ --save_stats ./xxx --save_raw_data ./xxx --no_print_raw_data Change-Id: I01ebeafc5f4eebd0a77746e9968367f267e93d83 Signed-off-by: Mengqi Guo <mqg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/756255 Reviewed-by: Puthikorn Voravootivat <puthik@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org>
* gsctool: provide an option to set/clear passwordVadim Bendebury2017-10-301-2/+79
| | | | | | | | | | | | | | | | | | | | | | | | This patch makes use of a recently introduced vendor command for password control. The new option '-P,password' is introduced to allow the device user to set/clear the CCD password. Command line echo is suppressed when password is being entered, so it is required to enter it twice. To stay consistent with the 'ccd' Cr50 console command conventions the word 'clear' should be used as the password when one wants to clear the CCD password. All policies for setting/clearing the password are the same as when setting it from the Cr50 console. BRANCH=cr50 BUG=b:62537474 TEST=set and clear password when accessing over /dev/tpm0. Verified that attempts to set/clear password over USB fail. Change-Id: I7721d9ce12da8b7c89fc80eaa69cb8dd001abdb8 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/741172 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* servo: add usb updaterNick Sanders2017-10-256-32/+138
| | | | | | | | | | | | | | This updater combines console and firmware update commands to update both RO and RW sections of servo_v4 and servo_micro. BRANCH=None BUG=b:37513705 TEST=updated firmware Change-Id: I9f585c90f5849f8dd7c9d2e08111ffbd5770fd54 Signed-off-by: Nick Sanders <nsanders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/668156 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* gsctool: allow to pass optional value for --rmaVadim Bendebury2017-10-171-45/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It would be much easier to use the --rma command line option if it allowed to pass the authentication code in a separate invocation. This patch changes the behavior of the --rma command line option and improves the help message to match actual features of gsctool. When passed without an extra parameter it requests the Cr50 to generate the RMA authentication challenge, prints the challenge on the console as before, and then exits instead of waiting for the user to enter the authentication code. When the extra parameter is given, it is considered the authentication code received from the server, the code is passed to the Cr50 and the response is reported to the user. BRANCH=none BUG=b:37952913 TEST=verified the expected behavior: localhost tmp # ./gsctool -r -t Challenge: CCYAQ 5ZUDP 9Q8NY S7TQR 7PVUR ETX7P T5YQK NGV9S 7TY8Z QY7H5 5DEH3 5EEWY UBJPA WN7YX SE35G TPS76 localhost tmp # ./gsctool -t -r EYE3E Processing response... rma unlock failed, code 1 localhost tmp # echo $? 3 localhost tmp # ./gsctool -t -r EYE3EWQG Processing response...RMA unlock succeeded. localhost tmp # echo $? 0 localhost tmp # Change-Id: I2c61ff3a3ef1718eb4f192321bebd8caba388aeb Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/722115
* gsctool: harden the APIs marking pointers constVadim Bendebury2017-10-171-2/+2
| | | | | | | | | | | | | | | This is just a tweak marking pointers to the vendor command payloads as const, as the command payloads are not supposed to be modified by the communication layers. BRANCH=none BUG=none TEST=make buildall -j; make -c ./extra/usb_updater Change-Id: I68f15e8c77dc892173ff0241072128d960712a80 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/722114 Reviewed-by: Andrey Pronin <apronin@chromium.org>
* g: rename usb_updater into gsctoolVadim Bendebury2017-10-104-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The usb_updater utility has long been not just an updater, and has long been using other interfaces in addition to USB. gsctool is a much more suitable name. CQ-DEPEND=CL:709776 BRANCH=cr50 BUG=b:67007500 TEST=verified that make -C ./extra/usb_updater generates ./extra/usb_updater/gsctool: $ ./extra/usb_updater/gsctool --help Usage: gsctool [options] <binary image> This updates the Cr50 RW firmware over USB. The required argument is the full RO+RW image. Options: [...] $ Change-Id: I3ab70c28acf3664ddefaa923a87ba1fd5c3c437b Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/709738 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* gsctool: add RMA authentication optionVadim Bendebury2017-10-031-6/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch uses the VENDOR_CC_RMA_CHALLENGE_RESPONSE vendor command to request the Cr50 generate the RMA authentication challenge and to have the Cr50 verify the authentication code received from the server. The new command line option is -r/--rma_auth. Presently it works only when Cr50 is accessed over the TPM interface (as opposed to USB), i.e. command line options -s or -t are also present, and the utility is running on the Chrome OS device. CQ-DEPEND=CL:690992 BRANCH=none BUG=b:37952913 TEST=on a Bob device ran the command with correct and incorrect authentication codes, observed expected behavior (reported success or error): localhost ~ # /var/tmp/usb_updater -t -r Challenge: B9FPX D93GM JTJE7 ZNR74 E2GZF 94E8B TXBFX UJ4WZ 3ZQ98 XZ42D D4MVT RA2WG UDMKP A8FMH GXJQG BAKAS Now enter response: 7996N3NW RMA unlock succeeded. localhost ~ # /var/tmp/usb_updater -t -r error 4 <<=== this is the time throttle error localhost ~ # /var/tmp/usb_updater -t -r Challenge: B9BLC F7B3D 7WY8V DKGQF 6CFP8 UCZRU UCZRW YKUG7 ZGNVC F4ZEH X75LE BANWE UDMKP A8FMH GXJQG BAKAS Now enter response: 7996N3NW <<==== this is an incorrect code rma unlock failed, code 6 localhost ~ # Change-Id: Ifbf1a349e3d2655cea6c33f928d9cf58a6408531 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/690443 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* cr50: enable rma_authVadim Bendebury2017-10-021-0/+13
| | | | | | | | | | | | | | | | | | Enable necessary flags for the Cr50 to start supporting RMA authentication. This also requires that the RMA server public key definition is split between the actual and test. Even though they are the same at this time, the actual public key would be defined in the new future and it would be different from the test key. BRANCH=cr50 BUG=b:65253310 TEST=make buildall -j passes. More tests were conducted on the full patchset. Change-Id: I5a3f9d8c71374d78192e3f0a2752391b842da962 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/691554 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* gsctool: improve vendor command processing robustnessVadim Bendebury2017-10-021-11/+20
| | | | | | | | | | | | | | | | With upcoming RMA authentication extensions the size of the vendor command responses is going to increase. Let's allow 500 bytes per response (the expected maximum is 80 bytes plus TPM header). BRANCH=cr50 BUG=b:37952913 TEST=verified that gsctool (aka usb_updater) still allows to retrieve Cr59 information and update Cr50 image. Change-Id: Ic61b6b89ffe20e534029bd12fea4140882a9afc8 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/690442 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* rma_reset: fix board ID ordering and add the missing breakVadim Bendebury2017-09-301-1/+6
| | | | | | | | | | | | | | | The Board ID is stored in Cr50 in reversed byte order, make sure it is used in the challenge calculation in the same form. BRANCH=none BUG=b:37952913 TEST=verified that the proper byte order is used when challenge source is created. Change-Id: I6c6b46431005ce9438a4be9aa43aafed30a645aa Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/693615 Reviewed-by: Michael Tang <ntang@chromium.org>
* sweetberry: adding a flag to print milliwattsMengqi Guo2017-09-291-5/+13
| | | | | | | | | | | | | | | | | | Adding a flag to print power numbers in milliwatts instead of microwatts, to be the same as servo ina board. This will make it easier for power team to keep track of power numbers in the future. BRANCH=None BUG=b:35578707 TEST=./powerlog.py -b xxx.board -c xxx.scenario --mW python -m unittest -v stats_manager_unittest Change-Id: I397da26561324227682404e62ee025384e7624eb Signed-off-by: Mengqi Guo <mqg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/688743 Reviewed-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Puthikorn Voravootivat <puthik@chromium.org>
* sweetberry: calculate statistics for sweetberry readingsMengqi Guo2017-09-294-27/+278
| | | | | | | | | | | | | | | | | | | This CL provides the tool to calculate statistics for sweetberry readings and present them in a clear & easy to read format. It also provides the flag to store raw data and statistics summary, should the need arise. There are also some code cleanup for powerlog.py. BRANCH=None BUG=b:35578707 TEST=./powerlog.py -b xxx.board -c xxx.scenario --print_stats \ --save_stats --save_raw_data python -m unittest -v stats_manager_unittest Change-Id: I4aa732756fe6512f37acfcb59b11d950101887d7 Signed-off-by: Mengqi Guo <mqg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/667241 Reviewed-by: Nick Sanders <nsanders@chromium.org>
* Update rma_reset command line interface.Sam Hurst2017-09-291-45/+285
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Usage: rma_reset --key_id <arg> --board_id <arg> --device_id <arg> --hw_id <arg> | --auth_code <arg> These value are used for generating the challenge response and all are mandatory. -k,--key_id Index of the server private key -b,--board_id BoardID type field -d,--device_id Device-unique identifier -w,--hw_id Hardware id The -t parameter, not listed, will use the default values to generate the challenge response This value is the authorization code and any other parameters are ignored -a,--auth_code Reset authorization code BUG=b:37952913 BRANCH=none TEST=make buildall Signed-off-by: Sam Hurst <shurst@chromium.org> Change-Id: Idc916b123928328a3425fa4eee22afc2ec179fc1 Reviewed-on: https://chromium-review.googlesource.com/665388 Commit-Ready: Sam Hurst <shurst@google.com> Commit-Ready: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Sam Hurst <shurst@google.com> Reviewed-by: Michael Tang <ntang@chromium.org>
* rma_reset: hide generated files from gitVadim Bendebury2017-09-281-0/+5
| | | | | | | | | | | | | | | | | This prevents the files from showing in 'git status' output. BRANCH=none BUG=none TEST=verify that the running the following does not show any generated files: make -C extra/rma_reset; git status Change-Id: Ib3ff7772cf4a66e4a0d23ed859c30ac05c2e507d Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/691016 Reviewed-by: Michael Tang <ntang@chromium.org>
* tigertool: add serial number checkNick Sanders2017-09-281-0/+24
| | | | | | | | | | | | | Add --check_serial to check serial number. BRANCH=None BUG=b:35849284 TEST=check serial number. Change-Id: I1e2d5617bcf65e2388b88aca7ed63b9cdc096d87 Signed-off-by: Nick Sanders <nsanders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/676723 Reviewed-by: Wai-Hong Tam <waihong@google.com>
* usb_updater: allow to communicate with cr50 using trunks_sendVadim Bendebury2017-09-071-12/+176
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is necessary to be able to access Cr50 using usb_updater without stopping trunksd services. This patch adds another option for usb_updater to communicate with Cr50, using the trunks_send command. A new command line option '-t' is added to allow to choose the new interface. When communicating over trunks_send the same processing is used as when communicating over /dev/tpm0, just instead of talking to the hardware device, popen() function is used to run trunks_send --raw command and to gain access to its console output. BRANCH=none BUG=none TEST=ran various commands using the new '-t' option: # ./usb_updater -t /opt/google/cr50/firmware/cr50.bin.prod read 524288(0x80000) bytes from /opt/google/cr50/firmware/cr50.bin.prod start target running protocol version 6 keyids: RO 0xaa66150f, RW 0xb93d6539 offsets: backup RO at 0x40000, backup RW at 0x4000 sending 0x32288 bytes to 0x4000 ------- update complete reboot requested image updated [reboot...] # ./usb_updater -t -f start target running protocol version 6 keyids: RO 0xaa66150f, RW 0xb93d6539 offsets: backup RO at 0x40000, backup RW at 0x4000 Current versions: RO 0.0.10 RW 0.0.23 Change-Id: I9c7481c30c2f6908e0d1ac4f204654d2fd1b3b2e Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/634629 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org>
* stack_analyzer: Use board/$BOARD/analyzestack.yaml by defaultNicolas Boichat2017-09-073-23/+43
| | | | | | | | | | | | BRANCH=none BUG=chromium:648840 TEST=make BOARD=hammer analyzestack Change-Id: Id05fee7e085a02dd4c2d36880f6891c3eb86b404 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/637550 Reviewed-by: Che-yu Wu <cheyuw@google.com> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* extra/stack_analyzer: Configurable exception frame size.Che-yu Wu2017-09-054-8/+17
| | | | | | | | | | | | | | | | | Make the size of extra stack needed by exceptions configurable. It can be set in the annotation file. BUG=chromium:648840 BRANCH=none TEST=extra/stack_analyzer/stack_analyzer_unittest.py make BOARD=elm SECTION=RW \ ANNOTATION=./extra/stack_analyzer/example_annotation.yaml \ analyzestack Change-Id: Idf2a59650dd20257a0291f89d788c0c83b91a7c9 Signed-off-by: Che-yu Wu <cheyuw@google.com> Reviewed-on: https://chromium-review.googlesource.com/649454 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* extra/stack_analyzer: Support function sets in invalid paths.Che-yu Wu2017-09-053-23/+76
| | | | | | | | | | | | | | | | | | | There are lots of invalid paths have common segments. In this patch, each vertex of an invalid path can be a function set. Examples can be found in extra/stack_analyzer/example_annotation.yaml BUG=chromium:648840 BRANCH=none TEST=extra/stack_analyzer/stack_analyzer_unittest.py make BOARD=elm SECTION=RW \ ANNOTATION=./extra/stack_analyzer/example_annotation.yaml \ analyzestack Change-Id: Ib10d68edd04725af4d803f54f7e208e55d574c7d Signed-off-by: Che-yu Wu <cheyuw@google.com> Reviewed-on: https://chromium-review.googlesource.com/649453 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>