README: point to the new repository, drop all code The repository has been renamed, point to https://chromium.googlesource.com/chromiumos/platform/dagwood, drop all the code, keep the README and metadata. BUG=none TEST=check on gitiles Change-Id: Ic882b69b02fe395f3aad328458c4cb31be96f12d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec-aic-tester/+/6206533 Reviewed-by: Keith Short <keithshort@chromium.org> Tested-by: Fabio Baltieri <fabiobaltieri@google.com> Commit-Queue: Fabio Baltieri <fabiobaltieri@google.com>
diff --git a/PRESUBMIT.cfg b/PRESUBMIT.cfg deleted file mode 100644 index 9e173e4..0000000 --- a/PRESUBMIT.cfg +++ /dev/null
@@ -1,5 +0,0 @@ -[Hook Overrides] -tab_check: false - -[Hook Scripts] -cros format = cros format --check --exclude "*.xml" --exclude "extra/usb_updater/*.json" --exclude "third_party/*" --commit ${PRESUBMIT_COMMIT}
diff --git a/README.md b/README.md index a45898d..9225586 100644 --- a/README.md +++ b/README.md
@@ -1,167 +1,3 @@ # EC AIC Tester -## Firmware build, flash and debug - -The firmware can be built and flashed both with or without the chroot, though -it's recommended reusing the checkout that is part of a ChromiumOS SDK as that -includes the necessary configuration to upload changes to Gerrit. - -### Chroot build - -TODO - -### Out of chroot build - -This setup reuses the repository that is part of the normal chroot setup, just -adds a west workspace on top of it, which can coexist with the normal one -managed with repo. - -Venv setup (only needed once) - -``` -sudo apt install python3-venv -python3 -m venv ~/chromiumos/src/platform/ec-aic-tester/.venv -``` - -Enter the venv (once before either setting up or building): -``` -source ~/chromiumos/src/platform/ec-aic-tester/.venv/bin/activate -``` - -Initialize the project modules and install dependencies (only needed once): - -``` -cd ~/chromiumos/src/platform/ec-aic-tester -pip install west -unset ZEPHYR_BASE # only needed if there's other Zephyr checkouts in the system -west init -l firmware -west update -o=--depth=1 -n -pip install -U -r zephyr/scripts/requirements.txt -west sdk install -t arm-zephyr-eabi -sudo apt install cmake ninja-build ccache dfu-util -``` - -Build and flash: - -``` -cd ~/chromiumos/src/platform/ec-aic-tester -west update # only needed if there was a breaking change in the modules -west build firmware -west flash -``` - -### Build without a ChromiumOS SDK - -It's possible to build, flash and debug the firmware without the whole -chromiumos checkout, in that case just pick an arbitrary directory as a -workspace instead of `~/chromiumos/src/platform/ec-aic-tester` and initialize -it with `west init --mf firmware/west.yml -m -https://chromium.googlesource.com/chromiumos/platform/ec-aic-tester`, the rest -of the process it the same. - -This setup takes less disk space, but results in a checkout with no tools to -upload changelists. - -### Using the usptream repositories instead of chromium mirrored ones - -The project is setup to use the chromium mirror of Zephyr and modules, but can -also be built against the upstream repositories directly. To do that use the -`west-upstream.yml` manifest when initializing the west workspace, for example - -``` -west init -l firmware --mf west-upstream.yml -``` - -### Build with a standalone full Zephyr checkout - -The firmware can be built against an existing Zephyr project checkout, in that -case follow the project [Getting Started -Guide](https://docs.zephyrproject.org/latest/getting_started/index.html), make -sure that the `ZEPHYR_BASE` variable is set and run `west build` from the -project `firwmare` directory. - -### Available runners - -There's multiple options for flashing and debugging the board firmware, -depending on what's hardware is available. - -#### USB-DFU - -Just for flashing, uses the embedded USB DFU bootloader, requires no additional -hardware. Put the board in DFU mode (press NRST while holding the BOOT0 button) -and then run: - -``` -west flash -r dfu-util -``` - -NOTE: flashing with dfu-util normally fails in an error and requires a manual -reset of the board - -#### JLink - -JLink can be used for both flahing and debugging, requires the [J-Link Software](https://www.segger.com/downloads/jlink/#J-LinkSoftwareAndDocumentationPack) installed. - -Flash with: - -``` -west flash -r jlink -``` - -or start a debugging session with - -``` -west debug -r jlink -``` - -#### ST-LINK - -ST-LINK requires the [STM32CubeProgrammer host -tools](https://docs.zephyrproject.org/latest/develop/flash_debug/host-tools.html#stm32cubeprogrammer-flash-host-tools). - -Flash with: - -``` -west flash -r stm32cubeprogrammer -``` - -or - -``` -west flash -r openocd -``` - -or start a debugging session with - -``` -west debug -r stm32cubeprogrammer -``` - -or - -``` -west debug -r openocd -``` - -## Flashing the AIC board - -### ITE - -``` -zmake build ite-aic -itecomdbgr -f build/zephyr/ite-aic/output/ec.bin -d /dev/ttyACM1 -# reset the ec (ec reset) -``` - -### NPCX - -Assuming the tester shell is on /dev/ttyACM0 and the EC on /dev/ttyACM1, from -the chroot in the EC directory: - -``` -zmake build npcx-aic -# power on the ec (ec power on) enter bootloader mode (npcx_boot) on the tester shell -uartupdatetool --port=ttyACM1 --baudrate=115200 --opr=wr --addr=0x200C3020 --file build/zephyr/npcx-aic/output/npcx_monitor.bin -uartupdatetool --port=ttyACM1 --baudrate=115200 --opr=wr --auto --offset=0 --file build/zephyr/npcx-aic/output/ec.bin -# reset the ec (ec reset) -``` +Moved to https://chromium.googlesource.com/chromiumos/platform/dagwood
diff --git a/firmware/CMakeLists.txt b/firmware/CMakeLists.txt deleted file mode 100644 index cd6e142..0000000 --- a/firmware/CMakeLists.txt +++ /dev/null
@@ -1,26 +0,0 @@ -# Copyright 2024 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -cmake_minimum_required(VERSION 3.20.0) - -set(BOARD_ROOT ${CMAKE_CURRENT_LIST_DIR}) -set(BOARD ec_aic_tester) - -find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) -project(ec-aic-tester) - -zephyr_include_directories(include) - -target_sources(app PRIVATE - src/ec.c - src/main.c - src/usbd.c -) - -target_sources_ifdef(CONFIG_DT_HAS_ZEPHYR_UART_BRIDGE_ENABLED app PRIVATE src/uart-bridge.c) -target_sources_ifdef(CONFIG_DT_HAS_CROS_NPCX_BOOT_ENABLED app PRIVATE src/npcx_boot.c) -target_sources_ifdef(CONFIG_I2C_EEPROM_TARGET app PRIVATE src/i2c_target.c) -target_sources_ifdef(CONFIG_DT_HAS_CROS_I2C_MUX_ENABLED app PRIVATE src/i2c_mux.c) - -zephyr_linker_sources(ROM_SECTIONS src/usb_request.ld)
diff --git a/firmware/boards/google/ec_aic_tester/Kconfig.ec_aic_tester b/firmware/boards/google/ec_aic_tester/Kconfig.ec_aic_tester deleted file mode 100644 index 81eb913..0000000 --- a/firmware/boards/google/ec_aic_tester/Kconfig.ec_aic_tester +++ /dev/null
@@ -1,6 +0,0 @@ -# Copyright 2024 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -config BOARD_EC_AIC_TESTER - select SOC_STM32H743XX
diff --git a/firmware/boards/google/ec_aic_tester/board.cmake b/firmware/boards/google/ec_aic_tester/board.cmake deleted file mode 100644 index 77e4628..0000000 --- a/firmware/boards/google/ec_aic_tester/board.cmake +++ /dev/null
@@ -1,16 +0,0 @@ -# Copyright 2024 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -board_runner_args(jlink "--device=STM32H743ZG" "--speed=4000") -board_runner_args(pyocd "--target=stm32h743zgtx") -board_runner_args(openocd --cmd-post-verify "reset halt") -board_runner_args(openocd --target-handle=_CHIPNAME.cpu0) -board_runner_args(stm32cubeprogrammer "--port=swd" "--reset-mode=hw") -board_runner_args(dfu-util "--pid=0483:df11" "--alt=0" "--dfuse") - -include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) -include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake) -include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) -include(${ZEPHYR_BASE}/boards/common/stm32cubeprogrammer.board.cmake) -include(${ZEPHYR_BASE}/boards/common/dfu-util.board.cmake)
diff --git a/firmware/boards/google/ec_aic_tester/board.yml b/firmware/boards/google/ec_aic_tester/board.yml deleted file mode 100644 index 665d5d9..0000000 --- a/firmware/boards/google/ec_aic_tester/board.yml +++ /dev/null
@@ -1,10 +0,0 @@ -# Copyright 2024 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -board: - name: ec_aic_tester - full_name: EC AIC Tester - vendor: google - socs: - - name: stm32h743xx
diff --git a/firmware/boards/google/ec_aic_tester/ec_aic_tester.dts b/firmware/boards/google/ec_aic_tester/ec_aic_tester.dts deleted file mode 100644 index a5e247b..0000000 --- a/firmware/boards/google/ec_aic_tester/ec_aic_tester.dts +++ /dev/null
@@ -1,331 +0,0 @@ -/* Copyright 2024 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/dts-v1/; -#include <st/h7/stm32h743Xg.dtsi> -#include <st/h7/stm32h743bgtx-pinctrl.dtsi> -#include <zephyr/dt-bindings/input/input-event-codes.h> - -/ { - model = "Google EC AIC Tester"; - compatible = "google,ec-aic-tester"; - - chosen { - /* change to &usart1 to move the shell to J3/J4 */ - zephyr,console = &cdc_acm_uart_shell; - zephyr,shell-uart = &cdc_acm_uart_shell; - zephyr,sram = &sram0; - zephyr,flash = &flash0; - zephyr,dtcm = &dtcm; - }; - - leds { - compatible = "gpio-leds"; - status_led: mcu_pb02 { - gpios = <&gpiob 2 GPIO_ACTIVE_HIGH>; - }; - }; - - gpio_keys: gpio-keys { - compatible = "gpio-keys"; - user_button: mcu_pb01 { - gpios = <&gpiob 1 GPIO_ACTIVE_LOW>; - zephyr,code = <INPUT_KEY_0>; - }; - }; - - aliases { - led0 = &status_led; - sw0 = &user_button; - watchdog0 = &iwdg; - die-temp0 = &die_temp; - }; - - uart_bridge: uart-bridge { - compatible = "zephyr,uart-bridge"; - usb { - device = <&cdc_acm_uart_ec>; - transfer-size = <64>; - }; - uart { - device = <&uart4>; - transfer-size = <1>; - }; - }; - - pp3300_mecc_core: pp3300_mecc_core { - compatible = "regulator-fixed"; - regulator-name = "pp3300_mecc_core"; - enable-gpios = <&gpiob 8 GPIO_ACTIVE_HIGH>; - }; - - pp3300_mecc_z: pp3300_mecc_z { - compatible = "regulator-fixed"; - regulator-name = "pp3300_mecc_z"; - enable-gpios = <&gpiob 9 GPIO_ACTIVE_HIGH>; - }; - - pp3300_mecc_s: pp3300_mecc_s { - compatible = "regulator-fixed"; - regulator-name = "pp3300_mecc_s"; - enable-gpios = <&gpiob 10 GPIO_ACTIVE_HIGH>; - }; - - ppvar_mecc_vref: ppvar_mecc_vref { - compatible = "regulator-fixed"; - regulator-name = "ppvar_mecc_vref"; - enable-gpios = <&gpiob 11 GPIO_ACTIVE_HIGH>; - }; - - pp1800_mecc_z: pp1800_mecc_z { - compatible = "regulator-fixed"; - regulator-name = "pp1800_mecc_z"; - enable-gpios = <&gpiob 12 GPIO_ACTIVE_HIGH>; - }; - - pp1800_mecc_s: pp1800_mecc_s { - compatible = "regulator-fixed"; - regulator-name = "pp1800_mecc_s"; - enable-gpios = <&gpiob 13 GPIO_ACTIVE_HIGH>; - }; - - pp5000_mecc_z: pp5000_mecc_z { - compatible = "regulator-fixed"; - regulator-name = "pp5000_mecc_z"; - enable-gpios = <&gpiob 14 GPIO_ACTIVE_HIGH>; - }; - - ppvar_mecc_rtc: ppvar_mecc_rtc { - compatible = "regulator-fixed"; - regulator-name = "ppvar_mecc_rtc"; - enable-gpios = <&gpiob 15 GPIO_ACTIVE_HIGH>; - }; - - aic-pins { - compatible = "cros,aic-pins"; - ec-rst-gpios = <&gpioe 3 GPIO_ACTIVE_LOW>; - io-gpios = <&gpioc 2 GPIO_ACTIVE_HIGH>, /* CCD_MODE_L */ - <&gpioc 4 GPIO_ACTIVE_HIGH>, /* EN_PP5000_FAN */ - <&gpioe 13 GPIO_ACTIVE_HIGH>, /* I2C_MECC_PDC4_INT_L */ - - /* TODO: figure out why some signals are not getting - * through on the NPCX AIC board - */ - - /* KSI */ - /* <&gpiok 0 GPIO_ACTIVE_HIGH>, */ /* MCU_OUT_KBD_SCANIN_A_ODL */ - <&gpiok 1 GPIO_ACTIVE_HIGH>, /* MCU_OUT_KBD_SCANIN_B_ODL */ - <&gpiok 2 GPIO_ACTIVE_HIGH>, /* MCU_OUT_KBD_SCANIN_C_ODL */ - /* <&gpiok 3 GPIO_ACTIVE_HIGH>, */ /* MCU_OUT_KBD_SCANIN_D_ODL */ - <&gpiok 4 GPIO_ACTIVE_HIGH>, /* MCU_OUT_KBD_SCANIN_E_ODL */ - <&gpiok 5 GPIO_ACTIVE_HIGH>, /* MCU_OUT_KBD_SCANIN_F_ODL */ - <&gpiok 6 GPIO_ACTIVE_HIGH>, /* MCU_OUT_KBD_SCANIN_G_ODL */ - <&gpiok 7 GPIO_ACTIVE_HIGH>, /* MCU_OUT_KBD_SCANIN_H_ODL */ - - /* KSO */ - /* <&gpioj 0 GPIO_ACTIVE_HIGH>, */ /* MCU_IN_KBD_SCANOUT_A */ - /* <&gpioj 1 GPIO_ACTIVE_HIGH>, */ /* MCU_IN_KBD_SCANOUT_B */ - <&gpioj 2 GPIO_ACTIVE_HIGH>, /* MCU_IN_KBD_SCANOUT_C */ - <&gpioj 3 GPIO_ACTIVE_HIGH>, /* MCU_IN_KBD_SCANOUT_D */ - <&gpioj 4 GPIO_ACTIVE_HIGH>, /* MCU_IN_KBD_SCANOUT_E */ - <&gpioj 5 GPIO_ACTIVE_HIGH>, /* MCU_IN_KBD_SCANOUT_F */ - /* <&gpioj 6 GPIO_ACTIVE_HIGH>, */ /* MCU_IN_KBD_SCANOUT_G */ - /* <&gpioj 7 GPIO_ACTIVE_HIGH>, */ /* MCU_IN_KBD_SCANOUT_H */ - /* <&gpioj 8 GPIO_ACTIVE_HIGH>, */ /* MCU_IN_KBD_SCANOUT_J */ - /* <&gpioj 9 GPIO_ACTIVE_HIGH>, */ /* MCU_IN_KBD_SCANOUT_K */ - <&gpioj 10 GPIO_ACTIVE_HIGH>, /* MCU_IN_KBD_SCANOUT_L */ - <&gpioj 11 GPIO_ACTIVE_HIGH>, /* MCU_IN_KBD_SCANOUT_M */ - <&gpioj 12 GPIO_ACTIVE_HIGH>, /* MCU_IN_KBD_SCANOUT_N */ - <&gpioj 13 GPIO_ACTIVE_HIGH>, /* MCU_IN_KBD_SCANOUT_P */ - <&gpioj 14 GPIO_ACTIVE_HIGH>, /* MCU_IN_KBD_SCANOUT_Q */ - <&gpioj 15 GPIO_ACTIVE_HIGH>; /* MCU_IN_KBD_SCANOUT_R */ - /* <&gpioh 3 GPIO_ACTIVE_HIGH>, */ /* MCU_IN_KBD_SCANOUT_S */ - /* <&gpioj 4 GPIO_ACTIVE_HIGH>; */ /* MCU_IN_KBD_SCANOUT_T */ - }; - - npcx-boot { - compatible = "cros,npcx-boot"; - npcx-boot-gpios = <&gpioa 1 GPIO_ACTIVE_LOW>; - pinctrl-0 = <&pa1_gpio>; - pinctrl-1 = <&uart4_rx_pa1>; - pinctrl-names = "gpio", "default"; - }; - - i2c-mux-a { - compatible = "cros,i2c-mux"; - en-gpios = <&gpioi 14 GPIO_ACTIVE_HIGH>; - a-gpios = <&gpioi 12 GPIO_ACTIVE_HIGH>, - <&gpioi 13 GPIO_ACTIVE_HIGH>; - port-count = <4>; - }; - - i2c-mux-b { - compatible = "cros,i2c-mux"; - en-gpios = <&gpiof 13 GPIO_ACTIVE_HIGH>; - a-gpios = <&gpiof 12 GPIO_ACTIVE_HIGH>; - port-count = <2>; - }; -}; - -&pinctrl { - pa1_gpio: pa1_gpio { - pinmux = <STM32_PINMUX('A', 1, GPIO)>; - }; -}; - -&clk_lsi { - status = "okay"; -}; - -&clk_hsi48 { - status = "okay"; -}; - -&clk_hse { - clock-frequency = <DT_FREQ_M(48)>; - status = "okay"; -}; - -&pll { - div-m = <12>; - mul-n = <240>; - div-p = <2>; - div-q = <2>; - div-r = <2>; - clocks = <&clk_hse>; - status = "okay"; -}; - -&pll2 { - div-m = <24>; - mul-n = <120>; - div-p = <2>; - div-q = <3>; - div-r = <2>; - clocks = <&clk_hse>; - status = "okay"; -}; - -&rcc { - clocks = <&pll>; - clock-frequency = <DT_FREQ_M(480)>; - d1cpre = <1>; - hpre = <2>; - d1ppre = <2>; - d2ppre1 = <2>; - d2ppre2 = <2>; - d3ppre = <2>; -}; - -/* Debug UART, J3/J4 */ -&usart1 { - pinctrl-0 = <&usart1_rx_pb7 &usart1_tx_pb6>; - pinctrl-names = "default"; - current-speed = <115200>; - status = "okay"; -}; - -/* EC UART */ -&uart4 { - pinctrl-0 = <&uart4_rx_pa1 &uart4_tx_pa0>; - pinctrl-names = "default"; - current-speed = <115200>; - status = "okay"; -}; - -zephyr_udc0: &usbotg_fs { - pinctrl-0 = <&usb_otg_fs_dm_pa11 &usb_otg_fs_dp_pa12>; - pinctrl-names = "default"; - status = "okay"; - - cdc_acm_uart_shell: cdc_acm_uart_shell { - compatible = "zephyr,cdc-acm-uart"; - }; - cdc_acm_uart_ec: cdc_acm_uart_ec { - compatible = "zephyr,cdc-acm-uart"; - }; -}; - -&rtc { - clocks = <&rcc STM32_CLOCK_BUS_APB4 0x00010000>, - <&rcc STM32_SRC_LSI RTC_SEL(2)>; - status = "okay"; -}; - -/* target interface, connected to the U9 mux */ -&i2c2 { - pinctrl-0 = <&i2c2_scl_pf1 &i2c2_sda_pf0>; - pinctrl-names = "default"; - status = "okay"; - clock-frequency = <I2C_BITRATE_STANDARD>; - - eeprom0: eeprom@50 { - reg = <0x50>; - size = <256>; - compatible = "zephyr,i2c-target-eeprom"; - status = "okay"; - }; -}; - -/* target interface, connected to the U11 mux */ -&i2c4 { - pinctrl-0 = <&i2c4_scl_pf14 &i2c4_sda_pf15>; - pinctrl-names = "default"; - status = "okay"; - clock-frequency = <I2C_BITRATE_STANDARD>; - - eeprom1: eeprom@51 { - reg = <0x51>; - size = <256>; - compatible = "zephyr,i2c-target-eeprom"; - status = "okay"; - }; -}; - -/* connected to J5, QWIIC port */ -&i2c3 { - pinctrl-0 = <&i2c3_scl_ph7 &i2c3_sda_ph8>; - pinctrl-names = "default"; - status = "okay"; - clock-frequency = <I2C_BITRATE_FAST>; -}; - -&adc1 { - pinctrl-0 = <&adc1_inp15_pa3>; - pinctrl-names = "default"; - st,adc-clock-source = "SYNC"; - st,adc-prescaler = <4>; - status = "okay"; -}; - -&die_temp { - status = "okay"; -}; - -&adc3 { - pinctrl-0 = <&adc3_inp5_pf3>; - pinctrl-names = "default"; - st,adc-clock-source = "SYNC"; - st,adc-prescaler = <4>; - status = "okay"; -}; - -&dac1 { - status = "okay"; - pinctrl-0 = <&dac1_out1_pa4 &dac1_out2_pa5>; - pinctrl-names = "default"; -}; - -&rng { - status = "okay"; -}; - -&backup_sram { - status = "okay"; -}; - -&iwdg1 { - status = "okay"; -};
diff --git a/firmware/boards/google/ec_aic_tester/ec_aic_tester_defconfig b/firmware/boards/google/ec_aic_tester/ec_aic_tester_defconfig deleted file mode 100644 index 50e8c05..0000000 --- a/firmware/boards/google/ec_aic_tester/ec_aic_tester_defconfig +++ /dev/null
@@ -1,10 +0,0 @@ -# Copyright 2024 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -CONFIG_ARM_MPU=y -CONFIG_HW_STACK_PROTECTION=y -CONFIG_SERIAL=y -CONFIG_CONSOLE=y -CONFIG_UART_CONSOLE=y -CONFIG_GPIO=y
diff --git a/firmware/boards/google/ec_aic_tester/support/openocd.cfg b/firmware/boards/google/ec_aic_tester/support/openocd.cfg deleted file mode 100644 index 8f350be..0000000 --- a/firmware/boards/google/ec_aic_tester/support/openocd.cfg +++ /dev/null
@@ -1,25 +0,0 @@ -# Copyright 2023 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -source [find board/st_nucleo_h743zi.cfg] - -reset_config srst_only srst_nogate connect_assert_srst - -$_CHIPNAME.cpu0 configure -event gdb-attach { - echo "Debugger attaching: halting execution" - gdb_breakpoint_override hard -} - -$_CHIPNAME.cpu0 configure -event gdb-detach { - echo "Debugger detaching: resuming execution" - resume -} - -# Due to the use of connect_assert_srst, running gdb requires -# to reset halt just after openocd init. -rename init old_init -proc init {} { - old_init - reset halt -}
diff --git a/firmware/dts/bindings/cros,aic-pins.yaml b/firmware/dts/bindings/cros,aic-pins.yaml deleted file mode 100644 index ab14aa4..0000000 --- a/firmware/dts/bindings/cros,aic-pins.yaml +++ /dev/null
@@ -1,17 +0,0 @@ -# Copyright 2025 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -description: | - Various pin definitions for the AIC tester board. - -compatible: "cros,aic-pins" - -properties: - ec-rst-gpios: - type: phandle-array - required: true - - io-gpios: - type: phandle-array - required: true
diff --git a/firmware/dts/bindings/cros,i2c-mux.yaml b/firmware/dts/bindings/cros,i2c-mux.yaml deleted file mode 100644 index 06c077c..0000000 --- a/firmware/dts/bindings/cros,i2c-mux.yaml +++ /dev/null
@@ -1,24 +0,0 @@ -# Copyright 2025 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -description: | - I2C multiplexer device - -compatible: "cros,i2c-mux" - -properties: - en-gpios: - type: phandle-array - required: true - description: GPIO connected to the enable pin - - a-gpios: - type: phandle-array - required: true - description: GPIOs connected to the A* pins - - port-count: - type: int - required: true - description: Number of ports used in the multiplexer
diff --git a/firmware/dts/bindings/cros,npcx-boot.yaml b/firmware/dts/bindings/cros,npcx-boot.yaml deleted file mode 100644 index 5f5eef1..0000000 --- a/firmware/dts/bindings/cros,npcx-boot.yaml +++ /dev/null
@@ -1,24 +0,0 @@ -# Copyright 2025 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -description: | - Support data to reset an NPCX chip in bootloader mode. - -compatible: "cros,npcx-boot" - -include: pinctrl-device.yaml - -properties: - pinctrl-0: - required: true - - pinctrl-1: - required: true - - pinctrl-names: - required: true - - npcx-boot-gpios: - type: phandle-array - required: true
diff --git a/firmware/dts/bindings/zephyr,uart-bridge.yaml b/firmware/dts/bindings/zephyr,uart-bridge.yaml deleted file mode 100644 index 22a58e1..0000000 --- a/firmware/dts/bindings/zephyr,uart-bridge.yaml +++ /dev/null
@@ -1,40 +0,0 @@ -# Copyright 2024 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -description: | - UART bridge - - Bridges data from two serial devices, for example a USB CDC-ACM serial port - and an hardware UART. - - The device node must have exactly two child nodes for the two devices to be - bridged together. Example configuration: - - uart-bridge { - compatible = "zephyr,uart-bridge"; - usb { - device = <&cdc_acm_uart_ec>; - transfer-size = <64>; - }; - uart { - device = <&uart4>; - transfer-size = <1>; - }; - }; - -compatible: "zephyr,uart-bridge" - -child-binding: - description: Peer device node - properties: - device: - type: phandle - description: | - Phandle of a serial device. - - transfer-size: - type: int - description: | - The maximum number of bytes to try and transfer to the device in one - go.
diff --git a/firmware/prj.conf b/firmware/prj.conf deleted file mode 100644 index b420901..0000000 --- a/firmware/prj.conf +++ /dev/null
@@ -1,42 +0,0 @@ -# Copyright 2024 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -CONFIG_GPIO=y -CONFIG_LOG=y -CONFIG_LOG_PROCESS_THREAD_SLEEP_MS=100 -CONFIG_DEBUG_THREAD_INFO=y -CONFIG_COMPILER_TRACK_MACRO_EXPANSION=n -CONFIG_APPLICATION_DEFINED_SYSCALL=y - -# USB -CONFIG_USB_DEVICE_STACK=n -CONFIG_USB_DEVICE_STACK_NEXT=y -CONFIG_USBD_CDC_ACM_CLASS=y -CONFIG_UART_LINE_CTRL=y -CONFIG_UDC_DRIVER_LOG_LEVEL_WRN=y -CONFIG_USBD_CDC_ACM_LOG_LEVEL_OFF=y -CONFIG_USBD_LOG_LEVEL_WRN=y - -# I2C -CONFIG_I2C_TARGET=y -CONFIG_I2C_EEPROM_TARGET=y - -# Subsystems -CONFIG_SHELL=y -CONFIG_I2C=y -CONFIG_LED=y -CONFIG_INPUT=y -CONFIG_REGULATOR=y -CONFIG_DAC=y - -# Shell commands -CONFIG_GPIO_SHELL=y -CONFIG_I2C_SHELL=y -CONFIG_LED_SHELL=y -CONFIG_REGULATOR_SHELL=y -CONFIG_DAC_SHELL=y -CONFIG_INPUT_SHELL=y -CONFIG_INPUT_EVENT_DUMP=y - -CONFIG_SHELL_PROMPT_UART="ec-aic-tester:~$ "
diff --git a/firmware/src/ec.c b/firmware/src/ec.c deleted file mode 100644 index 07285e4..0000000 --- a/firmware/src/ec.c +++ /dev/null
@@ -1,236 +0,0 @@ -/* Copyright 2025 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#define DT_DRV_COMPAT cros_aic_pins - -#include "ec.h" -#include "usb_request.h" - -#include <zephyr/drivers/gpio.h> -#include <zephyr/drivers/regulator.h> -#include <zephyr/input/input.h> -#include <zephyr/kernel.h> -#include <zephyr/logging/log.h> -#include <zephyr/shell/shell.h> -#include <zephyr/sys/util.h> - -LOG_MODULE_REGISTER(ec, LOG_LEVEL_INF); - -BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1, - "only one 'cros,aic-pins' compatible node may be present"); - -static const struct gpio_dt_spec ec_rst_gpio = - GPIO_DT_SPEC_INST_GET(0, ec_rst_gpios); - -static const struct gpio_dt_spec ec_io_gpio[] = { DT_INST_FOREACH_PROP_ELEM_SEP( - 0, io_gpios, GPIO_DT_SPEC_GET_BY_IDX, (, )) }; - -static const struct device *reg_pp3300_mecc_core = - DEVICE_DT_GET(DT_NODELABEL(pp3300_mecc_core)); -static const struct device *reg_pp3300_mecc_z = - DEVICE_DT_GET(DT_NODELABEL(pp3300_mecc_z)); -static const struct device *reg_pp3300_mecc_s = - DEVICE_DT_GET(DT_NODELABEL(pp3300_mecc_s)); -static const struct device *reg_ppvar_mecc_vref = - DEVICE_DT_GET(DT_NODELABEL(ppvar_mecc_vref)); -static const struct device *reg_pp1800_mecc_z = - DEVICE_DT_GET(DT_NODELABEL(pp1800_mecc_z)); -static const struct device *reg_pp1800_mecc_s = - DEVICE_DT_GET(DT_NODELABEL(pp1800_mecc_s)); -static const struct device *reg_pp5000_mecc_z = - DEVICE_DT_GET(DT_NODELABEL(pp5000_mecc_z)); -static const struct device *reg_ppvar_mecc_rtc = - DEVICE_DT_GET(DT_NODELABEL(ppvar_mecc_rtc)); - -static bool ec_power_enabled; - -static void ec_power(bool enable) -{ - if (enable) { - regulator_enable(reg_pp3300_mecc_core); - regulator_enable(reg_pp3300_mecc_z); - regulator_enable(reg_pp3300_mecc_s); - regulator_enable(reg_ppvar_mecc_vref); - regulator_enable(reg_pp1800_mecc_z); - regulator_enable(reg_pp1800_mecc_s); - regulator_enable(reg_pp5000_mecc_z); - regulator_enable(reg_ppvar_mecc_rtc); - } else { - regulator_disable(reg_ppvar_mecc_rtc); - regulator_disable(reg_pp5000_mecc_z); - regulator_disable(reg_pp1800_mecc_s); - regulator_disable(reg_pp1800_mecc_z); - regulator_disable(reg_ppvar_mecc_vref); - regulator_disable(reg_pp3300_mecc_s); - regulator_disable(reg_pp3300_mecc_z); - regulator_disable(reg_pp3300_mecc_core); - } - - ec_power_enabled = enable; -} - -static void button_input_cb(struct input_event *evt, void *user_data) -{ - if (evt->type != INPUT_EV_KEY) { - return; - } - - if (!evt->value) { - return; - } - - switch (evt->code) { - case INPUT_KEY_0: - ec_power(!ec_power_enabled); - break; - default: - LOG_WRN("unknown code: %d", evt->code); - } -} - -INPUT_CALLBACK_DEFINE(DEVICE_DT_GET(DT_NODELABEL(gpio_keys)), button_input_cb, - NULL); - -static int expect_pin(const struct shell *sh, uint8_t i) -{ - /* TODO: make it work with more than 32 pins */ - uint32_t state = 0; - uint32_t expect = BIT(i); - - for (uint8_t j = 0; j < ARRAY_SIZE(ec_io_gpio); j++) { - const struct gpio_dt_spec *gpio = &ec_io_gpio[j]; - int val; - - val = gpio_pin_get_dt(gpio); - if (val) { - state |= BIT(j); - } - } - - if (state != expect) { - shell_print(sh, "unexpected state (%d) %08x != %08x", i, state, - expect); - return -1; - } - - shell_info(sh, "match state (%d) %08x", i, state); - return 0; -} - -#define IO_SWEEP_TIMEOUT_MS 5000 - -static int cmd_io_sweep(const struct shell *sh, size_t argc, char **argv) -{ - uint64_t start_time; - int ret; - - for (uint8_t i = 0; i < ARRAY_SIZE(ec_io_gpio); i++) { - const struct gpio_dt_spec *gpio = &ec_io_gpio[i]; - - ret = gpio_pin_configure_dt(gpio, GPIO_INPUT); - if (ret < 0) { - LOG_ERR("gpio configuration failed: %d", ret); - return ret; - } - } - - start_time = k_uptime_get(); - for (uint8_t i = 0; i < ARRAY_SIZE(ec_io_gpio); i++) { - while (true) { - if (k_uptime_get() - start_time > IO_SWEEP_TIMEOUT_MS) { - goto timeout; - } - - ret = expect_pin(sh, i); - if (ret < 0) { - k_sleep(K_MSEC(100)); - continue; - } - break; - } - } - - shell_info(sh, "sweep matched all pins successfully"); - - return 0; - -timeout: - shell_error(sh, "timeout"); - - return -ETIME; -} - -void ec_reset(void) -{ - gpio_pin_set_dt(&ec_rst_gpio, 1); - - k_sleep(K_MSEC(100)); - - gpio_pin_set_dt(&ec_rst_gpio, 0); -} - -static int cmd_ec_reset(const struct shell *sh, size_t argc, char **argv) -{ - ec_reset(); - - return 0; -} - -static int cmd_ec_power(const struct shell *sh, size_t argc, char **argv) -{ - int err = 0; - bool on; - - on = shell_strtobool(argv[1], 0, &err); - if (err) { - shell_error(sh, "Invalid argument: %s", argv[2]); - return err; - } - - ec_power(on); - - return 0; -} - -/* clang-format off */ -SHELL_STATIC_SUBCMD_SET_CREATE(ec_cmds, - SHELL_CMD_ARG(io_sweep, NULL, "io_sweep", cmd_io_sweep, 1, 0), - SHELL_CMD_ARG(power, NULL, "power on|off", cmd_ec_power, 2, 0), - SHELL_CMD_ARG(reset, NULL, "reset", cmd_ec_reset, 1, 0), - SHELL_SUBCMD_SET_END); -/* clang-format on */ - -SHELL_CMD_REGISTER(ec, &ec_cmds, "EC control commands", NULL); - -static void ec_cb(uint16_t index, uint16_t value) -{ - switch (index) { - case USB_REQ_EC_RESET: - LOG_INF("usb ec reset"); - ec_reset(); - break; - case USB_REQ_POWER: - LOG_INF("usb ec power %d", value); - ec_power(value); - break; - } -} - -USB_REQUEST_CALLBACK_DEFINE(ec_cb); - -static int ec_init(void) -{ - int ret; - - ret = gpio_pin_configure_dt(&ec_rst_gpio, GPIO_OUTPUT_INACTIVE); - if (ret < 0) { - LOG_ERR("gpio configuration failed: %d", ret); - return ret; - } - - return 0; -} - -SYS_INIT(ec_init, APPLICATION, 99);
diff --git a/firmware/src/ec.h b/firmware/src/ec.h deleted file mode 100644 index dd1a3ec..0000000 --- a/firmware/src/ec.h +++ /dev/null
@@ -1,7 +0,0 @@ -/* Copyright 2025 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Send a reset pulse to the EC board */ -void ec_reset(void);
diff --git a/firmware/src/i2c_mux.c b/firmware/src/i2c_mux.c deleted file mode 100644 index 5e2a3df..0000000 --- a/firmware/src/i2c_mux.c +++ /dev/null
@@ -1,140 +0,0 @@ -/* Copyright 2025 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include <zephyr/device.h> -#include <zephyr/drivers/gpio.h> -#include <zephyr/kernel.h> -#include <zephyr/logging/log.h> -#include <zephyr/shell/shell.h> -#include <zephyr/sys/util.h> - -#define DT_DRV_COMPAT cros_i2c_mux - -LOG_MODULE_REGISTER(i2c_mux, LOG_LEVEL_INF); - -struct i2c_mux_config { - const struct gpio_dt_spec en_gpio; - const struct gpio_dt_spec *a_gpio; - uint8_t a_gpio_count; - uint8_t port_count; -}; - -static int i2c_mux_select(const struct device *dev, uint8_t port) -{ - const struct i2c_mux_config *cfg = dev->config; - int ret; - - if (port >= cfg->port_count) { - return -EINVAL; - } - - for (uint8_t i = 0; i < cfg->a_gpio_count; i++) { - const struct gpio_dt_spec *gpio = &cfg->a_gpio[i]; - uint8_t val = IS_BIT_SET(port, i) != 0 ? 1 : 0; - - ret = gpio_pin_set_dt(gpio, val); - if (ret < 0) { - LOG_ERR("gpio set failed: %d", ret); - return ret; - } - } - - return 0; -} - -static const struct i2c_mux_api { - /* empty, just for use in shell_device_filter */ -} i2c_mux_api; - -static bool i2c_mux_device_filter(const struct device *dev) -{ - return dev->api == &i2c_mux_api; -} - -static void device_name_get(size_t idx, struct shell_static_entry *entry) -{ - const struct device *dev = - shell_device_filter(idx, i2c_mux_device_filter); - - entry->syntax = (dev != NULL) ? dev->name : NULL; - entry->handler = NULL; - entry->help = NULL; - entry->subcmd = NULL; -} - -SHELL_DYNAMIC_CMD_CREATE(dsub_device_name, device_name_get); - -static int cmd_i2c_mux(const struct shell *sh, size_t argc, char **argv) -{ - const struct device *dev; - int err = 0; - int port; - - dev = device_get_binding(argv[1]); - if (dev == NULL) { - shell_error(sh, "Device %s not available", argv[1]); - return -ENODEV; - } - - port = shell_strtol(argv[2], 0, &err); - if (err) { - shell_error(sh, "Invalid argument: %s", argv[2]); - return err; - } - - err = i2c_mux_select(dev, port); - if (err < 0) { - shell_error(sh, "i2c_mux_select error: %d", err); - return err; - } - - return 0; -} - -SHELL_CMD_ARG_REGISTER(i2c_mux, &dsub_device_name, "I2C multiplexer control", - cmd_i2c_mux, 3, 0); - -static int i2c_mux_init(const struct device *dev) -{ - const struct i2c_mux_config *cfg = dev->config; - int ret; - - ret = gpio_pin_configure_dt(&cfg->en_gpio, GPIO_OUTPUT_ACTIVE); - if (ret < 0) { - LOG_ERR("gpio configuration failed: %d", ret); - return ret; - } - - for (uint8_t i = 0; i < cfg->a_gpio_count; i++) { - const struct gpio_dt_spec *gpio = &cfg->a_gpio[i]; - - ret = gpio_pin_configure_dt(gpio, GPIO_OUTPUT_INACTIVE); - if (ret < 0) { - LOG_ERR("gpio configuration failed: %d", ret); - return ret; - } - } - - return 0; -} - -#define I2C_MUX_INIT(n) \ - const struct gpio_dt_spec i2c_mux_a_gpio_##n[] = { \ - DT_INST_FOREACH_PROP_ELEM_SEP(n, a_gpios, \ - GPIO_DT_SPEC_GET_BY_IDX, (, )) \ - }; \ - \ - static const struct i2c_mux_config i2c_mux_cfg_##n = { \ - .en_gpio = GPIO_DT_SPEC_INST_GET(n, en_gpios), \ - .a_gpio = i2c_mux_a_gpio_##n, \ - .a_gpio_count = ARRAY_SIZE(i2c_mux_a_gpio_##n), \ - .port_count = DT_INST_PROP(n, port_count), \ - }; \ - \ - DEVICE_DT_INST_DEFINE(n, i2c_mux_init, NULL(n), NULL, \ - &i2c_mux_cfg_##n, POST_KERNEL, \ - CONFIG_I2C_INIT_PRIORITY, &i2c_mux_api); - -DT_INST_FOREACH_STATUS_OKAY(I2C_MUX_INIT)
diff --git a/firmware/src/i2c_target.c b/firmware/src/i2c_target.c deleted file mode 100644 index ec7d51d..0000000 --- a/firmware/src/i2c_target.c +++ /dev/null
@@ -1,48 +0,0 @@ -/* Copyright 2025 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include <zephyr/drivers/i2c.h> -#include <zephyr/kernel.h> -#include <zephyr/logging/log.h> - -LOG_MODULE_REGISTER(i2c_traget, LOG_LEVEL_INF); - -static int i2c_target_device_init(const struct device *dev) -{ - int ret; - - if (!device_is_ready(dev)) { - LOG_ERR("device %s not ready", dev->name); - return -ENODEV; - } - - ret = i2c_target_driver_register(dev); - if (ret < 0) { - LOG_ERR("i2c target device %s register failed: %d", dev->name, - ret); - return ret; - } - - return 0; -} - -static int i2c_target_init(void) -{ - int ret; - - ret = i2c_target_device_init(DEVICE_DT_GET(DT_NODELABEL(eeprom0))); - if (ret < 0) { - return ret; - } - - ret = i2c_target_device_init(DEVICE_DT_GET(DT_NODELABEL(eeprom1))); - if (ret < 0) { - return ret; - } - - return 0; -} - -SYS_INIT(i2c_target_init, APPLICATION, 99);
diff --git a/firmware/src/main.c b/firmware/src/main.c deleted file mode 100644 index 8bc0a40..0000000 --- a/firmware/src/main.c +++ /dev/null
@@ -1,25 +0,0 @@ -/* Copyright 2024 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include <zephyr/drivers/led.h> -#include <zephyr/kernel.h> -#include <zephyr/logging/log.h> -#include <zephyr/shell/shell.h> - -LOG_MODULE_REGISTER(main, LOG_LEVEL_INF); - -const struct led_dt_spec status_led = LED_DT_SPEC_GET(DT_NODELABEL(status_led)); - -int main(void) -{ - LOG_INF("started"); - - while (true) { - led_on_dt(&status_led); - k_sleep(K_MSEC(1000)); - led_off_dt(&status_led); - k_sleep(K_MSEC(1000)); - } -}
diff --git a/firmware/src/npcx_boot.c b/firmware/src/npcx_boot.c deleted file mode 100644 index c65b952..0000000 --- a/firmware/src/npcx_boot.c +++ /dev/null
@@ -1,81 +0,0 @@ -/* Copyright 2025 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#define DT_DRV_COMPAT cros_npcx_boot - -#include "ec.h" -#include "usb_request.h" - -#include <zephyr/drivers/gpio.h> -#include <zephyr/drivers/pinctrl.h> -#include <zephyr/kernel.h> -#include <zephyr/logging/log.h> -#include <zephyr/shell/shell.h> -#include <zephyr/shell/shell_uart.h> - -LOG_MODULE_REGISTER(npcx_boot, LOG_LEVEL_INF); - -BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1, - "only one 'cros,npcx-boot' compatible node may be present"); - -#define PINCTRL_STATE_GPIO 2 - -PINCTRL_DT_INST_DEFINE(0); -const struct pinctrl_dev_config *npcx_boot_pcfg = - PINCTRL_DT_INST_DEV_CONFIG_GET(0); -const struct gpio_dt_spec npcx_boot_gpio = - GPIO_DT_SPEC_INST_GET(0, npcx_boot_gpios); - -static int cmd_npcx_boot(const struct shell *sh, size_t argc, char **argv) -{ - int ret; - - ret = pinctrl_apply_state(npcx_boot_pcfg, PINCTRL_STATE_GPIO); - if (ret < 0) { - shell_error(sh, "1 pinctrl configuration failed: %d", ret); - return ret; - } - - ret = gpio_pin_configure_dt(&npcx_boot_gpio, GPIO_OUTPUT_ACTIVE); - if (ret < 0) { - shell_error(sh, "gpio configuration failed: %d", ret); - return ret; - } - - ec_reset(); - - k_sleep(K_MSEC(100)); - - ret = gpio_pin_configure_dt(&npcx_boot_gpio, GPIO_INPUT); - if (ret < 0) { - shell_error(sh, "gpio configuration failed: %d", ret); - return ret; - } - - ret = pinctrl_apply_state(npcx_boot_pcfg, PINCTRL_STATE_DEFAULT); - if (ret < 0) { - shell_error(sh, "2 pinctrl configuration failed: %d", ret); - return ret; - } - - return 0; -} - -SHELL_CMD_REGISTER(npcx_boot, NULL, "Enter NPCX bootloader", cmd_npcx_boot); - -static void npcx_boot_cb(uint16_t index, uint16_t value) -{ - const struct shell *sh = shell_backend_uart_get_ptr(); - - if (index != USB_REQ_NPCX_BOOT) { - return; - } - - LOG_INF("npcx boot"); - - cmd_npcx_boot(sh, 0, NULL); -} - -USB_REQUEST_CALLBACK_DEFINE(npcx_boot_cb);
diff --git a/firmware/src/uart-bridge.c b/firmware/src/uart-bridge.c deleted file mode 100644 index 6c6c8af..0000000 --- a/firmware/src/uart-bridge.c +++ /dev/null
@@ -1,227 +0,0 @@ -/* Copyright 2025 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include <zephyr/device.h> -#include <zephyr/drivers/uart.h> -#include <zephyr/kernel.h> -#include <zephyr/logging/log.h> -#include <zephyr/sys/ring_buffer.h> -#include <zephyr/usb/usb_device.h> - -#define DT_DRV_COMPAT zephyr_uart_bridge - -LOG_MODULE_REGISTER(uart_bridge, LOG_LEVEL_INF); - -#define RING_BUF_SIZE 256 -#define RING_BUF_FULL_THRESHOLD (RING_BUF_SIZE / 3) - -struct uart_bridge_peer_config { - const struct device *dev; - size_t transfer_size; -}; - -struct uart_bridge_config { - struct uart_bridge_peer_config peer[2]; -}; - -struct uart_bridge_peer_data { - uint8_t buf[RING_BUF_SIZE]; - struct ring_buf rb; - bool paused; -}; - -struct uart_bridge_data { - struct uart_bridge_peer_data peer[2]; -}; - -static const struct device * -uart_bridge_get_peer(const struct device *dev, const struct device *bridge_dev) -{ - const struct uart_bridge_config *cfg = bridge_dev->config; - - if (dev == cfg->peer[0].dev) { - return cfg->peer[1].dev; - } else if (dev == cfg->peer[1].dev) { - return cfg->peer[0].dev; - } else { - return NULL; - } -} - -void uart_bridge_settings_update(const struct device *dev, - const struct device *bridge_dev) -{ - struct uart_config cfg; - const struct device *peer_dev = uart_bridge_get_peer(dev, bridge_dev); - int ret; - - if (peer_dev == NULL) { - LOG_DBG("%s: not a bridge dev", dev->name); - return; - } - - LOG_DBG("update settings: dev=%s bridge=%s peer=%s", dev->name, - bridge_dev->name, peer_dev->name); - - ret = uart_config_get(dev, &cfg); - if (ret) { - LOG_WRN("%s: failed to get the uart config: %d", dev->name, - ret); - return; - } - - ret = uart_configure(peer_dev, &cfg); - if (ret) { - LOG_WRN("%s: failed to set the uart config: %d", peer_dev->name, - ret); - return; - } - - LOG_INF("uart settings: baudrate=%d parity=%d", cfg.baudrate, - cfg.parity); -} - -static uint8_t uart_bridge_get_idx(const struct device *dev, - const struct device *bridge_dev, bool own) -{ - const struct uart_bridge_config *cfg = bridge_dev->config; - - if (dev == cfg->peer[0].dev) { - return own ? 0 : 1; - } else { - return own ? 1 : 0; - } -} - -static void uart_bridge_handle_rx(const struct device *dev, - const struct device *bridge_dev) -{ - const struct uart_bridge_config *cfg = bridge_dev->config; - struct uart_bridge_data *data = bridge_dev->data; - - const struct uart_bridge_peer_config *own_cfg = - &cfg->peer[uart_bridge_get_idx(dev, bridge_dev, true)]; - const struct uart_bridge_peer_config *peer_cfg = - &cfg->peer[uart_bridge_get_idx(dev, bridge_dev, false)]; - struct uart_bridge_peer_data *own_data = - &data->peer[uart_bridge_get_idx(dev, bridge_dev, true)]; - - uint8_t buffer[own_cfg->transfer_size]; - int rb_len, recv_len; - - if (ring_buf_space_get(&own_data->rb) < RING_BUF_FULL_THRESHOLD) { - LOG_DBG("%s: buffer full: pause", dev->name); - uart_irq_rx_disable(dev); - own_data->paused = true; - return; - } - - recv_len = uart_fifo_read(dev, buffer, sizeof(buffer)); - if (!recv_len) - return; - - rb_len = ring_buf_put(&own_data->rb, buffer, recv_len); - if (rb_len < recv_len) { - LOG_WRN("%s: rx drop %u bytes", dev->name, recv_len - rb_len); - } - - uart_irq_tx_enable(peer_cfg->dev); -} - -static void uart_bridge_handle_tx(const struct device *dev, - const struct device *bridge_dev) -{ - const struct uart_bridge_config *cfg = bridge_dev->config; - struct uart_bridge_data *data = bridge_dev->data; - - const struct uart_bridge_peer_config *own_cfg = - &cfg->peer[uart_bridge_get_idx(dev, bridge_dev, true)]; - const struct uart_bridge_peer_config *peer_cfg = - &cfg->peer[uart_bridge_get_idx(dev, bridge_dev, false)]; - struct uart_bridge_peer_data *peer_data = - &data->peer[uart_bridge_get_idx(dev, bridge_dev, false)]; - - uint8_t buffer[own_cfg->transfer_size]; - int rb_len, send_len; - - rb_len = ring_buf_get(&peer_data->rb, buffer, sizeof(buffer)); - if (!rb_len) { - LOG_DBG("%s: buffer empty, disable tx irq", dev->name); - uart_irq_tx_disable(dev); - return; - } - - send_len = uart_fifo_fill(dev, buffer, rb_len); - if (send_len < rb_len) { - LOG_WRN("%s: tx dropped %d bytes", dev->name, - rb_len - send_len); - } - - if (peer_data->paused && - ring_buf_space_get(&peer_data->rb) > RING_BUF_FULL_THRESHOLD) { - LOG_DBG("%s: buffer free: resume", dev->name); - uart_irq_rx_enable(peer_cfg->dev); - peer_data->paused = false; - return; - } -} - -static void interrupt_handler(const struct device *dev, void *user_data) -{ - const struct device *bridge_dev = user_data; - - while (uart_irq_update(dev) && uart_irq_is_pending(dev)) { - if (uart_irq_rx_ready(dev)) { - uart_bridge_handle_rx(dev, bridge_dev); - } - if (uart_irq_tx_ready(dev)) { - uart_bridge_handle_tx(dev, bridge_dev); - } - } -} - -static int uart_bridge_init(const struct device *dev) -{ - const struct uart_bridge_config *cfg = dev->config; - struct uart_bridge_data *data = dev->data; - - ring_buf_init(&data->peer[0].rb, RING_BUF_SIZE, data->peer[0].buf); - ring_buf_init(&data->peer[1].rb, RING_BUF_SIZE, data->peer[1].buf); - - /* Wait 100ms for the host to do all settings */ - k_msleep(100); - - uart_irq_callback_user_data_set(cfg->peer[0].dev, interrupt_handler, - (void *)dev); - uart_irq_callback_user_data_set(cfg->peer[1].dev, interrupt_handler, - (void *)dev); - uart_irq_rx_enable(cfg->peer[0].dev); - uart_irq_rx_enable(cfg->peer[1].dev); - - return 0; -} - -#define UART_BRIDGE_PEER_DEFINE(node_id) \ - { \ - .dev = DEVICE_DT_GET(DT_PHANDLE(node_id, device)), \ - .transfer_size = DT_PROP(node_id, transfer_size), \ - } - -#define UART_BRIDGE_INIT(n) \ - BUILD_ASSERT(DT_INST_CHILD_NUM(n) == 2, \ - "uart-bridge must have exactly 2 child nodes"); \ - \ - static const struct uart_bridge_config uart_bridge_cfg_##n = { \ - .peer = { DT_INST_FOREACH_CHILD_STATUS_OKAY_SEP( \ - n, UART_BRIDGE_PEER_DEFINE, (, )) }, \ - }; \ - \ - static struct uart_bridge_data uart_bridge_data_##n; \ - \ - DEVICE_DT_INST_DEFINE(n, uart_bridge_init, NULL(n), \ - &uart_bridge_data_##n, &uart_bridge_cfg_##n, \ - POST_KERNEL, CONFIG_SERIAL_INIT_PRIORITY, NULL); - -DT_INST_FOREACH_STATUS_OKAY(UART_BRIDGE_INIT)
diff --git a/firmware/src/uart-bridge.h b/firmware/src/uart-bridge.h deleted file mode 100644 index a766090..0000000 --- a/firmware/src/uart-bridge.h +++ /dev/null
@@ -1,18 +0,0 @@ -/* Copyright 2025 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include <zephyr/device.h> - -/** - * @brief Update the hardware port settings on an uart bridge - * - * If dev is part bridge_dev, then the dev uart configuration are applied to - * the other device in the uart bridge. This allows propagating the settings - * from a USB CDC-ACM port to a hardware UART. - * - * If dev is not part of bridge_dev then the function is a no-op. - */ -void uart_bridge_settings_update(const struct device *dev, - const struct device *bridge_dev);
diff --git a/firmware/src/usb_request.h b/firmware/src/usb_request.h deleted file mode 100644 index f281fea..0000000 --- a/firmware/src/usb_request.h +++ /dev/null
@@ -1,20 +0,0 @@ -/* Copyright 2025 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include <stdint.h> - -#define USB_REQ_EC_RESET 0 -#define USB_REQ_POWER 1 -#define USB_REQ_NPCX_BOOT 2 - -struct usb_request_callback { - void (*callback)(uint16_t index, uint16_t value); -}; - -#define USB_REQUEST_CALLBACK_DEFINE(_callback) \ - static const STRUCT_SECTION_ITERABLE( \ - usb_request_callback, _usb_request_callback__##_callback) = { \ - .callback = _callback, \ - }
diff --git a/firmware/src/usb_request.ld b/firmware/src/usb_request.ld deleted file mode 100644 index d99a755..0000000 --- a/firmware/src/usb_request.ld +++ /dev/null
@@ -1,8 +0,0 @@ -/* Copyright 2025 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include <zephyr/linker/iterable_sections.h> - -ITERABLE_SECTION_ROM(usb_request_callback, Z_LINK_ITERABLE_SUBALIGN)
diff --git a/firmware/src/usbd.c b/firmware/src/usbd.c deleted file mode 100644 index 4a486de..0000000 --- a/firmware/src/usbd.c +++ /dev/null
@@ -1,209 +0,0 @@ -/* Copyright 2024 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "uart-bridge.h" -#include "usb_request.h" - -#include <zephyr/device.h> -#include <zephyr/input/input.h> -#include <zephyr/kernel.h> -#include <zephyr/usb/usbd.h> - -LOG_MODULE_REGISTER(usbd_app, LOG_LEVEL_INF); - -#define USB_VID 0x18d1 -#define USB_PID 0x5214 -#define USB_MANUFACTURER_NAME "Google" -#define USB_DEVICE_NAME "EC AIC Tester" -#define USB_MAX_POWER 250 - -USBD_DEVICE_DEFINE(app_usbd, DEVICE_DT_GET(DT_NODELABEL(zephyr_udc0)), USB_VID, - USB_PID); - -USBD_DESC_LANG_DEFINE(app_usb_lang); -USBD_DESC_MANUFACTURER_DEFINE(app_usb_mfr, USB_MANUFACTURER_NAME); -USBD_DESC_PRODUCT_DEFINE(app_usb_product, USB_DEVICE_NAME); -USBD_DESC_SERIAL_NUMBER_DEFINE(app_usb_sn); - -static const uint8_t attributes = 0; - -USBD_DESC_CONFIG_DEFINE(fs_cfg_desc, "FS Configuration"); -USBD_DESC_CONFIG_DEFINE(hs_cfg_desc, "HS Configuration"); -USBD_CONFIGURATION_DEFINE(app_usb_fs_config, attributes, USB_MAX_POWER, - &fs_cfg_desc); -USBD_CONFIGURATION_DEFINE(app_usb_hs_config, attributes, USB_MAX_POWER, - &hs_cfg_desc); - -static int to_host_cb(const struct usbd_context *const ctx, - const struct usb_setup_packet *const setup, - struct net_buf *const buf) -{ - LOG_INF("%d: %d %d %d %d", setup->RequestType.type, setup->bRequest, - setup->wLength, setup->wIndex, setup->wValue); - - return 0; -} - -static int to_dev_cb(const struct usbd_context *const ctx, - const struct usb_setup_packet *const setup, - const struct net_buf *const buf) -{ - STRUCT_SECTION_FOREACH(usb_request_callback, callback) - { - callback->callback(setup->wIndex, setup->wValue); - } - - return 0; -} - -USBD_VREQUEST_DEFINE(vnd_vreq, 0, to_host_cb, to_dev_cb); - -static void usbd_msg_cb(struct usbd_context *const usbd_ctx, - const struct usbd_msg *const msg) -{ - int ret; - - LOG_DBG("USBD message: %s", usbd_msg_type_string(msg->type)); - - if (msg->type == USBD_MSG_CDC_ACM_LINE_CODING || - msg->type == USBD_MSG_CDC_ACM_CONTROL_LINE_STATE) { - uart_bridge_settings_update( - msg->dev, DEVICE_DT_GET(DT_NODELABEL(uart_bridge))); - } - - if (!usbd_can_detect_vbus(usbd_ctx)) { - return; - } - - switch (msg->type) { - case USBD_MSG_VBUS_READY: - ret = usbd_enable(usbd_ctx); - if (ret) { - LOG_ERR("Failed to enable device support"); - } - - break; - case USBD_MSG_VBUS_REMOVED: - ret = usbd_disable(usbd_ctx); - if (ret) { - LOG_ERR("Failed to disable device support"); - } - - break; - case USBD_MSG_RESUME: - break; - case USBD_MSG_SUSPEND: - break; - default: - break; - } -} - -static struct usbd_context *usbd_init_device(void) -{ - int err; - - err = usbd_add_descriptor(&app_usbd, &app_usb_lang); - if (err) { - LOG_ERR("Failed to initialize language descriptor (%d)", err); - return NULL; - } - - err = usbd_add_descriptor(&app_usbd, &app_usb_mfr); - if (err) { - LOG_ERR("Failed to initialize manufacturer descriptor (%d)", - err); - return NULL; - } - - err = usbd_add_descriptor(&app_usbd, &app_usb_product); - if (err) { - LOG_ERR("Failed to initialize product descriptor (%d)", err); - return NULL; - } - - err = usbd_add_descriptor(&app_usbd, &app_usb_sn); - if (err) { - LOG_ERR("Failed to initialize SN descriptor (%d)", err); - return NULL; - } - - if (usbd_caps_speed(&app_usbd) == USBD_SPEED_HS) { - err = usbd_add_configuration(&app_usbd, USBD_SPEED_HS, - &app_usb_hs_config); - if (err) { - LOG_ERR("Failed to add High-Speed configuration"); - return NULL; - } - - err = usbd_register_all_classes(&app_usbd, USBD_SPEED_HS, 1); - if (err) { - LOG_ERR("Failed to add register classes"); - return NULL; - } - - usbd_device_set_code_triple(&app_usbd, USBD_SPEED_HS, 0, 0, 0); - } - - err = usbd_add_configuration(&app_usbd, USBD_SPEED_FS, - &app_usb_fs_config); - if (err) { - LOG_ERR("Failed to add Full-Speed configuration"); - return NULL; - } - - err = usbd_register_all_classes(&app_usbd, USBD_SPEED_FS, 1); - if (err) { - LOG_ERR("Failed to add register classes"); - return NULL; - } - - usbd_device_set_code_triple(&app_usbd, USBD_SPEED_FS, 0, 0, 0); - - err = usbd_msg_register_cb(&app_usbd, usbd_msg_cb); - if (err) { - LOG_ERR("Failed to register message callback"); - return NULL; - } - - err = usbd_device_register_vreq(&app_usbd, &vnd_vreq); - if (err) { - LOG_ERR("Failed to register vreq"); - return NULL; - } - - err = usbd_init(&app_usbd); - if (err) { - LOG_ERR("Failed to initialize device support"); - return NULL; - } - - return &app_usbd; -} - -static int app_usbd_enable(void) -{ - struct usbd_context *usbd; - int ret; - - usbd = usbd_init_device(); - if (usbd == NULL) { - LOG_ERR("Failed to initialize USB device"); - return -ENODEV; - } - - if (usbd_can_detect_vbus(usbd)) { - return 0; - } - - ret = usbd_enable(usbd); - if (ret != 0) { - LOG_ERR("Failed to enable USB"); - return 0; - } - - return 0; -} -SYS_INIT(app_usbd_enable, APPLICATION, 0);
diff --git a/firmware/west-upstream.yml b/firmware/west-upstream.yml deleted file mode 100644 index c00005e..0000000 --- a/firmware/west-upstream.yml +++ /dev/null
@@ -1,17 +0,0 @@ -# Copyright 2024 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -manifest: - remotes: - - name: zephyrproject-rtos - url-base: https://github.com/zephyrproject-rtos - - projects: - - name: zephyr - remote: zephyrproject-rtos - revision: main - import: - name-allowlist: - - cmsis - - hal_stm32
diff --git a/firmware/west.yml b/firmware/west.yml deleted file mode 100644 index b38d2d9..0000000 --- a/firmware/west.yml +++ /dev/null
@@ -1,27 +0,0 @@ -# Copyright 2024 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -manifest: - remotes: - - name: chromium - url-base: https://chromium.googlesource.com/chromiumos - - projects: - - name: zephyr - remote: chromium - repo-path: third_party/zephyr - revision: main - west-commands: scripts/west-commands.yml - - - name: cmsis - remote: chromium - repo-path: third_party/zephyr/cmsis - revision: chromeos-main - path: modules/hal/cmsis - - - name: hal_stm32 - remote: chromium - repo-path: third_party/zephyr/hal_stm32 - revision: chromeos-main - path: modules/hal/stm32
diff --git a/flash_npcx.py b/flash_npcx.py deleted file mode 100755 index c2af335..0000000 --- a/flash_npcx.py +++ /dev/null
@@ -1,67 +0,0 @@ -#!/usr/bin/env python3 -# Copyright 2025 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import argparse -import os -import sys -import time - -import usb - - -args = None -target = None - - -def find_usb_device(): - dev = usb.core.find(manufacturer="Google", product="EC AIC Tester") - if dev is None: - raise ValueError("Device not found") - - return dev - - -# bRequest values: -# bit 7 = 0: host to device -# bit 6..5 = vendor -# bit 4..0 = device -TO_DEV_REQ_TYPE = 0x40 -# bit 7 = 0: device to host -# bit 6..5 = vendor -# bit 4..0 = device -TO_HOST_REQ_TYPE = 0xC0 - -# Must match the definitions in firmware/src/usb_request.h -USB_REQ_EC_RESET = 0 -USB_REQ_POWER = 1 -USB_REQ_NPCX_BOOT = 2 - - -def main(argv): - global args - global target - - parser = argparse.ArgumentParser() - parser.add_argument("-p", "--port", type=str, default="ttyACM2") - args = parser.parse_args(argv) - - dev = find_usb_device() - - dev.ctrl_transfer(TO_DEV_REQ_TYPE, 0, 1, USB_REQ_POWER, 0) - - dev.ctrl_transfer(TO_DEV_REQ_TYPE, 0, 0, USB_REQ_NPCX_BOOT, 0) - - os.system( - f"uartupdatetool --port={args.port} --baudrate=115200 --opr=wr --addr=0x200C3020 --file build/zephyr/npcx-aic/output/npcx_monitor.bin" - ) - os.system( - f"uartupdatetool --port={args.port} --baudrate=115200 --opr=wr --auto --offset=0 --file build/zephyr/npcx-aic/output/ec.bin" - ) - - dev.ctrl_transfer(TO_DEV_REQ_TYPE, 0, 0, USB_REQ_EC_RESET, 0) - - -if __name__ == "__main__": - sys.exit(main(sys.argv[1:]))