Skip to content

fix: ESP32 hard_reset now sets DTR before toggling RTS#342

Merged
mangelajo merged 1 commit into
mainfrom
esp32-reset
Mar 19, 2026
Merged

fix: ESP32 hard_reset now sets DTR before toggling RTS#342
mangelajo merged 1 commit into
mainfrom
esp32-reset

Conversation

@mangelajo

@mangelajo mangelajo commented Mar 19, 2026

Copy link
Copy Markdown
Member

Summary

  • Fix hard_reset: On ESP32 boards with the classic auto-program circuit (two cross-coupled NPN transistors, e.g. ESP32 DevKitC), EN is only pulled low when DTR and RTS are in opposite states. The previous hard_reset only toggled RTS without controlling DTR, so it was ineffective when DTR happened to be in the wrong state. Now explicitly de-asserts DTR before toggling RTS.
  • Improve enter_bootloader docs: Updated comments to accurately describe the transistor circuit behavior (DTR/RTS pin states → EN/IO0 effects) instead of the misleading direct-pin comments.
  • Strengthen tests: test_hard_reset and test_enter_bootloader now verify the exact DTR/RTS signal sequences using PropertyMock, rather than just checking the methods don't crash.

Test plan

  • All 11 existing tests pass (make pkg-test-jumpstarter-driver-esp32)
  • test_hard_reset asserts DTR=[False], RTS=[True, False]
  • test_enter_bootloader asserts DTR=[False, True, False], RTS=[True, False]
  • Manual verification on an ESP32 DevKitC board that hard_reset now correctly resets the chip

Made with Cursor

On boards with the classic auto-program circuit (two cross-coupled NPN
transistors), EN is only pulled low when DTR and RTS are in opposite
states. The previous hard_reset only toggled RTS without controlling
DTR, making it ineffective when DTR was in an unknown state.

Also updates tests to verify the exact DTR/RTS signal sequences for
both hard_reset and enter_bootloader.

Made-with: Cursor
@netlify

netlify Bot commented Mar 19, 2026

Copy link
Copy Markdown

Deploy Preview for jumpstarter-docs ready!

Name Link
🔨 Latest commit cac8287
🔍 Latest deploy log https://app.netlify.com/projects/jumpstarter-docs/deploys/69bbebe428afe400081c24d3
😎 Deploy Preview https://deploy-preview-342--jumpstarter-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: be9ef46d-8c97-49ad-bc65-dd9fd372c1ad

📥 Commits

Reviewing files that changed from the base of the PR and between bb7493b and cac8287.

📒 Files selected for processing (2)
  • python/packages/jumpstarter-driver-esp32/jumpstarter_driver_esp32/driver.py
  • python/packages/jumpstarter-driver-esp32/jumpstarter_driver_esp32/driver_test.py

📝 Walkthrough

Walkthrough

Updated the ESP32 driver's hard_reset method to explicitly de-assert DTR before manipulating RTS, improving GPIO control sequencing for proper auto-program circuit behavior. Enhanced docstrings and test coverage to document and verify the explicit DTR/RTS pin control sequence.

Changes

Cohort / File(s) Summary
ESP32 Reset/Bootloader Control Logic
python/packages/jumpstarter-driver-esp32/jumpstarter_driver_esp32/driver.py
Modified hard_reset to call set_dtr(False) before set_rts(True), adding explicit DTR de-assertion. Updated docstrings for both hard_reset and enter_bootloader methods to clarify classic auto-program circuit behavior and alignment with esptool's "ClassicReset" semantics.
GPIO Control Tests
python/packages/jumpstarter-driver-esp32/jumpstarter_driver_esp32/driver_test.py
Added _make_mock_serial() helper for tracking DTR/RTS property assignments via PropertyMock. Enhanced test_hard_reset and test_enter_bootloader with assertions verifying exact GPIO state sequences: dtr=[False] and rts=[True, False] for reset; dtr=[False, True, False] and rts=[True, False] for bootloader entry.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • evakhoni

Poem

🐰 Reset lines dance with DTR's grace,
RTS follows at the perfect pace,
ClassicReset's way we now obey,
GPIO sequences saved the day! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main change: setting DTR before toggling RTS in the hard_reset method for ESP32 boards.
Description check ✅ Passed The description is detailed and directly related to the changeset, explaining the technical rationale for the fix, documentation improvements, and test enhancements.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch esp32-reset
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mangelajo mangelajo enabled auto-merge March 19, 2026 12:32
@mangelajo mangelajo requested a review from bennyz March 19, 2026 12:32
@mangelajo mangelajo merged commit d1e9012 into main Mar 19, 2026
31 checks passed
@raballew raballew deleted the esp32-reset branch June 5, 2026 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants