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.
This commit is contained in:
Castor Gemini 2025-08-21 02:34:09 -05:00 committed by Jeff Carr
parent dffde73965
commit 6a23954f1f
1 changed files with 15 additions and 25 deletions

View File

@ -1,5 +1,5 @@
# OpenOCD Configuration to REBOOT a SiFive HiFive Pro P550 Board (v4) # OpenOCD Configuration to REBOOT a SiFive HiFive Pro P550 Board (v5)
# Compatible with OpenOCD 0.12.0 # Correctly handles separate JTAG and System resets to prevent timeouts.
# ---------------------------------------------------------------- # ----------------------------------------------------------------
# 1. Adapter and Board Configuration # 1. Adapter and Board Configuration
@ -30,32 +30,22 @@ target smp riscv.cpu0 riscv.cpu1 riscv.cpu2 riscv.cpu3
# 3. Reset Configuration and Execution # 3. Reset Configuration and Execution
# ---------------------------------------------------------------- # ----------------------------------------------------------------
# Configure the reset type, but without the unsupported timing flags. # CRITICAL: Configure the reset strategy.
# We will control the pulse manually. # 'srst_only': The 'reset' command will only pulse the nSRST line.
reset_config srst_only # '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 init
# --- Manual Reboot Sequence for OpenOCD 0.12.0 --- # Issue the system reset. Because of the config above, this will now
echo "!!! Manually asserting system reset (nSRST)..." # cleanly pulse the nSRST line, causing a hardware reboot.
# Pull nSRST low (active low, so '0' asserts it) echo "!!! Issuing system reset to reboot the board..."
ftdi_set_signal nSRST 0 reset
# Hold the reset for 100ms to ensure the board registers it
sleep 100
echo "!!! De-asserting system reset and attempting to halt..." echo "!!! Board has been reset and should be rebooting now."
# 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
# Exit OpenOCD # Exit OpenOCD
shutdown shutdown