ESP32: esptool: error: too few arguments

This is the last part of the output with --verbose:

"c:\python27\python.exe" "C:\Users\gijs\.platformio\packages\tool-esptoolpy@1.20100.0\esptool.py" --chip esp32 elf2image --flash_mode dio --flash_freq 40m --flash_size 4MB -o .pioenvs\esp32dev\firmware.bin .pioenvs\esp32dev\firmware.elf
esptool.py v2.1
MethodWrapper(["upload"], [".pioenvs\esp32dev\firmware.bin"])
Auto-detected: COM9
"c:\python27\python.exe" "C:\Users\gijs\.platformio\packages\framework-arduinoespressif32\tools\esptool.py" --before default_reset --after hard_reset --chip esp32 --port "COM9" --baud 460800
usage: esptool [-h] [--chip {auto,esp8266,esp32}] [--port PORT] [--baud BAUD]
[--before {default_reset,no_reset}]
[--after {hard_reset,soft_reset,no_reset}] [--no-stub]
{load_ram,dump_mem,read_mem,write_mem,write_flash,run,image_info,make_image,elf2image,read_mac,chip_id,flash_id,read_flash_status,write_flash_status,read_flash,verify_flash,erase_flash,erase_region,version}
...
esptool: error: too few arguments
*** [upload] Error 2

I already uninstalled and reinstalled PlatformIO and all related plugins from Atom.

Any idea what’s going on here?

I cannot reproduce this.

Could you provide the output of pio --version and do a pio platform update (and maybe a pio upgrade --dev)?

When I build the blink example:

