diff options
author | Craig Hesling <hesling@chromium.org> | 2019-07-26 09:32:11 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-10-25 17:58:19 +0000 |
commit | 7eded13a72691fdce4d66f59c5b119969afa35c0 (patch) | |
tree | 5786465fa15045ca1524de72a9947bf78d6c5a89 | |
parent | 5866ec2921784004f66f9a0407f97c1659d674fb (diff) | |
download | chrome-ec-7eded13a72691fdce4d66f59c5b119969afa35c0.tar.gz |
fuzz_host_cmd: Add fpsensor task + fp host cmds
This CL enables the fpsensor task and adds the following
remaining fingerprint host commands to the fuzzer:
* EC_CMD_FP_PASSTHRU
* EC_CMD_FP_INFO
* EC_CMD_FP_FRAME
* EC_CMD_FP_STATS
* EC_CMD_FP_TEMPLATE
BRANCH=none
BUG=b:116065496
TEST=make buildall -j
TEST=make run-host_command_fuzz
TEST=# Pull in TEST_COVERAGE fix
git fetch "https://chromium.googlesource.com/chromiumos/platform/ec" \
refs/changes/86/1725186/1 && git cherry-pick FETCH_HEAD
make host-host_command_fuzz TEST_COVERAGE=1
timeout 5m ./build/host/host_command_fuzz/host_command_fuzz.exe
llvm-profdata merge -sparse default.profraw -o default.profdata
llvm-cov show build/host/host_command_fuzz/host_command_fuzz.exe \
--instr-profile=default.profdata --format=html --output-dir=cov
# Inspect cov/.../common/fpsensor/fpsensor_state.c.html to verify
Change-Id: Icad9493ba41cd4daa61a30246d01afd1dbe16c56
Signed-off-by: Craig Hesling <hesling@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1682945
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Commit-Queue: Sean Abraham <seanabraham@chromium.org>
-rw-r--r-- | board/host/board.c | 8 | ||||
-rw-r--r-- | board/host/board.h | 7 | ||||
-rw-r--r-- | board/host/gpio.inc | 5 | ||||
-rw-r--r-- | common/fpsensor/build.mk | 3 | ||||
-rw-r--r-- | fuzz/host_command_fuzz.mocklist | 5 | ||||
-rw-r--r-- | fuzz/host_command_fuzz.tasklist | 2 | ||||
-rw-r--r-- | include/fpsensor_state.h | 5 | ||||
-rw-r--r-- | test/fpsensor.mocklist | 3 |
8 files changed, 31 insertions, 7 deletions
diff --git a/board/host/board.c b/board/host/board.c index 086a6f1359..80ac631d19 100644 --- a/board/host/board.c +++ b/board/host/board.c @@ -44,7 +44,11 @@ BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); test_mockable void button_interrupt(enum gpio_signal signal) { -}; +} + +test_mockable void fps_event(enum gpio_signal signal) +{ +} #ifdef CONFIG_I2C /* I2C ports */ @@ -62,6 +66,8 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); #ifdef CONFIG_SPI_MASTER /* SPI devices */ const struct spi_device_t spi_devices[] = { + /* Fingerprint sensor (SCLK at 4Mhz) */ + { CONFIG_SPI_FP_PORT, 3, GPIO_SPI1_NSS }, }; const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices); diff --git a/board/host/board.h b/board/host/board.h index d202e23f7a..ac44f31907 100644 --- a/board/host/board.h +++ b/board/host/board.h @@ -73,4 +73,11 @@ enum { #define PD_MIN_CURRENT_MA 500 #define PD_MIN_POWER_MW 7500 +/* Configuration for fake Fingerprint Sensor */ +#define CONFIG_SPI_MASTER +#define CONFIG_SPI_FP_PORT 1 /* SPI1: third master config */ + +#define CONFIG_RNG +void fps_event(enum gpio_signal signal); + #endif /* __CROS_EC_BOARD_H */ diff --git a/board/host/gpio.inc b/board/host/gpio.inc index d80e172448..324721068b 100644 --- a/board/host/gpio.inc +++ b/board/host/gpio.inc @@ -14,6 +14,8 @@ GPIO_INT(AC_PRESENT, PIN(0, 2), GPIO_INT_BOTH, extpower_interrupt) GPIO_INT(VOLUME_DOWN_L, PIN(0, 3), GPIO_INT_BOTH, button_interrupt) GPIO_INT(VOLUME_UP_L, PIN(0, 4), GPIO_INT_BOTH, button_interrupt) GPIO_INT(CHARGE_DONE, PIN(0, 5), GPIO_INT_BOTH, inductive_charging_interrupt) +/* Fingerprint */ +GPIO_INT(FPS_INT, PIN(0, 14), GPIO_INT_RISING, fps_event) GPIO(EC_INT_L, PIN(0, 6), 0) GPIO(WP, PIN(0, 7), 0) @@ -24,3 +26,6 @@ GPIO(ENABLE_BACKLIGHT, PIN(0, 10), 0) /* Inductive charging */ GPIO(CHARGE_EN, PIN(0, 11), 0) GPIO(BASE_CHG_VDD_EN, PIN(0, 12), 0) + +/* Fingerprint */ +GPIO(SPI1_NSS, PIN(0, 13), GPIO_OUT_HIGH) diff --git a/common/fpsensor/build.mk b/common/fpsensor/build.mk index 687496bf2a..03bc80f2ef 100644 --- a/common/fpsensor/build.mk +++ b/common/fpsensor/build.mk @@ -9,9 +9,8 @@ _fpsensor_dir:=$(dir $(lastword $(MAKEFILE_LIST))) all-obj-$(HAS_TASK_FPSENSOR)+=$(_fpsensor_dir)fpsensor_state.o all-obj-$(HAS_TASK_FPSENSOR)+=$(_fpsensor_dir)fpsensor_crypto.o -ifneq ($(CONFIG_SPI_FP_PORT),) all-obj-$(HAS_TASK_FPSENSOR)+=$(_fpsensor_dir)fpsensor.o -endif + ifeq ($(HAS_MOCK_FP_SENSOR),) all-obj-$(HAS_TASK_FPSENSOR)+=$(_fpsensor_dir)fpsensor_stubs.o endif diff --git a/fuzz/host_command_fuzz.mocklist b/fuzz/host_command_fuzz.mocklist index efcf062742..be1527bff0 100644 --- a/fuzz/host_command_fuzz.mocklist +++ b/fuzz/host_command_fuzz.mocklist @@ -4,5 +4,6 @@ */ #define CONFIG_TEST_MOCK_LIST \ - MOCK(FP_SENSOR) \ - MOCK(ROLLBACK) + MOCK(FP_SENSOR) \ + MOCK(MKBP_EVENTS) \ + MOCK(ROLLBACK) diff --git a/fuzz/host_command_fuzz.tasklist b/fuzz/host_command_fuzz.tasklist index c95bf17c64..2ff8a94d98 100644 --- a/fuzz/host_command_fuzz.tasklist +++ b/fuzz/host_command_fuzz.tasklist @@ -7,4 +7,4 @@ * See CONFIG_TASK_LIST in config.h for details. */ #define CONFIG_TEST_TASK_LIST \ - TASK_TEST(FPSENSOR, fp_task_simulate, NULL, TASK_STACK_SIZE) + TASK_TEST(FPSENSOR, fp_task, NULL, TASK_STACK_SIZE) diff --git a/include/fpsensor_state.h b/include/fpsensor_state.h index 4047fca74d..f7bb3a3f1e 100644 --- a/include/fpsensor_state.h +++ b/include/fpsensor_state.h @@ -25,6 +25,7 @@ #if defined(HAVE_PRIVATE) && !defined(TEST_BUILD) #define HAVE_FP_PRIVATE_DRIVER +/* Include the device specific header file */ #define PRIV_HEADER(header) STRINGIFY(header) #include PRIV_HEADER(FP_SENSOR_PRIVATE) #else @@ -35,6 +36,10 @@ #define FP_ALGORITHM_TEMPLATE_SIZE 0 #define FP_MAX_FINGER_COUNT 5 #endif +#ifdef TEST_BUILD +/* This represents the mock of the private */ +#define HAVE_FP_PRIVATE_DRIVER +#endif #define SBP_ENC_KEY_LEN 16 #define FP_ALGORITHM_ENCRYPTED_TEMPLATE_SIZE \ (FP_ALGORITHM_TEMPLATE_SIZE + \ diff --git a/test/fpsensor.mocklist b/test/fpsensor.mocklist index 3aeffc8dd3..3a90debc1f 100644 --- a/test/fpsensor.mocklist +++ b/test/fpsensor.mocklist @@ -4,5 +4,6 @@ */ #define CONFIG_TEST_MOCK_LIST \ - MOCK(FP_SENSOR) \ + MOCK(FP_SENSOR) \ + MOCK(MKBP_EVENTS) \ MOCK(TIMER) |