Repository navigation
ch347: drive target reset over SWD on the TRST pin - #4440
Open
pauliuszaleckas wants to merge 1 commit into
Open
pauliuszaleckas wants to merge 1 commit into
pauliuszaleckas wants to merge 1 commit into
Conversation
Contributor
|
FYI #4113 (comment) might be relevant to connect-under-reset. |
Contributor
Author
SWD leaves the TRST pin unused, so a generic CH347 can drive the target's reset line through it with the GPIO command, the same way the OpenOCD driver does. TRST is pin 9 on both chips, but a different GPIO: GPIO5 on the CH347T and GPIO3 on the CH347F. The line is pulled low to assert and released to an input, so it needs a pull-up. A known board keeps its own wiring, including no reset at all. Over JTAG a generic CH347 still writes no GPIO. Entering SWD releases the line, since the chip keeps GPIO state and an earlier session may have been killed with reset held. Leaving SWD with reset held releases it first. The asserted pin is remembered, so drop releases it after a protocol switch too. Tested on a CH347T with an S32K118 whose RESET_b is wired to TRST: the GPIO readback follows assert and release, RCM_SRS reports a pin reset after a pulse, and a line left low is released on entering SWD. A JTAG session afterwards drives the pin as TRST again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pauliuszaleckas
force-pushed
the
ch347-swd-trst-reset
branch
from
October 11, 2026 10:39
7b48d07 to
c20db0f
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SWD leaves the TRST pin unused, so a generic CH347 can drive the target's reset line through it with the GPIO command. This matches the OpenOCD CH347 driver (review 9700).
This changes the earlier rule that a generic CH347 never writes a GPIO. That rule now holds only for JTAG.
Testing
On a CH347T (firmware 5.44) with an S32K118 whose
RESET_bis wired to TRST:RCM_SRSreports a pin reset (0x40) after a pulse, against 0x400 afterSYSRESETREQ.Unit tests cover the board override, protocol switching while reset is held, and the release on drop.
Note: connect-under-reset on Cortex-M
On the S32K118,
--connect-under-resetdrives the pin correctly but still times out waiting for the halt. This is unrelated to this driver.cortex_m_reset_catch_setsetsDEMCR.VC_CORERESETwhile the chip is held in reset, butC_DEBUGENis only set byenable_arm_debugafter the release (#3485). The previous session'sdebug_core_stopcleared it, so the vector catch never fires. SettingC_DEBUGENalong with the catch makes it halt every time. I'll handle that in a separate PR.🤖 Generated with Claude Code