diff options
-rw-r--r-- | board/nucleo-f072rb/gpio.inc | 2 | ||||
-rw-r--r-- | board/stm32l476g-eval/gpio.inc | 2 | ||||
-rw-r--r-- | cts/common/dut_common.c | 1 | ||||
-rw-r--r-- | cts/common/th_common.c | 1 | ||||
-rwxr-xr-x | cts/cts.py | 10 | ||||
-rw-r--r-- | cts/gpio/dut.c | 99 | ||||
-rw-r--r-- | cts/gpio/gpio_common.h | 21 | ||||
-rw-r--r-- | cts/gpio/th.c | 97 |
8 files changed, 225 insertions, 8 deletions
diff --git a/board/nucleo-f072rb/gpio.inc b/board/nucleo-f072rb/gpio.inc index 91f8252e7f..7b38555ef8 100644 --- a/board/nucleo-f072rb/gpio.inc +++ b/board/nucleo-f072rb/gpio.inc @@ -23,4 +23,6 @@ ALTERNATE(PIN_MASK(A, 0x000C), 1, MODULE_UART, 0) /* USART2: PA2/PA3 */ /* CTS Signals */ GPIO(HANDSHAKE_INPUT, PIN(A, 4), GPIO_INPUT | GPIO_PULL_UP) GPIO(HANDSHAKE_OUTPUT, PIN(B, 0), GPIO_ODR_LOW) +GPIO(INPUT_TEST, PIN(C, 1), GPIO_INPUT | GPIO_PULL_UP) +GPIO(OUTPUT_TEST, PIN(C, 0), GPIO_ODR_LOW) #endif diff --git a/board/stm32l476g-eval/gpio.inc b/board/stm32l476g-eval/gpio.inc index 210c618e4c..4878f3b857 100644 --- a/board/stm32l476g-eval/gpio.inc +++ b/board/stm32l476g-eval/gpio.inc @@ -23,4 +23,6 @@ ALTERNATE(PIN_MASK(G, 0x0180), GPIO_ALT_F8, MODULE_UART, 0) /* LPUART: PG7/8 */ /* CTS Signals */ GPIO(HANDSHAKE_OUTPUT, PIN(D, 2), GPIO_ODR_LOW) GPIO(HANDSHAKE_INPUT, PIN(C, 12), GPIO_INPUT | GPIO_PULL_UP) +GPIO(OUTPUT_TEST, PIN(C, 11), GPIO_ODR_LOW) +GPIO(INPUT_TEST, PIN(C, 10), GPIO_INPUT | GPIO_PULL_UP) #endif diff --git a/cts/common/dut_common.c b/cts/common/dut_common.c index f8c18fd81c..9b0561eaa9 100644 --- a/cts/common/dut_common.c +++ b/cts/common/dut_common.c @@ -7,6 +7,7 @@ #include "timer.h" #include "watchdog.h" #include "cts_common.h" +#include "dut_common.h" /* Returns unknown because TH could potentially still get stuck * even if the DUT completes the sync diff --git a/cts/common/th_common.c b/cts/common/th_common.c index 1c75ef9dee..8e9bd47fa3 100644 --- a/cts/common/th_common.c +++ b/cts/common/th_common.c @@ -7,6 +7,7 @@ #include "timer.h" #include "watchdog.h" #include "cts_common.h" +#include "th_common.h" /* Return SUCCESS if and only if we reach end of function * Returning success here means sync was successful diff --git a/cts/cts.py b/cts/cts.py index 9c4940b6ff..79550a9aff 100755 --- a/cts/cts.py +++ b/cts/cts.py @@ -106,19 +106,17 @@ def flash_boards(dut_board, th_serial_loc): 'flash write_image erase build/' + th_board + '/ec.bin 0x08000000', 'reset halt'] - dut_flash_cmds = ['reset_config connect_assert_srst', + dut_flash_cmds = ['hla_serial ' + dut_hla, + 'reset_config connect_assert_srst', 'init', 'reset init', 'flash write_image erase build/' + dut_board + '/ec.bin 0x08000000', 'reset halt'] - if dut_hla != None: - dut_flash_cmds.insert(0, 'hla_serial ' + dut_hla) - openocd_cmd(th_flash_cmds, th_cfg) openocd_cmd(dut_flash_cmds, dut_cfg) - openocd_cmd(['init', 'reset init', 'resume'], th_cfg) - openocd_cmd(['init', 'reset init', 'resume'], dut_cfg) + openocd_cmd(['hla_serial ' + th_hla, 'init', 'reset init', 'resume'], th_cfg) + openocd_cmd(['hla_serial ' + dut_hla, 'init', 'reset init', 'resume'], dut_cfg) def main(): global ocd_script_dir diff --git a/cts/gpio/dut.c b/cts/gpio/dut.c index 7120a4da3e..c1b32ef0de 100644 --- a/cts/gpio/dut.c +++ b/cts/gpio/dut.c @@ -10,12 +10,109 @@ #include "watchdog.h" #include "dut_common.h" #include "cts_common.h" +#include "gpio_common.h" + +enum cts_error_code sync_test(void) +{ + return SUCCESS; +} + +enum cts_error_code set_high_test(void) +{ + gpio_set_flags(GPIO_OUTPUT_TEST, GPIO_ODR_LOW); + gpio_set_level(GPIO_OUTPUT_TEST, 1); + msleep(READ_WAIT_TIME_MS*2); + return UNKNOWN; +} + +enum cts_error_code set_low_test(void) +{ + gpio_set_flags(GPIO_OUTPUT_TEST, GPIO_ODR_LOW); + gpio_set_level(GPIO_OUTPUT_TEST, 0); + msleep(READ_WAIT_TIME_MS*2); + return UNKNOWN; +} + +enum cts_error_code read_high_test(void) +{ + int level; + + gpio_set_flags(GPIO_INPUT_TEST, GPIO_INPUT | GPIO_PULL_UP); + msleep(READ_WAIT_TIME_MS); + level = gpio_get_level(GPIO_INPUT_TEST); + if (level) + return SUCCESS; + else + return FAILURE; +} + +enum cts_error_code read_low_test(void) +{ + int level; + + gpio_set_flags(GPIO_INPUT_TEST, GPIO_INPUT | GPIO_PULL_UP); + msleep(READ_WAIT_TIME_MS); + level = gpio_get_level(GPIO_INPUT_TEST); + if (!level) + return SUCCESS; + else + return FAILURE; +} + +enum cts_error_code od_read_high_test(void) +{ + int level; + + gpio_set_flags(GPIO_OUTPUT_TEST, GPIO_ODR_HIGH | GPIO_PULL_UP); + msleep(READ_WAIT_TIME_MS); + level = gpio_get_level(GPIO_OUTPUT_TEST); + if (!level) + return SUCCESS; + else + return FAILURE; +} void cts_task(void) { + enum cts_error_code results[GPIO_CTS_TEST_COUNT]; + int i; + + sync(); + results[0] = sync_test(); sync(); - CPRINTS("Successful Sync!"); + results[1] = set_low_test(); + sync(); + results[2] = set_high_test(); + sync(); + results[3] = read_high_test(); + sync(); + results[4] = read_low_test(); + sync(); + results[5] = od_read_high_test(); + + CPRINTS("GPIO test suite finished"); uart_flush_output(); + CPRINTS("Results:"); + for (i = 0; i < GPIO_CTS_TEST_COUNT; i++) { + switch (results[i]) { + case SUCCESS: + CPRINTS("%d) Passed", i); + break; + case FAILURE: + CPRINTS("%d) Failed", i); + break; + case BAD_SYNC: + CPRINTS("%d) Bad sync", i); + break; + case UNKNOWN: + CPRINTS("%d) Test result unknown", i); + break; + default: + CPRINTS("%d) ErrorCode not recognized", i); + break; + } + } + while (1) { watchdog_reload(); sleep(1); diff --git a/cts/gpio/gpio_common.h b/cts/gpio/gpio_common.h new file mode 100644 index 0000000000..b19d23165a --- /dev/null +++ b/cts/gpio/gpio_common.h @@ -0,0 +1,21 @@ +/* Copyright 2016 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef __GPIO_COMMON_H +#define __GPIO_COMMON_H + +/* sync_test tests whether sync completes successfully + * set_low_test checks if the dut can set a line low + * set_high test checks if the dut can set a line high + * read_low_test checks if the dut can read a line that is low + * read_high_test checks if the dut can read a line that is high + * od_read_high_test checks if the dut reads its true pin level (success) + * or its register level when configured as a low open drain output pin + */ + +#define READ_WAIT_TIME_MS 100 +#define GPIO_CTS_TEST_COUNT 6 + +#endif diff --git a/cts/gpio/th.c b/cts/gpio/th.c index 7120a4da3e..ddc46f6602 100644 --- a/cts/gpio/th.c +++ b/cts/gpio/th.c @@ -10,12 +10,107 @@ #include "watchdog.h" #include "dut_common.h" #include "cts_common.h" +#include "gpio_common.h" + +enum cts_error_code sync_test(void) +{ + return SUCCESS; +} + +enum cts_error_code set_high_test(void) +{ + int level; + + gpio_set_flags(GPIO_INPUT_TEST, GPIO_INPUT | GPIO_PULL_UP); + msleep(READ_WAIT_TIME_MS); + level = gpio_get_level(GPIO_INPUT_TEST); + if (level) + return SUCCESS; + else + return FAILURE; +} + +enum cts_error_code set_low_test(void) +{ + int level; + + gpio_set_flags(GPIO_INPUT_TEST, GPIO_INPUT | GPIO_PULL_UP); + msleep(READ_WAIT_TIME_MS); + level = gpio_get_level(GPIO_INPUT_TEST); + if (!level) + return SUCCESS; + else + return FAILURE; +} + +enum cts_error_code read_high_test(void) +{ + gpio_set_flags(GPIO_OUTPUT_TEST, GPIO_ODR_LOW); + gpio_set_level(GPIO_OUTPUT_TEST, 1); + msleep(READ_WAIT_TIME_MS*2); + return UNKNOWN; +} + +enum cts_error_code read_low_test(void) +{ + gpio_set_flags(GPIO_OUTPUT_TEST, GPIO_ODR_LOW); + gpio_set_level(GPIO_OUTPUT_TEST, 0); + msleep(READ_WAIT_TIME_MS*2); + return UNKNOWN; +} + +enum cts_error_code od_read_high_test(void) +{ + gpio_set_flags(GPIO_INPUT_TEST, GPIO_OUTPUT | GPIO_ODR_LOW); + msleep(READ_WAIT_TIME_MS*2); + return UNKNOWN; +} void cts_task(void) { + enum cts_error_code results[GPIO_CTS_TEST_COUNT]; + int i; + + /* Don't bother checking sync's return value now because + * host will deal with hanging syncs/tests as well as + * interpreting test results later + */ + sync(); + results[0] = sync_test(); sync(); - CPRINTS("Successful Sync!"); + results[1] = set_low_test(); + sync(); + results[2] = set_high_test(); + sync(); + results[3] = read_high_test(); + sync(); + results[4] = read_low_test(); + sync(); + results[5] = od_read_high_test(); + + CPRINTS("GPIO test suite finished"); uart_flush_output(); + CPRINTS("Results:"); + for (i = 0; i < GPIO_CTS_TEST_COUNT; i++) { + switch (results[i]) { + case SUCCESS: + CPRINTS("%d) Passed", i); + break; + case FAILURE: + CPRINTS("%d) Failed", i); + break; + case BAD_SYNC: + CPRINTS("%d) Bad sync", i); + break; + case UNKNOWN: + CPRINTS("%d) Test result unknown", i); + break; + default: + CPRINTS("%d) ErrorCode not recognized", i); + break; + } + } + while (1) { watchdog_reload(); sleep(1); |