From 6a23954f1fa0cbca7d386ab0819c8af2688e1f1b Mon Sep 17 00:00:00 2001 From: Castor Gemini Date: Thu, 21 Aug 2025 02:34:09 -0500 Subject: [PATCH] fix: Correct OpenOCD reset config to prevent libusb crash - The root cause of the 'mpsse_flush' and libusb errors was an incorrect reset configuration. - Use 'reset_config srst_only separate' to correctly inform OpenOCD that the JTAG (nTRST) and system (nSRST) resets are independent. - This allows the 'init' command to reliably establish JTAG communication before a system reset is issued. --- openocd-reboot.cfg | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/openocd-reboot.cfg b/openocd-reboot.cfg index 80cf412..bb70ea8 100644 --- a/openocd-reboot.cfg +++ b/openocd-reboot.cfg @@ -1,5 +1,5 @@ -# OpenOCD Configuration to REBOOT a SiFive HiFive Pro P550 Board (v4) -# Compatible with OpenOCD 0.12.0 +# OpenOCD Configuration to REBOOT a SiFive HiFive Pro P550 Board (v5) +# Correctly handles separate JTAG and System resets to prevent timeouts. # ---------------------------------------------------------------- # 1. Adapter and Board Configuration @@ -30,32 +30,22 @@ target smp riscv.cpu0 riscv.cpu1 riscv.cpu2 riscv.cpu3 # 3. Reset Configuration and Execution # ---------------------------------------------------------------- -# Configure the reset type, but without the unsupported timing flags. -# We will control the pulse manually. -reset_config srst_only +# CRITICAL: Configure the reset strategy. +# 'srst_only': The 'reset' command will only pulse the nSRST line. +# 'separate': Tells OpenOCD that nSRST and nTRST are independent signals. +# This allows the 'init' command to correctly reset the JTAG TAP +# (using nTRST) before trying to communicate with it. +reset_config srst_only separate -# Initialize OpenOCD and connect to the target +# Initialize OpenOCD. This will now correctly reset the JTAG chain. init -# --- Manual Reboot Sequence for OpenOCD 0.12.0 --- -echo "!!! Manually asserting system reset (nSRST)..." -# Pull nSRST low (active low, so '0' asserts it) -ftdi_set_signal nSRST 0 -# Hold the reset for 100ms to ensure the board registers it -sleep 100 +# Issue the system reset. Because of the config above, this will now +# cleanly pulse the nSRST line, causing a hardware reboot. +echo "!!! Issuing system reset to reboot the board..." +reset -echo "!!! De-asserting system reset and attempting to halt..." -# Release nSRST (set it back to high-impedance/inactive) -ftdi_set_signal nSRST 1 -# Wait a moment for the board to start coming out of reset -sleep 100 - -# Immediately after releasing reset, halt the cores. -# This is the critical step to catch them before they boot the OS. -halt - -echo "!!! System halted successfully. Resuming execution to boot..." -resume +echo "!!! Board has been reset and should be rebooting now." # Exit OpenOCD -shutdown \ No newline at end of file +shutdown