summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* body_detection: Remove get_resolutionGwendal Grignou2023-01-112-13/+2
| | | | | | | | | | | | | | | | | EC accelerometer drivers already pad data from sensors when resolution is less than 16 bits. No more resolution processing is needed when measuring body activity. BUG=b:262680246 BRANCH=none TEST=Unit test. Change-Id: Iff7df3915e855e25abc287a3c2caa477fd678f27 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4148783 Reviewed-by: Diana Z <dzigterman@chromium.org> Tested-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* test: Disable ASAN for 2 functionsJeremy Bettis2023-01-102-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | These two functions return a pointer to memory on the stack, which is very naughty and ASAN catches that. However, this is intended to see if the compiler optimizes out "unnecessary" writes to data that will "clearly" never be used again, since it's on the stack. Disable ASAN on these functions to prevent the compiler from being too smart. BRANCH=None BUG=b:264432260 TEST=make clobber -j$(nproc) && \ make runtests -j$(nproc) && \ make -j$(nproc) tests-bloonchipper tests-dartmonkey && \ make clobber -j$(nproc) && \ make -j$(nproc) TEST_ASAN=y runtests && \ echo SUCCESS Change-Id: If1ca3a6c97f34021b99dd246858ac3a3be7692a8 Signed-off-by: Jeremy Bettis <jbettis@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4136969 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org>
* run_device_tests.py: Handle UnicodeDecodeErrorAndrea Grandi2023-01-101-2/+4
| | | | | | | | | | | | | | | | | | In some tests, the FPMCU ouputs log messages that are causing UnicodeDecodeError exceptions because they cannot be decoded. Instead of crashing the test, handle these exception more gracefully by printing the FPMCU log as-is. BUG=b:264674276 TEST=test/run_device_tests.py -b bloonchipper -t abort BRANCH=none Change-Id: I7b8bbc5da650a48b8e206dc72dd9756659af0f3c Signed-off-by: Andrea Grandi <agrandi@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4149567 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* chgstv2: optimization battery protection for low voltageTang Qijun2023-01-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Deep_charge_battery needs to precharge first, and then enter the idle or charge state. Because before entering deep_charge_battery, the curr.state state may be the idle state, which may cause no precharge process. Therefore, add a flag to curr.batt.flags for record whether the precharge process has been performed. BRANCH=trogdor BUG=b:263921114 TEST=After the battery is discharged below voltage_min, the charging process enters deep_charge_battery and precharges first, and when the battery voltage is greater than voltage_min, it enters the charge state and charges normally. TEST=run-battery_get_params_smart Change-Id: I3a353bbcb4149b873176006bc009fbd3e8824aab Signed-off-by: Tang Qijun <qijun.tang@ecs.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4125706 Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Bob Moragues <moragues@chromium.org>
* SBS: Make battery_get_params clear flags selectivelyDaisuke Nojiri2023-01-101-0/+10
| | | | | | | | | | | | | | | | | | | | | | | Currently, battery_get_params clear all flags in batt.flags. This patch makes the function clear only the flags which are explicitly set or unset by battery_get_params. With this change, the charger task can add a flag to batt.flags. There isn't yet functionality change by this patch. BUG=b:263921114 BRANCH=None TEST=run-battery_get_params_smart run-sbs_charging_v2 TEST=./twister -i --toolchain host -s \ external/platform/ec/zephyr/test/drivers/drivers.default Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I5708ab6de81bc0a7c28961b13960fd89460b2e1c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4136966 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Bob Moragues <moragues@chromium.org>
* run_device_test: Fix implicit concat warningBobby Casey2023-01-091-1/+1
| | | | | | | | | | | | BUG=none BRANCH=none TEST=none Signed-off-by: Bobby Casey <bobbycasey@google.com> Change-Id: Iee67a31886a5cd7532acc01f684fbdd4d5cd7b76 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4121373 Reviewed-by: Andrea Grandi <agrandi@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* SBS: Add more unit tests for battery_get_paramsDaisuke Nojiri2023-01-091-6/+155
| | | | | | | | | | | | | | | | | Currently, we test only BATT_FLAG_RESPONSIVE and BAD_ANY. This patch adds test for the other flags. It also explicitly tests flag transitions (0 -> 1 and 1 -> 0), and reading voltages and currents. BUG=None BRANCH=None TEST=run-battery_get_params_smart Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Ia83d782c427aff1e12b71e0f1569e1e577648671 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4137167 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* run_device_tests.py: Add option to control private testsAndrea Grandi2023-01-071-7/+24
| | | | | | | | | | | | | | | | | Add new command line argument to control whether private tests are executed or not. BUG=b:263297326 TEST=test/run_device_test.py --with_private=only TEST=test/run_device_test.py --with_private=yes TEST=test/run_device_test.py --with_private=no BRANCH=none Change-Id: I9f80dcfd9e69b59407f7c8d2fb2ecb31a4bb60b1 Signed-off-by: Andrea Grandi <agrandi@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4119424 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* test: Disable always_memset test with ASANJeremy Bettis2023-01-061-0/+3
| | | | | | | | | | | | | | | | | always_memset fails when run with ASAN. Disable it for now to let the CQ run ASAN tests correctly. BRANCH=None BUG=b:264432260,b:257393779 TEST=make TEST_ASAN=y runtests Change-Id: Ie3986cf631014f097ce27ab97af55b1bd78e776b Signed-off-by: Jeremy Bettis <jbettis@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4136959 Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Tested-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* common: Add WRITE_MASK macroDaisuke Nojiri2023-01-051-0/+28
| | | | | | | | | | | | | | | WRITE_MASK(v,m,s) sets masks <m> for <v> if <s> is true or clears masks if <s> is false. BUG=None BRANCH=None TEST=run-compile_time_macros Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I9dd541c37b0be0528ab66e33ddcf152f7323034a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4136965 Reviewed-by: Keith Short <keithshort@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* flash: Introduce function which provides number of flash banksPatryk Duda2023-01-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In CrosEC, PHYSICAL_BANKS contains information how many banks the flash has. If all banks have the same size the value is a result of dividing flash size by bank size. If banks have different sizes, we define it as CONFIG_FLASH_MULTIPLE_REGION alias. When running Zephyr, these information are available through flash pages API. In CrosEC, newly introduced crec_flash_total_banks() function returns PHYSICAL_BANKS. Next commit will introduce the function counterpart in Zephyr EC build. BUG=b:239712345 BRANCH=none TEST=make buildall -j TEST=./test/run_device_tests.py --board bloonchipper \ --tests flash_physical TEST=./test/run_device_tests.py --board dartmonkey \ --tests flash_physical TEST=Compile bloonchipper firmware and flash it on dragonclaw board. Run 'flashinfo' command. Make sure that there are 12 sectors under 'Protected now:' line. Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I797b7ca60047c3c1549c95e8515888f56b0059e8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4111601 Tested-by: Patryk Duda <patrykd@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Patryk Duda <patrykd@google.com>
* tree: Replace "unsigned" with "unsigned int"Andrea Grandi2023-01-041-1/+1
| | | | | | | | | | | | | | | | | Fix checkpatch error: > Prefer 'unsigned int' to bare use of 'unsigned' BUG=b:262047616 TEST=./util/compare_build.sh -b all -j 120 => MATCH BRANCH=none Change-Id: Ibf82332a1e1ea0a0a03d3993336e24883e495e05 Signed-off-by: Andrea Grandi <agrandi@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4126483 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* run_device_tests.py: Improve logs readabilityAndrea Grandi2023-01-031-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | The output logs from the FPMCU are not decoded and can be hard to read. Improve readability by decoding escape characters (e.g. \n) and by reducing the size of the log lines header. Before: DEBUG:root:b'Running test_num_iterations...\r\n' DEBUG:root:b'Pass: num_calls == 5\r\n' After: DEBUG:Running test_num_iterations... DEBUG:Pass: num_calls == 5 BUG=b:263804978 TEST=test/run_device_tests.py -b bloonchipper -t benchmark BRANCH=none Change-Id: Ie0332cd100d83e8daaf0ee4b41997b97242c58a6 Signed-off-by: Andrea Grandi <agrandi@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4126660 Reviewed-by: Josie Nordrum <josienordrum@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* test: Add function to compare BenchmarkResultsAndrea Grandi2023-01-031-0/+23
| | | | | | | | | | | | | | BUG=b:263804978 TEST=test/run_device_tests.py -b bloonchipper -t benchmark TEST=make run-benchmark BRANCH=none Change-Id: I042aa1aee854201a4e00a0939f2cb924af0e63f1 Signed-off-by: Andrea Grandi <agrandi@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4126544 Reviewed-by: Josie Nordrum <josienordrum@google.com> Reviewed-by: Bobby Casey <bobbycasey@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* test: Add more tests for benchmark.hAndrea Grandi2023-01-031-0/+41
| | | | | | | | | | | | | | | | | | | Add more test coverage for scenarios where we are observing issues while running benchmarks. This helps excluding an issue with the benchmark library itself. BUG=b:246366702 BRANCH=none TEST=test/run_device_tests.py -b bloonchipper -t benchmark TEST=test/run_device_tests.py -b dartmonkey -t benchmark TEST=make run-benchmark Change-Id: Ibfa41d0fcb8af1f672b50d456d7954f281b919fe Signed-off-by: Andrea Grandi <agrandi@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4121097 Reviewed-by: Josie Nordrum <josienordrum@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Bobby Casey <bobbycasey@google.com>
* test: Add test for std::chrono::system_clockTom Hughes2022-12-154-0/+47
| | | | | | | | | | | | | | BRANCH=none BUG=b:234181908, b:254530679 TEST=./test/run_device_tests.py --board bloonchipper -t libcxx TEST=./test/run_device_tests.py --board dartmonkey -t libcxx Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I86753187a5d3e7e363fd1a8d9f89e61b42cd8521 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4062465 Reviewed-by: Andrea Grandi <agrandi@google.com> Reviewed-by: Bobby Casey <bobbycasey@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* test: Add gettimeofday testTom Hughes2022-12-154-0/+111
| | | | | | | | | | | | | BRANCH=none BUG=b:234181908, b:254530679 TEST=make run-gettimeofday -j Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ia18214cb436ff058a71e037584a3c7663d63eef0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4062464 Reviewed-by: Andrea Grandi <agrandi@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Bobby Casey <bobbycasey@google.com>
* test: Increase tolerance of timer testAndrea Grandi2022-12-131-1/+1
| | | | | | | | | | | | | | | | | | | Timer test is flaky on hardware so we increase the tolerance to avoid false errors. This is okay since the primary goal of the test is to verify we can build timer functions on all platforms, not verify their accuracy. BUG=b:260723169 TEST=test/run_device_tests.py -b bloonchipper -t timer TEST=test/run_device_tests.py -b dartmonkey -t timer TEST=make run-timer BRANCH=none Signed-off-by: Andrea Grandi <agrandi@google.com> Change-Id: I0442fe212ce305b04ad89ba67e227abd6bcc7fa1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4093614 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* fan: Rewrite and test the most common custom fan_percent_to_rpm.Richard Yeh2022-12-131-0/+112
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | temp_ratio_to_rpm_hysteresis uses a sorted fan_table containing a mapping of temp_ratio (percent, 0-100) to fan rpm. This clarifies the relationship of temperature to fan speed, while reducing the number of static variables. The existing temp_ratio expressing the percentage of cooling needed (temperature from temp_fan_off to temp_fan_max) suggests the possibility that a proportional-integral-derivative (PID) feedback controller might have been considered; but the default implementation is purely linear (mapping to fan speed from min to max) and this stepwise one just enables hysteresis --- different speeds when the board is warming up than when cooling down. The hysteresis attempts to avoid oscillations in temperature and fan speed. This refactoring is in preparation for reusing this implementation for {ambassador, genesis, moonbuggy, scout}. {kalista, berknip, chronicler, dewatt, endeavour, ezkinil, fizz} define CONFIG_FAN_RPM_CUSTOM and use this or nearly this implementation of a fan_percent_to_rpm with hysteresis. {chronicler} also performs boxcar smoothing of the input. {osiris}, which has two fans, and {jinlon, redrix, and other boards with multiple sensors}, use a similar but not exactly the same implementation, and would need additional abstraction. See: https://source.chromium.org/search?q=f:ec%2Fb%20fan_step%20-f:board.c BRANCH=refactor-fan-percent-to-rpm BUG=b:252966838,b:191187610,chromium:1383859 TEST=make -j run-fan && make -j buildall && make -j runhosttests Signed-off-by: Richard Yeh <rcy@google.com> Change-Id: I50ad4d78ac1145f92573a417646c1f57b8945463 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4021951 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* test: Add a test for global object initializationTom Hughes2022-12-104-0/+61
| | | | | | | | | | | | | | BRANCH=none BUG=b:261636413 TEST=./test/run_device_tests.py -b dartmonkey -t global_initialization => Fails without https://crrev.com/c/4081571 Cq-Depend: chromium:4081571 Change-Id: Ic92a5e92538c22d81d769d0f26be65abe0905656 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4083114 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Andrea Grandi <agrandi@google.com>
* include/util: Remove swap macroTom Hughes2022-12-091-19/+0
| | | | | | | | | | | | | | | The swap macro is not used anywhere and it conflicts with std::swap in C++. BRANCH=none BUG=b:260234709 TEST=make buildall Change-Id: Ic2166265ed98c9c72b2c8d4f04a8209a788f9ee3 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4089950 Reviewed-by: Andrea Grandi <agrandi@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* test: Add timer testAndrea Grandi2022-12-074-0/+54
| | | | | | | | | | | | | | | | | Verify the existing usleep() function in preparation for moving its implementation into the builtin folder. BUG=b:260723169 TEST=test/run_device_tests.py -b bloonchipper -t timer TEST=test/run_device_tests.py -b dartmonkey -t timer TEST=make run-timer BRANCH=none Change-Id: I532fa5ac7abf7b16b4d1a86ea5e961f08fb2f1b7 Signed-off-by: Andrea Grandi <agrandi@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4068487 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* test: Test initialization of static std::vectorAndrea Grandi2022-12-071-0/+15
| | | | | | | | | | | | | | BUG=b:243964606 TEST=util/run_device_tests.py --board=bloonchipper \ --tests=std_vector TEST=make run-std_vector BRANCH=none Change-Id: Iaedfc90694c1db8ec5ed4f7b824254e09a693d1f Signed-off-by: Andrea Grandi <agrandi@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4083112 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* test: Test stack initialization of std::vectorAndrea Grandi2022-12-071-0/+15
| | | | | | | | | | | | | | BUG=b:243964606 TEST=util/run_device_tests.py --board=bloonchipper \ --tests=std_vector TEST=make run-std_vector BRANCH=none Change-Id: Ib260c2fef75c0bdc20f6714f99aa066456b36ec6 Signed-off-by: Andrea Grandi <agrandi@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4083111 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* TCPMv2: Pass NAK VDM headers to DPMDiana Z2022-12-061-1/+1
| | | | | | | | | | | | | | | Pass the VDM headers for NAK messages to the DPM, in order for them to be available to pass on to the AP. BRANCH=None BUG=b:208884535 TEST=./twister -T ./zephyr/test Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I75cedee472ac2232f49df7b2f91b63f204a527cb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3990994 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* test: Sort header filesJeremy Bettis2022-11-3077-139/+149
| | | | | | | | | | | | | | | | | | | | | Sort all includes in test with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j72 buildall_only runtests TEST=zmake compare-builds -a Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: Iae52f99a3a8b5623c1c92722c325ca92816fa856 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4052760 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Aaron Massey <aaronmassey@google.com> Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org>
* Rename CONFIG_CHARGER_INPUT_CURRENT to _CHARGER_DEFAULT_CURRENT_LIMITPeter Marheine2022-11-291-2/+2
| | | | | | | | | | | | | | | | | | | "Default input current" is not a very clear name, so rename this option to better express its use as a default value that is set in the charger. This is made possible by splitting other uses into CHARGER_MIN_INPUT_CURRENT_LIMIT, making the only use for CHARGER_INPUT_CURRENT be as a default. BUG=b:163093572 TEST=make buildall; zmake build -a BRANCH=none LOW_COVERAGE_REASON=isl9241 and sm5803 currently lack emulators Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: Ia9c1df9061825b15477466e85343afeb2a371288 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4025404 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* test: Fix TypeError in run_device_tests.pyAndrea Grandi2022-11-291-1/+1
| | | | | | | | | | | | BUG=b:260607990 TEST=run_device_tests.py --help BRANCH=none Signed-off-by: Andrea Grandi <agrandi@google.com> Change-Id: I51166b553497a20e2ba8743d2da682768a3d2cd6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4062572 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* i8042: Send command response from priority queueDaisuke Nojiri2022-11-281-48/+53
| | | | | | | | | | | | | | | | | | | | | This patch also makes KEYPROTO task hold sending a scancode when it receives SETLEDS command until it returns ACK to the second byte (and leaves STATE_ATKBD_SETLEDS). This patch also removes and repositions some kblog_put calls because checking OBF and writing to DBBOUT must be done as atomically as possible to minimize the race condition. BUG=b:237981131,b:247795316 BRANCH=None TEST=Taniks. Press search+alt then 'k' 100 times. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I7ccfae99b3657ead5fa9e3c337db623aaffdb0bc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3901253 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* Add default implementation of board_set_charge_limitPeter Marheine2022-11-242-4/+4
| | | | | | | | | | | | | | | | | | | The majority of boards simply call charge_set_input_current_limit() from board_set_charge_limit() now that the minimum current limit and derating are available as config options. Make this the default behavior of the charge manager, overridable by boards as needed. Boards that have existing custom behavior retain it, with their versions of board_set_charge_limit() marked as __override as necessary. BUG=b:163093572 TEST=make buildall; zmake build -a BRANCH=none Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: I72475ca0e8381596cafbcda4b042c7f884ae0432 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4022857 Reviewed-by: Keith Short <keithshort@chromium.org>
* run_device_tests.py: Resolve error in type hintBobby Casey2022-11-231-2/+2
| | | | | | | | | | | | | | | Resolve the error in find_section_offset's type hint, it should be Tuple(int, int) rather than (int, int) BUG=b:250028913 TEST=./test/run_device_tests.py -b bloonchipper --flasher=servo_micro BRANCH=none Signed-off-by: Bobby Casey <bobbycasey@google.com> Change-Id: I88e86b14efb0fc6f7a39d0c19c83a44d8eb0b975 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3931127 Reviewed-by: Andrea Grandi <agrandi@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* test: Add AES-GCM decrypt benchmarkAndrea Grandi2022-11-231-4/+17
| | | | | | | | | | | | | BUG=b:235476822 TEST=test/run_device_tests.py -b bloonchipper -t aes TEST=make run-aes BRANCH=none Signed-off-by: Andrea Grandi <agrandi@google.com> Change-Id: Ic117d7a137065729e284b3c435062d4ce473e8d0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4032755 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Bobby Casey <bobbycasey@google.com>
* test: Use benchmark library in aes testAndrea Grandi2022-11-231-13/+9
| | | | | | | | | | | | | BUG=b:235476822 TEST=test/run_device_tests.py -b bloonchipper -t aes TEST=make run-aes BRANCH=none Signed-off-by: Andrea Grandi <agrandi@google.com> Change-Id: Iae7e144d39ad34571a8f0a4f328feb42d08b09c3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4032315 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Bobby Casey <bobbycasey@google.com>
* test: Convert AES test to C++Andrea Grandi2022-11-171-5/+9
| | | | | | | | | | | | | | | | Convert the AES test file from C to C++ to be able to use the benchmark library later on. BUG=b:235476822 TEST=test/run_device_tests.py -b bloonchipper -t aes TEST=make run-aes BRANCH=none Signed-off-by: Andrea Grandi <agrandi@google.com> Change-Id: I5f0dd0a5f256e75b8688b28cc37c56b2f98039d0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4026545 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* cortex-m mpu: illegal shift fixstabilize-15245.B-mainBoris Mittelberg2022-11-151-0/+23
| | | | | | | | | | | | | | | | Shifting left by 32 is undefined behavior. An AND operation with mask of 0xffffffff is meaningless, so just avoid it. BUG=b:64477774 BRANCH=none TEST=none Signed-off-by: Boris Mittelberg <bmbm@google.com> Change-Id: Ibcb3359f453345caee01936c074a9c0ae5aff7dc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4021135 Tested-by: Peter Marheine <pmarheine@chromium.org> Reviewed-by: Peter Marheine <pmarheine@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* test: Add rng_benchmark testAndrea Grandi2022-11-114-0/+92
| | | | | | | | | | | | | | BRANCH=none BUG=b:246836252 TEST=./test/run_device_tests.py --board bloonchipper -t rng_benchmark TEST=./test/run_device_tests.py --board dartmonkey -t rng_benchmark Signed-off-by: Andrea Grandi <agrandi@google.com> Change-Id: Ib1a2a4b0fc8e3d55022e94727417c38e5e94359b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4019773 Reviewed-by: Bobby Casey <bobbycasey@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* test/kb_scan: Add 1ms delay at the beginning of each test stepRob Barnes2022-11-091-0/+3
| | | | | | | | | | | | | | | | | | | | | There's a race condition between this test and system init. Specifically, calling weak functions during system init can cause kb_scan test to fail. I don't fully understand the source of the race condition, but adding just a 1ms delay at the beginning of each test step resolves the issue. BUG=b:258231435 BRANCH=None TEST=kb_scan and kb_scan_strict pass on host Change-Id: I624d4f62533d25fb128ab6f39408fd643c2fa869 Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4012962 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* Makefile.toolchain: Enable -ftrapv for fingerprint boardsTom Hughes2022-11-094-0/+277
| | | | | | | | | | | | | | | | | | | | | | The "-ftrapv" flag generates an exception for *signed* integer overflow: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html. This commit adds a unit test to verify the behavior. For now this is clang-only, since the gcc toolchain is missing the "trapping arithmetic functions": __addvsi3, __subvsi3, etc. https://gcc.gnu.org/onlinedocs/gccint/Integer-library-routines.html BRANCH=none BUG=b:144957935, b:258074414 TEST=./test/run_device_tests.py --board dartmonkey -t ftrapv TEST=./test/run_device_tests.py --board bloonchipper -t ftrapv Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I2235c2d289bab2a17d7915978c17aaa07302403d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4007158 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Andrea Grandi <agrandi@google.com>
* test: Add libc_printf testTom Hughes2022-11-044-0/+45
| | | | | | | | | | | | | BRANCH=none BUG=b:234181908, b:254530679 TEST=./test/run_device_tests.py --board dartmonkey -t libc_printf Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I5ac9838dd59cb048325a27cc28d7859da040b52d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3997616 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Bobby Casey <bobbycasey@google.com> Reviewed-by: Andrea Grandi <agrandi@google.com>
* tcpmv2: dpm: Convert dpm_run to a 1st class SM frameworkScott Collyer2022-11-032-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL adds a type-c state machine framework for the Device Policy Manager (dpm) layer of USB-PD. This CL is focused just on adding the state machine policy and minimizing any changes in the existing DPM support functions. Because the DPM is no longer being called directly from the PE layer, an interlock mechanism is used to control when the DPM state machine will take any actions. This CL also renames include/usb_pd_dpm.h to include/usb_pd_dpm_sm.h to be consistent with include file naming for the other TCPMv2 layer state machine include files. BUG=b:194504052 BRANCH=none TEST=Verified that mode entry/exit is successful for DP, TBT, and USB4 on Voxel. ectool typeccontrol <port> 0 -> exit mode ectool typeccontrol <port> 2 0 -> DP ectool typeccontrol <port> 2 1 -> TBT ectool typeccontrol <port> 2 2 -> USB4 Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I196d342b031b96874d354610182be79eac613d00 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3922467 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Scott Collyer <scollyer@chromium.org>
* test: Add benchmark library (C++)Andrea Grandi2022-11-024-0/+110
| | | | | | | | | | | | | | | | | Add a benchmark library (benchmark.h) to measure the execution time of functions. It is written in C++ to simplify the interface. For example, it can be used to benchmark lambdas with captures. BUG=b:246366702 BRANCH=none TEST=test/run_device_tests.py -b bloonchipper -t benchmark TEST=make run-benchmark Signed-off-by: Andrea Grandi <agrandi@google.com> Change-Id: Ibed907609a27566e386c511153fcd2d819981356 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3971378 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* test/fpsensor_hw: Convert to C++Tom Hughes2022-11-011-1/+1
| | | | | | | | | | | | BRANCH=none BUG=b:243700149, b:234181908 TEST=./test/run_device_tests.py --board dartmonkey -t fpsensor_hw Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I2c32f2493abf60dea0de6c1a8671598f8b30034b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3860407 Reviewed-by: Bobby Casey <bobbycasey@google.com> Reviewed-by: Andrea Grandi <agrandi@google.com>
* test: sensor tests: Include what we needGwendal Grignou2022-10-281-1/+5
| | | | | | | | | | | | | | Do not include LID_ANGLE when the test is not exercising that code. Include math library whenever it is needed. BUG=None BRANCH=none TEST=make -j buildall passes. Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: I3e0fe478e7970155cc9d2b8cae590ae5ce7b4392 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3984437 Reviewed-by: Boris Mittelberg <bmbm@google.com>
* tcpmv2: expand alert storm count to 1800mike2022-10-281-1/+1
| | | | | | | | | | | | | | | | | | | Since anx3447 does not support the BIST function fully, tcpm need expand the alert storm to avoid generating watchdog. BUG=b:229812911 BRANCH=none TEST=Pass BIST test mode with ANX3447 on kingler, make run-usb_pd_int PASS Signed-off-by: mike <mike5@huaqin.corp-partner.google.com> Change-Id: I4b1ac6ca4b48a24967b6fffd2134ea24aede1a5f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3716411 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: wen zhang <zhangwen6@huaqin.corp-partner.google.com> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
* motion_sense: Trigger AP interrupt based on sensor timestampGwendal Grignou2022-10-281-0/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, interrupt trigering is based on the time when the motion sensor task is scheduled. If the task is delayed for processing a first sample but not a second one, the second sample will be delayed until the third sample arrive: / sensor interrupt / sensor interrupt / sensor int | / task scheduling| / task scheduling | / task +-delay-+----------------+-+--------------------+-+ <--------- 10 ms --------X------------ 10 ms -----> <------- < 10 ms ----> event delayed until the next sample. To address the issue: 1 - add more leeway to schedule the interrupt. Instead of 3us, allow to trigger an interrupt if the delta between samples is more than the expect delta minus 1ms. 2 - Use the sensor timestamp provided to the FIFO, keep sensor timestamp for every sensor. When the timestamp difference is larger than the requested rate, we schedule an interrupt. Fixes: 0c71c474869 ("motion sense: Calculate loop time based on sensor needs") BUG=b:242263033 BRANCH=none TEST=Ran "tast run localhost:22552 hardware.SensorIioserviceHard" Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: I9ccf08c1180820e699cf84069df3e4541768988d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3966709 Reviewed-by: Yuval Peress <peress@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* test: Check that std::vector memory is destroyedAndrea Grandi2022-10-241-0/+30
| | | | | | | | | | | | | | | Add test that creates a new vector after one has been destroyed. BUG=b:243964606 TEST=util/run_device_tests.py --board=dartmonkey \ --tests=std_vector TEST=make run-std_vector BRANCH=none Signed-off-by: Andrea Grandi <agrandi@google.com> Change-Id: Ia6a6c906deea2c75181e77bf2ee994e89c66c5fe Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3971020 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* test: Add basic test of std::vectorAndrea Grandi2022-10-214-0/+96
| | | | | | | | | | | | | | | | Verify that dynamic memory allocation works correctly. BUG=b:243964606 TEST=util/run_device_tests.py --board=dartmonkey \ --tests=std_vector TEST=make run-std_vector BRANCH=none Signed-off-by: Andrea Grandi <agrandi@google.com> Change-Id: Iae7ff1070786e3d5e3c8ba4dcddeeeb9979b0306 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3969861 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Bobby Casey <bobbycasey@google.com>
* test: Add panic testTom Hughes2022-10-185-0/+136
| | | | | | | | | | | | | | | | | | | | Add a test for ARM that verifies that exception_panic() correctly preserves the registers we expect it to. BRANCH=none BUG=b:172020503 TEST=./test/run_device_tests.py --board bloonchipper -t panic TEST=make BOARD=discovery-stm32f072 test-panic openocd -c "set BOARD discovery-stm32f072" \ -c "set BUILD_DIR build/discovery-stm32f072/panic" \ -f board/discovery-stm32f072/openocd-flash.cfg screen /dev/ttyUSB1 > runtest Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I592483c922652df8a4fb2b0a0a5fb57b1480b8b6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3288761 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* test: Add on-device exception testTom Hughes2022-10-144-0/+105
| | | | | | | | | | | BRANCH=none BUG=b:234181908 TEST=./test/run_device_tests.py --board bloonchipper -t exception Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I4d5651be6048af357b68956097deea255551a6db Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3932262 Reviewed-by: Andrea Grandi <agrandi@google.com>
* test: Add on-device abort() testTom Hughes2022-10-144-0/+92
| | | | | | | | | | | BRANCH=none BUG=b:234181908 TEST=./test/run_device_tests.py --board bloonchipper abort Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ic92cacdf018bbc8454ed4c7f72546a3ed4d7e4fe Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3933257 Reviewed-by: Andrea Grandi <agrandi@google.com>