summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* test: Make it possible to run rsa tests on hammer boardstabilize-10718.88.Bstabilize-10718.71.Bstabilize-10718.69.Bstabilize-10718.111.Brelease-R68-10718.BNicolas Boichat2018-05-243-2/+4
| | | | | | | | | | | | | BRANCH=poppy BUG=b:35647963 BUG=b:77608104 TEST=make run-rsa run-rsa3 TEST=make BOARD=hammer test-rsa3, test on board Change-Id: Id4bd8d5f550dbc6569d88ced114849b3b6411b2f Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1071410 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Cr50: Add logging functionality to PinWeaver.Allen Webb2018-04-272-16/+764
| | | | | | | | | | | | | | | | | | | | | In order to be able to recover from the AP and Cr50 getting out of sync, this logging functionality gives Cr50 a way to track the state changes of the merkle tree so that the AP can be updated to the current state as long as it has a recent enough copy. This involves packing the important information so it can be stored efficiently on flash, and adding the necessary messages for the replay. CQ-DEPEND=CL:895395,CL:929430 BRANCH=none BUG=chromium:809729, chromium:809745 TEST=cd ~/src/platform/ec && V=1 make run-weaver_ng -j Change-Id: I40f98de2c8e9706cccb5b922215699f2132fa121 Signed-off-by: Allen Webb <allenwebb@google.com> Reviewed-on: https://chromium-review.googlesource.com/963773 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* Cr50: Added Pinweaver base implementation.Allen Webb2018-04-274-0/+1763
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds some of the ground work for hardware backed brute force resistance on Cr50. The feature is called Pinweaver. It will initially be used to enable PIN authentication on CrOS devices without reducing the security of the platform. A Merkle tree is used to validate encrypted metadata used to track login attempts. The metadata tracks counts of failed attempts, a timestamp of the last failed attempt, the secrets, and any associated parameters. Instead of storing the metadata on Cr50 an AES-CTR is used with an HMAC to encrypt the data so it can be stored off-chip and loaded when needed. The Merkle tree is used to track the current state of all the metadata to prevent replay attacks of previously exported copies. It is a tree of hashes whose root hash is stored on Cr50, and whose leaves are the HMACs of the encrypted metadata. BRANCH=none BUG=chromium:809730, chromium:809741, chromium:809743, chromium:809747 TEST=cd ~/src/platform/ec && V=1 make run-pinweaver -j Change-Id: Id10bb49d8ebc5a487dd90c6093bc0f51dadbd124 Signed-off-by: Allen Webb <allenwebb@google.com> Reviewed-on: https://chromium-review.googlesource.com/895395 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* cleanup: CONFIG_USB_PD_CUSTOM_VDM is not usedDivya Sasidharan2018-04-091-1/+0
| | | | | | | | | | | | | | | | | | | The pd_custom_vdm is called in common/usb_pd_protocol no matter you have this defined or not. No where else I see pd_vdm being used. So we should not have to deal with this CONFIG_USB_PD_CUSTOM_VDM. BUG=None BRANCH=None TEST=make buildall -j Change-Id: I4e8b710240ee27b12625d797e7824f29044e6462 Signed-off-by: Divya Sasidharan <divya.s.sasidharan@intel.com> Reviewed-on: https://chromium-review.googlesource.com/998520 Commit-Ready: Divya S Sasidharan <divya.s.sasidharan@intel.com> Tested-by: Divya S Sasidharan <divya.s.sasidharan@intel.com> Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Jett Rink <jettrink@chromium.org>
* cr50: use run time generated public RMA key definitionVadim Bendebury2018-04-041-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | Use RMA public key definition generated based on the binary blob containing the key and key ID. Key generation is controlled by the make file in common/, but actual key blob comes from the board directory. The structure holding the key and key ID is being modified to allow initialization using a flat array. No more need in defining CONFIG_RMA_AUTH_SERVER_PUBLIC_KEY and CONFIG_RMA_AUTH_SERVER_KEY_ID. BRANCH=cr50, cr50-mp BUG=b:73296144, b:74100307 TEST='make buildall' still succeeds. test RMA server generated authentication codes are accepted when unlocking RMA. Change-Id: I8ade94de6eb69b3e49bc5b948dbac20e59962acf Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/990783 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Code cleanup: Remove cold reset logicVijay Hiremath2018-04-031-1/+1
| | | | | | | | | | | | | | | | | | | | | Majority of the chipsets do not have a dedicated GPIO to trigger AP cold reset. Current code either ignores cold reset or does a warm reset instead or have a work around to put AP in S5 and then bring back to S0. In order to avoid the confusion, removed the cold reset logic and only apreset is used hence forth. BUG=b:72426192 BRANCH=none TEST=make buildall -j Manually tested on GLKRVP, apreset EC command can reset AP. Change-Id: Ie32d34f2f327ff1b61b32a4d874250dce024cf35 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/991052 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> Reviewed-by: Jett Rink <jettrink@chromium.org>
* driver: sensor: Remove set_resolution when NOOPGwendal Grignou2018-03-151-8/+0
| | | | | | | | | | | | | | set_resolution is only used for few sensors and is not exposed to the AP. Remove definition when sensors have a fixed resolution. BUG=none BRANCH=master TEST=compile, kevin has enough space for perform_calib. Change-Id: I8482387e135356467edaee44da3a0e47cf1db524 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/961222 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* fan: Allow board to configure fans at run timeDaisuke Nojiri2018-03-061-19/+20
| | | | | | | | | | | | | | | This patch splits struct fan_t into two parts: base configuration and RPM configuration. RPMs are expected to be different from model to model while a base configuration is most likely shared. BUG=b:73720175 BRANCH=none TEST=make buildall Change-Id: Iff17573f110e07e88d097dd848cf91ee98b83176 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/949382 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* ec: add crc32_ctx..() to take context parameter.Marius Schilder2018-02-234-0/+98
| | | | | | | | | | | | | | | | | | Add crc32_ctx.. functions to take context parameter. This allows for multiple instances to exist in parallel. Signed-off-by: mschilder@google.com TEST=make buildall -j8 succeeds BRANCH=none BUG=b:73832883 Change-Id: I66bbc56377eeebf01c790caad0bc4c7a51a1bc58 Reviewed-on: https://chromium-review.googlesource.com/935825 Commit-Ready: Marius Schilder <mschilder@chromium.org> Tested-by: Marius Schilder <mschilder@chromium.org> Reviewed-by: Marius Schilder <mschilder@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* buttons: Make buttons[] common.Aseda Aboagye2017-11-172-33/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | Nearly every board had a buttons array defined in which its contents had the standard volume buttons. This commit creates a single common buttons array that can contain the standard volume buttons and recovery buttons. If a board has volume up and down buttons, they can simply define CONFIG_VOLUME_BUTTONS and it will populate the buttons array with the standard definition. The buttons are active low and have a 30 ms debounce period. Similiarly, if a board has a dedicated recovery button, defining CONFIG_DEDICATED_RECOVERY_BUTTON will also populate the buttons array with a recovery button. BUG=chromium:783371 BRANCH=None TEST=make -j buildall. TEST=Flash a device with CONFIG_VOLUME_BUTTONS, verify pressing volume buttons still work. Change-Id: Ie5d63670ca4c6b146ec8ffb64d40ea9ce437b913 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/773794 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
* cleanup: Remove llama boardShawn Nematbakhsh2017-11-091-3/+0
| | | | | | | | | | | | | | | | | The llama is a South American relative of the camel, though the llama does not have a hump. These sturdy creatures are domestic animals used by the peoples of the Andes Mountains. BUG=None TEST=`make buildall -j` BRANCH=None Change-Id: I55dbd8d5b0b14c41e27c4ef473833563f38878c3 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/761298 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* charge_manager: Enter safe mode at bootShawn Nematbakhsh2017-11-021-0/+43
| | | | | | | | | | | | | | | | | | | | | | | | Charge port / current selection often needs to be significantly altered when a battery cannot provide sufficient charge, so have charge_manager initially enter safe mode. After a battery with sufficient capacity has been identified, charge manager will leave safe mode, and port / current selection will return to standard rules. BUG=chromium:777596 BRANCH=None TEST=Pass charge_manager unit tests. On kevin, remove battery, attach Apple PD charger, verify safe mode is not exited and device does not brown out. Hot-plug battery and verify safe mode is exited. Next, remove battery, attach to Samus, verify safe mode is not exited and device doesn't brown out. Hot-plug battery, verify that safe mode is exited and no active charge port, due to dual-role exclusion. Change-Id: I7784865750087a037aad8dbbac058b22c77ba6d4 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/733954 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* chg_ramp: Add charge_is_consuming_full_input_current().Aseda Aboagye2017-11-011-1/+1
| | | | | | | | | | | | | | | | | | | Most boards had an identical implementation for this function, previously known as board_is_consuming_full_charge(). To reduce copy paste, let's just move it to common code. Boards that charge ramp without a battery will have to define their own implementation, but there probably won't be any boards like that in the near future. BUG=None BRANCH=None TEST=make -j buildall Change-Id: Ic99a378ac26dfd35d7d718bf9376eacfa8609166 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/748919 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
* PD: Make current USB PD Stack REV 3 compliantSam Hurst2017-10-244-26/+215
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement the following required features in the USB PD Rev. 3.0 specification. Not_supported control message: Inform a port partner that a particular message is not supported. Battery capabilities extended message: Report battery design capacity and last full charge capacity. Battery status data message: Report battery state of charge Collision avoidance: New scheme to avoid collisions caused when both source and sink want to send messages. Cable communication: Only the VCONN source can communicate with the cable plug. This is NOT implemented because although the drivers have the capability of communicating with a cable plug, the PD stack doesn't currently need to talk to a cable plug. This is okay since the current PD design doesn't source or sink more than 3 amps and all Type-C cables are required to be 3 amp capable. BUG=b:64411727 BRANCH=None TEST=`make -j buildall` Passed relevant PD Rev 2.0 compliance tests Successful PD negotiation with PD Rev 2.0 and 3.0 chargers Tested with low power none PD charger. Modified a Kevin to operate as a PD 3.0 charger and sent all required messages and verified the return messages. Also tested collision avoidance by verifying that a sink only transmits when the source indicates it's okay. Used Twinkie to verify that PD was operating as v3.0. Signed-off-by: Sam Hurst <shurst@chromium.org> Change-Id: Ifd77e92ec4e9106236f9221393d2bfb97263d979 Reviewed-on: https://chromium-review.googlesource.com/603003 Commit-Ready: Sam Hurst <shurst@google.com> Tested-by: Sam Hurst <shurst@google.com> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* charge_ramp: Ramp USB-C DTS sourcesShawn Nematbakhsh2017-10-191-0/+1
| | | | | | | | | | | | | | | | | | | | suzy-qable advertises 1.5A, but its actual capability depends on the host USB port it is attached to. Since suzy-qable is ubiquitous and other DTS sources may behave in the same way, ramp the input current limit in order to find a reasonable maximum. BUG=chromium:770296 BRANCH=None TEST=Attach suzy-qable to kevin and reef, verify that neither OCs and EC console via cr50 is available on reef. Also verify donette chargers kevin at 3A and does not ramp. Change-Id: Idd0683ede3a44111a01da6b4faab52f388ee82fd Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/693295 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* charge_manager: Support no-battery / no-host boardsShawn Nematbakhsh2017-10-171-12/+10
| | | | | | | | | | | | | | | | Boards without batteries and/or without host command support may wish to use charge_manager. BUG=chromium:769895 BRANCH=None TEST=`make buildall -j` Change-Id: I2455528de3300a0651791752a05409c888b5f2a3 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/713943 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* tcpc: Don't retry sending of source capsShawn Nematbakhsh2017-10-131-0/+6
| | | | | | | | | | | | | | | | | TCPM will retry sending of source caps on failure and retrying in TCPC will cause us to violate PD_T_SEND_SOURCE_CAP. BUG=None TEST=Attach servo_v4 to twinkie, verify source caps are sent in ~100ms intervals and not in bursts of four. BRANCH=servo_v4 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: I3264e5578afbde7b9d2c003b6744974329a253d4 Reviewed-on: https://chromium-review.googlesource.com/719729 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* cleanup: Use CONFIG_BATTERY to indicate whether a board has a batteryShawn Nematbakhsh2017-10-131-0/+1
| | | | | | | | | | | | | BUG=b:35528297 BRANCH=None TEST=`make buildall -j` Change-Id: I9e4814b4172f20711f7edd691c9569f9130aec8e Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/713395 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* charge_ramp: Move ramp allowed / ilim callbacks to common codeShawn Nematbakhsh2017-10-062-12/+24
| | | | | | | | | | | | | | | | | | | | | The decision on whether to ramp (and how high) depends on the quirks of charger identification, so move the decision out of board, into the drivers that implement usb_charger. Also, rename CONFIG_CHARGE_RAMP to CONFIG_CHARGE_RAMP_SW, to better contrast with the existing CONFIG_CHARGE_RAMP_HW. BUG=None TEST=Manual on kevin, verify ramp occurs when port plugged into Z840 workstation. BRANCH=None Change-Id: I5b395274133837a18a4f4ac34b59b623287be175 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/702681 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* common: make rma_auth work with the serverVadim Bendebury2017-10-041-4/+1
| | | | | | | | | | | | | | | | | A couple of bugs have crept in with the latest series of patches: - the board ID value endianness does not have to be changed - the test RMA server public key value is wrong BRANCH=cr50 BUG=b:67007905 TEST=the generated challenge is now accepted by the server, and the generated auth code matches between the server and the Cr50. Change-Id: I18f413ab0bcc14d9cc50b115ac3784fdfcd5851c Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/700798 Reviewed-by: Michael Tang <ntang@chromium.org>
* cr50: enable rma_authVadim Bendebury2017-10-021-0/+14
| | | | | | | | | | | | | | | | | | 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>
* common: add TPM vendor command to support RMA authenticationVadim Bendebury2017-10-021-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | The new vendor command operates in two modes: when received with a zero size payload, it triggers the Cr50 to generate a new RMA authentication challenge and the expected authentication code value. When receive with the payload, it compares the received payload with the pre-calculate authentication code, and returns to the host the comparison result (passed/not passed). A care is taken not to accept payload until at least there is a valid calculated auth code present (to avoid reporting a match on a payload of all zeros). Test config needed to be modified to allow compiling of the ccprintf wrapper. BRANCH=cr50 BUG=b:37952913 TEST=with the rest of the patches applied observed expected behavior of generating challenge/response and verifying the auth code. Change-Id: I30638b0ceef68830565f222dd1f4af17cfc8d7ef Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/690992
* commom: generalize rma_auth to and make it match server expectationsVadim Bendebury2017-10-021-1/+5
| | | | | | | | | | | | | | | | | | | | | | | Different devices could have different sized unique device IDs. Let's just use the IDs as is if they are no larger than the rma_challenge:device_id field, or the first 8 bytes of the HMAC_sha256 value of the unique device ID, where the unique device ID is used both as the key and the payload. The server expects the board ID field in big endian format, let's swap it before calculating the RMA auth challenge. The test's server side implementation needs to be also adjusted. BRANCH=cr50 BUG=b:37952913 TEST=make buildall -j passes. With the rest of the patches applied RMA authentication process generates sensible values. Change-Id: Ia1fbf9161e01de30a2da8214258008f6e5f7d915 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/690991 Reviewed-by: Michael Tang <ntang@chromium.org>
* rtc: Add functions and tests for time conversionPhilip Chen2017-09-264-0/+127
| | | | | | | | | | | | | | | | | | | | | To implement rtc driver for some ec chips, we need to convert between calandar date and seconds (since epoch time, 01-01-1970 00:00:00). Sicne these functions are HW-independent, let's add common/rtc.c, include/rtc.h, and unit test for this. BUG=b:63908519 BRANCH=none TEST=make buildall test -j Change-Id: Icb1e768d2b3674d5225b83e09475e984eb104d06 Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/666985 Commit-Ready: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org> Reviewed-by: Brian Norris <briannorris@chromium.org>
* tpmtest: make the test work againVadim Bendebury2017-09-264-3/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The TPM test directory has bitrotted and does not compile any more, leave alone pass tests. This patch updates the tests to match changed EC codebase: test/tpm_test/Makefile - look for include files in more directories test/tpm_test/bn_test.c - add implementation of always_memset() which for the EC tree now comes from a different tree and provide a plug for watchdog_reload() which is no used by dcrypto code (which in fact is not a good idea, but an issue for another day). test/tpm_test/hash_test.py - update to match new format of return messages test/tpm_test/upgrade_test.py - update to match the new format of return messages and limit the test to installing just 2K worth of data BRANCH=cr50 BUG=none TEST=./test/tpmtest/tpmtest.py now passes Change-Id: Ibcd7fcfba06cd83023e35a2ac4f37ec896492ad4 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/665322 Reviewed-by: Nagendra Modadugu <ngm@google.com> Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* common: Substitute modified CRC8 with CRC-5-USBSam Hurst2017-09-121-8/+18
| | | | | | | | | | | | | | | | | | | | The modified CRC8 implementation didn't detect some errors. For example, using the modified CRC8: CC5QQLALU and DC5QQLALU calculates to the same value. BUG=b:37952913 BRANCH=none TEST=make buildall Used online CRC-5-USB calculator to test several values against this implementation. Signed-off-by: Sam Hurst <shurst@chromium.org> Change-Id: I5a17941e25691872a25b41525f65f36e2ed1d4fa Reviewed-on: https://chromium-review.googlesource.com/660812 Commit-Ready: Sam Hurst <shurst@google.com> Tested-by: Sam Hurst <shurst@google.com> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Michael Tang <ntang@chromium.org>
* EFS: Add support for early firmware selectionDaisuke Nojiri2017-09-121-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Chromebox ECs performs EFS: verifying firmware before the AP boots. This patch updates host commands which are required for the EFS. The change includes: * Update EC_CMD_FLASH_REGION_INFO to accept EC_FLASH_REGION_UPDATE * Update EC_CMD_VBOOT_HASH to accept EC_VBOOT_HASH_OFFSET_UPDATE When EC_FLASHS_REGION_UPDATE is specified, EC_CMD_FLASH_REGION_INFO returns the slot which currently is not hosting a running RW copy. When EC_VBOOT_HASH_OFFSET_UPDATE is specified, EC_CMD_VBOOT_HASH computs the hash of the update slot. This hash covers the entire region, including the signature at the end. This patch undefines CONFIG_CMD_USBMUX and CONFIG_CMD_TYPEC for gru to create space. BUG=b:65028930 BRANCH=none CQ-DEPEND=CL:648071 TEST=On Fizz, verify: 1. RW_B is old and updated by soft sync. RW_B is activated and executed after reboot. System continues to boot to OS. 2. RW_A is old and updated by soft sync. RW_A is activated and executed after reboot. System continues to boot to OS. Change-Id: I9ece907b764d07ce94054ba27996e048c665a80a Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/648448
* cleanup: Remove 'ryu' boardShawn Nematbakhsh2017-09-111-3/+0
| | | | | | | | | | | | | | | Remove 'ryu' and related ryu-only code. BUG=None TEST=`make buildall -j` BRANCH=None Change-Id: I19b966ea6964a7ed083724f7de80ae192235a406 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/656314 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* common/sha256: agressive SHA-256 unrolling as an optionNicolas Boichat2017-09-113-0/+8
| | | | | | | | | | | | | | | | Reduces "hash done" time from ~1.30 to ~1.15s on soraka. BRANCH=none BUG=chromium:702378 BUG=b:64196191 TEST=Boot soraka, looks at hash done time. TEST=make run-sha256 run-sha256_unrolled passes. Change-Id: Ia29ee27404d6e9aa615ff59755b59d3f26648e71 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/652327 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Treat SYSTEM_IMAGE_RW_B also as RW copyDaisuke Nojiri2017-09-091-1/+1
| | | | | | | | | | | | | | SYSTEM_IMAGE_RW_B hasn't been globally treated as a RW copy. This change makes EC treat it also as a RW copy. BUG=none BRANCH=none TEST=make buildall Change-Id: Iae5a9090cdf30f980014daca44cdf8f2a65ea1f2 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/656337 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* EFS: Add error codesDaisuke Nojiri2017-08-291-8/+8
| | | | | | | | | | | | | | | This patch defines more error codes to make the consle more descriptive. BUG=none BRANCH=none TEST=Boot Fizz. Change-Id: I84cc6cd7f309bb2f2e1f36dea6cf5a7f0f862f50 Reviewed-on: https://chromium-review.googlesource.com/639160 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* vboot: Move common code under common/vbootDaisuke Nojiri2017-07-134-0/+181
| | | | | | | | | | | | | | | This patch moves the code which can be shared with other data verification schemes (e.g. RWSIG) under common/vboot. It also adds unit tests for it. BUG=b:38462249 BRANCH=none TEST=make run-vboot. Verify verification succeeds on Fizz. Change-Id: Icab4d96dd2c154a12b01c41ebe9b46286b4b590e Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/563463 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* test/x25519: Optionally test 1 million iterations of x25519Nicolas Boichat2017-07-031-3/+32
| | | | | | | | | | | | | | BRANCH=none BUG=b:62813194 TEST=#define TEST_X25519_1M_ITERATIONS in test/x25519.c Increase timeout in util/run_host_test to 1000 seconds make run-x25519 -j Change-Id: I8157d756df3e1a6573791ff6aab458acffae0f0c Reviewed-on: https://chromium-review.googlesource.com/554439 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* common: Add RMA reset auth challenge-response cryptoRandall Spangler2017-06-304-0/+228
| | | | | | | | | | | | | | | | RMA auth uses X25519 to generate a relatively small challenge and response. Currently, nothing calls the rma_auth code. We'll need console and TPM vendor commands to do so. BUG=b:37952913 BRANCH=none TEST=make buildall Change-Id: Iec7f2d0e3dc8243f79b009ead16bb3ba9f1bef9d Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/544184
* test/x25519: First test speed, then test implementationNicolas Boichat2017-06-291-3/+4
| | | | | | | | | | | | | | | | | | | Makes it easier to tune implementation speed. BRANCH=none BUG=b:62813194 TEST=- Increase CONFIG_RO_SIZE to 60kb - Increase console stack size to 2048 - Define CONFIG_CURVE25519_CORTEXM0 (next patch) make BOARD=hammer PROJECT=x25519 TEST_BUILD=y ./util/flash_ec --board=hammer --image=build/hammer/x25519.bin EC console: runtest Change-Id: I9097e326a3772b2e05f9b90a68ac715ed467c442 Reviewed-on: https://chromium-review.googlesource.com/542636 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* common: Add base32 encodingRandall Spangler2017-06-284-1/+224
| | | | | | | | | | | | | | Base32 encoding is used to turn the RMA reset binary challenge/response into less-typo-prone text, at 5 bits per character. BUG=b:37952913 BRANCH=none TEST=make runtests Change-Id: I474750a20204ba353cea1e91982aa03e8071c0c2 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/544177 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* cleanup: Remove big and pit boardsShawn Nematbakhsh2017-06-222-6/+2
| | | | | | | | | | | | | | | | | Remove big and pit boards along with several now-obsolete CONFIGs / source files. BUG=chromium:735109 TEST=`make buildall -j` BRANCH=None CQ-DEPEND=CL:544681 Change-Id: Ieb784bd36157fd1f6240cd19de6e6d12191a8097 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/540667 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* sha256: add support for hmac_sha256, and add test for sha256Nicolas Boichat2017-06-144-0/+243
| | | | | | | | | | | | | | BRANCH=none BUG=b:38486828 TEST=make run-sha256 TEST=make buildall -j Change-Id: I4c5b5d81ae5650ebfbdc989a0d860eeb0a60f68b Reviewed-on: https://chromium-review.googlesource.com/530207 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* test/entropy: Add host test and compute entropyNicolas Boichat2017-06-132-8/+41
| | | | | | | | | | | | | | | | | | Check that added entropy is at least somewhat acceptable. BRANCH=none BUG=b:38486828 TEST=make BOARD=hammer -j tests ./util/flash_ec --board=hammer --image=build/hammer/test-entropy.bin EC console: runtest, get around 4000/1000 (=4) bits of entropy, value matches (roughly) the value obtained using the awk script. TEST=make run-entropy Change-Id: I88d0e9ec0e38ab3ec70d3e8163b8ac1556df978d Reviewed-on: https://chromium-review.googlesource.com/523482 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* hammer: Add board_get_entropy function (and test)Nicolas Boichat2017-06-063-0/+80
| | | | | | | | | | | | | | | | | | | | | | | | This function will be used to generate some entropy using the Clock Recovery System. BRANCH=none BUG=b:38486828 TEST=make BOARD=hammer -j tests ./util/flash_ec --board=hammer --image=build/hammer/test-entropy.bin EC console: runtest TEST=Test fails when no USB connection is active TEST=Test passes when USB connection is active TEST=Pasting the values into: tr ';' '\n' | awk 'BEGIN { e = 0; tot=16384.0 } { p = $1/tot; if (p > 0) { e -= p*log(p)/log(2) } } END { print e }' shows an entropy > 4 bits per sample. Change-Id: I2363c7bce42c72c33ef0bf3f099d709ee9c13d13 Reviewed-on: https://chromium-review.googlesource.com/518608 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Remove references to individual gendersThiemo Nagel2017-05-291-3/+3
| | | | | | | | | | | | | | | Remove references to individual genders in comments/examples. No functional change. For the rationale, cf. https://chromium.googlesource.com/chromium/src/+/master/styleguide/gender_neutral_code.md BUG=none TEST=none Change-Id: I756d22c617fe1a8fde2e967796e112e2c6159bf9 Reviewed-on: https://chromium-review.googlesource.com/517123 Commit-Ready: Thiemo Nagel <tnagel@chromium.org> Tested-by: Thiemo Nagel <tnagel@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* tests: Split utils in 2 subtestsNicolas Boichat2017-05-254-142/+182
| | | | | | | | | | | | | | | | | | | | | | | | | | | | utils test is a little too large for hammer's small RO, so we split it in 2 test: utils and utils_str. Instead of one test that requires about 8kb extra flash, we have 2 tests that take respectively 3.4kb (utils_str) and 4.6kb (utils) of extra flash. BRANCH=none BUG=chromium:726113 TEST=make BOARD=hammer tests -j util/flash_ec --board=hammer --image=build/hammer/test-utils.bin runtest => pass Repeat with test-utils_str.bin TEST=Before this change: make runtests -j ./util/run_host_test utils | grep Running | sort > old Apply this change: make runtests -j (./util/run_host_test utils; ./util/run_host_test utils_str) \ | grep Running | sort > new diff old new => No difference (except timing) Change-Id: I917d572e671d6ce0a8799508761f55de7bd83133 Reviewed-on: https://chromium-review.googlesource.com/514604 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* chg_ramp: Don't change ICL until vals are init'd.Aseda Aboagye2017-03-301-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When the charge ramp task starts, it starts up in the DISCONNECTED state. From this state, it's possible to set the input current limit to 0 mA. However, upon task start, we shouldn't take any action until we have valid values from a new charge supplier or a supplier leaving. This commit changes the charge ramp task to not touch the input current limit until the charge ramp state changes or the desired input current changes at least once. BUG=b:36468002 BRANCH=gru,master TEST=Flash kevin EC RW or build AP FW that contains the fix that will by sync'd by EC SW sync. Make sure WP is asserted to prevent PD communications in RO. Unplug battery. Plug in AC, verify that system can boot up to UI on AC alone. TEST=make -j buildall Change-Id: I351917bce7902c49d1bb842a0cc83dd161d75b6f Reviewed-on: https://chromium-review.googlesource.com/461382 Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/463927 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* motion_lid: no angle correction when lid closephilipchen2017-03-171-0/+14
| | | | | | | | | | | | | | | | | | | | BUG=b:36107214 BRANCH=gru TEST=manually on kevin: (1) make DUT in tablet mode (2) swiftly close the lid (3) check ec log and confirm DUT can read small angle and turn into clamshell mode when lid is closed. TEST=make runtests Change-Id: I7ebf10d38a8b300960ebf46be717d48522c6fd0b Reviewed-on: https://chromium-review.googlesource.com/455458 Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> (cherry picked from commit 75ba9147c392367037c21e79899f463c32c1f92f) Reviewed-on: https://chromium-review.googlesource.com/457137 Commit-Ready: Philip Chen <philipchen@chromium.org>
* pd: Add tcpc_select_rp_value to stub tcpm driverScott2017-03-021-0/+5
| | | | | | | | | | | | | | | | | | | | | | The function tcpm_select_rp_value() is used to set a given Rp value. This function was not supported for boards that use the config option CONFIG_USB_PD_TCPC. This CL adds a weak board_ function which can be overloaded for boards that have the requirement to set Rp to different values. BUG=chrome-os-partner:61878 BRANCH=servo TEST=run 'make buildall'. On plankton added a console command to trigger a call to tcpm_select_rp_value(0, 0), verified that it returned 2 (EC_ERROR_NOT_IMPLEMENTED). Then added board_select_rp_value() to plankton's board.c and verified that it returned 0. Change-Id: I1cd6f0ed51717736d30575c58025bd9a1c5d6fc4 Signed-off-by: Scott <scollyer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/446685 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* cr50: Store console lock state in NvMem vars.Aseda Aboagye2017-02-272-0/+11
| | | | | | | | | | | | | | | | | | | | | | This commit enables the use of the nvmem vars module. The console lock state is migrated from using the long life scratch register, to nvmem vars instead which will persist across power on reboots. BUG=b:35586145 BRANCH=None TEST=Flash a dev image. Lock the console. Remove all power from the system. Power on system and verify that console is still locked. Unlock the console, remove power from the system, power on the system, verify that the console is now unlocked. TEST=Repeat the above test, but using the nvtestvar console command instead. Change-Id: I03a2098bb0017cfca59889457a332eafb0e95db6 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/445804 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* curve25519: strip-down, build and testVincent Palatin2017-02-234-101/+165
| | | | | | | | | | | | | | | | | | | | | | | | | | | Keep only the most compact version of the curve25519 code and remove the remaining unused code for easier compilation. Do the minimal changes to make it compile in the EC code base, there should be no real functional changes. Re-use the wording from BoringSSL include/openssl/curve25519.h for the header. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:62991 TEST=run x25519 on host (ie 'make run-x25519') and the STM32L4 target: make BOARD=eve_fp PROJECT=x25519 TEST_BUILD=y ./util/flash_ec --board=eve_fp --image=build/eve_fp/x25519.bin execute 'runtest' in the console. Change-Id: I13dbe453eff39b461effb1b3ffa549afc1749fef Reviewed-on: https://chromium-review.googlesource.com/444187 Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Adam Langley <agl@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* import curve25519 code from BoringSSLVincent Palatin2017-02-231-0/+126
| | | | | | | | | | | | | | | | | | | | | | | | | | Import the implementation of the curve25519 public key cryptography from BoringSSL. It's the unmodified crypto/curve25519/curve25519.c file from the repository at sha c034e2d3ce16df5f89134515bc113eb4f3a28e0e. (current HEAD of chromium-stable branch) It will be used as a primitive to implement a Diffie-Hellman exchange. The test code in test/x25519.c is also imported unmodified from BoringSSL crypto/curve25519/x25519_test.cc. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:62991 TEST=with follow-up CLs, run curve25519 test vectors on host, MEC1322 and STM32 targets. Change-Id: Ie497f78249f505e32d8e025b0537e82bf4476298 Reviewed-on: https://chromium-review.googlesource.com/444186 Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* cr50: Make sure TPM wipe only clears TPM data.Aseda Aboagye2017-02-231-26/+46
| | | | | | | | | | | | | | | | | | | | Previously, wiping the TPM would wipe all of NvMem, however, it really should only clear the TPM's NvMem space. This commit adds a function to clear a given NvMem user's space and makes the TPM only clear its space. BUG=chrome-os-partner:61597 BRANCH=None TEST=Add code for using nvmem vars, create a test variable, add a user to snappy, unlock the console, verify that the user is no longer present on the system and the test nvmem var still exists. TEST=make -j buildall Change-Id: Ic98baa5166a1ef9ae76e910b1b9ab100300e947f Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/445803 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* rwsig: Add support for rwsig image typesNicolas Boichat2017-02-173-14/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | usbpd1 futility image type is deprecated and should not be used for new designs. This adds proper support for rwsig image type. Key and signatures are added at linker stage step (futility cannot directly create such signed images). Thanks to VB21 header, rwsig.c can now tell how many bytes of the RW image need to be cryptographically verified, and ensure that the rest is blank (0xff). BRANCH=none BUG=chromium:690773 TEST=make BOARD=hammer; flash, RW image is verified correctly. TEST=make runtests -j TEST=For the rest of the tests: Change config option to CONFIG_RWSIG_TYPE_RWSIG TEST=make BOARD=hammer; flash, hammer still verifies correctly. TEST=cp build/hammer/ec.RW.bin build/hammer/ec.RW.bin.orig; futility sign --type rwsig --prikey build/hammer/key.vbprik2 \ build/hammer/ec.RW.bin diff build/hammer/ec.RW.bin build/hammer/ec.RW.bin.orig => Same file TEST=Add CONFIG_CMD_FLASH, flashwrite 0x1e000, reboot, EC does not verify anymore. TEST=dump_fmap build/hammer/ec.bin shows KEY_RO and SIG_RW at correct locations. Change-Id: I50ec828284c2d1eca67fa8cbddaf6f3b06606c82 Reviewed-on: https://chromium-review.googlesource.com/441546 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>