summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* test/malloc: Add a test for double-free when using mallocstabilize-15415.B-mainTom Hughes2023-04-071-0/+25
| | | | | | | | | | | | | | | | | | BRANCH=none BUG=b:274737509 TEST=Add RUN_TEST(test_malloc_double_free) to run_test ./test/run_device_tests.py --board bloonchipper -t malloc => PASS TEST=Add RUN_TEST(test_malloc_double_free) to run_test ./test/run_device_tests.py --board dartmonkey -t malloc => PASS TEST=Add RUN_TEST(test_malloc_double_free) to run_test make run-malloc Change-Id: I1695d3b5cbf5d29bbaf35aaddcea76be51de53f7 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4406092 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* test: Add a test for malloc/freeTom Hughes2023-04-074-0/+106
| | | | | | | | | | | | | | | BRANCH=none BUG=b:274737509 TEST=./test/run_device_tests.py --board bloonchipper -t malloc => PASS TEST=./test/run_device_tests.py --board dartmonkey -t malloc => PASS TEST=make run-malloc Change-Id: Ida58335dcacbeefad56804246897810936c98546 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4390609 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* fpsensor: Rename fpsensor_detect functionsBobby Casey2023-04-061-1/+1
| | | | | | | | | | | | | | | | Rename get_fp_sensor_type and get_fp_sensor_spi_select to fpsensor_detect_get_type and fpsensor_detect_get_spi_select to be more consistent with other APIs BRANCH=none BUG=b:256674283 TEST=./util/compare_build.sh -b all -j 120 => MATCH Change-Id: Ie548ff5b33079cbc607cb9552efdfe9676da4c02 Signed-off-by: Bobby Casey <bobbycasey@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4283704 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* fp_sensor_mock: Rename fp_sensor_mockBobby Casey2023-04-061-1/+1
| | | | | | | | | | | | | | | | | Rename fp_sensor_mock files to fpsensor_mock to be consistent with other file names. This helps avoid issues with scripts using pattern matched filenames, such as util/migrated_files.sh. BRANCH=none BUG=none TEST=compare_build.sh -b fp => MATCH TEST=make BOARD=bloonchipper tests TEST=make BOARD=dartmonkey tests Change-Id: I6f7e213cbf72a59cfd5994c66dc7b93ea44c6505 Signed-off-by: Bobby Casey <bobbycasey@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4334695 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* test: Add unit tests for sbrkTom Hughes2023-04-044-0/+98
| | | | | | | | | | | | | | BRANCH=none BUG=b:234181908 TEST=./test/run_device_tests.py --board bloonchipper -t sbrk => PASS TEST=./test/run_device_tests.py --board dartmonkey -t sbrk => PASS Change-Id: I02d6fe269718f0f4f7f5d72e6a8f01bb4e6b4cfd Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4396773 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* Revert "test/fpsensor_hw: fpsensor_hw test compiles and runs with gtest"Aashish Sharma2023-03-252-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 050c151b39c9cad3bb487b9218a822bb8a50615a. Reason for revert: Causing CQ compilation failures Original change's description: > test/fpsensor_hw: fpsensor_hw test compiles and runs with gtest > > BRANCH=none > BUG=b:254530679 > TEST=make BOARD=bloonchipper test-fpsensor_hw -j > TEST=make BOARD=dartmonkey test-fpsensor_hw -j > > Cq-Depend: chromium:3994436, chrome-internal:5548068 > Signed-off-by: Tom Hughes <tomhughes@chromium.org> > Change-Id: I1908ea496cd69c7d0e0cd84a841bd4c1692a1bf2 > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3994291 > Reviewed-by: Firas Sammoura <fsammoura@google.com> > Reviewed-by: Andrea Grandi <agrandi@google.com> Bug: b:254530679,b:275142246 Change-Id: Iecf582a135487c794449a4f5f4422304003f1e84 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4369173 Auto-Submit: Aashish Sharma <shraash@google.com> Owners-Override: Aashish Sharma <shraash@google.com> Commit-Queue: Aashish Sharma <shraash@google.com> Tested-by: Aashish Sharma <shraash@google.com> Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
* test/fpsensor_hw: fpsensor_hw test compiles and runs with gtestTom Hughes2023-03-242-12/+6
| | | | | | | | | | | | | | BRANCH=none BUG=b:254530679 TEST=make BOARD=bloonchipper test-fpsensor_hw -j TEST=make BOARD=dartmonkey test-fpsensor_hw -j Cq-Depend: chromium:3994436, chrome-internal:5548068 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I1908ea496cd69c7d0e0cd84a841bd4c1692a1bf2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3994291 Reviewed-by: Firas Sammoura <fsammoura@google.com> Reviewed-by: Andrea Grandi <agrandi@google.com>
* test: Add a wrapper for googletestTom Hughes2023-03-241-0/+35
| | | | | | | | | | | | | | | | | | This wrapper makes it possible for unit tests that want to use googletest just need to include "ec_test.h". All googletest test cases will automatically be run. Failure/success is printed in the same format as traditional EC tests for compatibility. BRANCH=none BUG=b:254530679 TEST=make BOARD=bloonchipper test-fpsensor_hw -j TEST=make BOARD=dartmonkey test-fpsensor_hw -j Change-Id: I96bfd2067ad53412998184657b5a6cbb1e24126a Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4348158 Reviewed-by: Andrea Grandi <agrandi@google.com> Reviewed-by: Firas Sammoura <fsammoura@google.com>
* test/motion_lid: Integrate with tablet hall sensorGwendal Grignou2023-03-232-9/+91
| | | | | | | | | | | | | | | | | | Include GMR tablet sensor in testing to verify that they are not on the way to lid calculation. Check we enter/exit tablet mode on lid angle, check GMR does not send incorrect information, trigger uncessary tablet mode changes. BUG=b:267680317, b:270994196 BRANCH=trogdor, dedede, many more potentially. TEST=Check with 'make run-motion_lid' Change-Id: I96d5f386dd0a3e0c207485e58d5ccdbe2d1f025f Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4338480 Reviewed-by: Douglas Anderson <dianders@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* common/tablet: Allow getting out of tablet mode when sensors are brokenGwendal Grignou2023-03-236-2/+310
| | | | | | | | | | | | | | | | | | | | | When sensors stop working, at least one accelerometer, the EC can not calculate the lid angle anymore. Add hook to the lid opening event, to be able to get out out of tablet mode when lid close. Move scope of the variables that keep track of the lid angle deduced from the GMR sensors. BUG=b:267680317, b:270994196 BRANCH=trogdor, dedede, many more potentially. TEST=Added unit tests. Change-Id: Iaf7cc0d27fba32b3c8616a0674a47af815921ac4 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4338479 Reviewed-by: Douglas Anderson <dianders@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* tree: Run clang-format on C++ filesTom Hughes2023-03-162-2/+2
| | | | | | | | | | | BRANCH=none BUG=none TEST=CQ passes Change-Id: I4e359ebbfacfa10239e991ee89da82db5161ef20 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4338476 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* test/fpsensor_hw: Include config.h instead of board.hTom Hughes2023-03-151-2/+2
| | | | | | | | | | | | | | | | | | | | When running clang-format (which rearranged headers), the build for the fpsensor_hw started failing with "Include config.h instead of board.h": https://chromium.googlesource.com/chromiumos/platform/ec/+/3089e438e3a89aab1ca67c8488c6d7519f4ee630/include/config.h#5862 board.h shouldn't be included directly; instead we can just include config.h, which includes board.h. BRANCH=none BUG=none TEST=CQ passes Change-Id: Id9dc6374ccaa34ae45b184f62eded6c84eb20cba Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4342815 Reviewed-by: Firas Sammoura <fsammoura@google.com>
* crc16: Add CRC-16 utility functionsDerek Huang2023-03-081-0/+16
| | | | | | | | | | | | | | | | | crc-16 is required for CPS8200 firmware update to validate the correctness of the firmware after programming the firmware to CPS8200 flash. This patch add CRC-16 utility functions and the test. BUG=b:195708351 BRANCH=none TEST=make -j buildall; make run-crc Change-Id: I198993387833464e151acd19531e18c6d077b8f1 Signed-off-by: Derek Huang <derekhuang@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4269952 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* driver/fingerprint: Add _FPC suffix to FPC macrosBobby Casey2023-03-031-1/+1
| | | | | | | | | | | | | | | This commit is based on http://crrev.com/c/2727971, which was reverted in http://crrev.com/c/2810517 BRANCH=none BUG=b:264457390 TEST=test/run_device_tests.py -b bloonchipper TEST=test/run_device_tests.py -b dartmonkey Signed-off-by: Bobby Casey <bobbycasey@google.com> Change-Id: Ife7373d366228a7940b87b036be1bb7c2a1cf770 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4273187 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* chgstv2: Separate v0 and v1 param struct for EC_CMD_CHARGE_CURRENT_LIMITDaisuke Nojiri2023-03-031-1/+1
| | | | | | | | | | | | | | This CL separates param struct for v0 and v1 of EC_CMD_CHARGE_CURRENT_LIMIT. BUG=b:265372046 BRANCH=None TEST=buildall Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I836f15fade7f1660475af7ceeebadb9082b45e84 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4292617 Reviewed-by: caveh jalali <caveh@chromium.org>
* fpsensor: Rename fpsensor_private.h to fpsensor_utils.hBobby Casey2023-03-021-1/+1
| | | | | | | | | | | | | | | | Rename fpsensor_private.h as it does not contain any private interfaces and is included by non-private source files. BRANCH=none BUG=none TEST=make BOARD=bloonchipper TEST=make BOARD=dartmonkey TEST=make run-fpsensor_crypto Signed-off-by: Bobby Casey <bobbycasey@google.com> Change-Id: I4f9233c8c7b5ffdf84fdd0c11c3166dd65f4a913 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4273186 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* USB-PD: Print DPM state only if debug_level >= 2Daisuke Nojiri2023-03-021-0/+8
| | | | | | | | | | | | | | | | | | | | | | Printing DPM state names is not much useful unless you're debugging timing issues). Normally, it's mostly either in 'waiting' or 'ready'. This patch introduces dpm_debug_level and sets it to DEBUG_LEVEL_1 by default. It can be configured by CONFIG_USB_PD_DEBUG_LEVEL. This prevents the EC console from being flooded by DPM state names when a policy engine sends an EPR keep alive message. BUG=b:257320026 BRANCH=None TEST=On Agah, turn on/off DPM debug messages by the pd dump command. LOW_COVERAGE_REASON=code coverage falsely reporting no coverage for closing braces on if conditions Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I7da0c2fb775cd0978e08464c8923757094c12ca7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4289286 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPM: Divorce v1 and v2 alternate mode handlingDiana Z2023-02-231-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Retire the common DFP mode support to the TCPMv1 specific module from whence it came. Since TCPMv1 does not support TBT, all TBT functions can be removed from its copy. Move the DFP support for TCPMv2 to the DPM and its modules. Note that the reduced redundancy in tracking active alternate modes means that we can remove the majority of the "generic" mode handling. This results in approximately 1k additional free flash space for boards. For now, leave the svdm_dp_* interfaces in place as boards are using them as entry points to modify the DP mode sequencing. Also leave a stripped down version of pd_dfp_exit_mode() in place, though this would be worth consolidating to a new API in the future. BRANCH=None BUG=b:170372521,b:159856063 TEST=all unit tests passing, confirm display works on nipperkin (ECOS) and skyrim (zephyr) boards, USB4 and TBT regression tested on skolas LOW_COVERAGE_REASON=b/243151272 filed for improving TBT coverage, common/mock files no longer relevant Change-Id: Idbe59bc7c6a0ab6103e8fa158e69275a142f8a16 Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4211277 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* Add unit test for EC_CMD_CHARGE_CURRENT_LIMIT v1Daisuke Nojiri2023-02-191-27/+87
| | | | | | | | | | | | | | This patch add unit test for EC_CMD_CHARGE_CURRENT_LIMIT v1. BUG=b:265372046,b:269725114 BRANCH=None TEST=make run-sbs_charging_v2 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I1f1528f0017c30a1b24b1593b5355938d99ddd6e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4263562 Reviewed-by: Peter Marheine <pmarheine@chromium.org> Commit-Queue: Peter Marheine <pmarheine@chromium.org>
* i8042: return self-test status on resetBoris Mittelberg2023-02-171-3/+14
| | | | | | | | | | | | | | | | | As described in PS/2 keyboard protocol spec, the reset command 0xff is followed by diagnostic self-test, aka BAT. Along with the ACK for reset command EC must return BAT status. BRANCH=none BUG=b:134366527 TEST=buildall; make run-kb_8042; depthcharge screen on brya Change-Id: I5803d06b204d552c458ad443393f80072d41e40e Signed-off-by: Boris Mittelberg <bmbm@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4252007 Reviewed-by: Raul Rangel <rrangel@chromium.org> Reviewed-by: CoolStar <coolstarorganization@gmail.com> Tested-by: Raul Rangel <rrangel@chromium.org>
* TCPMv2: Remove PE_FLAGS_VDM_SETUP_DONEAbe Levkoy2023-02-131-3/+36
| | | | | | | | | | | | | | Remove a PE flag that is redundant with the discovery state. Update the discovery state where appropriate to keep it internally consistent. BUG=b:189353401 TEST=voxel: Attach TBT4 hub; verify discovery sequence BRANCH=none Change-Id: I8ea870271ee95eb1dd4633370f7e39ca789f1328 Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4237156 Reviewed-by: Diana Z <dzigterman@chromium.org>
* run_device_tests: Temporarily ignore long line errorsBobby Casey2023-02-091-0/+2
| | | | | | | | | | | | | | run_device_tests has gotten long enough to report an error about lines being too long. Ignore this error until it is refactored. BUG=none BRANCH=none TEST=none Change-Id: I461de971f4ce0b9912895511c459c8f54a62db6d Signed-off-by: Bobby Casey <bobbycasey@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4193839 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* run_device_tests: Add option to test with production app imageBobby Casey2023-02-091-16/+53
| | | | | | | | | | | | | | | | | | | | | Add the ability to run tests against the production application image. It should be noted that the production image does not support the "runtest" command so any tests using a production image must supply appropriate commands using pre/post test callbacks (to be added in a future CL) and/or supplying finish_regexes. Also add a test to verify this functionality. Tests using the standard application image should not have a target buildable via make, as they use the standard app) but may be run from run_device_tests.py. BUG=b:180445334 BRANCH=none TEST=run_device_tests.py -b dartmonkey Signed-off-by: Bobby Casey <bobbycasey@google.com> Change-Id: I76cc248775a4cafdfcc4278799156a291277a19b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4193835 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Andrea Grandi <agrandi@google.com>
* test: Check TPM_SEED is reset after rebootFiras Sammoura2023-02-084-0/+116
| | | | | | | | | | | | | | | Add a unit test to check that TPM_SEED is reset after the FPMCU is rebooted. BRANCH=None BUG=b:143471027 TEST=test/run_device_tests.py -b dartmonkey -t tpm_seed_clear TEST=test/run_device_tests.py -b bloonchipper -t tpm_seed_clear Change-Id: I478c8ffcfc75c8188438d56958f0bf16f752efef Signed-off-by: Firas Sammoura <fsammoura@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4199160 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* docs: Add missing sudo to commandTom Hughes2023-02-081-1/+1
| | | | | | | | | | | | | BRANCH=none BUG=none TEST=run "JLinkRemoteServerCLExe -select USB" Cannot connect to J-Link. Retrying in 5 seconds.. TEST=run "sudo JLinkRemoteServerCLExe -select USB" -> success Change-Id: If701bacfc4ce04d778be0f6800b4bb266866f1af Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4228735 Reviewed-by: Firas Sammoura <fsammoura@google.com>
* TCPM: Separate Discovery into its own moduleDiana Z2023-02-071-0/+3
| | | | | | | | | | | | | | | | | | | | Discovery can be a separate feature from DFP mode entry, as any data role can run discovery in PD 3.0. Additionally, boards may want to enable discovery separate from full EC mode entry so put this feature behind a new CONFIG indicating its scope. BRANCH=None BUG=b:266714542 LOW_COVERAGE_REASON=only moving functions to a new file, b/267964449 filed to track expanding the testing of these functions later TEST=./twister -T ./zephyr/test, run on both nipperkin (ECOS) and skyrim (zephyr) to confirm cable and device identities are being reported correctly Change-Id: I84a08eaf4775ed427112d62777ff38f8a914a750 Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4211268 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Gate DP module support on a CONFIGDiana Z2023-02-072-8/+3
| | | | | | | | | | | | | | | | | | | | | | | Add a CONFIG option to gate DP mode support within the embedded controller. By default, turn the DP module off if the AP is controlling the VDMs for mode entry. For modules which do not implement the DP config option, the header now defines stubs for DP specific functions to use. This obsoletes some of the stub functions from older unit tests. BRANCH=None BUG=b:266714542 TEST=on skyrim, compile with DP disabled and observe 3162 bytes saved, run zmake compare-builds -a and util/compare_build.sh -b all, ./twister -T ./zephyr/test passes (note: ECOS compare builds needed all assert statements removed to pass, as they grab the line number, zephyr compare builds passed before HC mode entry was revamped) Change-Id: I9619eb5d34e418f1972c4bf16d4cf9c8d551eac5 Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4201454 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* run_device_tests: Add explicit function to power cycle the boardBobby Casey2023-02-071-3/+9
| | | | | | | | | | | | | | | BUG=b:180445334 BRANCH=none TEST=run_device_tests.py -b dartmonkey -t system_is_locked_wp_off TEST=run_device_tests.py -b dartmonkey -t system_is_locked_wp_on TEST=run_device_tests.py -b dartmonkey -t flash_physical TEST=run_device_tests.py -b dartmonkey -t flash_write_protect Change-Id: I4bee052e1766ff1eb09123cb494ea59d857fef18 Signed-off-by: Bobby Casey <bobbycasey@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4121374 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Andrea Grandi <agrandi@google.com>
* ec: Use chromite isort configJeremy Bettis2023-02-032-5/+8
| | | | | | | | | | | | | | | | | | Remove the .isort.cfg from platform/ec and use the one from chromite instead. This should be compatible with cros format. BRANCH=None BUG=b:267757300 TEST=Ran firmware_builder.py Change-Id: Ice4955b6995bd1f9380e97f58e89efb7c1e8aeb1 Signed-off-by: Jeremy Bettis <jbettis@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4221928 Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* TCPMv2: Queue Attention messages for consumptionDiana Z2023-01-251-0/+4
| | | | | | | | | | | | | | | Set up a queue within the DPM to hold VDM:Attention messages which the AP will be able to deplete at its leisure. BRANCH=None BUG=b:208884535 TEST=builds with and without AP VDM control Change-Id: Ia73ac3c6164251ab021776fdca252033646797dd Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4171490 Code-Coverage: Aaron Massey <aaronmassey@google.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* 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>