summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* ish: Trim down the release branchstabilize-wristpin-14469.59.B-ishstabilize-voshyr-14637.B-ishstabilize-quickfix-14695.187.B-ishstabilize-quickfix-14695.124.B-ishstabilize-quickfix-14526.91.B-ishstabilize-14695.85.B-ishstabilize-14695.107.B-ishstabilize-14682.B-ishstabilize-14633.B-ishstabilize-14616.B-ishstabilize-14589.B-ishstabilize-14588.98.B-ishstabilize-14588.14.B-ishstabilize-14588.123.B-ishstabilize-14536.B-ishstabilize-14532.B-ishstabilize-14528.B-ishstabilize-14526.89.B-ishstabilize-14526.84.B-ishstabilize-14526.73.B-ishstabilize-14526.67.B-ishstabilize-14526.57.B-ishstabilize-14498.B-ishstabilize-14496.B-ishstabilize-14477.B-ishstabilize-14469.9.B-ishstabilize-14469.8.B-ishstabilize-14469.58.B-ishstabilize-14469.41.B-ishstabilize-14442.B-ishstabilize-14438.B-ishstabilize-14411.B-ishstabilize-14396.B-ishstabilize-14395.B-ishstabilize-14388.62.B-ishstabilize-14388.61.B-ishstabilize-14388.52.B-ishstabilize-14385.B-ishstabilize-14345.B-ishstabilize-14336.B-ishstabilize-14333.B-ishrelease-R99-14469.B-ishrelease-R98-14388.B-ishrelease-R102-14695.B-ishrelease-R101-14588.B-ishrelease-R100-14526.B-ishfirmware-cherry-14454.B-ishfirmware-brya-14505.B-ishfirmware-brya-14505.71.B-ishfactory-kukui-14374.B-ishfactory-guybrush-14600.B-ishfactory-cherry-14455.B-ishfactory-brya-14517.B-ishJack Rosenthal2021-11-05284-43125/+0
| | | | | | | | | | | | | | | | | | | | | | In the interest of making long-term branch maintenance incur as little technical debt on us as possible, we should not maintain any files on the branch we are not actually using. This has the added effect of making it extremely clear when merging CLs from the main branch when changes have the possibility to affect us. The follow-on CL adds a convenience script to actually pull updates from the main branch and generate a CL for the update. BUG=b:204206272 BRANCH=ish TEST=make BOARD=arcada_ish && make BOARD=drallion_ish Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I17e4694c38219b5a0823e0a3e55a28d1348f4b18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262038 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* test/rollback_entropy: Add __maybe_unused to arraysTom Hughes2021-09-281-3/+4
| | | | | | | | | | | | | | | | | | Clang warns that "_EXPECTED_SECRET is not needed and will not be emitted". The same warning occurs for _EXPECTED_SECRET2, and _EXPECTED_UNINITIALIZED_ROLLBACK_SECRET. While this is true, we still want the BUILD_ASSERT() evaluated at compile time, so mark it as "__maybe_unused" to suppress the warning. BRANCH=none BUG=b:172020503 TEST=make buildall -j TEST=make BOARD=dartmonkey tests -j Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I6ab0f4070654e74c1c8ef5d1ba7b125d490633f7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3174597 Reviewed-by: Ting Shen <phoenixshen@chromium.org>
* ec: Fail on uninitialized variablesJeremy Bettis2021-09-241-2/+2
| | | | | | | | | | | | | | | | | | | | | | | The zephyr toolchain has -Werror=maybe-uninitialized enabled by default, so enable it for all gcc EC builds to prevent possible uninitialized vars from sneaking into the codebase. For clang builds, use -Werror=uninitialized instead. BRANCH=None BUG=None TEST=in docker: make -j CRYPTOC_DIR="${MODULES_DIR}/cryptoc" \ FTDIVERSION=1 HOSTGCOV='gcov' \ CROSS_COMPILE_arm=/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi- \ coverage in chroot; make try_build_boards buildall_only Change-Id: I3efb4b2958f2037606195743d768870e1d0b18b9 Signed-off-by: Jeremy Bettis <jbettis@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3171939 Tested-by: Jeremy Bettis <jbettis@chromium.org> Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* test/utils: Switch to run-time test to fix clang buildTom Hughes2021-09-231-1/+4
| | | | | | | | | | | | | | | | | | | | | The BUILD_ASSERT that was used fails to compile with clang: error: static_assert expression is not an integral constant expression BUILD_ASSERT(str1 != str3) BRANCH=none BUG=b:172020503 TEST=make buildall -j TEST=./test/run_device_tests.py --board dartmonkey --compiler clang --tests=utils --remote 127.0.0.1:2551 TEST=./test/run_device_tests.py --board dartmonkey --compiler gcc --tests=utils --remote 127.0.0.1:2551 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Id93ea45b653b86fd5a79ed565e1fa94ffd317723 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3174596 Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
* ec: Exclude version test from coverage buildsJeremy Bettis2021-09-211-0/+2
| | | | | | | | | | | | | | | | | | | The version host test only works inside the chroot, and doesn't really contribute to coverage, so exclude it from coverage builds. BRANCH=None BUG=None TEST=in docker: make -j CRYPTOC_DIR="${MODULES_DIR}/cryptoc" \ FTDIVERSION=1 HOSTGCOV='gcov' \ CROSS_COMPILE_arm=/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi- \ coverage Change-Id: I05ee9968360d8e76199fc3ee65d0ca1f2eae7ed4 Signed-off-by: Jeremy Bettis <jbettis@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3171940 Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* test/run_device_tests.py: Allow specifying compilerTom Hughes2021-09-211-4/+16
| | | | | | | | | | | | | | | | | Default to using gcc, but allow selecting clang so that we can test it. BRANCH=none BUG=b:172020503 TEST=./test/run_device_tests.py --compiler clang --board dartmonkey --tests sha256 --remote 127.0.0.1:2551 TEST=./test/run_device_tests.py --board dartmonkey --tests sha256 --remote 127.0.0.1:2551 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I3cfd04825df8cac54fbee1ba1b084ea581e62e53 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3172037 Reviewed-by: Craig Hesling <hesling@chromium.org> Reviewed-by: Patryk Duda <patrykd@google.com>
* system: Add CrOS FWID to version outputRob Barnes2021-09-143-0/+160
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | EC version does not follow the the AP and OS version. This causes confusion during development. This change augments the EC version output to include the CrOS FWID when available. The CrOS FWID will be missing when the CrOS EC is built outside of cros_sdk. When CrOS FWID is missing 'CROS_FWID_MISSING' will be used. Zephyr/zmake support will be added later, CROS_FWID32 is set to 'CROS_FWID_MISSING' in zephyr builds until then. BUG=b:188073399 TEST=version 21-05-20 16:43:18.627 Chip: Nuvoton NPCX993F A.00160101 21-05-20 16:43:18.631 Board: 1 21-05-20 16:43:18.631 RO: guybrush_v2.0.8770+f47439f75 21-05-20 16:43:18.634 guybrush_13983.0.21_05_20 21-05-20 16:43:18.639 RW_A: * guybrush_v2.0.8770+f47439f75 21-05-20 16:43:18.641 * guybrush_13983.0.21_05_20 21-05-20 16:43:18.644 RW_B: guybrush_v2.0.8770+f47439f75 21-05-20 16:43:18.644 guybrush_13983.0.21_05_20 21-05-20 16:43:18.647 Build: guybrush_v2.0.8770+f47439f75 21-05-20 16:43:18.651 guybrush_13983.0.21_05_20 2021-05-20 21-05-20 16:43:18.657 16:31:19 robbarnes@robbarnes0 ectool version RO version: guybrush_v2.0.8770+f47439f75 RO cros fwid: guybrush_13983.0.21_05_20 RW version: guybrush_v2.0.8770+f47439f75 RW cros fwid: guybrush_13983.0.21_05_20 Firmware copy: RO Build info: guybrush_v2.0.8770+f47439f75 guybrush_13983.0.21_05_20 2021-05-20 16:31:19 robbarnes@robbarnes0 Tool version: 1.1.9999-f47439f @robbarnes0 BRANCH=None Signed-off-by: Rob Barnes <robbarnes@google.com> Change-Id: Ief0a0c6e9d35edc72ac2d4780ee203be41d7305f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2894145 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* test: accel_cal: add setup/teardown methodsYuval Peress2021-08-311-3/+11
| | | | | | | | | | | | | BRANCH=none BUG=none TEST=make buildall -j Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I2df3668b826a0f5aef3b6ac5dc9a55dca965eea8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3133801 Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* TCPM: Rename enum tcpm_sop_type and its constantsAbe Levkoy2021-08-3122-141/+141
| | | | | | | | | | | | | | | As a followup to CL:3104290, give the TCPCI TRANSMIT and RX_BUF_FRAME_TYPE types more consistent names. Most of them can be used for receiving, not just transmitting. Fix lint errors thus revealed. BUG=b:155476419 TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I399ec479eacc18622fc4d3f55f8bdabf4560fcff Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3125995 Reviewed-by: Keith Short <keithshort@chromium.org>
* adc: Include adc_chip.h from adc.hCaveh Jalali2021-08-271-1/+0
| | | | | | | | | | | | | | | | This reorganizes adc.h and adc_chip.h so that general code only needs to know about adc.h. adc_chip.h is now included by adc.h directly and does not need to be included in general code. BRANCH=none BUG=b:181271666 TEST=buildall passes (with next patch in series) Cq-Depend: chromium:3120316 Change-Id: I8bc107c6900e831a57f7a7fb8668eb08bb179d6c Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3120315 Reviewed-by: Keith Short <keithshort@chromium.org>
* common: Add Milli Kelvin conversion macrosRob Barnes2021-08-212-0/+47
| | | | | | | | | | | | | | Add macros to convert to and from milli kelvin and various temperature units. Utilize round_divide for more accurate conversions. BUG=b:176994331 TEST=Unit test BRANCH=None Change-Id: Ie6750b9d2d2b8093fdf9c14f904382e91d8d95bb Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3078051 Reviewed-by: Keith Short <keithshort@chromium.org>
* system: fix system_get_scratchpad APIYuval Peress2021-08-204-14/+26
| | | | | | | | | | | | | | | The current API for system_get_scratchpad mixes the status and the value being read. Update the signature to allow both. BRANCH=none BUG=b:195481980 TEST=make testall && zmake testall Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I3a5f5ad523d507c53a5d474806f58afafb82e70c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3074828 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* TCPM: Remove enum pd_msg_typeAbe Levkoy2021-08-1813-44/+45
| | | | | | | | | | | | | Convert usages of this enum to tcpm_sop_type. BUG=b:155476419 TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I5fed273d72e7ad0e191db0cb0d121b70bdd9ecdb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3104291 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPM: Rename enum tcpm_transmit_typeAbe Levkoy2021-08-182-8/+10
| | | | | | | | | | | | | | | Rename tcpm_transmit_type to tcpm_sop_type to reflect that it can be used for Rx as well. Describe it in comments. This prepares to consolidate enum pd_msg_type into this enum. BUG=b:155476419 TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: Ife97d4ad51c48f2e832b94e007954919e236a309 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3104290 Reviewed-by: Keith Short <keithshort@chromium.org>
* chgstv2/sustainer: Stop AC current when dischargingDaisuke Nojiri2021-08-091-1/+67
| | | | | | | | | | | | | | | | | | | Currently, the battery sustainer discharges the battery using CHARGE_CONTROL_IDLE, which uses the AC current and stops the current from the battery. With this change, when lower < upper, the sustainer discharges using DISCHARGE. When lower == upper, the sustainer discharges using IDLE. BUG=b:188457962 BRANCH=None TEST=run-sbs_charging_v2 Change-Id: I4af31eff488bc9cfa627f84994b685488c3c9061 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3049290 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Derek Basehore <dbasehore@chromium.org>
* chgstv2/sustainer: Add tests for full battery and ACDaisuke Nojiri2021-08-091-15/+63
| | | | | | | | | | | | | | | | | | Currently, unit tests do not check whether the battery sustainer can be enabled when the battery is already full or when the AC is already present. This patch adds tests which check the battery sustainer can be enabled when the battery is already full or when the AC is already present. BUG=b:188457962 BRANCH=None TEST=run-sbs_charging_v2 Change-Id: I4ec9785554d126baca0b60e889c4a2dabbfb628a Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3078401 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* util: Add strcspnRob Barnes2021-08-091-0/+28
| | | | | | | | | | | | | | | Add the standard string function strcspn. strcspn calculates the length of the initial segment of s which consists entirely of bytes not in reject. BUG=None TEST=make run-utils_str BRANCH=None Signed-off-by: Rob Barnes <robbarnes@google.com> Change-Id: I3eb9a4fff42cb0fdcdb288d00f8070e0f22b2179 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3057730 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* test: Crispen up fp host testEvan Green2021-08-021-13/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix some issues with the FP test in preparation for switching the host tests to compile in 32-bit mode. There are a few things going on with the FP tests. The first thing to know about x86 is the compiler has a hard time restricting itself to 32-bits even when you're seemingly only working with float types. Part of this is C's fault, since C promotes floats to doubles in cases like arguments handed to printf. This results in weirdness. For instance, if I add a union like this: union evanfloat { float f; unsigned int i; }; And then print out the result and golden values from test_fpv3_dot(), I get this: 421a5e35 421a5e35 38.592000 38.591999 How is it that the same hex value prints two different floats, even when the values I'm passing are from the union, and I can see the byte value contents of the floats are the same? The compiler gets exuberant here and keeps the computation result in the floating point registers, then lets them ride on through to printf. As an experiment, I tried printing values from this union instead: union evandouble { double d; unsigned long long i; }; And I get the following: 40434bc6a58b4390 40434bc6a0000000 38.592000 38.591999 What this shows is that even though the return type of fpv3_dot() is a float, the compiler is carrying around the extra precision of a double computation. The test was all carefully crafted to have the correct answers, unfortunately with this implicit double advantage built in. So we run afoul of this when we try to compile with -m32. i686 only has access to the old x87 FPU instructions, rather than SSE2 that's part of AMD64. As such, the double advantages come out slightly different, resulting in 1ULP (unit in last place) variations between x86_64 and i686. These are likely errors that accumulate differently in intermediate results of functions like fpv3_dot(). Really that's all fine, we just have to account for this in the test so that both x86_64 and i686 can pass correctly. In some cases like test_fpv3_dot(), this can be achieved by creating a volatile fp_t and assigning the result to that. This forces the compiler to dump the final value out of the FPU registers and save a float into memory, truncating the hidden double bits. In other cases, AMD64 and i686 disagreed by 1ULP, but the golden value disagreed with both by a handful of ULP. Fix those golden values so their hex values lined up better. But even with the fixed golden values, amd64 and i686 still disagreed on some results by 1ULP. In these cases it was necessary to increase the tolerance from 0.0 to an approximation of 1ULP. As a side note, expressing the tolerances as absolute values is a bit brittle, as it requires that your testing values and results stay within a certain exponent. If we were to write a new floating point test, it might be better to have the test comparison macros decompose the values into exponent and mantissa, and then compare those separately with a tolerance on the mantissa. BUG=b:179062230 BRANCH=none TEST=make -j runhosttest BOARD=host on both amd64 and i686 Signed-off-by: Evan Green <evgreen@chromium.org> Change-Id: I3f8d36713dfa9f2f8adefb1b4db1e47b84dec1f0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3059227 Reviewed-by: Eric Yilun Lin <yllin@google.com>
* test: Ensure time move forward in usb_pd_intEvan Green2021-08-021-2/+5
| | | | | | | | | | | | | | | | | | | | test_storm_not_triggered_for_32bit_overflow wanted to check to ensure the storm detection worked across the 32-bit boundary, so it forced the current time to 0xff000000. It assumed however that this timestamp was in the future. If it's in the past (say for instance someone else has bumped time forward) then the storm tracking is broken and this test fails. Since it is not the goal of this test to see how the storm tracker behaves when time moves backwards, fix up the test to ensure it's got the high bit set but is also in the future. BUG=b:179062230 BRANCH=none TEST=make -j runhosttests Signed-off-by: Evan Green <evgreen@chromium.org> Change-Id: Iac4c68e2bf46649a01477dbd1dabfcf0d95b1371 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3059232 Reviewed-by: Jett Rink <jettrink@chromium.org>
* test: Make more and smaller allocations in shmallocEvan Green2021-08-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The shmalloc test works like this: * Randomly select a slot out of 12. * If that slot is occupied, free it. If that slot is free, attempt to make an allocation of size rand() % total_heap_size. * At the end of the test, assert (among other things) that we were able to make at least 5 allocations at once given 500000 iterations. It turns out that getting 5 outstanding allocations at once using this algorithm is not trivial. I did a simulation with a simpler version of this that just attempts to make (rand % total) size allocations without overflowing the max [1], and found that the average number of allocations you're able to make is about 1.8, with a standard deviation of 0.9. That means that the test is asserting that in 500000 iterations it will be able to do >3 standard deviations better than the mean in ~500000/1.8 iterations. Since we never vary the rand seed, and we happened to get lucky with the default seed, it all works. But when I try to compile in 32-bit mode, I think I get an unlucky default seed, and always fail this 5 allocation test. There are a few knobs you could twist to fix this: * You could reduce the allocation bar below 5. * You could increase the iteration count above 500000. * You could increase the slot count above 12 so that the first dice roll favors trying allocations more. * You could decrease the max allocation size from "total" to reduce the amount each allocation can occupy. This change opts for the last option. Reducing the max allocation to total / 2 increases the (simplified) simulation result to a mean of 3.5 with a standard deviation of 1.27. This means the test now only has to do better than < 1 standard deviation from the mean in 500000 iterations. This is still probabilistic, but is much less likely to break if you sneeze on it wrong. [1] https://paste.googleplex.com/6653229610827776 BUG=b:179062230 BRANCH=none TEST=make -j runhosttests BOARD=host and x86_64 and i686. Signed-off-by: Evan Green <evgreen@chromium.org> Change-Id: Ifb16533ee6fa02ce2613c32b1462b78ef0c6cd21 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3059230 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* test: Fix sbs_charging_v2's charge_control() cmd versionEvan Green2021-08-021-1/+1
| | | | | | | | | | | | | | | | | charge_control() was sending EC_CMD_CHARGE_CONTROL version 2, but leaving params.cmd uninitialized. Apparently we were just getting lucky. I did not get as lucky when compiling in 32-bit mode. This test is clearly sending the version 1 form of the command, so make the version number match the intent so the EC doesn't fail the command. BUG=b:179062230 BRANCH=none TEST=make -j runhosttests BOARD=host on x86_64 and i686 Signed-off-by: Evan Green <evgreen@chromium.org> Change-Id: Ie440ff825e1125bb50b4ac2477ba983e00ef303e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3059229 Reviewed-by: Diana Z <dzigterman@chromium.org>
* test: Fix printf formatting in usb_typec_drp_acc_trysrc.cEvan Green2021-07-311-2/+2
| | | | | | | | | | | | | | | | | | Fix a couple of minor formatting errors where constants with LL or ULL suffixes were being printed. On x86_64 printing these as %l is fine because longs are 64-bits. On i686 this comes out as an error because long is 32-bits. Use the correct ll specifier for these, and in one case ensure it comes out as a 64-bit value by adding LL. BUG=b:179062230 BRANCH=none TEST=make -j runhosttests on i686 and x86_64 Signed-off-by: Evan Green <evgreen@chromium.org> Change-Id: Ic59c9647aa70f58e497b9615122ca4c202504365 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3059228 Commit-Queue: caveh jalali <caveh@chromium.org> Reviewed-by: caveh jalali <caveh@chromium.org>
* flash: Set CBI EEPROM WP immediately if SW WP setAseda Aboagye2021-07-301-0/+39
| | | | | | | | | | | | | | | | | | | | | | With `CONFIG_EEPROM_CBI_WP`, the EC will set the the CBI EEPROM WP according to `system_is_locked`. The system lock status is also cached. In order to prevent requiring an EC reboot after setting the software write protect status, this commit will set the CBI EEPROM WP status when the SW WP is asserted along with the HW WP. This is the same criteria that `system_is_locked` would use when deciding if the system is locked. BUG=b:181769483 BRANCH=None TEST=Build and flash a reworked lalala, enable HW WP, enable SW WP via `flashrom -p ec --wp-enable` and verify that EC_CBI_WP is asserted immediately without requiring an EC reboot. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I987a5b7652134be11c82855aab9ed4eb1442b57c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3058077 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* cbi: Add CONFIG_EEPROM_CBI_WPAseda Aboagye2021-07-294-0/+71
| | | | | | | | | | | | | | | | | | | | | This commit adds the config option, CONFIG_EEPROM_CBI_WP. It is to be defined when the EC directly controls the CBI EEPROM WP signal. The EC will set the WP according to the result of `system_is_locked()`. Note that once the WP is set, the EC must be reset via EC_RST_ODL in order for the WP to become unset. This is enabled by the accompanying hardware. BUG=b:181769483 BRANCH=None TEST=`make -j buildall` Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: If490594ab4dd24af98119b01299215b997913b66 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3046412 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Auto-Submit: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* test/stm32f_rtc: Allow running the test multiple timesCraig Hesling2021-07-281-0/+2
| | | | | | | | | | | | | | | | | | This allows running the test back-to-back at the console during a single boot. BRANCH=none BUG=b:194720920 TEST=./test/run_device_tests.py --board bloonchipper --tests stm32f_rtc minicom -D$(dut-control -o raw_fpmcu_console_uart_pty) > runtest > runtest Change-Id: Ibe986d0482bc3dd9a07a7cc0a4f6bf55c5d4c466 Signed-off-by: Craig Hesling <hesling@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3055120 Reviewed-by: Patryk Duda <patrykd@google.com> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* keyboard: Add strict debouncerDaisuke Nojiri2021-07-284-3/+163
| | | | | | | | | | | | | | | | | This CL adds CONFIG_KEYBOARD_STRICT_DEBOUNCE. It makes the keyboard debouncer register a key stroke after deounce is done. This CL also adds a unit test. BUG=b:193505909 BRANCH=Dedede TEST=make run-kb_scan_strict TEST=Blipper Change-Id: Ia380657021035930afab5cafffa8cc2edd7ff475 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3044405 Reviewed-by: Jett Rink <jettrink@chromium.org>
* test/run_device_tests.py: Plumb "remote" arg to flash_jlink.pyCraig Hesling2021-07-281-7/+17
| | | | | | | | | | | | | | | | | | BRANCH=none BUG=none TEST=# Do not start JLinkRemoteServerCLExe ./test/run_device_tests.py --tests stm32f_rtc # Should flash over USB ./test/run_device_tests.py --remote localhost --tests stm32f_rtc # Should fail TEST=JLinkRemoteServerCLExe ./test/run_device_tests.py --remote localhost --tests stm32f_rtc # Ensure that the JLinkRemoteServerCLExe noted two connections. Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: I41e1fb32e10877f74d4de7d6d8294b53645434bd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3054819 Reviewed-by: Josie Nordrum <josienordrum@google.com>
* test/stm32f_rtc: Allow real rtc delay to be earlyCraig Hesling2021-07-271-5/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The current check for if the RTC delay is within 1ms, only accounts for actual delays that exceed 500ms. This doesn't seem right, since you would rather wake up early than late. This change allows the RTC delay to be early or late by the tolerance window. I have also tightened the tolerance window to +/- 500us. BRANCH=none BUG=b:194720920 TEST=# Repeat the following test 10 times ./test/run_device_tests.py --board bloonchipper --tests stm32f_rtc TEST=# Disable CONFIG_LOW_POWER_IDLE # Repeat the following test 10 times ./test/run_device_tests.py --board bloonchipper --tests stm32f_rtc TEST=# Disable CONFIG_LOW_POWER_IDLE and comment out idle loop "wfi" # instruction. # Repeat the following test 10 times ./test/run_device_tests.py --board bloonchipper --tests stm32f_rtc Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: I68505c4011d9e12d54ed2630975a5b3be42ba6f2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3055119 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* TCPMv2: Allow tests to clear PE data between runsDiana Z2021-07-271-0/+1
| | | | | | | | | | | | | | The PE stores internal state (ex. capabilities, identity responses) which should be cleared out between unit test runs. BRANCH=None BUG=None TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I77b3faefd3f887a68ca9593a7398ae9c3ffb2f17 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3025864 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* tablet_mode: Fix the race condition of setting the tablet modeWai-Hong Tam2021-07-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | There are 2 tablet mode triggers: * Lid: when the lid angle close to 360 degree, either detected by a GMR sensor or by the angle computed by 2 motion sensors. * Base: when the detachable base is detached. These 2 triggers set the tablet mode status, which as a boolean, resulting a race condition. This CL fixes the race condition. Each trigger updates its own bit. The final tablet mode status is the OR of all bits. BRANCH=Trogdor BUG=b:193873098 TEST=Attached the base, checked tablet_mode enabled; detached the base, checked tablet_mode disabled; flip base to 360 degree, checked tablet_mode disabled; move the base out of the lid, checked tablet_mode disabled. Change-Id: Ia9d9d2d66c194796c1039cc8b746c8d1f28a4496 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3044414 Reviewed-by: Ting Shen <phoenixshen@chromium.org>
* keyboard: Restore kb_scan testDaisuke Nojiri2021-07-232-9/+16
| | | | | | | | | | | | | | | kb_scan test was disabled due to crbug.com/976974. Since it's only partially broken, this CL enables the test and disables simulate_key_test. BUG=b:152931654 BRANCH=None TEST=make run-kb_scan Change-Id: I9496f34a320c81b113c241d6160091721a28a5de Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3044404 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* TCPMv2: Gate requesting sink capabilities on related featuresDiana Z2021-07-122-13/+2
| | | | | | | | | | | | | | | | | There are a number of features that may cause a board to need sink capabilities (3.0 A port balancing, FRS, or AP host commands). However, other boards may not need these and the added traffic can increase the liklihood of collisions on PD 2.0 connections. BRANCH=None BUG=b:192051705 TEST=connect honeybuns to TCPMv1 DUT and verify DP alternate mode can be reliably entered Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I70e2f360a9a45eee85ed555cb0165937c01a661a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3016407 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* chgstv2: Avoid force shutdown if chipset is shutting downDaisuke Nojiri2021-07-021-0/+16
| | | | | | | | | | | | | | | | Currently, EC forces the system to shut down even if the chipset is about to shut down. This patch makes EC wait for 1 second before it triggers a force shutdown if the chipset is shutting down. BUG=b:192463842 BRANCH=None TEST=buildall TEST=Verify Guybrush settles into S5 when it shuts down for low battery. Change-Id: Ic0bb3f17ac251d71907b282ae35279472077d576 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3000851
* cbi: Separate CBI EEPROM driver from CBI protocolPhilip Chen2021-06-291-1/+1
| | | | | | | | | | | | | | | | | Factor out the physical storage driver (cbi_eeprom.c) from the CBI data/protocol layer (cbi.c), setting up the groundwork to support more options of CBI sources. BRANCH=None BUG=b:186264627 TEST=make buildall -j Change-Id: Ic30a6f789970dd6723cf70d4e852ddb7161f796f Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2965848 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
* chgstv2: Add unit test for battery sustainerDaisuke Nojiri2021-06-281-1/+81
| | | | | | | | | | | | | This patch adds a unit test for the battery sustainer. BUG=b:188457962 BRANCH=None TEST=make run-sbs_charging_v2 Change-Id: Ica227cf4ee3f71a746150fb6a5f4e40ab8ca0720 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2987734 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* zephyr: update snprintf signature to be compatible with zephyr 2.6Yuval Peress2021-06-181-7/+3
| | | | | | | | | | | | | | | | Also update the tests for printf since the documentation makes no guarantee about negative size values. BRANCH=none BUG=b:190731415 TEST=build brya TEST=make run-printf Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I5e773362f1f30a1beb95284e589e49db3a1d8800 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2970989 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* run_device_tests: Use 'fw_wp_state' to control write protect statePatryk Duda2021-06-171-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | In hdctools/servo/data/servo_micro.xml 'fw_wp_en' control is described as "Enables forwarding of write-protect gpio. Must assert this and set fw_wp_vref prior to changing fw_wp.". It means that it needs to be enabled, but write protect state is controlled by 'fw_wp'. There is also 'fw_wp_state' control which is convenient wrapper for this. It sets 'fw_wp_en', 'fw_wp_vref' and 'fw_wp'. BUG=b:170432597 BRANCH=none TEST=Connect icetower using microservo. sudo servod --board icetower ./test/run_device_tests.py --board dartmonkey --test flash_write_protect Make sure that test is passed and HOST MCU WP diode glows during test. Don't use 'dut-control' to set write protect state. Signed-off-by: Patryk Duda <pdk@semihalf.com> Cq-Depend: chromium:2928423 Change-Id: Ia6164e877549956e8efb7fb5cd47d8c0d5ce2872 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2929119 Reviewed-by: Craig Hesling <hesling@chromium.org>
* util: Add function to convert binary first base3 numberWai-Hong Tam2021-06-161-0/+25
| | | | | | | | | | | | | | | | | | | | | | Add an util function to convert a ternary bit array (each element is either 0, 1, or 2) to a non-standard ternary number system where the first 2^n natural numbers are represented as they would be in a binary system (without any Z digits) and the following 3^n-2^n numbers use the remaining ternary representations in the normal ternary system order (skipping the values that were already used up). This function is useful for converting BOARd ID, which is initially used a binary and later decided to switch to tri-state after some revisions have already been built. BRANCH=Trogdor BUG=b:190250108 TEST=make runhosttests Change-Id: I853a04f3b28eb54c61855251dc5232c7e6994fef Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2964389 Reviewed-by: Julius Werner <jwerner@chromium.org>
* include/flash: rename the APIsTim Lin2021-06-093-10/+11
| | | | | | | | | | | | | | | | The names conflict when enabling both Zephyr's flash driver and CONFIG_FLASH_CROS option. Rename all the APIs in include/flash.h BUG=b:187192628 BRANCH=none TEST=make buildall -j4 Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com> Change-Id: If1fd0ea28fa9f5cec1c1daa8f72f63eb7a0e6500 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2931749 Commit-Queue: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* tcpmv2: Don't enable USB mode until PD state resolvedKeith Short2021-06-031-0/+5
| | | | | | | | | | | | | | | | | | | | | | Don't enable USB superspeed signals until the PD capability is known. This fixes an issue where platforms that enable the virtual USB mux violate the tSenderResponse timeout when the attached SRC sends the Source Capabilities message. BUG=b:187796705 BRANCH=none TEST=Volteer - connect PD charger, obsserve no hard reset TEST=Connect non-PD USB device, verify USB mode is enabled TEST=Connect USB+DP monitor, verify DP mode entry and USB mode enabled TEST=Connect USB4 dock, verify USB4 entry TEST=faft_pd test suite passes on Voxel Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I4be08874178d1e225cf41939b9626a81b0da0524 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2895424 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Tested-by: caveh jalali <caveh@chromium.org>
* Test: Add TC unit test for source disconnect detectionDiana Z2021-06-031-1/+73
| | | | | | | | | | | | | | Add a TC layer test for source disconnect, and also add some infrastructure to detect the test board's Vbus output. BRANCH=None BUG=b:153071799 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I72f2553d59b939bf236e0ae3ea6248df899ef4ca Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2921283 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* PE Test: Add unit test for PR swap interruption during power transitionDiana Z2021-05-171-0/+62
| | | | | | | | | | | | | | | | | When a non-interruptible AMS is interrupted during power transition, send a hard reset. Attempting a soft reset here will result in a bad connection state since Vbus is currently discharging and the soft reset process can't complete without Vbus presence. Add a unit test to enforce this. BRANCH=None BUG=b:184764468 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ifa20a7cea2c2c3a52e4ba4e88712c262c7c18967 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2897128 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: TD.PD.VNDI3.E3 VDM Identity Unit TestDiana Z2021-05-144-0/+121
| | | | | | | | | | | | | | | | Adds a unit test for TD.PD.VNDI3.E3 VDM Identity. Note that this currently only covers our default case of having no information to discover. There are additional items to verify if we expand the unit tests to have VDM information. BRANCH=None BUG=b:181194535 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I26b517f268eb9133fdd565783d44bbef2336048c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2893486 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* stm32: Add helper function for H7 flash ctrl regsJosie Nordrum2021-05-111-7/+2
| | | | | | | | | | | | | | | | | | | Add helper function definitions for H7 to API added in chromium:2220735. This should enable flash_physical test to run on Dartmonkey. Refactor code to pull flash registers function declarations from flash-reg.h instead of flash-f.h BRANCH=None BUG=b:157692395 TEST=On dartmonkey ./test/run_device_tests.py -t flash_physical => pass Signed-off-by: Josie Nordrum <josienordrum@google.com> Change-Id: I76846938748cbe77d534915856af0ebb7211d247 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2576799 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* fingerprint: Add test that reads hwidKevin Shelton2021-05-084-0/+39
| | | | | | | | | | | | | | | | | | | | | BUG=b:157576189 BRANCH=none TEST=make buildall -j, Using dragonclaw v0.2 and servo_micro: ./test/run_device_test.py -t fpsensor_hw --flasher=servo_micro, Using icetower and servo_micro: ./test/run_device_test.py -t fpsensor_wh --flasher=servo_micro --board dartmonkey; note: the testrunner hung after printing Test "fpsensor_hw": PASSED, but this hang seems unrelated Cq-Depend: chromium:2872432 Change-Id: I2a3b31776cd40d7f0b422f4845869953b8f07249 Signed-off-by: Kevin Shelton <kmshelton@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2314101 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* fingerprint: Support flash_ec in dev test runnerKevin Shelton2021-05-071-6/+22
| | | | | | | | | | | | | | | | | | | BRANCH=none BUG=b:151105339 TEST=with a dragonclaw rev 0.2: ./test/run_device_tests.py --flasher=servo_micro (flash_write_protect failed and the test runner hung after printing the test status, but this seems unrelated; all of the other tests looked to pass), ./test/run_device_tests.py and ./test/run_device_tests.py --flasher=jtrace (both get as far as executing flash_jlink.py, so the argument logic should be ok). Signed-off-by: Kevin Shelton <kmshelton@chromium.org> Change-Id: I0d41fb2fa4170292dd5a1212c601cf059ce2ee7b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2872432 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Commit-Queue: Tom Hughes <tomhughes@chromium.org>
* run_device_tests: remove -n flag from dut-control cmdJosie Nordrum2021-05-051-10/+7
| | | | | | | | | | | | | | | | | | | Removed the servo board name flag from dut-control command in run_device_tests.py. This flag is needed when there are many servos connected with servods running. Grepped platform/ec directory to remove all uses of this flag. BRANCH=None BUG=None TEST=ran AES test on dartmonkey with servo micro and jlink attached ./test/run_device_tests.py -b dartmonkey -t aes Signed-off-by: Josie Nordrum <JosieNordrum@google.com> Change-Id: I97bf3cd4c524a2b5fb292d255cde57a8b65fcdc4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2689320 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Commit-Queue: Josie Nordrum <josienordrum@google.com> Tested-by: Josie Nordrum <josienordrum@google.com>
* test: motionsense fifo: Fix time unitsYuval Peress2021-05-051-19/+19
| | | | | | | | | | | | | Convert time units in the test from ns to us BRANCH=none BUG=none TEST=make run-motion_sense_fifo Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I345ce43945d2bcd743347296430d76c2992a953a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2871056 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* common: motionsense fifo: Reset the initialized bits after commitYuval Peress2021-05-041-2/+7
| | | | | | | | | | | | | | | | | | | | | Previously once we had one sample from a sensor, we considered the fifo initialized. Meaning we would use our computed next timestamp to spread the timestamps. This was causing issues with some devices that ended up causing the timestamps to run ahead. Reset next_timestamp_initialized back to 0 after each commit. This will allow repeated timestamps but only if a driver stages/commits the same timestamp twice. Staging the same timestamp with only a single commit will still work as before (which is the expected path). BRANCH=none BUG=b:168335284 TEST=make run-motion_sense_fifo Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: Ib7c566f69d7c1e4e898050b67105555dd05376e5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2871055 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* compile_time_macros: Make _IS_ARRAY work with C++Tom Hughes2021-05-031-0/+13
| | | | | | | | | | | BRANCH=none BUG=b:144959033 TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I199f05eabad1182ca2da4489361426d04da06691 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2864513 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>