-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix macOS flashing using esp-idf fix from the PR espressif/esptool/pu…
- Loading branch information
1 parent
b1441b2
commit 52899f9
Showing
2 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- ext/esp-idf/components/esptool_py/esptool/esptool.py 2024-08-01 17:16:55 | ||
+++ esptool.py 2024-08-01 17:16:43 | ||
@@ -23,6 +23,16 @@ | ||
import time | ||
import zlib | ||
|
||
+# This fix is taken from this PR | ||
+# https://github.com/espressif/esptool/pull/718/commits/7e207d821919982df1ac1a1a5cf9f6e701f36ea1 | ||
+import fcntl | ||
+import termios | ||
+ | ||
+TIOCMSET = getattr(termios, 'TIOCMSET', 0x5418) | ||
+TIOCMGET = getattr(termios, 'TIOCMGET', 0x5415) | ||
+TIOCM_DTR = getattr(termios, 'TIOCM_DTR', 0x002) | ||
+TIOCM_RTS = getattr(termios, 'TIOCM_RTS', 0x004) | ||
+ | ||
try: | ||
import serial | ||
except ImportError: | ||
@@ -614,13 +624,25 @@ | ||
fpga_delay = True if self.FPGA_SLOW_BOOT and os.environ.get("ESPTOOL_ENV_FPGA", "").strip() == "1" else False | ||
delay = 7 if fpga_delay else 0.5 if extra_delay else 0.05 # 0.5 needed for ESP32 rev0 and rev1 | ||
|
||
- self._setDTR(False) # IO0=HIGH | ||
- self._setRTS(True) # EN=LOW, chip in reset | ||
+ self._setDTRAndRTS(False, False) | ||
+ self._setDTRAndRTS(True, True) | ||
+ self._setDTRAndRTS(False, True) # IO0=HIGH & EN=LOW, chip in reset | ||
time.sleep(0.1) | ||
- self._setDTR(True) # IO0=LOW | ||
- self._setRTS(False) # EN=HIGH, chip out of reset | ||
+ self._setDTRAndRTS(True, False) # IO0=LOW & # EN=HIGH, chip out of reset | ||
time.sleep(delay) | ||
- self._setDTR(False) # IO0=HIGH, done | ||
+ self._setDTRAndRTS(False, False) # IO0=HIGH, done | ||
+ | ||
+ def _setDTRAndRTS(self, dtr = False, rts = False): | ||
+ status = struct.unpack('I', fcntl.ioctl(self._port.fileno(), TIOCMGET, struct.pack('I', 0)))[0] | ||
+ if dtr: | ||
+ status |= TIOCM_DTR | ||
+ else: | ||
+ status &= ~TIOCM_DTR | ||
+ if rts: | ||
+ status |= TIOCM_RTS | ||
+ else: | ||
+ status &= ~TIOCM_RTS | ||
+ fcntl.ioctl(self._port.fileno(), TIOCMSET, struct.pack('I', status)) | ||
|
||
def _connect_attempt(self, mode='default_reset', usb_jtag_serial=False, extra_delay=False): | ||
""" A single connection attempt """ |