(Solved) ESP8266 pytool erase flash: need help pls!

I am using Platformio (Compiled & uploaded ESPmon to Robotdyn UNO+Wifi board, but when it started, I saw the old ESP logi, as well as the required ESPmon-xxx login, so then tried to erase the ESP8266 memory. ESPtools are in Platformio, but could not work out how to acess that, so loaded ESPtools & ran from root terminal. Results below:

[[email protected] doug]# -p /dev/ttyUSB0 erase_flash v2.6
Serial port /dev/ttyUSB0
Traceback (most recent call last):
  File "/usr/bin/", line 2959, in <module>
  File "/usr/bin/", line 2952, in _main
  File "/usr/bin/", line 2646, in main
    esp = ESPLoader.detect_chip(each_port, initial_baud, args.before, args.trace)
  File "/usr/bin/", line 259, in detect_chip
  File "/usr/bin/", line 460, in connect
    last_error = self._connect_attempt(mode=mode, esp32r0_delay=False)
  File "/usr/bin/", line 419, in _connect_attempt
    self._setRTS(True)   # EN=LOW, chip in reset
  File "/usr/bin/", line 391, in _setRTS
AttributeError: 'Serial' object has no attribute 'dtr'


Completely at sea here! I have enough knowledge to be dangerous! Can someone help pls??
ps: apparently the next version of Platformio is better, but I am still running the supported


I have been in a similar situation to you. I also use PlatformIO with just about enough understanding to be dangerous.

Somebody suggested I switch to Visual Studio Code and run platform from there. I did that and since then I have had much less difficulty.

The erase command is --port COM5 erase_flash

Works like a charm for me. Obviously that’s a Windows command and you will need to use the correct usb port. Also I have found you need to keep the PlatformIO environment up to date but that is fairly easy.


Fixed! Hopefully this will help someone else…

The issue was there were old versions of pyserial hanging around. Deleted them all (some by uninstalling from my Distro, & others as pip uninstall pyserial in a root terminal. (or use Sudo at your own risk! PCLinuxOS frowns on Sudo…)

The other issue I fixed was to install the correct USB parameters for the Linux /etc/udev/rules.d/99-platformio-udev.rules where I added the CH340 section:

SUBSYSTEMS=="usb", ATTRS{idVendor}=="1A86", ATTRS{idProduct}=="7523", MODE:="0666"

regards, Doug
(& thanks Ian: I have not used M$ windoze for abt 20 years! (Even loaded PCLinuxOS on my new Dell 2:1 I5 tablet.)

PlatformIO is a cross OS platform. (corrected hyperlinks above to correct domain).

[edit] I meant VS Code is Cross platform as well :frowning:


Visual Studio Code is cross platform. I just grabbed the windows example as it was on my tablet.