summaryrefslogtreecommitdiff
path: root/test/build.mk
Commit message (Collapse)AuthorAgeFilesLines
* cr50: consolidate FIPS module sources under board/cr50/dcryptoVadim Sukhomlinov2021-09-101-1/+1
| | | | | | | | | | | | | | | | | To simplify identification of FIPS module boundary, move all sources into same place. BUG=b:134594373 TEST=make buildall -j Signed-off-by: Vadim Sukhomlinov <sukhomlinov@google.com> Change-Id: I6acd12d12c00a3362041914bd515534f72a08ab2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3150057 Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Auto-Submit: Vadim Sukhomlinov <sukhomlinov@chromium.org> Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
* u2f: refactoring to split command processing and cryptoVadim Sukhomlinov2021-09-021-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Split U2F crypto from U2F command processing by moving all crypto code into boards/cr50 (platform hooks). U2F state management is part of common code and passed to U2F crypto as a parameter. Previously reviewed as https://crrev.com/c/3034852, but reverted due to ChromeOS dependency on include/u2f.h. In this revision this is addressed by restoring include/u2f.h with previous content and new additions and adjusting dependencies in other headers. BUG=b:134594373 TEST=make BOARD=cr50 CRYPTO_TEST=1 console: u2f_test test/tpmtest.py FAFT U2F tests pass Signed-off-by: Vadim Sukhomlinov <sukhomlinov@google.com> Change-Id: Iff1973c8e475216b801d7adde23b1ef6c4a6f699 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3119223 Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org> Tested-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Commit-Queue: Vadim Sukhomlinov <sukhomlinov@chromium.org>
* Revert "u2f: refactoring to split command processing and crypto"stabilize-14179.B-cr50_stabstabilize-14178.B-cr50_stabDavid Stevens2021-08-251-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 5ae1c684271a117539858cb12252959dfe46803c. Reason for revert: breaks chromeos-ec-headers BUG=b:197691499 Original change's description: > u2f: refactoring to split command processing and crypto > > Split U2F crypto from U2F command processing by moving all crypto > code into boards/cr50 (platform hooks). > > U2F state management is part of common code and passed to U2F crypto > as a parameter. > > BUG=b:134594373 > TEST=make BOARD=cr50 CRYPTO_TEST=1 > console: u2f_test > test/tpmtest.py > FAFT U2F tests pass > > Signed-off-by: Vadim Sukhomlinov <sukhomlinov@google.com> > Change-Id: I85442cddb2959bd3102f7f6e6047134ede90951b > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3034852 > Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> > Reviewed-by: Andrey Pronin <apronin@chromium.org> > Tested-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> > Commit-Queue: Vadim Sukhomlinov <sukhomlinov@chromium.org> Bug: b:134594373 Change-Id: I61a965995fcd53b4e155084f5f351574cb84cd1e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3115930 Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Owners-Override: David Stevens <stevensd@chromium.org>
* u2f: refactoring to split command processing and cryptoVadim Sukhomlinov2021-08-241-0/+2
| | | | | | | | | | | | | | | | | | | | | | Split U2F crypto from U2F command processing by moving all crypto code into boards/cr50 (platform hooks). U2F state management is part of common code and passed to U2F crypto as a parameter. BUG=b:134594373 TEST=make BOARD=cr50 CRYPTO_TEST=1 console: u2f_test test/tpmtest.py FAFT U2F tests pass Signed-off-by: Vadim Sukhomlinov <sukhomlinov@google.com> Change-Id: I85442cddb2959bd3102f7f6e6047134ede90951b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3034852 Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org> Tested-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Commit-Queue: Vadim Sukhomlinov <sukhomlinov@chromium.org>
* cr50: support EC-EFS 2.1Namyoon Woo2021-06-161-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | This patch adds the codes that support EC-EFS 2.1. However, it is not enabled. EC-EFS 2.0 is still enabled as default. BUG=b:187953899 TEST=built cr50 image, and ran it on hatch with CONFIG_EC_EFS2_VERSION defined as 0 and 1 respectively. For both cases, CrOS booted good. Also checked CrOS recovery was done good with corrupted TPM secdata, and booted good at the end. > ec_comm corrupt > ecrst pulse Ran the unittest for both version as well. $ make run-ec_comm $ make run-ec_comm21 Signed-off-by: Namyoon Woo <namyoon@google.com> Change-Id: I7623fa56dd44a01002628685826105afe76e034f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2891925 Tested-by: Namyoon Woo <namyoon@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org> Commit-Queue: Namyoon Woo <namyoon@chromium.org>
* cr50_stab: Add unittests for u2fstabilize-quickfix-13729.84.B-cr50_stabstabilize-quickfix-13729.73.B-cr50_stabstabilize-quickfix-13729.60.B-cr50_stabstabilize-13729.72.B-cr50_stabstabilize-13729.57.B-cr50_stabstabilize-13729.56.B-cr50_stabstabilize-13729.49.B-cr50_stabstabilize-13729.45.B-cr50_stabstabilize-13729.16.B-cr50_stabrelease-R89-13729.B-cr50_stabYicheng Li2021-01-121-0/+2
| | | | | | | | | | | | | | | | | | | | | The u2f functionality had no unittests at all. This change is more of a setup (in terms of build dependencies) so that u2f tests can be easily added in the future. This change comes with a few simple tests for u2f_generate. The basic idea here is to use board/host/dcrypto.h to mock the dcrypto functionalities. Since board/host/dcrypto.h includes an alternative to cryptoc's sha256 definitions, we need to exclude cryptoc/sha256.h in the test builds. BUG=b:172971998 TEST=make -j run-u2f TEST=make CR50_DEV=1 BOARD=cr50 -j Signed-off-by: Yicheng Li <yichengli@chromium.org> Change-Id: Idae6f55f599a017aedcaf0fe4cdb6c0506e72712 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2610133 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* coil: remove unused testsMary Ruthven2021-01-061-73/+0
| | | | | | | | | | | | | We're deleting unused code to reduce coil terms in platform/cr50. Remove unused tests to make this easier. BUG=b:175244613 TEST=make buildall -j Change-Id: I593caf5edfabda6ef24cc9eede2a8bb829c01b83 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2613134 Reviewed-by: Namyoon Woo <namyoon@chromium.org>
* introducing an unittest of EC-EFSNamyoon Woo2020-03-111-0/+2
| | | | | | | | | | | | | | | This patch adds a test case for EC-EFS functions. BUG=b:150650877 BRANCH=cr50 TEST=make run-ec_comm make runhosttests make buildall -j Signed-off-by: Namyoon Woo <namyoon@chromium.org> Change-Id: I90cdc3aa73cf8946da4cf094de5ca0adfaaa0a7c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2096338 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* usbc: fix storm tracker overflow issueJett Rink2019-11-221-0/+2
| | | | | | | | | | | | | | | | | | | If there is no USB-C interrupt activity for 2^31 microseconds, then there are more than ALERT_STORM_MAX_COUNT events within 2^31 microsecond (instead of ALERT_STORM_INTERVAL), then the interrupt storm would incorrectly detect a storm and disable the port due to incorrect math regarding 32-bit overflow. BRANCH=octopus and all branches with original storm detection (CL:1650484) BUG=b:144369187 TEST=unit test in CL Change-Id: I90b888ac092f81d151538d6018771fb32f8e9c39 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1925668 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* common: Refactor motion_sense_fifoYuval Peress2019-11-111-1/+2
| | | | | | | | | | | | | | | | | This change refactors the motion_sense_fifo to uniformly prefix all the functions to avoid collisions. It also adds several unit tests and fixes a few bugs with the fifo logic. BUG=b:137758297 BRANCH=kukui TEST=buildall TEST=run CTS on arcada, kohaku, and kukui TEST=boot kohaku (verify tablet mode works as expected) Change-Id: I6e8492ae5fa474d0aa870088ab56f76b220a73e3 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1835221 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* host: remove leftovers from using system clock in testsJack Rosenthal2019-10-251-1/+0
| | | | | | | | | | | | | | There was some leftover constants and a #include we are no longer using due to using a monotonic counter, clean it up. BUG=chromium:1013701 BRANCH=none TEST=buildall Change-Id: Ieeb130aef9ee89d65459f52c8f34753c30c3c388 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1879335 Reviewed-by: Edward Hill <ecgh@chromium.org>
* pd: Add PE FRS unit test for new stackDenis Brockus2019-10-161-0/+3
| | | | | | | | | | | BUG=none BRANCH=none TEST=make buildall -j Change-Id: I55453ddf1d1da0fdee902a33e14357716fb12c4a Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1859826 Reviewed-by: Jett Rink <jettrink@chromium.org>
* test: don't rely on system time for testsJett Rink2019-10-141-1/+1
| | | | | | | | | | | | | | | | Instead of relying on the host's clock, we need to monotonically increase a timestamp. This gives tests predictability. BRANCH=none BUG=chromium:1013701 TEST=ran usb_prl over 100 times without failure Change-Id: Id4a1e9a8cbd9dd44509747916c9073444d71af5c Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1860474 Tested-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
* Test: disable flaky usb_prl testEdward Hill2019-10-121-1/+1
| | | | | | | | | | | | | | | The usb_prl test continues to be flaky. Disable it until it can be fixed. BUG=chromium:1013701 BRANCH=none TEST=make -j runhosttests Change-Id: Iebdc3a1c812a8864951522d7134fe8098271c86f Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1856826 Reviewed-by: Raul E Rangel <rrangel@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* usbc: fix cc interpretation errorJett Rink2019-10-081-0/+2
| | | | | | | | | | | | | | Ensure that two Rp values are interpreted as a debug accessory. Added unit test for meaningful combinations. BRANCH=none BUG=none TEST=passes unit test. Change-Id: Ia454382f20f9377edc944dc01be133e062c218b0 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1845811 Reviewed-by: Edward Hill <ecgh@chromium.org>
* ppc: cleanup ppcDenis Brockus2019-10-061-0/+2
| | | | | | | | | | | | | | Allow limited PPC chips to default to EC_ERROR_UNIMPLEMENTED for functions in the driver that are not needed. BUG=b:138599218 BRANCH=none TEST=make buildall -j Change-Id: I5242ef285eb277c06d516ab09f7a74f76d7d34b2 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1829405 Reviewed-by: Edward Hill <ecgh@chromium.org>
* Revert "common: Refactor motion_sense_fifo"Scott Collyer2019-10-021-2/+1
| | | | | | | | | | | | | | | | | | | | | | This reverts commit 36b47ab3c06e477f5e95d6d9e84a5220248784e6. With this CL the lid angle calculation on hatch devices reports 500 which is what's used for can't caluclate a meaninfgul value. BUG=b:141840539 BRANCH=None TEST=On helios tested with this CL and saw that lid angle calculations returned 500 for lid angle. Then reverted the CL and verifed that lid angle calculations were correct. Used 'accelinfo on 10000' to check the EC reported lid angle. Change-Id: Id4e36219792d00357d2885e9944c58fe0e15c5ca Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1834705 Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Yuval Peress <peress@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Commit-Queue: Scott Collyer <scollyer@chromium.org>
* common: Refactor motion_sense_fifoYuval Peress2019-09-271-1/+2
| | | | | | | | | | | | | | | This change refactors the motion_sense_fifo to uniformly prefix all the functions to avoid collisions. It also adds several unit tests and fixes a few bugs with the fifo logic. BUG=b:137758297 BRANCH=None TEST=buildall & run CTS on arcada Change-Id: I7aae45382b07d6c8858e07215c33e710c7ed27ec Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1704166 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* common: Add uptime host commandTom Hughes2019-09-031-0/+2
| | | | | | | | | | | | | | | | | | This moves the EC_CMD_GET_UPTIME_INFO command from behind the CONFIG_CMD_AP_RESET_LOG config in chipset.c into the generic common/uptime.c file, so that all boards in the codebase can use it. If CONFIG_CMD_AP_RESET_LOG is enabled, the "AP reset stats" will be filled. Otherwise, ap_reset_stats is a no-op and recent_ap_reset is filled with zero. BRANCH=none BUG=chromium:997314 TEST=cat /sys/kernel/debug/cros_fp/uptime Change-Id: I3b6f91b2dd22d3d55b707309ec1fdfd26d42fd70 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1769393 Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
* common: add STATIC_IF and STATIC_IF_NOT macrosJack Rosenthal2019-08-201-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A common pattern to use with IS_ENABLED is like this: /* * This var should only be used if CONFIG_FOO. The linker errors if * CONFIG_FOO is not defined is intentional. */ #ifdef CONFIG_FOO static #else extern #endif int some_var; The issue with this is that it leads to an over-verbose and potentially hard to read pattern, and does not have the check that CONFIG_FOO was only defined to blank. Suppose a macro like this existed: STATIC_IF(CONFIG_FOO) int some_var; ... which expands to "static" when CONFIG_FOO is defined to empty, "extern" when CONFIG_FOO is not defined, and errors when CONFIG_FOO is defined to non-empty. This CL implements that, as well as the inverse (STATIC_IF_NOT). BUG=chromium:989786 BRANCH=none TEST=provided unit tests, buildall Change-Id: Ib57aaba62bc184fda9aa782a780d5f13ba44ae88 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1731859 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* test: add baseline test for TC_DRP_TRYSRC SMJett Rink2019-08-201-0/+3
| | | | | | | | | | | | BRANCH=none BUG=none TEST=unit test pass Change-Id: I0ecb9f0298fd43ca0db800311a309d98eb1e29b5 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1744658 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* test: add sanity check for existing state machinesJett Rink2019-08-201-3/+3
| | | | | | | | | | | | | | | | | | | | We want to ensure that our usb state machines - do not have any cycles - do not have any completely empty states - have names for every print statement if called These new unit tests allow us to have build-times checks for the above. BRANCH=none BUG=none TEST=tests pass. Made each test fail locally to ensure that tests were actually working. Change-Id: Idd2c4d69e83cf38c97278edd1727d86b52a85db9 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1744657 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* Improve unit test and fuzzer documentation storyCraig Hesling2019-07-201-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Update **test** directory description to README.md. * Add ** fuzz** directory description to README.md. * Add unit test and fuzzer make targets to `make help` * Change showboards to print-boards to be more consistent * Change showboards to use auto pretty print * Add print-tests, print-host-tests, and print-host-fuzzers This is necessary to remove the ambiguity about what a special name is for a given unit test. Documentation Story: The idea is to give a brief overview of what the test and fuzz directories are in README.md. README.md also mentions you should see `make help` for more detail. Running `make help` shows you more general test/fuzz commands, including the print-* commands. Running the print-* commands show you exact target names for all possible unit/fuzz test (both the build-only and run target names). BRANCH=none BUG=none TEST=make help TEST=make print-tests TEST=make print-host-tests TEST=make print-host-fuzzers TEST=make print-host-fuzzers | cat TEST=make print-boards TEST=make print-boards | cat TEST=make buildall -j Change-Id: I34b68196ac635ba71a1d45ceb5d35a3b36fd129f Signed-off-by: Craig Hesling <hesling@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1684714 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* Test: Disable kb_scan until flakiness is fixedDaisuke Nojiri2019-07-041-1/+1
| | | | | | | | | | | | | | | | | kb_scan is flaky, causing builders to fail randomly. We disable it until its flakiness is fixed. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=chromium:976974 BRANCH=none TEST=buildall Change-Id: Id896a5928f5a241594fdeb010c4f6bfe24302f3b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1684044 Reviewed-by: Luis Lozano <llozano@chromium.org> Commit-Queue: Luis Lozano <llozano@chromium.org> Tested-by: Luis Lozano <llozano@chromium.org>
* printf: Add unit tests for printf.cCraig Hesling2019-06-251-0/+2
| | | | | | | | | | | | | | | | These tests solidify the current behavior of the print formatter in order to verify future changes. Some commented out tests expose odd behavior that will be addressed in the follow up patch. BUG=chromium:974084 TEST=make V=1 run-printf BRANCH=none Change-Id: I9c45a075692992c7713a15d7f83099a2d13441e6 Signed-off-by: Craig Hesling <hesling@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1659834 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* LICENSE: remove unnecessary (c) after CopyrightTom Hughes2019-06-191-1/+1
| | | | | | | | | | | | | | | | Ran the following command: git grep -l 'Copyright (c)' | \ xargs sed -i 's/Copyright (c)/Copyright/g' BRANCH=none BUG=none TEST=make buildall -j Change-Id: I6cc4a0f7e8b30d5b5f97d53c031c299f3e164ca7 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1663262 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* fpsensor: Add API to check FP sensor encryption status.Yicheng Li2019-06-071-0/+2
| | | | | | | | | | | | | | | | | | Add EC command for the host to query FP sensor encryption status. Currently it's just FP TPM seed has been set or not. Add unit test for this command. Also add ectool command for querying encryption status. BRANCH=nocturne BUG=chromium:952275 TEST=ran unittests TEST=tested enrollment, matching and multifinger on DUT nocturne. TEST=tested querying sensor encryption status using ectool. Change-Id: I07d1e471ead85a517105b38d1ddd793c3046ce8f Signed-off-by: Yicheng Li <yichengli@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1633272 Reviewed-by: Nicolas Norvez <norvez@chromium.org>
* nvmem: make page header checksums different between prod and devVadim Bendebury2019-05-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | When moving an H1 between prod and dev Cr50 images, it is important to quickly determine that the NVMEM contents are not retrievable. The first object verified by the initialization routine is the page header, but since SHA value is used for integrity verification, it does not change despite the fact that the mode (and encryption keys as a result) changed. Using encrypted header value for integrity verification guarantees that when transition between prod and dev modes happen the initialization function discovers it right away and reinitializes NVMEM instead of trying to interpret corrupted objects. The host/dcrypto stub used for unit tests and fuzzing needs to be modified to ensure that page headers read from uninitialized flash do not look valid (where encrypted value of 0xffffffff is 0xffffffff). BRANCH=cr50, cr50-mp BUG=b:129710256 TEST=make buildall -j successd, as well as migration of a Chrome OS device from legacy to new nvmem layout. Change-Id: I613513cc67b14f553d2760919d6058f8dbed6e41 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1615423 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org>
* ec: common: Make IS_ENABLED fail on unknown valuesRaul E Rangel2019-05-151-0/+6
| | | | | | | | | | | | | | | | | If IS_ENABLED is called with any unknown values, a compiler error will be thrown. This change requires that the optimizer always be enabled, otherwise errors will be thrown when a value is not defined. BUG=none BRANCH=none TEST=make runtests TEST_LIST_HOST="is_enabled_error is_enabled" Change-Id: I1b166311f81d07e48b3665f4bc0e9502d2ccc4c6 Signed-off-by: Raul E Rangel <rrangel@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1592728 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* chocodile_vpdmcu: Firmware for chocodile mcuSam Hurst2019-04-081-0/+14
| | | | | | | | | | | | | | | | | | Implement Chocodile Charge-Through Vconn Powered firmware for mcu using new Type-C/PD State machine stack. BUG=b:115626873 BRANCH=none TEST=manual Charge-Through was tested on an Atlas running a DRP USB-C/PD state machine with CTUnattached.SNK and CTAttached.SNK states. Signed-off-by: Sam Hurst <shurst@chromium.org> Change-Id: I847f1bcd2fc3ce41e66edd133a10c943d5e8c819 Reviewed-on: https://chromium-review.googlesource.com/1225250 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Sam Hurst <shurst@google.com> Reviewed-by: Stefan Reinauer <reinauer@google.com>
* nvmem: test modifications to support the new schemeVadim Bendebury2019-04-051-3/+6
| | | | | | | | | | | | | | | | | | | | | This patch includes changes to support testing of the new nvmem implementation. Making fizz compatible required duplicating a lot of functionality available in the test/ directory (fuzz/nvmem_tpm2_mock.c is very similar to test/nvmem_tpm2_mock.c), but I could not find an easy way to avoid it. BRANCH=cr50, cr50-mp BUG=b:69907320, b:129710256 CQ-DEPEND=CL:1496607 TEST=with the rest of the patches applied 'make buildall -j' succeeds, which confirms both test and fuzz success. Change-Id: Ife999b04d22f8ddbe9ea5d35f4c3e21f57592754 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1450278 Reviewed-by: Andrey Pronin <apronin@chromium.org>
* common: add flash event log facilityVadim Bendebury2019-03-261-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds implementation and test for a generic logger saving log entries in the flash. The entries payload are limited to 64 bytes in size, each entry starts with a header, which includes - 8 bit type type to allow to interpret the payload - 6 bit size field (two top bits of the byte are left for user flags, not yet used) - 32 bit timestamp to allow to identify newer log entries (presently this is just a monotonically increasing number) - 8 bit crc field protecting the entire entry The entries are padded to make sure that they are ending on the flash write boundary. The location of the log is defined by the platform using it. There is a provision for allowing the platform to register a callback which is needed to be called to allow write access to the log (as is the case on H1). While the device is running, the log is growing until the allotted flash space is 90% full. If there is an attempt save another entry after that the log is compacted, namely the last 25% worth of flash space is preserved, the log space is erased and the saved contents written back. On restarts the log is compacted if its size exceeds 75% of the allotted flash space. An API is provided to add entries to the log and to retrieve an entry newer than a certain timestamp value. Thus starting with timestamp zero will result in reading the very first log entry. To read the next entry, the read function needs to be called with the timestamp value of the current entry. This allows to browse the entire log, one entry at a time. A CLI command compiled in when CONFIG_CMD_FLASH_LOG is defined, allows to add log and retrieve log entries. BUG=b:63760920 BRANCH=cr50, cr50-mp TEST=the included test case can be invoked by make run-flash_log and it passes. More tests are done when the rest of the patch stack is added. Change-Id: I3dcdf2704a1e08fd3101183e434ac4a4e4cf1b9a Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1525143 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org>
* motion_lid: Rewrite lid angle calculation based on chromium codeGwendal Grignou2019-03-261-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | Use code from ash/wm/tablet_mode/tablet_mode_controller.cc, in particular TabletModeController::HandleHingeRotation() to calculate lid angle. Add unit tests based on ash/wm/tablet_mode/tablet_mode_controller_unittest.cc and the data file accelerometer_test_data_literals.cc. BUG=b:120346412 BRANCH=none TEST=Check unit tests pass, check it compile on FPU based EC, EC without FPU and no 64 bit support (ampton). Check lid calculation is correct on eve: - with "while true ; do ectool motionsense lid_angle ; sleep 1 ; done" Check when hinge is almost vertical lid angle is close to constant or marked are unrieliable. Check when shaking device, lid angle is also unreliable Check with evtest SW_TABLET_MODE event is trigger when lid angle is available and cross 180 region. Change-Id: I545f7333ed9b53accedb75f238f747f66bae1f5d Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1388844 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Jett Rink <jettrink@chromium.org>
* mag_cal: Support fixed-point calculation.Yilun Lin2018-10-041-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Modified from floating point version. This includes changes to vec3, vec4, mat33, mat44, and mag_cal. Now fixed-point type (fp_*) functions is a function wrapper for both fixed-point and floating point version operations: * define CONFIG_FPU to use floating version mag_cal * undef CONFIG_FPU to use fixed-point version mag_cal Also, add tests for both float and fp types operations. TEST=define CONFIG_FPU; flash on reef; See ARC++ magnetmeter app moving. TEST=undef CONFIG_FPU; flash on reef; See ARC++ magnetmeter app moving. TEST=make runtests -j TEST=make buildalltests -j BUG=b:113364863 BRANCH=None Change-Id: Ie695945acb666912babb2a603e09c602a0624d44 Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/1260704 Commit-Ready: Yilun Lin <yllin@chromium.org> Tested-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* aes: Adapt AES code to build for ECNicolas Boichat2018-09-201-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Update header, C code, and tweak the assembly for ARMv7-M. Rename aes_now_* functions to AES_* to avoid the need for a separate wrapper. Also add a test with FIPS-197 test vectors, and speed test. BRANCH=none BUG=b:111160949 TEST=make run-aes -j TEST=make BOARD=nocturne_fp test-aes -j flash_fp_mcu aes.bin runtest => pass (C implementation speed: 11977 us for 1000 iterations) (ASM implementation speed: 5815 us for 1000 iterations) Signed-off-by: Vincent Palatin <vpalatin@chromium.org> Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Change-Id: I2048aae73decccb893bc1724b2617b0b902dd992 Reviewed-on: https://chromium-review.googlesource.com/1120340 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Adam Langley <agl@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* Move fuzzing tests into a fuzz subfolder.Allen Webb2018-08-221-4/+0
| | | | | | | | | | | | | BRANCH=none CQ-DEPEND=CL:*664115 BUG=chromium:876582 TEST=make -j buildall && make -j buildfuzztests Change-Id: Iade5e5138f495e6b3b99ec16f1a467861ade5537 Signed-off-by: Allen Webb <allenwebb@google.com> Reviewed-on: https://chromium-review.googlesource.com/1180179 Reviewed-by: Mattias Nissler <mnissler@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* CEC: Add unit tests for buffer handlingStefan Adolfsson2018-08-221-0/+2
| | | | | | | | | | | | | | | | | | Makes sure that we don't have and that we don't introduce buffer overflows in the CEC buffer handling. Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org> BUG=b:80288314 BRANCH=none TEST=make -j runtests Change-Id: Iad5f79add99e2582e60f0d11ed53a27ac67e8b8c Reviewed-on: https://chromium-review.googlesource.com/1073415 Commit-Ready: Stefan Adolfsson <sadolfsson@chromium.org> Tested-by: Stefan Adolfsson <sadolfsson@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Zhongze Hu <frankhu@google.com>
* test: host_command_fuzz: fuzzing testNicolas Boichat2018-08-161-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Writing fuzzing tests is a little tricky, as clang takes over the main function. Instead, we start the test main function in a thread, and have LLVMFuzzerTestOneInput prepare the host command buffer, and wake the TEST_RUNNER task. To make fuzzing faster, we only send somehow correctly formed requests, with a valid checksum and length (this can be disabled with an option). We also make sure that the emulator does not hibernate, reboot or jump to a different image when fuzzing is enabled. BRANCH=none BUG=chromium:854975 TEST=make buildfuzztests -j ASAN_OPTIONS="log_path=stderr" \ build/host/host_command_fuzz/host_command_fuzz.exe -timeout=5 Change-Id: I27b25e44c405f118dfc1296247479245e15e54b4 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1107523 Reviewed-by: Manoj Gupta <manojgupta@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Jonathan Metzman <metzman@chromium.org>
* test/build.mk: Allow boards to specify test listsNicolas Boichat2018-05-281-25/+1
| | | | | | | | | | | | | | | | | Some tests cannot be built on some boards (not enough SRAM, unusual configuration, etc.). Instead of the long list of exceptions in test/build.mk that we currently use, allow each board (or chip) build.mk to set test-list-y, and only use the default list if it is unset. BRANCH=poppy BUG=b:80167548 TEST=make buildalltests -j Change-Id: I803c691f419451aad4396529302a4805cbe3f9b5 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1074572 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Makefile.rules: Add buildalltests targetNicolas Boichat2018-05-261-2/+9
| | | | | | | | | | | | | | | | | In rare cases, it is useful to be able to build tests for all boards: buildall only builds the main image, but -paladin builders also builds test cases for each board. Also remove/fix tests for boards that currently fail. BRANCH=none BUG=b:35647963 TEST=make buildalltests -j, wait a long time, tests pass. Change-Id: Id6d978705a40a2045731cb08ad2ca5d62cc12ebb Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1072218 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* test: Make it possible to run rsa tests on hammer boardstabilize-10718.88.Bstabilize-10718.71.Bstabilize-10718.69.Bstabilize-10718.111.Brelease-R68-10718.BNicolas Boichat2018-05-241-1/+1
| | | | | | | | | | | | | BRANCH=poppy BUG=b:35647963 BUG=b:77608104 TEST=make run-rsa run-rsa3 TEST=make BOARD=hammer test-rsa3, test on board Change-Id: Id4bd8d5f550dbc6569d88ced114849b3b6411b2f Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1071410 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Cr50: Added Pinweaver base implementation.Allen Webb2018-04-271-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds some of the ground work for hardware backed brute force resistance on Cr50. The feature is called Pinweaver. It will initially be used to enable PIN authentication on CrOS devices without reducing the security of the platform. A Merkle tree is used to validate encrypted metadata used to track login attempts. The metadata tracks counts of failed attempts, a timestamp of the last failed attempt, the secrets, and any associated parameters. Instead of storing the metadata on Cr50 an AES-CTR is used with an HMAC to encrypt the data so it can be stored off-chip and loaded when needed. The Merkle tree is used to track the current state of all the metadata to prevent replay attacks of previously exported copies. It is a tree of hashes whose root hash is stored on Cr50, and whose leaves are the HMACs of the encrypted metadata. BRANCH=none BUG=chromium:809730, chromium:809741, chromium:809743, chromium:809747 TEST=cd ~/src/platform/ec && V=1 make run-pinweaver -j Change-Id: Id10bb49d8ebc5a487dd90c6093bc0f51dadbd124 Signed-off-by: Allen Webb <allenwebb@google.com> Reviewed-on: https://chromium-review.googlesource.com/895395 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* ec: add crc32_ctx..() to take context parameter.Marius Schilder2018-02-231-0/+2
| | | | | | | | | | | | | | | | | | Add crc32_ctx.. functions to take context parameter. This allows for multiple instances to exist in parallel. Signed-off-by: mschilder@google.com TEST=make buildall -j8 succeeds BRANCH=none BUG=b:73832883 Change-Id: I66bbc56377eeebf01c790caad0bc4c7a51a1bc58 Reviewed-on: https://chromium-review.googlesource.com/935825 Commit-Ready: Marius Schilder <mschilder@chromium.org> Tested-by: Marius Schilder <mschilder@chromium.org> Reviewed-by: Marius Schilder <mschilder@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* cleanup: Remove llama boardShawn Nematbakhsh2017-11-091-3/+0
| | | | | | | | | | | | | | | | | The llama is a South American relative of the camel, though the llama does not have a hump. These sturdy creatures are domestic animals used by the peoples of the Andes Mountains. BUG=None TEST=`make buildall -j` BRANCH=None Change-Id: I55dbd8d5b0b14c41e27c4ef473833563f38878c3 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/761298 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* PD: Make current USB PD Stack REV 3 compliantSam Hurst2017-10-241-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement the following required features in the USB PD Rev. 3.0 specification. Not_supported control message: Inform a port partner that a particular message is not supported. Battery capabilities extended message: Report battery design capacity and last full charge capacity. Battery status data message: Report battery state of charge Collision avoidance: New scheme to avoid collisions caused when both source and sink want to send messages. Cable communication: Only the VCONN source can communicate with the cable plug. This is NOT implemented because although the drivers have the capability of communicating with a cable plug, the PD stack doesn't currently need to talk to a cable plug. This is okay since the current PD design doesn't source or sink more than 3 amps and all Type-C cables are required to be 3 amp capable. BUG=b:64411727 BRANCH=None TEST=`make -j buildall` Passed relevant PD Rev 2.0 compliance tests Successful PD negotiation with PD Rev 2.0 and 3.0 chargers Tested with low power none PD charger. Modified a Kevin to operate as a PD 3.0 charger and sent all required messages and verified the return messages. Also tested collision avoidance by verifying that a sink only transmits when the source indicates it's okay. Used Twinkie to verify that PD was operating as v3.0. Signed-off-by: Sam Hurst <shurst@chromium.org> Change-Id: Ifd77e92ec4e9106236f9221393d2bfb97263d979 Reviewed-on: https://chromium-review.googlesource.com/603003 Commit-Ready: Sam Hurst <shurst@google.com> Tested-by: Sam Hurst <shurst@google.com> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* rtc: Add functions and tests for time conversionPhilip Chen2017-09-261-0/+2
| | | | | | | | | | | | | | | | | | | | | To implement rtc driver for some ec chips, we need to convert between calandar date and seconds (since epoch time, 01-01-1970 00:00:00). Sicne these functions are HW-independent, let's add common/rtc.c, include/rtc.h, and unit test for this. BUG=b:63908519 BRANCH=none TEST=make buildall test -j Change-Id: Icb1e768d2b3674d5225b83e09475e984eb104d06 Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/666985 Commit-Ready: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org> Reviewed-by: Brian Norris <briannorris@chromium.org>
* cleanup: Remove 'ryu' boardShawn Nematbakhsh2017-09-111-3/+0
| | | | | | | | | | | | | | | Remove 'ryu' and related ryu-only code. BUG=None TEST=`make buildall -j` BRANCH=None Change-Id: I19b966ea6964a7ed083724f7de80ae192235a406 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/656314 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* common/sha256: agressive SHA-256 unrolling as an optionNicolas Boichat2017-09-111-0/+2
| | | | | | | | | | | | | | | | Reduces "hash done" time from ~1.30 to ~1.15s on soraka. BRANCH=none BUG=chromium:702378 BUG=b:64196191 TEST=Boot soraka, looks at hash done time. TEST=make run-sha256 run-sha256_unrolled passes. Change-Id: Ia29ee27404d6e9aa615ff59755b59d3f26648e71 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/652327 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* vboot: Move common code under common/vbootDaisuke Nojiri2017-07-131-0/+2
| | | | | | | | | | | | | | | This patch moves the code which can be shared with other data verification schemes (e.g. RWSIG) under common/vboot. It also adds unit tests for it. BUG=b:38462249 BRANCH=none TEST=make run-vboot. Verify verification succeeds on Fizz. Change-Id: Icab4d96dd2c154a12b01c41ebe9b46286b4b590e Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/563463 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* common: Add RMA reset auth challenge-response cryptoRandall Spangler2017-06-301-0/+2
| | | | | | | | | | | | | | | | RMA auth uses X25519 to generate a relatively small challenge and response. Currently, nothing calls the rma_auth code. We'll need console and TPM vendor commands to do so. BUG=b:37952913 BRANCH=none TEST=make buildall Change-Id: Iec7f2d0e3dc8243f79b009ead16bb3ba9f1bef9d Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/544184