Authentication issue during OTA upload with PlatformIO (ESP32)

Hello everyone,

I’m working on an ESP32 project with PlatformIO and I’m encountering an issue with OTA upload when I add a password.

Context:

-OTA upload works perfectly** without a password (authentication disabled).
-OTA upload fails** when I set a password, with the following error in the logs:
22:47:29 [DEBUG]: Options: {‘esp_ip’: ‘BaseEsp32.local’, ‘host_ip’: ‘0.0.0.0’, ‘esp_port’: 3232, ‘host_port’: 24600, ‘auth’: ‘’, ‘image’: ‘.pio\build\esp32dev\firmware.bin’, ‘spiffs’: False, ‘debug’: True, ‘progress’: True, ‘timeout’: 10}
22:47:29 [INFO]: Starting on 0.0.0.0:24600
22:47:29 [INFO]: Upload size: 814000
Sending invitation to BaseEsp32.local
Authenticating…FAIL
22:47:34 [ERROR]: Authentication Failed
*** [upload] Error 1

– My platformio.ini configuration:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
upload_port = BaseEsp32.local
monitor_port = BaseEsp32.local
monitor_speed = 115200
upload_flags =
–port=3232
–auth=onverra

lib_deps =
jandrassy/TelnetStream@^1.3.0

– What I’ve tried:

  1. I added ArduinoOTA.setPassword("onverra") in my ESP32 code.
  2. When I add --auth=onverra in the upload_flags, authentication fails every time.

I can’t figure out why the authentication is failing, as the password seems correctly set up. Has anyone else encountered this issue or have any suggestions on what might be wrong?

Thanks in advance for your help!

The auth is set to '' because of a wrong indention in your platformio.ini:
Change your platformio.ini to

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
upload_port = BaseEsp32.local
monitor_port = BaseEsp32.local
monitor_speed = 115200
upload_flags =
  –port=3232
  –auth=onverra

lib_deps =
  jandrassy/TelnetStream@^1.3.0

If the port is 3232, you can leave this out as this is the default port.

Hello,

I tried what you suggested, but it didn’t work. Here is the current configuration of the platform.ini file:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
upload_port = BaseEsp32.local
monitor_port = BaseEsp32.local ; Not useful
monitor_speed = 115200

upload_flags =
-auth=onverra

lib_deps =
jandrassy/TelnetStream@^1.3.0

The error displayed by PlatformIO is as follows:

14:41:01 [DEBUG]: Options: {'esp_ip': 'BaseEsp32.local', 'host_ip': '0.0.0.0', 'esp_port': 3232, 'host_port': 32374, 'auth': '', 'image': '.pio\\build\\esp32dev\\firmware.bin', 'spiffs': False, 'debug': True, 'progress': True, 'timeout': 10} 
14:41:01 [INFO]: Starting on 0.0.0.0:32374
14:41:01 [INFO]: Upload size: 800352
Sending invitation to BaseEsp32.local 
Authenticating... FAIL
14:41:07 [ERROR]: Authentication Failed
*** [upload] Error 1


It seems that the authentication is failing.

Thank you in advance for your help.

You are still using the wrong indentation.

Put two spaces before -auth=onverra like so:

upload_flags =
  –auth=onverra

I write this :

[env:esp32dev]

platform = espressif32

board = esp32dev

framework = arduino

upload_port = BaseEsp32.local

monitor_port = BaseEsp32.local ; Not useful

monitor_speed = 115200

upload_flags =

–auth=onverra

lib_deps =

jandrassy/TelnetStream@^1.3.0

and i have this :

usage: esptool [-h]
[–chip {auto,esp8266,esp32,esp32s2,esp32s3beta2,esp32s3,esp32c3,esp32c6beta,esp32h2beta1,esp32h2beta2,esp32c2,esp32c6,esp32h2}]
[–port PORT] [–baud BAUD]
[–before {default_reset,usb_reset,no_reset,no_reset_no_sync}]
[–after {hard_reset,soft_reset,no_reset,no_reset_stub}]
[–no-stub] [–trace] [–override-vddsdio [{1.8V,1.9V,OFF}]]
[–connect-attempts CONNECT_ATTEMPTS]
{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,merge_bin,get_security_info,version}

esptool: error: argument operation: invalid choice: ‘–auth=onverra’ (choose from ‘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’, ‘merge_bin’, ‘get_security_info’, ‘version’)
*** [upload] Error 2

Please use pre-formatted text when you post code or log fragments. Otherwise it is not possible to see whether leading spaces are present in the lines or not.

If you do the formatting correctly (two leading spaces in front of -auth=onverra then this will be used correctly and the authentication works without issues.

Please use the exact formatting:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
upload_port = BaseEsp32.local
monitor_speed = 115200
upload_flags =
  –port=3232
  –auth=onverra

lib_deps =
  jandrassy/TelnetStream@^1.3.0

Also make sure, that the initial sketch (which you uploaded via serial / usb) is using the exact same password (“onverra”).