diff --git a/target/ast10x0/BOARDS.md b/target/ast10x0/BOARDS.md index 38c3035aa..4f1fd3510 100644 --- a/target/ast10x0/BOARDS.md +++ b/target/ast10x0/BOARDS.md @@ -34,9 +34,9 @@ GPIO connections should be as follows: | Raspberry Pi Pin | Target Device | Target Pin | |------------------|---------------|----------------| -| 23 | A | SRST (PIN1) | +| 27 | A | SRST (PIN1) | | 18 | A | FWSPICK (PIN2) | -| 25 | B | SRST (PIN1) | +| 17 | B | SRST (PIN1) | | 24 | B | FWSPICK (PIN2) | For I2C communication, connect pins 1 and 2 of J15. This links I2C2 between the devices. diff --git a/target/ast10x0/harness/evb_config.toml b/target/ast10x0/harness/evb_config.toml index c169c6044..bf155e7d1 100644 --- a/target/ast10x0/harness/evb_config.toml +++ b/target/ast10x0/harness/evb_config.toml @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 [gpio] -srst_pin = 23 +srst_pin = 27 fwspick_pin = 18 [uart] @@ -10,6 +10,6 @@ serial_port = "/dev/ttyUSB0" baudrate = 115200 [device_b] -srst_pin = 25 +srst_pin = 17 fwspick_pin = 24 serial_port = "/dev/ttyUSB1" diff --git a/target/ast10x0/harness/pi_test_runner.py b/target/ast10x0/harness/pi_test_runner.py index 9f418f9f4..13290ed88 100644 --- a/target/ast10x0/harness/pi_test_runner.py +++ b/target/ast10x0/harness/pi_test_runner.py @@ -32,6 +32,10 @@ def _gpio_set(pin: int, state: str) -> None: subprocess.run(["pinctrl", "set", str(pin), "op"] + state.split(), check=True) +def _gpio_set_input(pin: int, pull: str) -> None: + subprocess.run(["pinctrl", "set", str(pin), "ip", pull], check=True) + + def _sequence_to_fwspick_mode( srst_pin: int, fwspick_pin: int, port: serial.Serial ) -> None: @@ -41,7 +45,7 @@ def _sequence_to_fwspick_mode( port.read(4096) _gpio_set(fwspick_pin, "pn dh") time.sleep(1) - _gpio_set(srst_pin, "dh") + _gpio_set_input(srst_pin, "pn") time.sleep(1) diff --git a/target/ast10x0/harness/uart_test_exec.py b/target/ast10x0/harness/uart_test_exec.py index df4030920..7bcecabdb 100644 --- a/target/ast10x0/harness/uart_test_exec.py +++ b/target/ast10x0/harness/uart_test_exec.py @@ -116,10 +116,28 @@ def gpio_set(self, pin: int, state: str): except Exception as e: raise RuntimeError(f"Failed to set GPIO {pin} to {state}: {e}") + def gpio_set_input(self, pin: int, pull: str): + """Set GPIO pin to input with the given pull using pinctrl.""" + cmd = ["pinctrl", "set", str(pin), "ip", pull] + self.log(f"GPIO {pin}: input ({pull})") + + if self.args.dry_run: + self.log(f"DRY RUN: {' '.join(cmd)}") + return + + try: + self.run_command(cmd) + except Exception as e: + raise RuntimeError(f"Failed to set GPIO {pin} to input ({pull}): {e}") + def toggle_srst(self, state: str): - """Toggle SRST pin (dl=low, dh=high).""" + """Drive SRST pin low (state='dl').""" self.gpio_set(self.args.srst_pin, state) + def release_srst(self): + """Release SRST pin to input, floating (no pull).""" + self.gpio_set_input(self.args.srst_pin, "pn") + def toggle_fwspick(self, state: str): """Toggle FWSPICK pin (dh=high, dl=low).""" if state == "dh": @@ -148,7 +166,7 @@ def sequence_to_fwspick_mode(self): time.sleep(0.1) self.toggle_fwspick("dh") # FWSPICK high time.sleep(1) - self.toggle_srst("dh") # SRST high + self.release_srst() time.sleep(1) self.log("FWSPICK mode sequence complete") @@ -159,7 +177,7 @@ def sequence_to_normal_mode(self): time.sleep(0.1) self.toggle_srst("dl") # SRST low time.sleep(0.5) - self.toggle_srst("dh") # SRST high + self.release_srst() time.sleep(2) self.log("Normal boot mode sequence complete") @@ -439,7 +457,7 @@ def main(): # GPIO control parser.add_argument( - "--srst-pin", type=int, default=23, help="SRST GPIO pin number (default: 23)" + "--srst-pin", type=int, default=27, help="SRST GPIO pin number (default: 27)" ) parser.add_argument( "--fwspick-pin", @@ -551,8 +569,10 @@ def main(): try: # Handle manual GPIO operations if args.manual_srst: - state = "dl" if args.manual_srst in ["low", "dl"] else "dh" - executor.toggle_srst(state) + if args.manual_srst in ["low", "dl"]: + executor.toggle_srst("dl") + else: + executor.release_srst() return 0 if args.manual_fwspick: diff --git a/target/ast10x0/tests/mctp/server/README.md b/target/ast10x0/tests/mctp/server/README.md index 248d84070..23371c26e 100644 --- a/target/ast10x0/tests/mctp/server/README.md +++ b/target/ast10x0/tests/mctp/server/README.md @@ -150,7 +150,7 @@ GPIO pin assignments and serial port paths are defined in ```toml [gpio] -srst_pin = 23 # BCM pin connected to board A SRST +srst_pin = 27 # BCM pin connected to board A SRST fwspick_pin = 18 # BCM pin connected to board A FWSPICK [uart] @@ -158,7 +158,7 @@ serial_port = "/dev/ttyUSB0" # Board A serial port baudrate = 115200 [device_b] -srst_pin = 25 # BCM pin connected to board B SRST +srst_pin = 17 # BCM pin connected to board B SRST fwspick_pin = 24 # BCM pin connected to board B FWSPICK serial_port = "/dev/ttyUSB1" # Board B serial port ```