text       data     bss     dec     hex filename
125749    38280    2400  166429   28a1d .pioenvs\esp32dev\firmware.elf
"c:\python27\python.exe" "C:\Users\Maxi\.platformio\packages\tool-esptoolpy\esptool.py" --chip esp32 elf2image --flash_mode dio --flash_freq 40m --flash_size 4MB -o .pioenvs\esp32dev\firmware.bin .pioenvs\esp32dev\firmware.elf
esptool.py v2.3.1
Configuring upload protocol...
AVAILABLE: esptool, minimodule, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h
CURRENT: upload_protocol = esptool
MethodWrapper(["upload"], [".pioenvs\esp32dev\firmware.bin"])
Auto-detected: COM8
"c:\python27\python.exe" "C:\Users\Maxi\.platformio\packages\tool-esptoolpy\esptool.py" --chip esp32 --port "COM8" --baud 115200 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x1000 C:\Users\Maxi\.platformio\packages\framework-arduinoespressif32\tools\sdk\bin\bootloader_dio_40m.bin 0x8000 C:\Users\Maxi\.platformio\platforms\espressif32\examples\arduino-blink\.pioenvs\esp32dev\partitions.bin 0xe000 C:\Users\Maxi\.platformio\packages\framework-arduinoespressif32\tools\partitions\boot_app0.bin 0x10000 .pioenvs\esp32dev\firmware.bin
esptool.py v2.3.1
Connecting........_
Chip is ESP32D0WDQ6 (revision 0)
Features: WiFi, BT, Dual Core
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 12496 bytes to 8282...
Wrote 12496 bytes (8282 compressed) at 0x00001000 in 0.7 seconds (effective 135.8 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 144...
Wrote 3072 bytes (144 compressed) at 0x00008000 in 0.0 seconds (effective 1228.8 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 5957.9 kbit/s)...
Hash of data verified.
Compressed 164160 bytes to 83853...
Wrote 164160 bytes (83853 compressed) at 0x00010000 in 7.4 seconds (effective 177.3 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
============================================ [SUCCESS] Took 24.43 seconds ============================================
PS C:\Arduino\ESPeasy\arduino-1.8.3\portable\sketchbook\ESPEasy_Gijs\ESPEasy> pio --version
>>
PlatformIO, version 3.5.3rc2

pio platform update:

PS C:\Arduino\ESPeasy\arduino-1.8.3\portable\sketchbook\ESPEasy_Gijs\ESPEasy> pio platform update
Platform Atmel AVR
--------
Updating atmelavr                        @ 1.8.2          [Up-to-date]
Updating toolchain-atmelavr              @ 1.40902.1      [Up-to-date]
Updating framework-arduinoavr            @ 1.10620.2      [Up-to-date]

Platform Espressif 32
--------
Updating espressif32                     @ 1.0.1          [Up-to-date]
Updating tool-esptoolpy                  @ 1.20310.0      [Up-to-date]
Updating tool-espotapy                   @ 1.1.0          [Up-to-date]
Updating toolchain-xtensa32              @ 2.50200.80     [Up-to-date]
Updating framework-arduinoespressif32    @ 1.5.3          [Up-to-date]
Updating tool-mkspiffs                   @ 2.230.0        [Up-to-date]

Platform Espressif 32
--------
Updating espressif32                     @ 0.12.0         [Fixed]
Updating tool-esptoolpy                  @ 1.20100.0      [Up-to-date]
Updating toolchain-xtensa32              @ 1.50200.2      [Up-to-date]
Updating framework-arduinoespressif32    @ 1.4.0          [Up-to-date]
Updating tool-espotapy                   @ 1.1.0          [Up-to-date]

Platform Espressif 32 (Stage)
--------
Updating espressif32                     @ 4dfeae1        [Up-to-date]
Updating tool-esptoolpy                  @ 1.20310.0      [Up-to-date]
Updating tool-espotapy                   @ 1.1.0          [Up-to-date]
Updating toolchain-xtensa32              @ 2.50200.80     [Up-to-date]
Updating framework-arduinoespressif32    @ 89859f7        [Up-to-date]
Updating tool-mkspiffs                   @ 2.230.0        [Up-to-date]

Platform Espressif 8266
--------
Updating espressif8266                   @ 1.7.0          [Up-to-date]
Updating tool-mkspiffs                   @ 1.200.0        [Up-to-date]
Updating tool-esptool                    @ 1.413.0        [Up-to-date]
Updating tool-espotapy                   @ 1.1.0          [Up-to-date]
Updating framework-arduinoespressif8266  @ 1.20401.2      [Up-to-date]
Updating toolchain-xtensa                @ 1.40802.0      [Up-to-date]

Platform Espressif 8266
--------
Updating espressif8266                   @ 1.5.0          [Fixed]
Updating tool-mkspiffs                   @ 1.102.0        [Up-to-date]
Updating tool-esptool                    @ 1.409.0        [Up-to-date]
Updating tool-espotapy                   @ 1.0.0          [Up-to-date]
Updating framework-arduinoespressif8266  @ 1.20300.1      [Up-to-date]
Updating toolchain-xtensa                @ 1.40802.0      [Up-to-date]

Platform Espressif 8266
--------
Updating espressif8266                   @ 1.6.0          [Fixed]
Updating tool-mkspiffs                   @ 1.200.0        [Up-to-date]
Updating tool-esptool                    @ 1.409.0        [Up-to-date]
Updating tool-espotapy                   @ 1.1.0          [Up-to-date]
Updating framework-arduinoespressif8266  @ 1.20400.3      [Up-to-date]
Updating toolchain-xtensa                @ 1.40802.0      [Up-to-date]

Platform Espressif 8266 (Stage)
--------
Updating espressif8266                   @ 98da8ea        [Up-to-date]
Updating tool-mkspiffs                   @ 1.200.0        [Up-to-date]
Updating tool-esptool                    @ 1.413.0        [Up-to-date]
Updating tool-espotapy                   @ 1.1.0          [Up-to-date]
Updating framework-arduinoespressif8266  @ ab7e109        [Up-to-date]
Updating toolchain-xtensa                @ 1.40802.0      [Up-to-date]

Upgrade --dev:

PS C:\Arduino\ESPeasy\arduino-1.8.3\portable\sketchbook\ESPEasy_Gijs\ESPEasy> pio upgrade --dev
>>
Please wait while upgrading PlatformIO ...
PlatformIO has been successfully upgraded to 3.5.3rc2
Release notes: http://docs.platformio.org/en/latest/history.html

And still same result.

Our used esptool.py is different (esptool.py v2.1 vs esptool.py v2.3.1). Did you get the newer version after updating? Is still using the one from tool-esptoolpy@1.20100.0\esptool instead of the newest version 1.20310.0?

Also you have multiple versions of the ESP32 platform packages installed, some fixed version and a staging version? What’s your platformio.ini?

This is my platform.ini:

It used to work fine, until one of the last updates last week. (not sure if it is one of the last updates, I installed it last week)

That file uses a fixed-version platform = espressif32@0.12.0 at line 63. Comment that line out and uncomment line 64. Does that work now?

Otherwise try if you can reproduce this with a simple blink example, that platformio.ini file has 594 lines. The fixed version is probably the problem. combined that is uses a different esptool.py version, suddenly.

Still the same when using the staged version.

I will try to locate the Blink test version.

It was linked above (platform-espressif32/examples/arduino-blink at master · platformio/platform-espressif32 · GitHub). Does it upload normally with an unmodified platformio.ini? What if you put platform = espressif32@0.12.0? (BTW, when multiple enviroments are defined, you can use pio run -t upload -e esp32dev to use a specific environment)

I built the blink example.

[05/31/18 22:22:21] Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
Collected 23 compatible libraries
Looking for dependencies...
No dependencies
AttributeError: 'PlatformBoardConfig' object has no attribute 'update':
File "C: \python27\lib\site-packages\platformio\builder\main.py", line 158:
env.SConscript("$BUILD_SCRIPT")
File "C: \Users\gijs\.platformio\packages\tool-scons\script\..\engine\SCons\Script\SConscript.py", line 541:
return _SConscript(self.fs, *files, **subst_kw)
File "C: \Users\gijs\.platformio\packages\tool-scons\script\..\engine\SCons\Script\SConscript.py", line 250:
exec _file_ in call_stack[-1].globals
File "C: \Users\gijs\.platformio\platforms\espressif32 @src-9112e7894fcfd1325e3c29a50a2b0d5d\builder\main.py", line 249:
_update_max_upload_size(env)
File "C: \Users\gijs\.platformio\platforms\espressif32 @src-9112e7894fcfd1325e3c29a50a2b0d5d\builder\main.py", line 89:
env.BoardConfig().update("upload.maximum_size", max(sizes))
============================================== [ERROR] Took 1.16 seconds ==============================================

====================================================== [SUMMARY] ======================================================
Environment esp32dev            [ERROR]
Environment esp-wrover-kit      [SKIP]
Environment quantum             [SKIP]
Environment lolin32             [SKIP]
============================================== [ERROR] Took 1.17 seconds ==============================================

I’ve seen that error also in my quest to solve this issue the past 3 evenings.

(I added some spaces, since I got a report I could not have more than 2 links in a post as a new user, but there were no links)

For me the blink example compiles and uploads fine with both

platform = espressif32

and

platform = espressif32@0.12.0

With the @0.12.0 it outputs

MethodWrapper([".pioenvs\esp32dev\firmware.elf"], [".pioenvs\esp32dev\src\Blink.cpp.o"])
text       data     bss     dec     hex filename
124161    35144    2400  161705   277a9 .pioenvs\esp32dev\firmware.elf
"c:\python27\python.exe" "C:\Users\Maxi\.platformio\packages\tool-esptoolpy@1.20100.0\esptool.py" --chip esp32 elf2image --flash_mode dio --flash_freq 40m --flash_size 4MB -o .pioenvs\esp32dev\firmware.bin .pioenvs\esp32dev\firmware.elf
esptool.py v2.1
Configuring upload protocol...
MethodWrapper(["upload"], [".pioenvs\esp32dev\firmware.bin"])
Auto-detected: COM8
"c:\python27\python.exe" "C:\Users\Maxi\.platformio\packages\framework-arduinoespressif32@1.4.0\tools\esptool.py" --before default_reset --after hard_reset --chip esp32 --port "COM8" --baud 115200 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x1000 C:\Users\Maxi\.platformio\packages\framework-arduinoespressif32@1.4.0\tools\sdk\bin\bootloader_dio_40m.bin 0x8000 C:\Users\Maxi\.platformio\platforms\espressif32\examples\arduino-blink\.pioenvs\esp32dev\partitions.bin 0xe000 C:\Users\Maxi\.platformio\packages\framework-arduinoespressif32@1.4.0\tools\partitions\boot_app0.bin 0x10000 .pioenvs\esp32dev\firmware.bin
esptool.py v2.1
Connecting........_
Chip is ESP32D0WDQ6 (revision 0)
Uploading stub...
..

Where it correctly uses framework-arduinoespressif32@1.4.0\tools\esptool.py (yours shows framework-arduinoespressif32\tools\esptool.py)

Weird. I suggest purging your entire PIO installation and starting from scratch. At first make sure you uninstall everything ESP32 related (pio platform uninstall espressif32). Uninstall the plugin, search for your .platformio folder, delete everything in it, and re-install the plugin.

Would it be a good idea to also install everything in another folder?

And what is all PlatformIO related?
Is it also somewhere configured in Atom or VScode in another location other than the path of my Github location?

It should be good enough if every PIO was purged completly. If you installed it from CLI I’d to pip uninstall platformio (as admin), then delete the entire C:\Users\gijs\.platformio folder. If your IDE has a built-in core, you need to uninstall the plugin and search for the .platformio folder with the Windows Explorer. (Redirecting...)

Took a while, I removed everything related to PlatformIO, but still the same issues.
I guess I will go to sleep now and try to think about what to do next.
I’ve already been trying to get this to work for 4 evenings now.
I’m close to the point of format C: and reinstall everything on my laptop, which will probably take another 4 days to get it all working again.

Maybe I will try to get some other PC to install this and see if that will work with the latest PlatformIO.

See Error uploading: 'PlatformBoardConfig' object has no attribute 'update' · Issue #89 · platformio/platform-espressif32 · GitHub

We will release PIO Core 3.5.3 ASAP.

I just feel so stupid. Tried to upgrade to 3.5.3, but it keeps reporting

You’re up-to-date!
PlatformIO 3.5.4a1 is currently the newest version available.

And (ofcourse?) it still does report:

Uploading .pioenvs\esp32dev\firmware.bin

usage: esptool [-h] [--chip {auto,esp8266,esp32}] [--port PORT] [--baud BAUD]
[--before {default_reset,no_reset}]
[--after {hard_reset,soft_reset,no_reset}] [--no-stub]
[--trace]
{load_ram,dump_mem,read_mem,write_mem,write_flash,run,image_info,make_image,elf2image,read_mac,chip_id,flash_id,read_flash_status,write_flash_status,read_flash,verify_flash,erase_flash,erase_region,version}
...
esptool: error: too few arguments
*** [upload] Error 2
 [ERROR] Took 117.89 seconds
Environment esp32dev                    [ERROR]
 [ERROR] Took 117.90 seconds

Apparently I’m doing something wrong, but I have no idea what.
And I’m stuck for way longer than I would like to admit to myself.

Please run pio update.

All updated, same result.
All removed and reinstalled (platformIO plugins + config directories) and performed update as suggested:

text data bss dec hex filename

827745   281216   41248 1150209  118d01 .pioenvs\esp32dev\firmware.elf
Building .pioenvs\esp32dev\firmware.bin
esptool.py v2.3.1
Configuring upload protocol...
AVAILABLE: esptool, minimodule, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h
CURRENT: upload_protocol = esptool
Looking for upload port...
Auto-detected: COM9
Uploading .pioenvs\esp32dev\firmware.bin
usage: esptool [-h] [--chip {auto,esp8266,esp32}] [--port PORT] [--baud BAUD]
[--before {default_reset,no_reset}]
[--after {hard_reset,soft_reset,no_reset}] [--no-stub]
[--trace]
{load_ram,dump_mem,read_mem,write_mem,write_flash,run,image_info,make_image,elf2image,read_mac,chip_id,flash_id,read_flash_status,write_flash_status,read_flash,verify_flash,erase_flash,erase_region,version}
...
esptool: error: too few arguments
*** [upload] Error 2
 [ERROR] Took 104.63 seconds
Environment esp32dev                    [ERROR]
 [ERROR] Took 104.63 seconds

Linked file looks about 30% bigger by the way, but someone else already created an issue about that.

Could you run with pio run -v -t upload? You will see the full command.

Had already done that (verbose) run:

text       data     bss     dec     hex filename
827833   281360   41248 1150441  118de9 .pioenvs\esp32dev\firmware.elf
"c:\users\gijs\.platformio\penv\scripts\python.exe" "C:\Users\gijs\.platformio\packages\tool-esptoolpy\esptool.py" --chip esp32 elf2image --flash_mode dio --flash_freq 40m --flash_size 4MB -o .pioenvs\esp32dev\firmware.bin .pioenvs\esp32dev\firmware.elf
esptool.py v2.3.1
Configuring upload protocol...
AVAILABLE: esptool, minimodule, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h
CURRENT: upload_protocol = esptool
MethodWrapper(["upload"], [".pioenvs\esp32dev\firmware.bin"])
Auto-detected: COM9
"c:\users\gijs\.platformio\penv\scripts\python.exe" "C:\Users\gijs\.platformio\packages\tool-esptoolpy\esptool.py" --chip esp32 --port "COM9" --baud 460800
usage: esptool [-h] [--chip {auto,esp8266,esp32}] [--port PORT] [--baud BAUD]
[--before {default_reset,no_reset}]
[--after {hard_reset,soft_reset,no_reset}] [--no-stub]
[--trace]
{load_ram,dump_mem,read_mem,write_mem,write_flash,run,image_info,make_image,elf2image,read_mac,chip_id,flash_id,read_flash_status,write_flash_status,read_flash,verify_flash,erase_flash,erase_region,version}
...
esptool: error: too few arguments
*** [upload] Error 2

Edit:

Just to be complete, this is what’s being set in the pip in that venv:

C:\>cd Users\gijs\.platformio

C:\Users\gijs\.platformio>penv\Scripts\activate.bat

(penv) C:\Users\gijs\.platformio>pip freeze
bottle==0.12.13
certifi==2018.4.16
chardet==3.0.4
click==5.1
colorama==0.3.9
idna==2.6
lockfile==0.12.2
platformio==3.5.4a1
pyserial==3.4
requests==2.18.4
semantic-version==2.6.0
urllib3==1.22
  1. Please remove ~/.platformio/platforms folder
  2. Also, try to remove arduinoespressif32 package from ~/.platformio/packages folder. It seems that you have different framework source code and dev/platform.