From f844d06da223b06cf7b13e4228937a0fe8955f76 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Fri, 19 Jul 2024 15:43:25 +0200 Subject: [PATCH] targets/litex_acorn_baseboard_mini: Add detect_ftdi_chip method since newer batch of baseboard is mounted with FTDI ft4232 chips. FT2232 and FT4232 chips are footprint compatible but still need to be handled differently from software. --- litex_boards/targets/litex_acorn_baseboard_mini.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/litex_boards/targets/litex_acorn_baseboard_mini.py b/litex_boards/targets/litex_acorn_baseboard_mini.py index d5ea670..efb38ad 100755 --- a/litex_boards/targets/litex_acorn_baseboard_mini.py +++ b/litex_boards/targets/litex_acorn_baseboard_mini.py @@ -6,6 +6,8 @@ # Copyright (c) 2021-2024 Florent Kermarrec # SPDX-License-Identifier: BSD-2-Clause +import subprocess + from migen import * from litex.gen import * @@ -39,8 +41,18 @@ from litesata.phy import LiteSATAPHY # Platform ----------------------------------------------------------------------------------------- class Platform(sqrl_acorn.Platform): + def detect_ftdi_chip(self): + lsusb_log = subprocess.run(['lsusb'], capture_output=True, text=True) + for ftdi_chip in ["ft232", "ft2232", "ft4232"]: + if f"Future Technology Devices International, Ltd {ftdi_chip.upper()}" in lsusb_log.stdout: + return ftdi_chip + return None + def create_programmer(self, name="openocd"): - return OpenOCD("openocd_xc7_ft2232.cfg", "bscan_spi_xc7a200t.bit") + ftdi_chip = self.detect_ftdi_chip() + if ftdi_chip is None: + raise RuntimeError("No compatible FTDI device found.") + return OpenOCD(f"openocd_xc7_{ftdi_chip}.cfg", "bscan_spi_xc7a200t.bit") # CRG ----------------------------------------------------------------------------------------------