mirror of
https://github.com/marcelstoer/nodemcu-pyflasher.git
synced 2025-07-19 17:26:34 +00:00
Upgrade esptool.py to latest 2.0
Brings support for ESP32 and flash chips >4MB, fixes #15
This commit is contained in:
parent
9d1b526689
commit
750ee6cfb3
70
Main.py
70
Main.py
@ -10,10 +10,11 @@ import json
|
|||||||
import images as images
|
import images as images
|
||||||
from serial import SerialException
|
from serial import SerialException
|
||||||
from serial.tools import list_ports
|
from serial.tools import list_ports
|
||||||
from esptool import ESPROM
|
from esptool import ESPLoader
|
||||||
|
from esptool import NotImplementedInROMError
|
||||||
from argparse import Namespace
|
from argparse import Namespace
|
||||||
|
|
||||||
__version__ = "1.0.1"
|
__version__ = "2.0-beta"
|
||||||
__supported_baud_rates__ = [9600, 57600, 74880, 115200, 230400, 460800, 921600]
|
__supported_baud_rates__ = [9600, 57600, 74880, 115200, 230400, 460800, 921600]
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
@ -23,25 +24,17 @@ __supported_baud_rates__ = [9600, 57600, 74880, 115200, 230400, 460800, 921600]
|
|||||||
class RedirectText:
|
class RedirectText:
|
||||||
def __init__(self, text_ctrl):
|
def __init__(self, text_ctrl):
|
||||||
self.__out = text_ctrl
|
self.__out = text_ctrl
|
||||||
self.__pending_backspaces = 0
|
|
||||||
|
|
||||||
def write(self, string):
|
def write(self, string):
|
||||||
new_string = ""
|
if string.startswith("\r"):
|
||||||
number_of_backspaces = 0
|
# carriage return -> remove last line i.e. reset position to start of last line
|
||||||
for c in string:
|
current_value = self.__out.GetValue()
|
||||||
if c == "\b":
|
last_newline = current_value.rfind("\n")
|
||||||
number_of_backspaces += 1
|
new_value = current_value[:last_newline + 1] # preserve \n
|
||||||
else:
|
new_value += string[1:] # chop off leading \r
|
||||||
new_string += c
|
|
||||||
|
|
||||||
if self.__pending_backspaces > 0:
|
|
||||||
# current value minus pending backspaces plus new string
|
|
||||||
new_value = self.__out.GetValue()[:-1 * self.__pending_backspaces] + new_string
|
|
||||||
wx.CallAfter(self.__out.SetValue, new_value)
|
wx.CallAfter(self.__out.SetValue, new_value)
|
||||||
else:
|
else:
|
||||||
wx.CallAfter(self.__out.AppendText, new_string)
|
wx.CallAfter(self.__out.AppendText, string)
|
||||||
|
|
||||||
self.__pending_backspaces = number_of_backspaces
|
|
||||||
|
|
||||||
def flush(self):
|
def flush(self):
|
||||||
None
|
None
|
||||||
@ -59,24 +52,34 @@ class FlashingThread(threading.Thread):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
try:
|
try:
|
||||||
esp = ESPROM(port=self._config.port)
|
initial_baud = min(ESPLoader.ESP_ROM_BAUD, self._config.baud)
|
||||||
|
esp = ESPLoader.detect_chip(self._config.port, initial_baud)
|
||||||
|
esp = esp.run_stub()
|
||||||
|
if self._config.baud > initial_baud:
|
||||||
|
try:
|
||||||
|
esp.change_baud(self._config.baud)
|
||||||
|
except NotImplementedInROMError:
|
||||||
|
print("WARNING: ROM doesn't support changing baud rate. Keeping initial baud rate %d" % initial_baud)
|
||||||
|
|
||||||
|
args = Namespace()
|
||||||
|
args.flash_size = "detect"
|
||||||
|
args.flash_mode = self._config.mode
|
||||||
|
args.flash_freq = "40m"
|
||||||
|
args.no_progress = False
|
||||||
|
args.no_stub = False
|
||||||
|
args.verify = False # TRUE is deprecated
|
||||||
|
args.compress = True
|
||||||
|
args.addr_filename = [[int("0x00000", 0), open(self._config.firmware_path, 'rb')]]
|
||||||
|
|
||||||
|
if self._config.erase_before_flash:
|
||||||
|
esptool.erase_flash(esp, args)
|
||||||
|
esptool.write_flash(esp, args)
|
||||||
|
|
||||||
|
self._parent.log_message("Hard resetting...") # replicate behavior from esptool.py:2111
|
||||||
|
esp.hard_reset()
|
||||||
except SerialException as e:
|
except SerialException as e:
|
||||||
self._parent.report_error(e.strerror)
|
self._parent.report_error(e.strerror)
|
||||||
raise e
|
raise e
|
||||||
args = Namespace()
|
|
||||||
args.flash_size = "detect"
|
|
||||||
args.flash_mode = self._config.mode
|
|
||||||
args.flash_freq = "40m"
|
|
||||||
args.no_progress = False
|
|
||||||
args.verify = True
|
|
||||||
args.baud = self._config.baud
|
|
||||||
args.addr_filename = [[int("0x00000", 0), open(self._config.firmware_path, 'rb')]]
|
|
||||||
# needs connect() before each operation, see https://github.com/espressif/esptool/issues/157
|
|
||||||
if self._config.erase_before_flash:
|
|
||||||
esp.connect()
|
|
||||||
esptool.erase_flash(esp, args)
|
|
||||||
esp.connect()
|
|
||||||
esptool.write_flash(esp, args)
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -326,6 +329,9 @@ class NodeMcuFlasher(wx.Frame):
|
|||||||
def report_error(self, message):
|
def report_error(self, message):
|
||||||
self.console_ctrl.SetValue(message)
|
self.console_ctrl.SetValue(message)
|
||||||
|
|
||||||
|
def log_message(self, message):
|
||||||
|
self.console_ctrl.AppendText(message)
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
2213
esptool.py
2213
esptool.py
File diff suppressed because it is too large
Load Diff
BIN
images/gui.png
BIN
images/gui.png
Binary file not shown.
Before Width: | Height: | Size: 349 KiB After Width: | Height: | Size: 405 KiB |
Loading…
x
Reference in New Issue
Block a user