summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* tree: rename strtoul to strtoull since it is 64-bitJett Rink2020-11-111-27/+27
| | | | | | | | | | | | | | | A long is 32-bit, but a long long is 64-bit. The function name should be strtoull if it is returning 64 bits of data. BRANCH=none BUG=b:172592963 TEST=builds Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I04c40f9256ed37eb1cf9b6bd1b0ef0320fe49b0c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2530874 Commit-Queue: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: forward cros_crc8 to zephyrs crc8 implJett Rink2020-11-111-0/+14
| | | | | | | | | | | | | | | Shim in support for crc8 used in CBI, I2C, and other applications within platform/ec BRANCH=none BUG=b:168032589 TEST=add unit test for platform/ec and zephyr based CRC8 approaches and verify they both pass. Change-Id: Ib609f98596c4edc6e6f0d01b6242e62a1f95ad72 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2527811 Reviewed-by: Yuval Peress <peress@chromium.org>
* crc32: rename test crc32->crc to allow for crc8Jett Rink2020-11-115-5/+5
| | | | | | | | | | | | | | Instead of creating a new test for crc8, just make the existing crc32 test more generic. BRANCH=none BUG=none TEST=none Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I459e9b721a6cc0d94cef8c0d93102ad372095c34 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2527493 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* test: Add 3072-byte key test case for rsa testYicheng Li2020-11-114-5/+184
| | | | | | | | | | | | | | | | | | This is so that the unittest can be built for a board that actually uses 3072-byte RSA in RW signature verification, and run on-device. E.g. `build --BOARD=hatch_fp test-rsa` BRANCH=none BUG=b:169256204 TEST=make -j buildall TEST=make BOARD=bloonchipper test-rsa3, flash to Dragonclaw, rwsig verify OK, test passes. Change-Id: I1e67f05b76b53d96fe508832a94e9af5ad896d4d Signed-off-by: Yicheng Li <yichengli@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2429392 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* Zephyr: add more compliant implementation for irq_(un)lockYuval Peress2020-11-083-0/+94
| | | | | | | | | | | | | | | | | | This change replaces the stubbed irq_(un)lock static functions defined in task.h with new functions that behave more like the Zephyr implementation of irq_(un)lock functions. This should make the migration from interrupt_(dis|en)able to Zephyr more seamless. BRANCH=none BUG=b:172060699 TEST=Added unit tests, make runtests -j, and built for various boards: eve, volteer, arcada_ish, atlas, hatch, kohaku, nocturne, samus, and scarlet Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: Ia7ad2b8d7d411a11699353bf5d3cc36a261fad14 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2511720
* COIL: Rename CONFIG_I2C_CONTROLLERDiana Z2020-11-052-9/+9
| | | | | | | | | | | | | Rename CONFIG_I2C_CONTROLLER and related comments. BRANCH=None BUG=None TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ied6a1829bf54a5c9a32e6772982a4b8aa31aaf23 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2518659 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* test: fix stm32_rtc compilation errorDawid Niedzwiecki2020-11-031-1/+1
| | | | | | | | | | | | | | | After the atomic functions change, there is a compilation error of test-stm32_rtc. Remove volatile qualifier, because it is not needed for atomic functions - 'rtc_fired' is changed only by them. BUG=b:172079887 BRANCH=none TEST=make BOARD=bloonchipper test-stm32f_rtc Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I38c48697b0ce1b639dcf767d939bb8dcf1215f79 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2512205 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* atomic: rename atomic_read_clear to atomic_clearDawid Niedzwiecki2020-11-021-1/+1
| | | | | | | | | | | | | | | | | Rename atomic_read_clear to atomic_clear to be consistent with the rest of the atomic functions, which return the previous value of the variable. BUG=b:169151160 BRANCH=none TEST=buildall Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I2588971bd7687879a28ec637cf5f6c3d27d393f4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2505143 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* test/fpsensor: Add test for checking protocol infoTom Hughes2020-10-303-2/+95
| | | | | | | | | | | | | | | | | | Note that the "fpsensor_uart_ro" test is broken at this point due to b/171370392 and will be fixed in a followup commit. BRANCH=none BUG=b:171370392 TEST=Using dragonclaw v0.2 and servo_micro: ./test/run_device_tests.py -t fpsensor_uart_ro ./test/run_device_tests.py -t fpsensor_uart_rw ./test/run_device_tests.py -t fpsensor_spi_ro ./test/run_device_tests.py -t fpsensor_spi_rw Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I00cb5dd975fefe577381f1889e88aad000c8ba57 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2508859 Reviewed-by: Bhanu Prakash Maiya <bhanumaiya@google.com>
* test/fpsensor: Run the fpsensor test on deviceTom Hughes2020-10-304-12/+27
| | | | | | | | | | | | BRANCH=none BUG=b:171370392 TEST=Using dragonclaw v0.2 and servo_micro: ./test/run_device_tests.py -t fpsensor Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Idc24d9bdd5574ca7099e97e86e3b49011844380c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2507951 Reviewed-by: Bhanu Prakash Maiya <bhanumaiya@google.com>
* test/fpsensor: Add missing RUN_TEST macroTom Hughes2020-10-301-3/+3
| | | | | | | | | | | | | | The RUN_TEST macro is needed to perform the bookeeping on failures for the tests that are run. BRANCH=none BUG=b:171370392 TEST=make buildall -j Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I8b74c8ee39fd95391417267993e186eb2056456d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2508858 Reviewed-by: Bhanu Prakash Maiya <bhanumaiya@google.com>
* tree: Use new atomic_* implementationDawid Niedzwiecki2020-10-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | It is done as a part of porting to Zephyr. Since the implementation of atomic functions is done for all architectures use atomic_* instead of deprecated_atomic_*. Sometimes there was a compilation error "discards 'volatile' qualifier" due to dropping "volatile" in the argument of the functions, thus some pointers casts need to be made. It shouldn't cause any issues, because we are sure about generated asm (store operation will be performed). BUG=b:169151160 BRANCH=none TEST=buildall Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I98f590c323c3af52035e62825e8acfa358e0805a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2478949 Tested-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* test: Allow EC unit test to use Ztest APIPaul Fagerburg2020-10-231-19/+36
| | | | | | | | | | | | | | | | | | | | | | | | Provide a translation layer in test_utils.h for the Zephyr zassert macros to map onto EC's TEST_ASSERT macros. With a little bit of duplicated-but-not-quite-duplicated code (test_main vs. run_test) and some extra macros for the return type of the test cases, the tests can build for either the EC framework (by default) or the Zephyr Ztest framework (#ifdef CONFIG_ZEPHYR). Update the unit test documentation to explain why (and a brief "how") developers should use the Ztest API for new unit tests. BUG=b:168032590 BRANCH=none TEST=`TEST_LIST_HOST=base32 make runhosttests` Signed-off-by: Paul Fagerburg <pfagerburg@google.com> Change-Id: I26e60788c1468e44fed565dd31162759c7587ea6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2492527 Tested-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* TCPMv2: Avoid VCONN-Source discovery failureAbe Levkoy2020-10-211-0/+1
| | | | | | | | | | | | | | | | | Remove redundant checks for VCONN Source in pe_attempt_port_discovery (which prevent discovery from running). Allow pe_vdm_send_request to attempt to become VCONN Source if necessary. Make the checks in the VDM request child states more complete (not just checking for VCONN Source). BUG=b:170662791 TEST=Attach Tapex Creek board; observed successful discovery BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: Id7d3a1b82d1029f69b3e05b845632e7237524bc6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2486303 Tested-by: Li1 Feng <li1.feng@intel.com> Reviewed-by: Diana Z <dzigterman@chromium.org>
* common: online_calibration: Fix compilation issueGwendal Grignou2020-10-201-1/+1
| | | | | | | | | | | | | | | | | - Fix compilation error: sizeof() of an input array was not calculated properly. - Fix calling convention: use sensor pointer instead of sensor number - Use common formula to calculate sensor number. BUG=none BRANCH=none TEST=compile, unittest, load on eve with online calibration added. Change-Id: I06ff30eb5710cbe8f91c939b2ccc084c20a37847 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2486304 Reviewed-by: Yuval Peress <peress@chromium.org>
* TBT:Add support for exit mode SOP'/SOP'' on chipset transitionAyushee2020-10-141-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When chipset is transitioning to a new state or on sysjump, the EC re-negotiates to enter an alternate mode on booting up. This commit adds support for exiting Thunderbolt mode for SOP' and SOP'' for active cable on chipset transition and also moves all the alternate mode exit rotines to their respective files. It also delays deleting the SVID data until after the EXIT_MODE message has ACKed and avoids pd_dfp_exit_mode() from changing the alternate mode's internal states. This commit also makes sure that the mux is set to safe state before exiting the alternate mode and it is reconfigured according to the port's current data role on receiving ACK/NAK from the cable/port partner. BUG=b:151169925, b:159717794 BRANCH=none TEST=On reboot, able to exit and re-enter into DisplayPort mode, Thunderbolt mode with passive cable and thunderbolt mode with active cable. Change-Id: If1e48e9f31cd678e23fe89bd3494551b5d1a78f1 Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2415082 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* test/run_device_tests.py: Disable STM32F-specific test on icetowerTom Hughes2020-10-091-4/+13
| | | | | | | | | | | | | | Icetower is an STM32H743 device, so this test does not compile. BRANCH=none BUG=b:170432597 TEST=On Icetower v0.1 connected via servo_micro: ./test/run_device_tests.py -b dartmonkey Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Iaff85c24649ee50101441c9a75c57bd10b605c51 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2462159 Reviewed-by: Yicheng Li <yichengli@chromium.org>
* test/run_device_tests.py: Check for ASSERTION_FAILURETom Hughes2020-10-091-22/+41
| | | | | | | | | | | | | | | | | | Count an instance of ASSERTION_FAILURE as a test failure. There was a bug where the rollback tests correctly hit the data access violation, but then went into a boot loop due to hitting an ASSERTION_FAILURE. We now check the all the logs for failures. BRANCH=none BUG=b:170147314 TEST=./test/run_device_tests.py -b dartmonkey -t rollback_region0 TEST=./test/run_device_tests.py -b dartmonkey -t rollback_region1 TEST=./test/run_device_tests.py -b bloonchipper Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Iebe980af38383d6e71f46f799314e6275f047336 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2462544 Reviewed-by: Yicheng Li <yichengli@chromium.org>
* test/run_device_tests.py: Fix rollback region addresses for dartmonkeyTom Hughes2020-10-091-50/+73
| | | | | | | | | | | | BRANCH=none BUG=b:170147314, b:170432597 TEST=./test/run_device_tests.py -b dartmonkey -t rollback_region0 TEST=./test/run_device_tests.py -b dartmonkey -t rollback_region1 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: If1ff057165c462716820b783a8ef1dac7994fde1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2462543 Reviewed-by: Yicheng Li <yichengli@chromium.org>
* test/utils.c: Adjust expected speedup for STM32H743Tom Hughes2020-10-091-8/+15
| | | | | | | | | | | | BRANCH=none BUG=b:158580909, b:170432597 TEST=On Icetower v0.1 connected to servo_micro: ./test/run_device_tests.py -b dartmonkey -t utils Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: If5dcd7ade6397611b40b9c7a6f9560402a11c042 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2459229 Reviewed-by: Edward Hill <ecgh@chromium.org>
* common: include config.h from console.hJack Rosenthal2020-09-291-0/+4
| | | | | | | | | | | | | | | | | | | | | console.h currently relies on many config options to selectively define macros. It does not currently include config.h, which means these config options are not guaranteed to be defined by this point. We will need this for Zephyr as well. There were a few configuration header files which implicitly relied on the ording of including console.h to bring in stdint.h at some point. We explicitly include what we use here to fix that. BUG=b:167590251 BRANCH=none TEST=build passes Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Ia005577a2579962ee8b14c61930f37fe28bc8f5c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2427088 Reviewed-by: Yuval Peress <peress@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* tree: rename atomic_* functions to deprecated_atomic_*Jack Rosenthal2020-09-291-2/+2
| | | | | | | | | | | | | | | | We will move to an API compatible with Zephyr's API. See the bug for complete rationale and plan. BUG=b:169151160 BRANCH=none TEST=buildall Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Id611f663446abf00b24298a669f2ae47fef7f632 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2427507 Tested-by: Dawid Niedźwiecki <dn@semihalf.com> Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* fpsensor: Fix buffer check to account for overflowTom Hughes2020-09-251-1/+23
| | | | | | | | | | | BRANCH=none BUG=b:144957935 TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I1b4fa0a715869ccc37e48d75316ef52c367aa64a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2417529 Reviewed-by: Craig Hesling <hesling@chromium.org>
* test/utils: Add unit tests for safe_memcmpTom Hughes2020-09-241-0/+15
| | | | | | | | | | | | BRANCH=none BUG=b:169156874 TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I0bf4bdd654e6ba64b718c0d18650d561294744bc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2424067 Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* test: Add test_send_caps_error to usb_pe_drpEdward Hill2020-09-222-11/+102
| | | | | | | | | | | | | | | | | As requested in CL:2321869 review, make a new version of test_send_caps_error that uses the external interface of the PE layer. BUG=b:161835483 BRANCH=none TEST=make run-usb_pe_drp Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: I983b145cd1e731e844363955896898a2374a0a30 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2419834 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* TCPMv2: Move DPM requests to public APIAbe Levkoy2020-09-212-3/+3
| | | | | | | | | | | | | | | | It is safe (atomic bit ops) and will soon be necessary (new host commands) to send DPM requests from outside the PD tasks. Rename pe_dpm_request to pd_dpm_request and move the declarations into usb_pd.h to reflect this. BUG=b:168030639 TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: Ied43e9f6973a3172b98090cc068a607257dce21b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2415068 Reviewed-by: Jett Rink <jettrink@chromium.org>
* run_device_tests.py: Add type informationTom Hughes2020-09-101-15/+20
| | | | | | | | | | | | BRANCH=none BUG=b:162009542 TEST=mypy ./test/run_device_tests.py TEST=./test/run_device_tests.py Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I46d83c15eeaba03abd3477b516be22278a3dcf2b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2316522 Reviewed-by: Craig Hesling <hesling@chromium.org>
* test: body_detection: add unittest for algorithmChing-Kang Yen2020-09-037-3/+6397
| | | | | | | | | | | | | | | | | | Add test to check if the algorithm of body detection is correct. There are three testcases: OnBody: always in on-body state, should not change to off-body Off to On: change state from off-body to on-body On to Off: change state from on-body to off-body BRANCH=None BUG=b:123434029 TEST=make buildall Signed-off-by: Ching-Kang Yen <chingkang@chromium.org> Change-Id: Ib027fa3ed659f0d2efd7416888a9ee4ad519edd6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2329113 Reviewed-by: Heng-ruey Hsu <henryhsu@chromium.org>
* tcpmv2: allow early connection when waiting to allow LPMDenis Brockus2020-09-021-0/+38
| | | | | | | | | | | | | | | | | | While waiting to go into Low Power Mode the TCPC can detect a connection and we should honor that instead of waiting for the timeout and going into Auto Toggle. BUG=b:157718272 BRANCH=none TEST=FAFT_PD "dut-control usbc_pr:src20v" Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Ib3a3233ebf9b05b83446d7c1163e30fdcaf42aec Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2390848 Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* TCPMv2: Add DPM_REQUEST_GET_SRC_CAPDenis Brockus2020-09-022-4/+28
| | | | | | | | | | | | | | | | | | | | | As a SRC that runs on battery it can be handy to determine if the connected partner has unconstrained power available so we can try to PR_Swap to let them power us. This only requests the information, if it is not already available, and leaves it to other code to determine if the swap is a good idea. BUG=b:166446426 BRANCH=none TEST=connect a sink device and determine it performed the action Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: If45801a33df8b75e541989d7ee8f36ed316ffcc6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2381408 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: use sender_response message frameworkDenis Brockus2020-09-022-1/+1
| | | | | | | | | | | | | | | | | | Building up the framework to handle discarded DPM requests and using it on all of the sender_response messages BUG=b:165822172 BRANCH=none TEST=DUT-DUT PR_Swap Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I542d4cba89a923fb16588cc675d2ea4ab7954e0a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2376386 Tested-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* usb_pe_drp: new unit test with mocksPaul Fagerburg2020-08-3111-84/+192
| | | | | | | | | | | | | | | | | | | Add a new unit test for usb_pe_drp with mocks for the various subsystems that it will use. The fake_prl module is already essentially a mock for the PRL layer, so just move it into the mocks directory and make it available as mock to other tests. BUG=b:163421994 BRANCH=None TEST=`make runhosttests` succeeds Signed-off-by: Paul Fagerburg <pfagerburg@google.com> Change-Id: I2aea3fa0694e8d9e6bae1f47516cb4d5d2a1e714 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2364050 Tested-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* fpsensor: Run maintenance when in maintenance modeTom Hughes2020-08-311-0/+18
| | | | | | | | | | | | BRANCH=none BUG=b:76037094 TEST=make buildall -j Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ibe8649c3cf77ef4542b5fc46d7df5eee03293b56 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2364755 Commit-Queue: Craig Hesling <hesling@chromium.org> Reviewed-by: Craig Hesling <hesling@chromium.org>
* TCPMv2: Don't interrupt RX/TX Extended Chunked Msg sequenceSam Hurst2020-08-221-1/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Delay sending a new message during the reception or transmitting of Chunked messages. BRANCH=none BUG=b:161836223 TEST=make -j buildall manual: Transmitted an extended message and verified that the sequence was not interrupted by attempting to send a VDM message. Without patch Chunked message request that was interrupted. 20-08-14 10:46:13.473 C1: RECV 9a9f/1 [0]00008c00 20-08-14 10:46:13.494 C1: RECV 9c9f/1 [0]00009400 20-08-14 10:46:13.516 C1: RECV 9e9f/1 [0]00009c00 20-08-14 10:46:13.535 C1: RECV 909f/1 [0]0000a400 Try to send VDM. MSG_TYPE is corrupted, was 0x1f, now 0x0f 20-08-14 10:46:13.563 C1: RECV 928f/1 [0]0000ac00 20-08-14 10:46:13.591 C1: RECV 948f/1 [0]0000b400 20-08-14 10:46:13.618 C1: RECV 968f/1 [0]0000bc00 20-08-14 10:46:13.645 C1: RECV 988f/1 [0]0000c400 20-08-14 10:46:13.674 C1: RECV 9a8f/1 [0]0000cc00 With patch. Chunked message request was not interrupted. 20-08-14 10:50:56.052 C1: RECV 9a9f/1 [0]00008c00 20-08-14 10:50:56.075 C1: RECV 9c9f/1 [0]00009400 20-08-14 10:50:56.093 C1: RECV 9e9f/1 [0]00009c00 20-08-14 10:50:56.114 C1: RECV 909f/1 [0]0000a400 Try to send VDM. Message delayed 20-08-14 10:50:56.134 C1: RECV 929f/1 [0]0000ac00 20-08-14 10:50:56.155 C1: RECV 949f/1 [0]0000b400 20-08-14 10:50:56.175 C1: RECV 969f/1 [0]0000bc00 20-08-14 10:50:56.195 C1: RECV 989f/1 [0]0000c400 20-08-14 10:50:56.216 C1: RECV 9a9f/1 [0]0000cc00 20-08-14 10:50:56.242 C1: RECV 0c90/0 Try to send VDM. Signed-off-by: Sam Hurst <shurst@google.com>wq Change-Id: I5475792ee9f272fe4964e27839e55e3409a6a799 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2357414
* usbc: wake task on every state transitionJett Rink2020-08-192-19/+11
| | | | | | | | | | | | | | | | | | Whenever we change state, we should continue to wake the USB statemachine task up until is settles into a steady state were it is waiting/polling on a timer or event. BRANCH=none BUG=b:163152687 TEST=Ran GRL PD3.0 test on Trembyle and did not see any regressions. It did make a few tests pass that were failing before due to timing issues. Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: Idc3c1ae8d92a0f6a5cd4b82f9db6d7138d143f77 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2356954 Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
* common: gyro_cal: Implement gyroscope calibrationYuval Peress2020-08-184-0/+631
| | | | | | | | | | | | | | Implement the calibration code for the gyroscope which is ported over from AOSP's https://android.googlesource.com/device/google/contexthub/+/refs/heads/master/firmware/os/algos/calibration/gyroscope/ BUG=b:138303429,b:137204366,chromium:1023858 TEST=Added unit tests BRANCH=None Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: Ic1ab2efb66565cda0a96c9c06722136fb184df77 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2244934 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* test: rename usb_pe_drp to usb_pe_drp_oldPaul Fagerburg2020-08-178-8/+377
| | | | | | | | | | | | | | | | | Rename the current usb_pe_drp test to usb_pe_drp_old. There will be a new usb_pe_drp test that uses mocks and we will move the tests over in a controlled fashion. BUG=b:163421994 BRANCH=None TEST=`TEST_LIST_HOST=usb_pe_drp_old make runhosttests` works. Signed-off-by: Paul Fagerburg <pfagerburg@google.com> Change-Id: I2e0f79eb793d888109d00a96567042356c770502 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2357519 Tested-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* CBI: Make test fail if a tag is missing from unit testDaisuke Nojiri2020-08-141-0/+35
| | | | | | | | | | | | | | This patch adds a check in the unit test which fails if there is a tag missing from test_all_tags. This will force developers to pay attension to the unit test when adding a new tag. BUG=none BRANCH=none TEST=buildall Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I34d054493e16454c3662b289eaa6d4de362a26f4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2354200
* cleanup/usbc: organize all super states togetherJett Rink2020-08-131-7/+5
| | | | | | | | | | | | | | Like other state machine declarations, put all of the super states together to make it more clear when reading states. BRANCH=none BUG=none TEST=build and unit tests Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I1bb776434911d3acdb34abc64e7e8fa5f87154de Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2354193 Reviewed-by: Edward Hill <ecgh@chromium.org>
* usbc: add GEN_NOT_SUPPORTED macro for unsupported statesJett Rink2020-08-131-5/+3
| | | | | | | | | | | | | | | | | | | To enabled use of the IS_ENABLE macro we need to define some of the usb state machine states as extern variables that will never be linked. This allows the compiler to know about a state but will still fail the linking phase if the config option is not defined properly. This is just adding a convenience macro for this paradigm, not creating the paradigm itself. BRANCH=none BUG=none TEST=builds Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: Ia19b5babd43d536f043745314481475cf25f6e01 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2353369 Reviewed-by: Edward Hill <ecgh@chromium.org>
* test: remove no_empty_state testsJett Rink2020-08-137-73/+0
| | | | | | | | | | | | | | | | When we use IS_ENABLED style code we may have empty state machine states that are unused. The linker ensures that we never try to reference these states. This does mean that extra states do cost ~20 bytes each. This cost does seem worth it to keep the value of usb states stable. BRANCH=none BUG=none TEST=buildall Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I44c1454bed91c9e28d89ebd6b75e9df684c41844 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2354192 Reviewed-by: Edward Hill <ecgh@chromium.org>
* tcpmv2: wait before enabling HW auto toggleJett Rink2020-08-132-0/+27
| | | | | | | | | | | | | | | We need to ensure that the previous Rd or Rp has been held long enough before we transition into hardware auto toggle otherwise the first toggle might be too short and violate the DRP timing spec BRANCH=none BUG=b:163095971 TEST=Verify on scope Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I92e9f5ca7dbca2b347e438d774551cc11476195b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2343176 Reviewed-by: Edward Hill <ecgh@chromium.org>
* cbi: add Second Source Factory Cache (SSFC) CBI fieldMarco Chen2020-08-131-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | SSFC field will be leveraged to record what second source is used in the DUT by probing components in the factory or RMA. Firmware code should refer to this field to judge what driver should be configured for a specific component. For example, the board code can arrange what sensor driver should be set into motion_sensors array if there are multiple sources of base or lid sensor. As the definition of FW_CONFIG, it describe which "features" the firmware code should enable or disable. For example, whether lid / base sensors should be enabled or not but not care about what second source is in this DUT. BRANCH=none BUG=b:163285687 TEST=call `cbi-util` to create the cbi image with SSFC and show created content. TEST=`make buildall -j` TEST=`make runhosttests -j` Change-Id: Icb4aa00ae47ab025198e7fd5edd6aab96a4bf53e Signed-off-by: Marco Chen <marcochen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2344268 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* flash: allow programming larger EC imagesKeith Short2020-08-131-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For some ECs, the EC image size is limited by the amount of code RAM instead of 1/2 the total flash size. In this instance, there is unused flash that can be used for single use data objects. To support linking data objects into the unused flash area, increase the region size that can be programmed for RW images. Analysis of chips that are impacted by this change: Chip EC image limit New RW size limit mec1701h 188 KiB 256 KiB mec17xx_2E00 188 KiB 256 KiB npcx5m5g 96 KiB 128 KiB npcx5m6g 224 KiB 256 KiB npcx7m6f 192 KiB 256 KiB npcx7m6fb 192 KiB 256 KiB npcx7m6fc 192 KiB 256 KiB npcx7m6g 192 KiB 256 KiB npcx7m7wb 256 KiB 512 KiB npcx7m7wc 252 KiB 256 KiB Boards using other chips verified that CONFIG_RW_SIZE is the same as CONFIG_EC_WRITABLE_STORAGE_SIZE. EC_FLASH_REGION_RO isn't used by depthcharge, only EC_FLASH_REGION_WP_RO which is already set to the correct size. BUG=b:160330682 BRANCH=none TEST=make buildall Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I84b9dc84568273e1ab1473e301d27ffd2b07ba7f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2325764 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: caveh jalali <caveh@chromium.org> Commit-Queue: caveh jalali <caveh@chromium.org>
* mock/usb_pd_mock: remove tc functionsPaul Fagerburg2020-08-121-2/+1
| | | | | | | | | | | | | Remove tc_set_data_role and tc_set_power_role from usb_pd_mock. BUG=b:163421165 BRANCH=None TEST=`make runhosttests`, all unit tests pass Signed-off-by: Paul Fagerburg <pfagerburg@chromium.org> Change-Id: Ib380d2f04f833b58e23a16d0c6421316b72329fe Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2349282 Reviewed-by: Jett Rink <jettrink@chromium.org>
* test/usb_pe_drp: remove fake_batteryPaul Fagerburg2020-08-121-1/+1
| | | | | | | | | | | | | | | | The test/usb_pe_drp build includes fake_battery.o, which is not used in the unit test, so remove it from the build. BUG=b:163421994 BRANCH=None TEST=`make runhosttests`, all unit tests pass Signed-off-by: Paul Fagerburg <pfagerburg@google.com> Change-Id: Ie3167345415073de073386d1f4d82310563e9d27 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2349281 Tested-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* test: Soft_Reset sent regardless of Rp valueEdward Hill2020-08-122-3/+45
| | | | | | | | | | | | | | | Add test for TD.PD.SRC3.E26.Soft_Reset sent regardless of Rp value. BUG=b:161835483 BRANCH=none TEST=make -j run-usb_tcpmv2_tcpci Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: I972bffcb1c7a330aef4ebdff98fcd33af9a667be Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2340486 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* CBI: Add unit testDaisuke Nojiri2020-08-073-0/+206
| | | | | | | | | | | | This patch adds unit tests for Cros Board Info APIs. BUG=b:163038871 BRANCH=none TEST=buildall Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I7b2fdb2c4f13da12f8c0dc2ab526332cbd46d849 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2339393
* usbc: correctly handle Get_Source_Cap as a sinkPeter Marheine2020-08-063-4/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | USB Power Delivery Specification Revision 3.0, version 2.0 section 6.3.7 states that a dual-role port shall respond to Get_Source_Cap with its source capabilities, but this was incorrectly handled by responding with a request for source capabilities. Per section 8.3.3.18.10, implement the PE_DR_SNK_Give_Source_Cap state to handle this correctly. To support the new test, some helper functions for the fake PE are added and the test code's copy of the PE state enum is updated to be in sync with the real one. BUG=b:161400825,b:161331630 TEST=New host test for this state, and verified on Dalboz that requesting a PRS via the EC console (`pd 1 swap power`) now sends source capabilities when the partner requests them. BRANCH=None Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: I87c27d406e0a3f57cf2c25fa583bee51155b6b12 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2336233 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* tcpmc2: fix TD.PD.LL3.E2 Retransmission testJett Rink2020-08-062-143/+84
| | | | | | | | | | | | | | | | | | | | | | | We are retrying in both the TCPC hardware (4 total) and in the Protocol layer (3 total) when we do not get a GoodCRC back from the port partner. We are only suppose to retry up to nRetryCount times which is 2. This means we should be sending 3 total replies. Also correct a misinterpretation of the spec around SOP' and SOP" retries. We were not retrying those packets, but we should be retry them as the SOP. The SOP' device will not retry, but we (as the SOP) should retry packet that we are sending to them. The TCPM is not fast enough to meet the timing for tRetry (195 usec), so we need to perform the retries in the TCPC hardware layer. BRANCH=none BUG=b:150617035 TEST=Verify passing compliance test with GRL-C2 on Trembyle Change-Id: I55c4ab2f5ce8f64acf21af943862d96d9088622d Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2248960