diff options
author | YH Lin <yueherngl@chromium.org> | 2022-12-03 00:17:55 +0000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-12-05 17:43:18 +0000 |
commit | dd732876495ed4942d00b9f9ca8dd3b01bad7120 (patch) | |
tree | bdff671e5ad3e71e30ab56f4f084f34a2fd72e28 /util | |
parent | 184d13e77614be3be5374d3fef9d1edf66ec8687 (diff) | |
download | chrome-ec-dd732876495ed4942d00b9f9ca8dd3b01bad7120.tar.gz |
Revert "Merge remote-tracking branch cros/main into factory-brya-14909.124.B-main"factory-brya-14909.124.B-main
This reverts commit 184d13e77614be3be5374d3fef9d1edf66ec8687.
Reason for revert: broken build due to ec-utils.
Original change's description:
> Merge remote-tracking branch cros/main into factory-brya-14909.124.B-main
>
> Generated by: util/update_release_branch.py --baseboard brya --relevant_paths_file
> baseboard/brya/relevant-paths.txt factory-brya-14909.124.B-main
>
> Relevant changes:
>
> git log --oneline 19d4d68ffa..aa40b859b3 -- baseboard/brya board/agah
> board/anahera board/banshee board/brya board/crota board/felwinter
> board/gimble board/kano board/mithrax board/osiris board/primus
> board/redrix board/taeko board/taniks board/vell board/volmar
> driver/bc12/pi3usb9201_public.* driver/charger/bq25710.*
> driver/ppc/nx20p348x.* driver/ppc/syv682x_public.*
> driver/retimer/bb_retimer_public.* driver/tcpm/nct38xx.*
> driver/tcpm/ps8xxx_public.* driver/tcpm/tcpci.* include/power/alderlake*
> include/intel_x86.h power/alderlake* power/intel_x86.c
> util/getversion.sh
>
> e6da633c38 driver: Sort header files
> 234a87ae2d tcpci: Add FRS enable to driver structure
> a56be59ccd tcpm_header: add test for tcpm_dump_registers
> 57b3256963 Rename CONFIG_CHARGER_INPUT_CURRENT to _CHARGER_DEFAULT_CURRENT_LIMIT
> e420c8ff9a marasov: Modify TypeC and TypeA configuration.
> 43b53e0045 Add default implementation of board_set_charge_limit
> b75dc90677 Add CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT
> f1b563c350 baseboard: Sort header files
> 7d01b1e58d driver/retimer/ps8818.h: Add I2C ADDR FLAGS 0x30, 0x58, 0x70
> ec31407993 Add CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT
> 8f89f69a5b crota: disable lid angle sensor for clamshell
>
> BRANCH=None
> BUG=b:260630630 b:163093572 b:259002141 b:255184961 b:259354679
> BUG=b:247100970 b:254328661
> TEST=`emerge-brya chromeos-ec`
>
> Force-Relevant-Builds: all
> Change-Id: I0ecfa0e6af68631283c7a9e8f1afb9d827176c62
> Signed-off-by: YH Lin <yueherngl@google.com>
Bug: b:260630630 b:163093572 b:259002141 b:255184961 b:259354679
Bug: b:247100970 b:254328661
Change-Id: Ia14942d1bd6a502062399d77cb59d1f4b549b2c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4077247
Auto-Submit: YH Lin <yueherngl@chromium.org>
Tested-by: YH Lin <yueherngl@chromium.org>
Reviewed-by: Boris Mittelberg <bmbm@google.com>
Commit-Queue: YH Lin <yueherngl@chromium.org>
Diffstat (limited to 'util')
-rw-r--r-- | util/build.mk | 8 | ||||
-rwxr-xr-x | util/build_with_clang.py | 70 | ||||
-rw-r--r-- | util/cbi-util.c | 15 | ||||
-rwxr-xr-x | util/check_clang_format.py | 10 | ||||
-rwxr-xr-x | util/clangd_config.py | 2 | ||||
-rw-r--r-- | util/comm-dev.cc | 5 | ||||
-rw-r--r-- | util/comm-host.h | 8 | ||||
-rw-r--r-- | util/config_allowed.txt | 18 | ||||
-rw-r--r-- | util/corsola-relevant-paths.txt | 32 | ||||
-rwxr-xr-x | util/crash_analyzer.py | 18 | ||||
-rw-r--r-- | util/cros_ec_dev.h | 3 | ||||
-rw-r--r-- | util/ecst.h | 3 | ||||
-rw-r--r-- | util/ectool.cc | 114 | ||||
-rw-r--r-- | util/export_taskinfo.c | 4 | ||||
-rw-r--r-- | util/flash_fp_mcu | 20 | ||||
-rw-r--r-- | util/gen_emmc_transfer_data.c | 4 | ||||
-rw-r--r-- | util/gen_touchpad_hash.c | 12 | ||||
-rw-r--r-- | util/genvif.c | 24 | ||||
-rw-r--r-- | util/gpios_to_zephyr_dts.c | 2 | ||||
-rw-r--r-- | util/iteflash.c | 21 | ||||
-rwxr-xr-x | util/kconfig_check.py | 4 | ||||
-rwxr-xr-x | util/run_host_test | 84 | ||||
-rwxr-xr-x | util/twister_launcher.py | 182 | ||||
-rwxr-xr-x | util/twister_tags.py | 1 | ||||
-rwxr-xr-x | util/uart_stress_tester.py | 11 | ||||
-rwxr-xr-x | util/update_release_branch.py | 354 | ||||
-rw-r--r-- | util/usb_if.c | 4 | ||||
-rw-r--r-- | util/uut/com_port.h | 1 | ||||
-rwxr-xr-x | util/zephyr_to_resultdb.py | 96 |
29 files changed, 369 insertions, 761 deletions
diff --git a/util/build.mk b/util/build.mk index 12479d4a7c..2f7f6c48ff 100644 --- a/util/build.mk +++ b/util/build.mk @@ -97,11 +97,11 @@ build-util-bin-y += gen_touchpad_hash # Assume RW section (touchpad FW must be identical for both RO+RW) $(out)/util/gen_touchpad_hash: BUILD_LDFLAGS += -DSECTION_IS_RW=$(EMPTY) -BUILD_OPENSSL_CFLAGS := $(shell $(BUILD_PKG_CONFIG) --cflags openssl) -BUILD_OPENSSL_LDFLAGS := $(shell $(BUILD_PKG_CONFIG) --libs openssl) +HOST_OPENSSL_CFLAGS := $(shell $(HOST_PKG_CONFIG) --cflags openssl) +HOST_OPENSSL_LDFLAGS := $(shell $(HOST_PKG_CONFIG) --libs openssl) -$(out)/util/gen_touchpad_hash: BUILD_CFLAGS += $(BUILD_OPENSSL_CFLAGS) -$(out)/util/gen_touchpad_hash: BUILD_LDFLAGS += $(BUILD_OPENSSL_LDFLAGS) +$(out)/util/gen_touchpad_hash: BUILD_CFLAGS += $(HOST_OPENSSL_CFLAGS) +$(out)/util/gen_touchpad_hash: BUILD_LDFLAGS += $(HOST_OPENSSL_LDFLAGS) deps-y += $(out)/util/gen_touchpad_hash.d endif # CONFIG_TOUCHPAD_VIRTUAL_OFF diff --git a/util/build_with_clang.py b/util/build_with_clang.py index ae707718e4..a0afb8a4cd 100755 --- a/util/build_with_clang.py +++ b/util/build_with_clang.py @@ -10,7 +10,6 @@ import concurrent import logging import multiprocessing import os -import shutil import subprocess import sys import typing @@ -28,12 +27,10 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ # Boards that use CHIP:=stm32 and *not* CHIP_FAMILY:=stm32f0 # git grep --name-only 'CHIP:=stm32' | xargs grep -L 'CHIP_FAMILY:=stm32f0' | sed 's#board/\(.*\)/build.mk#"\1",#' "baklava", - "bellis", "discovery", "gingerbread", "hatch_fp", "hyperdebug", - "munna", "nocturne_fp", "nucleo-f411re", "nucleo-g431rb", @@ -46,11 +43,8 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ # Boards that use CHIP:=stm32 *and* CHIP_FAMILY:=stm32f0 # git grep --name-only 'CHIP:=stm32' | xargs grep -L 'CHIP_FAMILY:=stm32f0' | sed 's#board/\(.*\)/build.mk#"\1",#' "bland", - "burnet", "c2d2", - "cerise", "coffeecake", - "damu", "dingdong", "discovery-stm32f072", "don", @@ -62,11 +56,6 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ "gelatin", "hammer", "hoho", - "kakadu", - "kappa", - "katsu", - "krane", - "kukui", "magnemite", "masterball", "minimuffin", @@ -78,23 +67,14 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ "rainier", "scarlet", "servo_micro", - "servo_v4", "servo_v4p1", "staff", "star", - "stern", "tigertail", "twinkie", "wand", - "willow", "zed", "zinger", - # Boards that use CHIP:=mchp - # git grep --name-only 'CHIP:=mchp' | sed 's#board/\(.*\)/build.mk#"\1",#' - "adlrvpp_mchp1521", - "adlrvpp_mchp1727", - "mchpevb1", - "reef_mchp", # Boards that use CHIP:=max32660 # git grep --name-only 'CHIP:=max32660' | sed 's#board/\(.*\)/build.mk#"\1",#' "max32660-eval", @@ -110,6 +90,7 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ "banshee", "berknip", "bloog", + "bobba", "boldar", "brask", "brya", @@ -118,10 +99,12 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ "careena", "casta", "chronicler", + "coachz", "collis", "copano", "coral", "corori", + "corori2", "cret", "crota", "dalboz", @@ -144,7 +127,6 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ "fleex", "foob", "gaelin", - "gelarshie", "genesis", "gimble", "grunt", @@ -171,7 +153,6 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ "lux", "madoo", "magolor", - "marasov", "marzipan", "meep", "metaknight", @@ -184,7 +165,6 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ "nautilus", "nightfury", "nipperkin", - "nocturne", "npcx7_evb", "npcx9_evb", "npcx_evb", @@ -246,7 +226,6 @@ NDS32_BOARDS = [ "beetley", "blipper", "boten", - "dibbi", "drawcia", "galtic", "gooey", @@ -282,20 +261,39 @@ RISCV_BOARDS = [ ] BOARDS_THAT_FAIL_WITH_CLANG = [ + # Boards that use CHIP:=stm32 and *not* CHIP_FAMILY:=stm32f0 + "bellis", # overflows flash + "munna", # overflows flash # Boards that use CHIP:=stm32 *and* CHIP_FAMILY:=stm32f0 + "burnet", # overflows flash + "cerise", # overflows flash "chocodile_vpdmcu", # compilation error: b/254710459 + "damu", # overflows flash "fennel", # overflows flash "jacuzzi", # overflows flash "juniper", # overflows flash + "kakadu", # overflows flash + "kappa", # overflows flash + "katsu", # overflows flash "kodama", # overflows flash + "krane", # overflows flash + "kukui", # overflows flash "makomo", # overflows flash "oak", # overflows flash + "servo_v4", # overflows flash + "stern", # overflows flash + "willow", # overflows flash + # Boards that use CHIP:=mchp + # git grep --name-only 'CHIP:=mchp' | sed 's#board/\(.*\)/build.mk#"\1",#' + "adlrvpp_mchp1521", # compilation errors + "adlrvpp_mchp1727", # compilation errors + "mchpevb1", # compilation errors + "reef_mchp", # compilation errors # Boards that use CHIP:=npcx - "bobba", # overflows flash - "coachz", # overflows flash - "corori2", # overflows flash "garg", # overflows flash + "gelarshie", # overflows flash "mushu", # overflows flash + "nocturne", # overflows flash "terrador", # overflows flash "volteer", # overflows flash "waddledoo", # overflows flash @@ -362,27 +360,9 @@ def main() -> int: "--num_threads", "-j", type=int, default=multiprocessing.cpu_count() ) - group = parser.add_mutually_exclusive_group(required=False) - group.add_argument( - "--clean", - action="store_true", - help="Remove build directory before compiling", - ) - group.add_argument( - "--no-clean", - dest="clean", - action="store_false", - help="Do not remove build directory before compiling", - ) - parser.set_defaults(clean=True) - args = parser.parse_args() logging.basicConfig(level=args.log_level) - if args.clean: - logging.debug("Removing build directory") - shutil.rmtree("./build", ignore_errors=True) - check_boards() logging.debug("Building with %d threads", args.num_threads) diff --git a/util/cbi-util.c b/util/cbi-util.c index 2c262c181b..5bea9a04b9 100644 --- a/util/cbi-util.c +++ b/util/cbi-util.c @@ -5,22 +5,21 @@ * Cros Board Info utility */ -#include "crc8.h" -#include "cros_board_info.h" - +#include <compile_time_macros.h> #include <errno.h> +#include <dirent.h> +#include <getopt.h> #include <limits.h> #include <stdarg.h> #include <stdint.h> #include <stdio.h> -#include <stdlib.h> #include <string.h> - -#include <compile_time_macros.h> -#include <dirent.h> -#include <getopt.h> +#include <stdlib.h> #include <unistd.h> +#include "cros_board_info.h" +#include "crc8.h" + #define ARGS_MASK_BOARD_VERSION BIT(0) #define ARGS_MASK_FILENAME BIT(1) #define ARGS_MASK_SIZE BIT(2) diff --git a/util/check_clang_format.py b/util/check_clang_format.py index 5862c02a3d..df98bb0eda 100755 --- a/util/check_clang_format.py +++ b/util/check_clang_format.py @@ -12,7 +12,6 @@ the pre-upload checks. import logging import pathlib -import shlex import subprocess import sys from typing import List @@ -28,11 +27,6 @@ def main(argv=None): action="store_true", help="Fix any formatting errors automatically.", ) - parser.add_argument( - "file", - nargs="*", - help="File or directory to clang-format.", - ) opts = parser.parse_args(argv) logging.info("Validating all code is formatted with clang-format.") @@ -40,7 +34,7 @@ def main(argv=None): all_files = [ ec_dir / path for path in subprocess.run( - ["git", "ls-files", "-z"] + opts.file, + ["git", "ls-files", "-z"], check=True, cwd=ec_dir, stdout=subprocess.PIPE, @@ -62,14 +56,12 @@ def main(argv=None): if path.name.endswith(".c") or path.name.endswith(".h"): cmd.append(path) - logging.debug("Running %s", " ".join(shlex.quote(str(x)) for x in cmd)) result = subprocess.run( cmd, check=False, cwd=ec_dir, stderr=subprocess.PIPE, encoding="utf-8", - stdin=subprocess.DEVNULL, ) if result.stderr: logging.error("All C source must be formatted with clang-format!") diff --git a/util/clangd_config.py b/util/clangd_config.py index 1e013b4159..2553707c43 100755 --- a/util/clangd_config.py +++ b/util/clangd_config.py @@ -32,7 +32,7 @@ def ec_fetch_boards(ec_root: Path) -> Optional[List[str]]: def zephyr_fetch_projects(ec_root: Path) -> Optional[List[str]]: """Return a list of Zephyr projects seen.""" - base = str(ec_root) + "/zephyr/program/" + base = str(ec_root) + "/zephyr/projects/" boards = glob.glob(base + "*") if boards is None: diff --git a/util/comm-dev.cc b/util/comm-dev.cc index bbb79a448c..f6467492f9 100644 --- a/util/comm-dev.cc +++ b/util/comm-dev.cc @@ -292,8 +292,3 @@ int comm_init_dev(const char *device_name) return 0; } - -int comm_get_fd() -{ - return fd; -} diff --git a/util/comm-host.h b/util/comm-host.h index 0f07bb48f3..907df3df96 100644 --- a/util/comm-host.h +++ b/util/comm-host.h @@ -53,14 +53,6 @@ int comm_init_alt(int interfaces, const char *device_name, int i2c_bus); int comm_init_dev(const char *device_name); /** - * Get the file descriptor associated with the dev interface. comm_init_dev - * must be called first in order for the file descriptor to be valid. - * - * @return file descriptor - */ -int comm_get_fd(void); - -/** * Initialize input & output buffers * * @return 0 in case of success, or error code. diff --git a/util/config_allowed.txt b/util/config_allowed.txt index f7e20b379c..e503e96f94 100644 --- a/util/config_allowed.txt +++ b/util/config_allowed.txt @@ -122,7 +122,15 @@ CONFIG_BOARD_I2C_ADDR_FLAGS CONFIG_BOARD_ID_CMD_ACPI_EC1 CONFIG_BOARD_POST_GPIO_INIT CONFIG_BOARD_PRE_INIT +CONFIG_BODY_DETECTION +CONFIG_BODY_DETECTION_CONFIDENCE_DELTA +CONFIG_BODY_DETECTION_MAX_WINDOW_SIZE +CONFIG_BODY_DETECTION_OFF_BODY_CON +CONFIG_BODY_DETECTION_ON_BODY_CON CONFIG_BODY_DETECTION_SENSOR +CONFIG_BODY_DETECTION_STATIONARY_DURATION +CONFIG_BODY_DETECTION_VAR_NOISE_FACTOR +CONFIG_BODY_DETECTION_VAR_THRESHOLD CONFIG_BOOTBLOCK CONFIG_BOOTCFG_VALUE CONFIG_BOOT_HEADER_STORAGE_OFF @@ -161,6 +169,7 @@ CONFIG_CHARGE_MANAGER_BAT_PCT_SAFE_MODE_EXIT CONFIG_CHARGE_MANAGER_DRP_CHARGING CONFIG_CHARGE_MANAGER_EXTERNAL_POWER_LIMIT CONFIG_CHARGE_MANAGER_SAFE_MODE +CONFIG_CHARGE_STATE_DEBUG CONFIG_CHIPSET_ALDERLAKE CONFIG_CHIPSET_APL_GLK CONFIG_CHIPSET_APOLLOLAKE @@ -278,6 +287,7 @@ CONFIG_CMD_POWERLED CONFIG_CMD_POWER_AP CONFIG_CMD_PPC_DUMP CONFIG_CMD_PS2 +CONFIG_CMD_PWR_AVG CONFIG_CMD_RAND CONFIG_CMD_REGULATOR CONFIG_CMD_RESET_FLAGS @@ -332,6 +342,7 @@ CONFIG_CROS_EC_RW_MEM_SIZE CONFIG_CTN730 CONFIG_CTS_TASK_LIST CONFIG_CURVE25519 +CONFIG_CUSTOM_FAN_CONTROL CONFIG_DATA_RAM_SIZE CONFIG_DEBUG_BRINGUP CONFIG_DEBUG_DISABLE_WRITE_BUFFER @@ -376,6 +387,7 @@ CONFIG_ENABLE_JTAG_SELECTION CONFIG_EVENT_LOG_SIZE CONFIG_EXPERIMENTAL_CONSOLE CONFIG_EXTENDED_VERSION_INFO +CONFIG_EXTPOWER_DEBOUNCE_MS CONFIG_FAKE_SHMEM CONFIG_FANS CONFIG_FAN_DSLEEP @@ -407,7 +419,6 @@ CONFIG_FLASH_WRITE_SIZE CONFIG_FMAP CONFIG_FOO CONFIG_FORCE_CONSOLE_RESUME -CONFIG_FPU CONFIG_FPU_WARNINGS CONFIG_FP_SENSOR_ELAN515 CONFIG_FP_SENSOR_ELAN80 @@ -421,6 +432,7 @@ CONFIG_FW_PSTATE_OFF CONFIG_FW_PSTATE_SIZE CONFIG_GESTURE_DETECTION CONFIG_GESTURE_DETECTION_MASK +CONFIG_GESTURE_HOST_DETECTION CONFIG_GESTURE_ORIENTATION CONFIG_GESTURE_SAMPLING_INTERVAL_MS CONFIG_GESTURE_SENSOR_DOUBLE_TAP @@ -447,8 +459,10 @@ CONFIG_H2RAM_BASE CONFIG_H2RAM_HOST_LPC_IO_BASE CONFIG_H2RAM_SIZE CONFIG_HAS_TASK_PD_INT +CONFIG_HIBERNATE CONFIG_HIBERNATE_BATT_PCT CONFIG_HIBERNATE_BATT_SEC +CONFIG_HIBERNATE_DELAY_SEC CONFIG_HIBERNATE_PSL_COMPENSATE_RTC CONFIG_HIBERNATE_PSL_OUT_FLAGS CONFIG_HIBERNATE_PSL_VCC1_RST_WAKEUP @@ -549,6 +563,7 @@ CONFIG_ITE_FLASH_SUPPORT CONFIG_KEYBOARD_ASSISTANT_KEY CONFIG_KEYBOARD_BACKLIGHT CONFIG_KEYBOARD_BOOT_KEYS +CONFIG_KEYBOARD_FACTORY_TEST CONFIG_KEYBOARD_IRQ_GPIO CONFIG_KEYBOARD_KSO_BASE CONFIG_KEYBOARD_KSO_HIGH_DRIVE @@ -812,6 +827,7 @@ CONFIG_STM32_CLOCK_HSE_HZ CONFIG_STM32_CLOCK_LSE CONFIG_STM32_EXTENDED_RESET_FLAGS CONFIG_STM32_SPI1_CONTROLLER +CONFIG_STM_HWTIMER32 CONFIG_STREAM_SIGNATURE CONFIG_STREAM_USART CONFIG_STREAM_USART1 diff --git a/util/corsola-relevant-paths.txt b/util/corsola-relevant-paths.txt deleted file mode 100644 index 3bb8e4f5a7..0000000000 --- a/util/corsola-relevant-paths.txt +++ /dev/null @@ -1,32 +0,0 @@ -# Here you can place files of interest to be included in the commit message for -# merge commits to cros/firmware-corsola-15194.B -common/charge_state_v2.c -common/dps.c -common/mkbp_* -common/usb_charger.c -common/usb_common.c -common/usbc/*_pd_* -common/usbc/dp_alt_mode.c -common/usbc/usb_pe_drp_sm.c -common/usbc/usb_prl_sm.c -common/usbc/usb_sm.c -common/usbc/usb_tc_drp_acc_trysrc_sm.c -driver/battery/smart.c -driver/bc12/pi3usb9201.* -driver/charger/isl923x.* -driver/charger/rt949* -driver/ppc/nx20p348x.* -driver/ppc/rt1718s.* -driver/ppc/syv682x.* -driver/tcpm/anx7447.* -driver/tcpm/rt1718s.* -driver/tcpm/tcpci.* -driver/usb_mux/it5205.* -driver/usb_mux/ps8743.* -power/mt8186.c -zephyr/boards/arm/npcx9/* -zephyr/boards/riscv/it8xxx2/* -zephyr/drivers/* -zephyr/projects/corsola/* -zephyr/projects/corsola/* -zephyr/shim/* diff --git a/util/crash_analyzer.py b/util/crash_analyzer.py index 88592f800a..c2e07face2 100755 --- a/util/crash_analyzer.py +++ b/util/crash_analyzer.py @@ -124,23 +124,7 @@ def cm0_parse(match) -> dict: regs["ipsr"] = values[22] regs["cause"] = get_crash_cause(values[6]) # r4 - - # based on crash reports in case of asserrt the PC is in R3 - if regs["cause"] == "assert": - regs["symbol"] = get_symbol(values[5]) # r3 - else: - # Heuristics: try link register, then PC, then what is believed to be PC. - # When analyzing watchdogs, we try to be as close as possible to the caller - # function that caused the watchdog. - # That's why we prioritize LR (return address) over PC. - if regs["lr"] != -1: - regs["symbol"] = get_symbol(regs["lr"]) - elif regs["pc"] != -1: - regs["symbol"] = get_symbol(regs["pc"]) - else: - # Otherwise, if both LR and PC are empty, most probably - # PC is in R5. - regs["symbol"] = get_symbol(values[7]) # r5 + regs["symbol"] = get_symbol(values[7]) # r5 return regs diff --git a/util/cros_ec_dev.h b/util/cros_ec_dev.h index 6421afc601..3ffed56632 100644 --- a/util/cros_ec_dev.h +++ b/util/cros_ec_dev.h @@ -6,10 +6,9 @@ #ifndef __UTIL_CROS_EC_DEV_H #define __UTIL_CROS_EC_DEV_H -#include "ec_commands.h" - #include <linux/ioctl.h> #include <linux/types.h> +#include "ec_commands.h" #ifdef __cplusplus extern "C" { diff --git a/util/ecst.h b/util/ecst.h index fed160e22a..7d3dbbe153 100644 --- a/util/ecst.h +++ b/util/ecst.h @@ -11,10 +11,9 @@ Includes --------------------------------------------------------------------------*/ -#include <stdio.h> #include <stdlib.h> #include <string.h> - +#include <stdio.h> #include <curses.h> /*--------------------------------------------------------------------------- diff --git a/util/ectool.cc b/util/ectool.cc index fd27105d1f..61c0e85301 100644 --- a/util/ectool.cc +++ b/util/ectool.cc @@ -33,11 +33,8 @@ #include "lock/gec_lock.h" #include "misc_util.h" #include "panic.h" -#include "tablet_mode.h" #include "usb_pd.h" -#include <libec/add_entropy_command.h> - /* Maximum flash size (16 MB, conservative) */ #define MAX_FLASH_SIZE 0x1000000 @@ -316,8 +313,6 @@ const char help_str[] = " Display system info.\n" " switches\n" " Prints current EC switch positions\n" - " tabletmode [on | off | reset]\n" - " Manually force tablet mode to on, off or reset.\n" " temps <sensorid>\n" " Print temperature and temperature ratio between fan_off and\n" " fan_max values, which could be a fan speed if it's controlled\n" @@ -569,24 +564,39 @@ int cmd_adc_read(int argc, char *argv[]) int cmd_add_entropy(int argc, char *argv[]) { - bool reset = false; + struct ec_params_rollback_add_entropy p; + int rv; + int tries = 100; /* Wait for 10 seconds at most */ + if (argc >= 2 && !strcmp(argv[1], "reset")) - reset = true; + p.action = ADD_ENTROPY_RESET_ASYNC; + else + p.action = ADD_ENTROPY_ASYNC; - ec::AddEntropyCommand add_entropy_command(reset); - if (!add_entropy_command.Run(comm_get_fd())) { - fprintf(stderr, "Failed to run addentropy command\n"); - return -1; - } + rv = ec_command(EC_CMD_ADD_ENTROPY, 0, &p, sizeof(p), NULL, 0); - int rv = add_entropy_command.Result(); - if (rv != EC_RES_SUCCESS) { - rv = -EECRESULT - add_entropy_command.Result(); - fprintf(stderr, "Failed to add entropy: %d\n", rv); - return rv; + if (rv != EC_RES_SUCCESS) + goto out; + + while (tries--) { + usleep(100000); + + p.action = ADD_ENTROPY_GET_RESULT; + rv = ec_command(EC_CMD_ADD_ENTROPY, 0, &p, sizeof(p), NULL, 0); + + if (rv == EC_RES_SUCCESS) { + printf("Entropy added successfully\n"); + return EC_RES_SUCCESS; + } + + /* Abort if EC returns an error other than EC_RES_BUSY. */ + if (rv <= -EECRESULT && rv != -EECRESULT - EC_RES_BUSY) + goto out; } - printf("Entropy added successfully\n"); + rv = -EECRESULT - EC_RES_TIMEOUT; +out: + fprintf(stderr, "Failed to add entropy: %d\n", rv); return rv; } @@ -874,7 +884,7 @@ int cmd_test(int argc, char *argv[]) int cmd_s5(int argc, char *argv[]) { struct ec_params_get_set_value p; - struct ec_response_get_set_value r; + struct ec_params_get_set_value r; int rv, param; p.flags = 0; @@ -7261,37 +7271,6 @@ int cmd_switches(int argc, char *argv[]) return 0; } -int cmd_tabletmode(int argc, char *argv[]) -{ - struct ec_params_set_tablet_mode p; - - if (argc != 2) - return EC_ERROR_PARAM_COUNT; - - memset(&p, 0, sizeof(p)); - if (argv[1][0] == 'o' && argv[1][1] == 'n') { - p.tablet_mode = TABLET_MODE_FORCE_TABLET; - } else if (argv[1][0] == 'o' && argv[1][1] == 'f') { - p.tablet_mode = TABLET_MODE_FORCE_CLAMSHELL; - } else if (argv[1][0] == 'r') { - // Match tablet mode to the current HW orientation. - p.tablet_mode = TABLET_MODE_DEFAULT; - } else { - return EC_ERROR_PARAM1; - } - - int rv = ec_command(EC_CMD_SET_TABLET_MODE, 0, &p, sizeof(p), NULL, 0); - rv = (rv < 0 ? rv : 0); - - if (rv < 0) { - fprintf(stderr, "Failed to set tablet mode, rv=%d\n", rv); - } else { - printf("\n"); - printf("SUCCESS. The tablet mode has been set.\n"); - } - return rv; -} - int cmd_wireless(int argc, char *argv[]) { char *e; @@ -10170,10 +10149,7 @@ int cmd_typec_control(int argc, char *argv[]) " <mux_mode> is one of: dp, dock, usb, tbt,\n" " usb4, none, safe\n" " 5: Enable bist share mode\n" - " args: <0: DISABLE, 1: ENABLE>\n" - " 6: Send VDM REQ\n" - " args: <tx_type vdm_hdr [vdo...]>\n" - " <tx_type> is 0 - SOP, 1 - SOP', 2 - SOP''\n", + " args: <0: DISABLE, 1: ENABLE>\n", argv[0]); return -1; } @@ -10277,35 +10253,6 @@ int cmd_typec_control(int argc, char *argv[]) } p.bist_share_mode = conversion_result; break; - case TYPEC_CONTROL_COMMAND_SEND_VDM_REQ: - if (argc < 5) { - fprintf(stderr, "Missing VDM header and type\n"); - return -1; - } - if (argc > 4 + VDO_MAX_SIZE) { - fprintf(stderr, "Too many VDOs\n"); - return -1; - } - - conversion_result = strtol(argv[3], &endptr, 0); - if ((endptr && *endptr) || conversion_result > UINT8_MAX || - conversion_result < 0) { - fprintf(stderr, "Bad SOP* type\n"); - return -1; - } - p.vdm_req_params.partner_type = conversion_result; - - int vdm_index; - for (vdm_index = 0; vdm_index < argc - 4; vdm_index++) { - uint32_t vdm_entry = - strtoul(argv[vdm_index + 4], &endptr, 0); - if (endptr && *endptr) { - fprintf(stderr, "Bad VDO\n"); - return -1; - } - p.vdm_req_params.vdm_data[vdm_index] = vdm_entry; - } - p.vdm_req_params.vdm_data_objects = vdm_index; } rv = ec_command(EC_CMD_TYPEC_CONTROL, 0, &p, sizeof(p), ec_inbuf, @@ -11044,7 +10991,6 @@ const struct command commands[] = { { "sysinfo", cmd_sysinfo }, { "port80flood", cmd_port_80_flood }, { "switches", cmd_switches }, - { "tabletmode", cmd_tabletmode }, { "temps", cmd_temperature }, { "tempsinfo", cmd_temp_sensor_info }, { "test", cmd_test }, diff --git a/util/export_taskinfo.c b/util/export_taskinfo.c index 0fe8644792..af40ef8de6 100644 --- a/util/export_taskinfo.c +++ b/util/export_taskinfo.c @@ -6,11 +6,11 @@ * section definitions to export different tasklists. */ +#include <stdint.h> + #include "config.h" #include "task_id.h" -#include <stdint.h> - #ifdef SECTION_IS_RO #define GET_TASKINFOS_FUNC get_ro_taskinfos #elif defined(SECTION_IS_RW) diff --git a/util/flash_fp_mcu b/util/flash_fp_mcu index 4f8fa26749..578382c213 100644 --- a/util/flash_fp_mcu +++ b/util/flash_fp_mcu @@ -702,26 +702,6 @@ config_ghost() { config_brya } -config_rex() { - readonly TRANSPORT="SPI" - readonly DEVICE="/dev/spidev0.0" - - # See kernel/v5.15/drivers/pinctrl/intel/pinctrl-meteorlake.c - # for pin name and pin number. - # Examine `cat /sys/kernel/debug/pinctrl/INTC1083:00/gpio-ranges` on a - # rex device to determine gpio number from pin number. - # For example: GPP_B11, the pin number is 215 from the pinctrl-meteorlake.c. - # From the gpio-ranges, the gpio value is 925 + (215-204) = 936 - - readonly GPIO_CHIP="gpiochip573" - # FPMCU RST_ODL is on GPP_C23 = 637 + (52 - 29) = 660 - readonly GPIO_NRST=660 - # FPMCU BOOT0 is on GPP_C22 = 637 + (51 - 29) = 659 - readonly GPIO_BOOT0=659 - # FP_PWR_EN is on GPP_B11 = 925 + (215-204) = 936 - readonly GPIO_PWREN=936 -} - config_zork() { readonly TRANSPORT="UART" readonly DEVICE="/dev/ttyS1" diff --git a/util/gen_emmc_transfer_data.c b/util/gen_emmc_transfer_data.c index 1de9d6b5a0..3c80724594 100644 --- a/util/gen_emmc_transfer_data.c +++ b/util/gen_emmc_transfer_data.c @@ -6,14 +6,14 @@ * eMMC protocol. */ +#include <err.h> #include <errno.h> +#include <getopt.h> #include <stdint.h> #include <stdio.h> #include <string.h> #include <compile_time_macros.h> -#include <err.h> -#include <getopt.h> /* eMMC transfer block size */ #define BLOCK_SIZE 512 diff --git a/util/gen_touchpad_hash.c b/util/gen_touchpad_hash.c index edf1022bf9..98370038b7 100644 --- a/util/gen_touchpad_hash.c +++ b/util/gen_touchpad_hash.c @@ -3,16 +3,16 @@ * found in the LICENSE file. */ -#include "config.h" - -#include <stdint.h> +#include <err.h> +#include <getopt.h> #include <stdio.h> +#include <stdint.h> #include <string.h> +#include <unistd.h> -#include <err.h> -#include <getopt.h> #include <openssl/sha.h> -#include <unistd.h> + +#include "config.h" static void print_hex(FILE *out, uint8_t *digest, int len, int last) { diff --git a/util/genvif.c b/util/genvif.c index 892bf14367..543577cb11 100644 --- a/util/genvif.c +++ b/util/genvif.c @@ -5,25 +5,25 @@ #define _GNU_SOURCE /* for asprintf */ -#include "charge_manager.h" -#include "config.h" -#include "genvif.h" -#include "usb_pd.h" -#include "usb_pd_pdo.h" -#include "usb_pd_tcpm.h" - -#include <ctype.h> #include <errno.h> -#include <limits.h> #include <stdarg.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> -#include <stdlib.h> #include <string.h> - -#include <dirent.h> +#include <stdlib.h> #include <getopt.h> +#include <dirent.h> +#include <limits.h> +#include <ctype.h> + +#include "config.h" +#include "usb_pd.h" +#include "usb_pd_pdo.h" +#include "usb_pd_tcpm.h" +#include "charge_manager.h" + +#include "genvif.h" #define VIF_APP_VENDOR_VALUE "Google" #define VIF_APP_NAME_VALUE "EC GENVIF" diff --git a/util/gpios_to_zephyr_dts.c b/util/gpios_to_zephyr_dts.c index 7efcd67ceb..d0e51b3e46 100644 --- a/util/gpios_to_zephyr_dts.c +++ b/util/gpios_to_zephyr_dts.c @@ -32,8 +32,8 @@ #define _POSIX_C_SOURCE 200809L #include <ctype.h> -#include <stdio.h> #include <stdlib.h> +#include <stdio.h> #include <string.h> /* diff --git a/util/iteflash.c b/util/iteflash.c index 8b03c2e4cb..9085365135 100644 --- a/util/iteflash.c +++ b/util/iteflash.c @@ -8,26 +8,25 @@ /* remove when ftdi_usb_purge_buffers has been replaced to follow libftdi */ #define _FTDI_DISABLE_DEPRECATED -#include "compile_time_macros.h" -#include "usb_if.h" - #include <errno.h> +#include <fcntl.h> +#include <ftdi.h> +#include <getopt.h> +#include <linux/i2c-dev.h> +#include <linux/i2c.h> #include <signal.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <time.h> - -#include <fcntl.h> -#include <ftdi.h> -#include <getopt.h> -#include <linux/i2c-dev.h> -#include <linux/i2c.h> #include <sys/ioctl.h> -#include <sys/wait.h> +#include <time.h> #include <unistd.h> +#include <sys/wait.h> + +#include "compile_time_macros.h" +#include "usb_if.h" /* Default FTDI device : Servo v2. */ #define SERVO_USB_VID 0x18d1 diff --git a/util/kconfig_check.py b/util/kconfig_check.py index f3d127175c..e745b3aeca 100755 --- a/util/kconfig_check.py +++ b/util/kconfig_check.py @@ -259,8 +259,8 @@ class KconfigCheck: dirs.remove("Kconfig") if "boards" in dirs: dirs.remove("boards") - if "program" in dirs: - dirs.remove("program") + if "projects" in dirs: + dirs.remove("projects") if "test" in dirs: dirs.remove("test") if "chip" in dirs: diff --git a/util/run_host_test b/util/run_host_test index 3ee8ccc7ed..3108da1852 100755 --- a/util/run_host_test +++ b/util/run_host_test @@ -26,7 +26,6 @@ class TestResult(enum.Enum): @property def reason(self): - """Return a map of test result enums to descriptions.""" return { TestResult.SUCCESS: 'passed', TestResult.FAIL: 'failed', @@ -36,12 +35,11 @@ class TestResult(enum.Enum): def run_test(path, timeout=10): - """Runs a test.""" start_time = time.monotonic() env = dict(os.environ) env['ASAN_OPTIONS'] = 'log_path=stderr' - with subprocess.Popen( + proc = subprocess.Popen( [path], bufsize=0, stdin=subprocess.PIPE, @@ -49,50 +47,49 @@ def run_test(path, timeout=10): env=env, encoding='utf-8', errors='replace', - ) as proc: - - # Put the output pipe in non-blocking mode. We will then select(2) - # on the pipe to know when we have bytes to process. - os.set_blocking(proc.stdout.fileno(), False) - - try: - output_buffer = io.StringIO() - while True: - select_timeout = timeout - (time.monotonic() - start_time) - if select_timeout <= 0: - return TestResult.TIMEOUT, output_buffer.getvalue() - - readable, _, _ = select.select( - [proc.stdout], [], [], select_timeout) - - if not readable: - # Indicates that select(2) timed out. - return TestResult.TIMEOUT, output_buffer.getvalue() - - output_buffer.write(proc.stdout.read()) - output_log = output_buffer.getvalue() - - if 'Pass!' in output_log: - return TestResult.SUCCESS, output_log - if 'Fail!' in output_log: - return TestResult.FAIL, output_log - if proc.poll(): - return TestResult.UNEXPECTED_TERMINATION, output_log - finally: - # Check if the process has exited. If not, send it a SIGTERM, wait - # for it to exit, and if it times out, kill the process directly. - if not proc.poll(): - try: - proc.terminate() - proc.wait(timeout) - except subprocess.TimeoutExpired: - proc.kill() + ) + + # Put the output pipe in non-blocking mode. We will then select(2) + # on the pipe to know when we have bytes to process. + os.set_blocking(proc.stdout.fileno(), False) + + try: + output_buffer = io.StringIO() + while True: + select_timeout = timeout - (time.monotonic() - start_time) + if select_timeout <= 0: + return TestResult.TIMEOUT, output_buffer.getvalue() + + readable, _, _ = select.select( + [proc.stdout], [], [], select_timeout) + + if not readable: + # Indicates that select(2) timed out. + return TestResult.TIMEOUT, output_buffer.getvalue() + + output_buffer.write(proc.stdout.read()) + output_log = output_buffer.getvalue() + + if 'Pass!' in output_log: + return TestResult.SUCCESS, output_log + if 'Fail!' in output_log: + return TestResult.FAIL, output_log + if proc.poll(): + return TestResult.UNEXPECTED_TERMINATION, output_log + finally: + # Check if the process has exited. If not, send it a SIGTERM, wait for + # it to exit, and if it times out, kill the process directly. + if not proc.poll(): + try: + proc.terminate() + proc.wait(timeout) + except subprocess.TimeoutExpired: + proc.kill() def parse_options(argv): - """Parse command line flags.""" parser = argparse.ArgumentParser() - parser.add_argument('-t', '--timeout', type=float, default=120, + parser.add_argument('-t', '--timeout', type=float, default=60, help='Timeout to kill test after.') parser.add_argument('--coverage', action='store_const', const='coverage', default='host', dest='test_target', @@ -104,7 +101,6 @@ def parse_options(argv): def main(argv): - """The main function.""" opts = parse_options(argv) # Tests will be located in build/host, unless the --coverage flag was diff --git a/util/twister_launcher.py b/util/twister_launcher.py index 11202f9343..033b4c59dd 100755 --- a/util/twister_launcher.py +++ b/util/twister_launcher.py @@ -37,10 +37,6 @@ parameters that may be used, please consult the Twister documentation. # version: "version:5.8.0.chromium.3" # > # wheel: < -# name: "infra/python/wheels/pyelftools-py2_py3" -# version: "version:0.29" -# > -# wheel: < # name: "infra/python/wheels/pykwalify-py2_py3" # version: "version:1.8.0" # > @@ -81,10 +77,8 @@ parameters that may be used, please consult the Twister documentation. import argparse import json import os -import pathlib import re import shlex -import shutil import subprocess import sys import time @@ -98,8 +92,7 @@ def find_checkout() -> Path: if cros_checkout is not None: return Path(cros_checkout) - # Attempt to locate checkout location relatively if being run outside of - # chroot. + # Attempt to locate checkout location relatively if being run outside of chroot. try: cros_checkout = Path(__file__).resolve().parents[4] assert (cros_checkout / "src").exists() @@ -174,75 +167,59 @@ def is_rdb_login(): return ret.returncode == 0 -def upload_results(ec_base, outdir): +def upload_results(ec_base): """Uploads Zephyr Test results to ResultDB""" flag = False if is_rdb_login(): - json_path = pathlib.Path(outdir) / "twister.json" - - if json_path.exists(): - cmd = [ - "rdb", - "stream", - "-new", - "-realm", - "chromium:public", - "--", - "vpython3", - str(ec_base / "util/zephyr_to_resultdb.py"), - "--result=" + str(json_path), - "--upload=True", - ] - - start_time = time.time() - ret = subprocess.run( - cmd, capture_output=True, text=True, check=True - ) - end_time = time.time() - - # Extract URL to test report from captured output - rdb_url = re.search( - r"(?P<url>https?://[^\s]+)", ret.stderr.split("\n")[0] - ).group("url") - print(f"\nTEST RESULTS ({end_time - start_time:.3f}s): {rdb_url}\n") - flag = ret.returncode == 0 + json_path = ec_base / "twister-out" / "twister.json" + cmd = [ + "rdb", + "stream", + "-new", + "-realm", + "chromium:public", + "--", + str(ec_base / "util/zephyr_to_resultdb.py"), + "--result=" + str(json_path), + "--upload=True", + ] + + start_time = time.time() + ret = subprocess.run(cmd, capture_output=True, text=True, check=True) + end_time = time.time() + + # Extract URL to test report from captured output + rdb_url = re.search( + r"(?P<url>https?://[^\s]+)", ret.stderr.split("\n")[0] + ).group("url") + print(f"\nTEST RESULTS ({end_time - start_time:.3f}s): {rdb_url}\n") + flag = ret.returncode == 0 else: print("Unable to upload test results, please run 'rdb auth-login'\n") return flag -def check_for_skipped_tests(outdir): +def check_for_skipped_tests(ec_base): """Checks Twister json test report for skipped tests""" found_skipped = False - json_path = pathlib.Path(outdir) / "twister.json" - if json_path.exists(): - with open(json_path) as file: - data = json.load(file) + json_path = ec_base / "twister-out" / "twister.json" + with open(json_path) as file: + data = json.load(file) - for testsuite in data["testsuites"]: - for testcase in testsuite["testcases"]: - if testcase["status"] == "skipped": - tc_name = testcase["identifier"] - print(f"TEST SKIPPED: {tc_name}") - found_skipped = True + for testsuite in data["testsuites"]: + for testcase in testsuite["testcases"]: + if testcase["status"] == "skipped": + tc_name = testcase["identifier"] + print(f"TEST SKIPPED: {tc_name}") + found_skipped = True - file.close() + file.close() return found_skipped -def append_cmake_compiler(cmdline, cmake_var, exe_options): - """Picks the first available exe from exe_options and adds a cmake variable - to cmdline.""" - for exe in exe_options: - exe_path = shutil.which(exe) - if exe_path: - cmdline.append(f"-x={cmake_var}={exe_path}") - return - - def main(): """Run Twister using defaults for the EC project.""" @@ -256,6 +233,21 @@ def main(): if ec_base.resolve() not in zephyr_modules: zephyr_modules.append(ec_base) + # Prepare environment variables for export to Twister. Inherit the parent + # process's environment, but set some default values if not already set. + twister_env = dict(os.environ) + is_in_chroot = Path("/etc/cros_chroot_version").is_file() + extra_env_vars = { + "TOOLCHAIN_ROOT": os.environ.get( + "TOOLCHAIN_ROOT", + str(ec_base / "zephyr") if is_in_chroot else zephyr_base, + ), + "ZEPHYR_TOOLCHAIN_VARIANT": os.environ.get( + "ZEPHYR_TOOLCHAIN_VARIANT", "llvm" if is_in_chroot else "host" + ), + } + twister_env.update(extra_env_vars) + # Twister CLI args # TODO(b/239165779): Reduce or remove the usage of label properties # Zephyr upstream has deprecated the label property. We need to allow @@ -271,7 +263,6 @@ def main(): f"-x=ZEPHYR_BASE={zephyr_base}", f"-x=ZEPHYR_MODULES={';'.join([str(p) for p in zephyr_modules])}", ] - is_in_chroot = Path("/etc/cros_chroot_version").is_file() # `-T` flags (used for specifying test directories to build and run) # require special handling. When run without `-T` flags, Twister will @@ -285,31 +276,11 @@ def main(): parser.add_argument("-T", "--testsuite-root", action="append") parser.add_argument("-p", "--platform", action="append") parser.add_argument("-v", "--verbose", action="count", default=0) - parser.add_argument("--gcov-tool") - parser.add_argument( - "--no-upload-cros-rdb", dest="upload_cros_rdb", action="store_false" - ) parser.add_argument( - "-O", - "--outdir", - default=os.path.join(os.getcwd(), "twister-out"), + "--gcov-tool", default=str(ec_base / "util" / "llvm-gcov.sh") ) parser.add_argument( - "--toolchain", - default=os.environ.get( - "ZEPHYR_TOOLCHAIN_VARIANT", - "llvm" if is_in_chroot else "host", - ), - ) - parser.add_argument( - "--gcc", dest="toolchain", action="store_const", const="host" - ) - parser.add_argument( - "--llvm", - "--clang", - dest="toolchain", - action="store_const", - const="llvm", + "--no-upload-cros-rdb", dest="upload_cros_rdb", action="store_false" ) intercepted_args, other_args = parser.parse_known_args() @@ -323,14 +294,19 @@ def main(): for arg in intercepted_args.testsuite_root: twister_cli.extend(["-T", arg]) else: - # Use this set of test suite roots when no -T args are present. This - # should encompass all current Zephyr EC tests. The paths are meant to - # be as specific as possible to limit Twister's search scope. This saves - # significant time when starting Twister. - twister_cli.extend(["-T", str(ec_base / "common")]) - twister_cli.extend(["-T", str(ec_base / "zephyr/test")]) + # Use EC base dir when no -T args specified. This will cause all + # Twister-compatible EC tests to run. + twister_cli.extend(["-T", str(ec_base)]) twister_cli.extend(["-T", str(zephyr_base / "tests/subsys/shell")]) + # Pass through the chosen coverage tool, or fall back on the default choice + # (see add_argument above). + twister_cli.extend( + [ + "--gcov-tool", + intercepted_args.gcov_tool, + ] + ) if intercepted_args.platform: # Pass user-provided -p args when present. for arg in intercepted_args.platform: @@ -340,32 +316,6 @@ def main(): twister_cli.extend(["-p", "native_posix"]) twister_cli.extend(["-p", "unit_testing"]) - twister_cli.extend(["--outdir", intercepted_args.outdir]) - - # Prepare environment variables for export to Twister. Inherit the parent - # process's environment, but set some default values if not already set. - twister_env = dict(os.environ) - extra_env_vars = { - "TOOLCHAIN_ROOT": os.environ.get( - "TOOLCHAIN_ROOT", - str(ec_base / "zephyr") if is_in_chroot else str(zephyr_base), - ), - "ZEPHYR_TOOLCHAIN_VARIANT": intercepted_args.toolchain, - } - gcov_tool = None - if intercepted_args.toolchain == "host": - gcov_tool = "gcov" - elif intercepted_args.toolchain == "llvm": - gcov_tool = str(ec_base / "util" / "llvm-gcov.sh") - else: - print("Unknown toolchain specified:", intercepted_args.toolchain) - if intercepted_args.gcov_tool: - gcov_tool = intercepted_args.gcov_tool - if gcov_tool: - twister_cli.extend(["--gcov-tool", gcov_tool]) - - twister_env.update(extra_env_vars) - # Append additional user-supplied args twister_cli.extend(other_args) @@ -384,7 +334,7 @@ def main(): # Invoke Twister and wait for it to exit. result = subprocess.run(twister_cli, env=twister_env, check=False) - if check_for_skipped_tests(intercepted_args.outdir): + if check_for_skipped_tests(ec_base): result.returncode = 1 if result.returncode == 0: @@ -393,7 +343,7 @@ def main(): print("TEST EXECUTION FAILED") if is_tool("rdb") and intercepted_args.upload_cros_rdb: - upload_results(ec_base, intercepted_args.outdir) + upload_results(ec_base) sys.exit(result.returncode) diff --git a/util/twister_tags.py b/util/twister_tags.py index 68ac5846bd..692fdc1e99 100755 --- a/util/twister_tags.py +++ b/util/twister_tags.py @@ -29,7 +29,6 @@ TAG_TO_DESCRIPTION = { "mkbp": "Testing the MKBP (Matrix Keyboard Protocol) stack", "system": "Directly test functions in common/system.c or shim/src/system.c", "spi": "SPI related tests", - "uart": "UART related tests", } SCRIPT_PATH = os.path.realpath(__file__) diff --git a/util/uart_stress_tester.py b/util/uart_stress_tester.py index 05976889d6..3b29a50a2b 100755 --- a/util/uart_stress_tester.py +++ b/util/uart_stress_tester.py @@ -90,7 +90,6 @@ class UartSerial: "touch " + FLAG_FILENAME, # Create a temp file ], "cleanup_cmd": [ - "\x03", "rm -f " + FLAG_FILENAME, # Remove the temp file "dmesg -E", # Enable console message "logout", # Logout @@ -110,7 +109,7 @@ class UartSerial: "prompt": "ec:~$", "device_type": "EC(Zephyr)", "prepare_cmd": ["chan save", "chan 0"], # Disable console message - "cleanup_cmd": ["x", "", "chan restore"], + "cleanup_cmd": ["", "chan restore"], "end_of_input": CRLF, }, ) @@ -214,6 +213,8 @@ class UartSerial: self.serial.flushInput() self.serial.flushOutput() + # Send 'x' to cancel any previous chargen command still running. + self.run_command(["x"], delay=1) self.get_output() # drain data # Send a couple of line feeds, and capture the prompt text. @@ -329,9 +330,9 @@ class UartSerial: if captured: if self.num_ch_cap == 0: # Strip prompt on first read (if it's there) - start = captured.find("0123") - if start > 0: - captured = captured[start:] + prefixstr = self.dev_prof["prompt"] + " " + if captured.startswith(prefixstr): + captured = captured[len(prefixstr) :] # There is some output data. Reset the data starvation count. data_starve_count = 0 else: diff --git a/util/update_release_branch.py b/util/update_release_branch.py index 939d572dc4..0a871724fe 100755 --- a/util/update_release_branch.py +++ b/util/update_release_branch.py @@ -42,11 +42,11 @@ def git_commit_msg(cros_main, branch, head, merge_head, rel_paths, cmd): A String containing the git commit message with the exception of the Signed-Off-By field and Change-ID field. """ - relevant_commits_cmd, relevant_commits, relevant_hdr = get_relevant_commits( + relevant_commits_cmd, relevant_commits = get_relevant_commits( head, merge_head, "--oneline", rel_paths ) - _, relevant_bugs, _ = get_relevant_commits(head, merge_head, "", rel_paths) + _, relevant_bugs = get_relevant_commits(head, merge_head, "", rel_paths) relevant_bugs = set(re.findall("BUG=(.*)", relevant_bugs)) # Filter out "none" from set of bugs filtered = [] @@ -65,7 +65,7 @@ Merge remote-tracking branch {CROS_MAIN} into {BRANCH} Generated by: {COMMAND_LINE} -{RELEVANT_COMMITS_HEADER} +Relevant changes: {RELEVANT_COMMITS_CMD} @@ -93,7 +93,6 @@ Force-Relevant-Builds: all BRANCH=branch, RELEVANT_COMMITS_CMD=relevant_commits_cmd, RELEVANT_COMMITS=relevant_commits, - RELEVANT_COMMITS_HEADER=relevant_hdr, BUG_FIELD=bug_field, COMMAND_LINE=cmd, ) @@ -136,10 +135,8 @@ def get_relevant_commits(head, merge_head, fmt, relevant_paths): Returns: A tuple containing the arguments passed to the git log command and - stdout, and the header for the message + stdout. """ - if not relevant_paths: - return "", "", "" if fmt: cmd = [ "git", @@ -159,129 +156,7 @@ def get_relevant_commits(head, merge_head, fmt, relevant_paths): proc = subprocess.run( cmd, stdout=subprocess.PIPE, encoding="utf-8", check=True, shell=True ) - return "".join(proc.args), proc.stdout, "Relevant changes:" - - -def merge_repo( - base, cros_main, cmd_checkout, strategy, cmd, prunelist, relevant_paths -): - """Merge changes from ToT into this repo's branch. - - For this repo, merge the changes from ToT to the branch set - in the merge command. - - Args: - base: String indicating the Source directory of repo. - cros_main: String indicating the origin branch name - cmd_checkout: String list containing the checkout command to use. - strategy: String list containing the merge strategy, - cmd: String containing the command line - prunelist: String list containing the files to remove. - relevant_paths: String containing all the relevant paths for this - particular baseboard or board. - """ - # Change directory to the repo being merged - print('Starting merge in "%s"' % base) - print('Checkout command: "%s"' % " ".join(cmd_checkout)) - os.chdir(base) - # Check if we are already in merge process - result = subprocess.run( - ["git", "rev-parse", "--quiet", "--verify", "MERGE_HEAD"], - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, - check=False, - ) - - if result.returncode: - # Let's perform the merge - print("Updating remote...") - subprocess.run(["git", "remote", "update"], check=True) - subprocess.run(cmd_checkout, check=True) - cmd_merge = [ - "git", - "merge", - "--no-ff", - "--no-commit", - cros_main, - "-s", - ] - cmd_merge.extend(strategy) - print('Merge command: "%s"' % " ".join(cmd_merge)) - try: - subprocess.run(cmd_merge, check=True) - except subprocess.CalledProcessError: - # We've likely encountered a merge conflict due to new OWNERS file - # modifications. If we're removing the owners, we'll delete them. - if prunelist: - # Find the unmerged files - unmerged = ( - subprocess.run( - ["git", "diff", "--name-only", "--diff-filter=U"], - stdout=subprocess.PIPE, - encoding="utf-8", - check=True, - ) - .stdout.rstrip() - .split() - ) - - # Prune OWNERS files - for file in unmerged: - if file in prunelist: - subprocess.run(["git", "rm", file], check=False) - unmerged.remove(file) - - print("Removed non-root OWNERS files.") - if unmerged: - print( - "Unmerged files still exist! You need to manually resolve this." - ) - print("\n".join(unmerged)) - sys.exit(1) - else: - raise - else: - print( - "We have already started merge process.", - "Attempt to generate commit.", - ) - # Check whether any commit is needed. - changes = subprocess.run( - ["git", "status", "--porcelain"], - stdout=subprocess.PIPE, - encoding="utf-8", - check=True, - ).stdout.rstrip() - if not changes: - print("No changes have been found, skipping commit.") - return - - print("Generating commit message...") - branch = subprocess.run( - ["git", "rev-parse", "--abbrev-ref", "HEAD"], - stdout=subprocess.PIPE, - encoding="utf-8", - check=True, - ).stdout.rstrip() - head = subprocess.run( - ["git", "rev-parse", "--short", "HEAD"], - stdout=subprocess.PIPE, - encoding="utf-8", - check=True, - ).stdout.rstrip() - merge_head = subprocess.run( - ["git", "rev-parse", "--short", "MERGE_HEAD"], - stdout=subprocess.PIPE, - encoding="utf-8", - check=True, - ).stdout.rstrip() - - print("Typing as fast as I can...") - commit_msg = git_commit_msg( - cros_main, branch, head, merge_head, relevant_paths, cmd - ) - subprocess.run(["git", "commit", "--signoff", "-m", commit_msg], check=True) - subprocess.run(["git", "commit", "--amend"], check=True) + return "".join(proc.args), proc.stdout def main(argv): @@ -311,11 +186,7 @@ def main(argv): parser.add_argument("--baseboard") parser.add_argument("--board") parser.add_argument( - "release_branch", - help=( - "The name of the target release branch, " - "without the trailing '-main'." - ), + "release_branch", help=("The name of the target release" " branch") ) parser.add_argument( "--remote_prefix", @@ -326,11 +197,6 @@ def main(argv): default="cros", ) parser.add_argument( - "--srcbase", - help=("The base directory where the src tree exists."), - default="/mnt/host/source/", - ) - parser.add_argument( "--relevant_paths_file", help=( "A path to a text file which includes other " @@ -347,7 +213,7 @@ def main(argv): parser.add_argument( "--strategy_option", "-X", - help=("The strategy option for the chosen merge strategy"), + help=("The strategy option for the chosen merge " "strategy"), ) parser.add_argument( "--remove_owners", @@ -355,12 +221,6 @@ def main(argv): action=("store_true"), help=("Remove non-root OWNERS level files if present"), ) - parser.add_argument( - "--zephyr", - "-z", - action=("store_true"), - help=("If set, treat the board as a Zephyr based program"), - ) opts = parser.parse_args(argv[1:]) @@ -368,24 +228,17 @@ def main(argv): board_dir = "" if opts.baseboard: - # If a zephyr board, no baseboard allowed - if opts.zephyr: - raise Exception("--baseboard not allowed for Zephyr boards") # Dereference symlinks so "git log" works as expected. baseboard_dir = os.path.relpath("baseboard/" + opts.baseboard) baseboard_dir = os.path.relpath(os.path.realpath(baseboard_dir)) boards = get_relevant_boards(opts.baseboard) elif opts.board: - if opts.zephyr: - board_dir = os.path.relpath("zephyr/program/" + opts.board) - else: - board_dir = os.path.relpath("board/" + opts.board) + board_dir = os.path.relpath("board/" + opts.board) board_dir = os.path.relpath(os.path.realpath(board_dir)) boards = [opts.board] else: - # With no board or baseboard, not sure whether this should proceed - raise Exception("no board or baseboard specified") + boards = [] print("Gathering relevant paths...") relevant_paths = [] @@ -394,12 +247,10 @@ def main(argv): elif opts.board: relevant_paths.append(board_dir) - if not opts.zephyr: - for board in boards: - relevant_paths.append("board/" + board) + for board in boards: + relevant_paths.append("board/" + board) # Check for the existence of a file that has other paths of interest. - # Also check for 'relevant-paths.txt' in the board directory if opts.relevant_paths_file and os.path.exists(opts.relevant_paths_file): with open(opts.relevant_paths_file, "r") as relevant_paths_file: for line in relevant_paths_file: @@ -409,9 +260,17 @@ def main(argv): relevant_paths.append("util/getversion.sh") relevant_paths = " ".join(relevant_paths) + # Check if we are already in merge process + result = subprocess.run( + ["git", "rev-parse", "--quiet", "--verify", "MERGE_HEAD"], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + check=False, + ) + # Prune OWNERS files if desired - prunelist = [] if opts.remove_owners: + prunelist = [] for root, dirs, files in os.walk("."): for name in dirs: if "build" in name: @@ -432,83 +291,112 @@ def main(argv): for path in prunelist: print(" " + path) - # Create the merge and checkout commands to use. - cmd_checkout = [ - "git", - "checkout", - "-B", - opts.release_branch, - opts.remote_prefix + "/" + opts.release_branch, - ] - if opts.merge_strategy == "recursive" and not opts.strategy_option: - opts.strategy_option = "theirs" - print( - 'Using "%s" merge strategy' % opts.merge_strategy, - ( - "with strategy option '%s'" % opts.strategy_option - if opts.strategy_option - else "" - ), - ) - cros_main = opts.remote_prefix + "/" + "main" - strategy = [ - opts.merge_strategy, - ] - if opts.strategy_option: - strategy.append("-X" + opts.strategy_option) - cmd = " ".join(argv) - - # Merge each of the repos - merge_repo( - os.path.join(opts.srcbase, "src/platform/ec"), - cros_main, - cmd_checkout, - strategy, - cmd, - prunelist, - relevant_paths, - ) - if opts.zephyr: - # Strip off any trailing -main or -master from branch name - if opts.release_branch.endswith("-main"): - opts.release_branch = opts.release_branch[:-5] - if opts.release_branch.endswith("-master"): - opts.release_branch = opts.release_branch[:-7] - cmd_checkout = [ - "git", - "checkout", - "-B", - opts.release_branch, - opts.remote_prefix + "/" + opts.release_branch, - ] - prunelist = [] - if opts.remove_owners: - # Remove the top level OWNERS file from the list - # to avoid any conflict with the modified branch file. - prunelist.append("OWNERS") - merge_repo( - os.path.join(opts.srcbase, "src/third_party/zephyr/main"), - cros_main, - cmd_checkout, - strategy, - cmd, - prunelist, - [], + if result.returncode: + # Let's perform the merge + print("Updating remote...") + subprocess.run(["git", "remote", "update"], check=True) + subprocess.run( + [ + "git", + "checkout", + "-B", + opts.release_branch, + opts.remote_prefix + "/" + opts.release_branch, + ], + check=True, + ) + print("Attempting git merge...") + if opts.merge_strategy == "recursive" and not opts.strategy_option: + opts.strategy_option = "theirs" + print( + 'Using "%s" merge strategy' % opts.merge_strategy, + ( + "with strategy option '%s'" % opts.strategy_option + if opts.strategy_option + else "" + ), ) - # cmsis repo has different remote - cros_main = opts.remote_prefix + "/" + "chromeos-main" - merge_repo( - os.path.join(opts.srcbase, "src/third_party/zephyr/cmsis"), + cros_main = opts.remote_prefix + "/" + "main" + arglist = [ + "git", + "merge", + "--no-ff", + "--no-commit", cros_main, - cmd_checkout, - strategy, - cmd, - prunelist, - [], + "-s", + opts.merge_strategy, + ] + if opts.strategy_option: + arglist.append("-X" + opts.strategy_option) + try: + subprocess.run(arglist, check=True) + except: + # We've likely encountered a merge conflict due to new OWNERS file + # modifications. If we're removing the owners, we'll delete them. + if opts.remove_owners and prunelist: + # Find the unmerged files + unmerged = ( + subprocess.run( + ["git", "diff", "--name-only", "--diff-filter=U"], + stdout=subprocess.PIPE, + encoding="utf-8", + check=True, + ) + .stdout.rstrip() + .split() + ) + + # Prune OWNERS files + for file in unmerged: + if file in prunelist: + subprocess.run(["git", "rm", file], check=False) + unmerged.remove(file) + + print("Removed non-root OWNERS files.") + if unmerged: + print( + "Unmerged files still exist! You need to manually resolve this." + ) + print("\n".join(unmerged)) + sys.exit(1) + else: + raise + else: + print( + "We have already started merge process.", + "Attempt to generate commit.", ) + + print("Generating commit message...") + branch = subprocess.run( + ["git", "rev-parse", "--abbrev-ref", "HEAD"], + stdout=subprocess.PIPE, + encoding="utf-8", + check=True, + ).stdout.rstrip() + head = subprocess.run( + ["git", "rev-parse", "--short", "HEAD"], + stdout=subprocess.PIPE, + encoding="utf-8", + check=True, + ).stdout.rstrip() + merge_head = subprocess.run( + ["git", "rev-parse", "--short", "MERGE_HEAD"], + stdout=subprocess.PIPE, + encoding="utf-8", + check=True, + ).stdout.rstrip() + + cmd = " ".join(argv) + print("Typing as fast as I can...") + commit_msg = git_commit_msg( + cros_main, branch, head, merge_head, relevant_paths, cmd + ) + subprocess.run(["git", "commit", "--signoff", "-m", commit_msg], check=True) + subprocess.run(["git", "commit", "--amend"], check=True) print( ( - "Finished! **Please review the commit(s) to see if they're to your " + "Finished! **Please review the commit to see if it's to your " "liking.**" ) ) diff --git a/util/usb_if.c b/util/usb_if.c index eec8b22f5b..0cd642834a 100644 --- a/util/usb_if.c +++ b/util/usb_if.c @@ -4,12 +4,12 @@ * found in the LICENSE file. */ -#include "usb_if.h" - #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "usb_if.h" + /* Return 0 on error, since it's never gonna be EP 0 */ static int find_endpoint(const struct libusb_interface_descriptor *iface, uint16_t subclass, uint16_t protocol, diff --git a/util/uut/com_port.h b/util/uut/com_port.h index 0a5d843e0f..ca52bdd234 100644 --- a/util/uut/com_port.h +++ b/util/uut/com_port.h @@ -10,7 +10,6 @@ #define __UTIL_UUT_COM_PORT_H #include <stdbool.h> - #include <termios.h> #ifdef __cplusplus diff --git a/util/zephyr_to_resultdb.py b/util/zephyr_to_resultdb.py index 6c378bde5c..48bfe151e4 100755 --- a/util/zephyr_to_resultdb.py +++ b/util/zephyr_to_resultdb.py @@ -11,11 +11,8 @@ import argparse import base64 -import datetime import json import os -import pathlib -import re import requests # pylint: disable=import-error @@ -50,7 +47,7 @@ def translate_duration(testcase): if not time: return None - return f"{float(time)/1000:.9f}s" + return f"{time}ms" def testcase_summary(testcase): @@ -62,7 +59,9 @@ def testcase_summary(testcase): or "reason" in testcase or translate_status(testcase["status"]) == "SKIP" ): - html = '<p><text-artifact artifact-id="test_log"></p>' + html = ( + '<p><text-artifact artifact-id="artifact-content-in-request"></p>' + ) return html @@ -83,113 +82,40 @@ def testcase_artifact(testcase): return base64.b64encode(artifact.encode()) -def testsuite_artifact(testsuite): - """Translates ZTEST testcase to ResultDB artifact""" - artifact = "Unknown" - - if "log" in testsuite and testsuite["log"]: - artifact = testsuite["log"] - - return base64.b64encode(artifact.encode()) - - -def testcase_to_result(testsuite, testcase, base_tags, config_tags): - """Translates ZTEST testcase to ResultDB format - See TestResult type in - https://crsrc.org/i/go/src/go.chromium.org/luci/resultdb/sink/proto/v1/test_result.proto - """ +def testcase_to_result(testsuite, testcase): + """Translates ZTEST testcase to ResultDB format""" result = { "testId": testcase["identifier"], "status": translate_status(testcase["status"]), "expected": translate_expected(testcase["status"]), "summaryHtml": testcase_summary(testcase), "artifacts": { - "test_log": { + "artifact-content-in-request": { "contents": testcase_artifact(testcase), - }, - "testsuite_log": { - "contents": testsuite_artifact(testsuite), - }, + } }, + # TODO(b/239952573) Add all test configs as tags "tags": [ + {"key": "category", "value": "ChromeOS/EC"}, {"key": "platform", "value": testsuite["platform"]}, ], "duration": translate_duration(testcase), "testMetadata": {"name": testcase["identifier"]}, } - for (key, value) in base_tags: - result["tags"].append({"key": key, "value": value}) - - for (key, value) in config_tags: - result["tags"].append({"key": key.lower(), "value": value}) - - if result["status"] == "FAIL" and "log" in testcase and testcase["log"]: - assert_msg = re.findall( - r"Assertion failed.*$", testcase["log"], re.MULTILINE - ) - result["failureReason"] = {"primaryErrorMessage": assert_msg[0]} - return result -def get_testsuite_config_tags(twister_dir, testsuite): - """Creates config tags from the testsuite""" - config_tags = [] - suite_path = f"{twister_dir}/{testsuite['platform']}/{testsuite['name']}" - dot_config = f"{suite_path}/zephyr/.config" - - if pathlib.Path(dot_config).exists(): - with open(dot_config) as file: - lines = file.readlines() - - for line in lines: - # Ignore empty lines and comments - if line.strip() and not line.startswith("#"): - result = re.search(r"(\w+)=(.+$)", line) - config_tags.append((result.group(1), result.group(2))) - else: - print(f"Can't find config file for {testsuite['name']}") - - return config_tags - - -def create_base_tags(data): - """Creates base tags needed for Testhaus""" - base_tags = [] - - queued_time = datetime.datetime.fromisoformat( - data["environment"]["run_date"] - ) - base_tags.append( - ("queued_time", queued_time.strftime("%Y-%m-%d %H:%M:%S.%f UTC")) - ) - - base_tags.append(("zephyr_version", data["environment"]["zephyr_version"])) - base_tags.append(("board", data["environment"]["os"])) - base_tags.append(("toolchain", data["environment"]["toolchain"])) - - return base_tags - - def json_to_resultdb(result_file): """Translates Twister json test report to ResultDB format""" with open(result_file) as file: data = json.load(file) results = [] - base_tags = create_base_tags(data) for testsuite in data["testsuites"]: - config_tags = get_testsuite_config_tags( - os.path.dirname(result_file), testsuite - ) for testcase in testsuite["testcases"]: if testcase["status"]: - results.append( - testcase_to_result( - testsuite, testcase, base_tags, config_tags - ) - ) + results.append(testcase_to_result(testsuite, testcase)) file.close() |