Uploading to Arduino Nano Esp32 false success

I can’t upload anything to Arduino Nano Esp32. The upload reports success but the old code persist.

Uploading from Arduino IDE works fine, but not from PlatformIO.

The same code has previously been successfully uploaded to Arduino Nano, if that is relevant.

I already reset the Arduino’s bootloader, as that was suggested in other similar (but not same) cases.

Can anyone give any tips on how to debug this, or know the solution already? Any help is much appreciated :slight_smile:.

My PlatformIO extension for VSCode is version 3.3.2.

My computer is Macbook Pro with Sonoma 14.2.

Here is my platformio.ini:

[env]
platform = espressif32
board = arduino_nano_esp32
framework = arduino
lib_deps = 
	fastled/FastLED@^3.6.0
	mokolea/InputDebounce@^1.6.0
	paulstoffregen/Encoder@^1.4.2
monitor_speed = 115200

[env:primary]
build_src_filter = 
	+<*> -<main.secondary.cpp>

[env:secondary]
build_src_filter = 
	+<*> -<main.primary.cpp>

And here is the whole upload output:

Processing primary (platform: espressif32; board: arduino_nano_esp32; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/arduino_nano_esp32.html
PLATFORM: Espressif 32 (6.5.0) > Arduino Nano ESP32
HARDWARE: ESP32S3 240MHz, 320KB RAM, 16MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, dfu, esp-bridge, esp-builtin, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-arduinoespressif32 @ 3.20014.231204 (2.0.14) 
 - tool-dfuutil-arduino @ 1.11.0 
 - tool-esptoolpy @ 1.40501.0 (4.5.1) 
 - tool-mkfatfs @ 2.0.1 
 - tool-mklittlefs @ 1.203.210628 (2.3) 
 - tool-mkspiffs @ 2.230.0 (2.30) 
 - toolchain-riscv32-esp @ 8.4.0+2021r2-patch5 
 - toolchain-xtensa-esp32s3 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 36 compatible libraries
Scanning dependencies...
Dependency Graph
|-- FastLED @ 3.6.0
|-- InputDebounce @ 1.6.0
|-- Encoder @ 1.4.4
|-- EEPROM @ 2.0.0
|-- ArduinoOTA @ 2.0.0
|-- ESPmDNS @ 2.0.0
|-- WiFi @ 2.0.0
Building in release mode
Retrieving maximum program size .pio/build/primary/firmware.elf
Checking size .pio/build/primary/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  18.8% (used 61736 bytes from 327680 bytes)
Flash: [==        ]  24.6% (used 774341 bytes from 3145728 bytes)
Configuring upload protocol...
AVAILABLE: cmsis-dap, dfu, esp-bridge, esp-builtin, esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = dfu
Uploading .pio/build/primary/firmware.bin
dfu-util 0.11-arduino4

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2021 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Opening DFU capable USB device...
Device ID 2341:0070
Device DFU version 0101
Claiming USB DFU Interface...
Setting Alternate Interface #0 ...
Determining device status...
DFU state(2) = dfuIDLE, status(0) = No error condition is present
DFU mode device DFU version 0101
Device returned transfer size 4096
Copying data from PC to DFU device

Download        [                         ]   0%            0 bytes
Download        [=                        ]   4%        32768 bytes
Download        [==                       ]   8%        65536 bytes
Download        [==                       ]   9%        73728 bytes
Download        [===                      ]  12%        94208 bytes
Download        [====                     ]  16%       126976 bytes
Download        [=====                    ]  20%       159744 bytes
Download        [======                   ]  24%       188416 bytes
Download        [======                   ]  26%       204800 bytes
Download        [=======                  ]  28%       221184 bytes
Download        [========                 ]  32%       249856 bytes
Download        [=========                ]  36%       282624 bytes
Download        [==========               ]  40%       315392 bytes
Download        [===========              ]  44%       344064 bytes
Download        [===========              ]  46%       360448 bytes
Download        [============             ]  48%       376832 bytes
Download        [=============            ]  52%       405504 bytes
Download        [==============           ]  56%       438272 bytes
Download        [===============          ]  60%       471040 bytes
Download        [================         ]  64%       499712 bytes
Download        [================         ]  65%       512000 bytes
Download        [=================        ]  68%       532480 bytes
Download        [==================       ]  72%       561152 bytes
Download        [===================      ]  76%       593920 bytes
Download        [====================     ]  80%       626688 bytes
Download        [=====================    ]  84%       655360 bytes
Download        [=====================    ]  84%       659456 bytes
Download        [======================   ]  88%       688128 bytes
Download        [=======================  ]  92%       716800 bytes
Download        [======================== ]  96%       749568 bytes
Download        [=========================] 100%       774704 bytes
Download done.
DFU state(7) = dfuMANIFEST, status(0) = No error condition is present
DFU state(2) = dfuIDLE, status(0) = No error condition is present
Done!
==================================================================== [SUCCESS] Took 10.45 seconds ====================================================================

Update: The upload works fine with a simple test project that just prints some stuff to serial. But not with my real project.

It looks as if you have two projects in the same project folder and want to switch between the two projects by selecting the environment.

Does the upload work if you remove these entries in platformio.ini and split the projects into (real) separate folders?

Unfortunately that does not help. The upload still fails to update the running program.

I guess I have to start commenting out some code and libraries to see if some of them is the cause of this. Though it would seem unlikely.

I have created a simple “single folder multiple projects” project where you can switch between projects by selecting the corresponding environment.

image

image

GitHub - sivar2311/PlatformIO_Multi-Project.

The reason for this behaviour seems to be the library paulstoffregen/Encoder. If I remove it from use, the upload works normally. Why that is I don’t know yet. But the issues from that repository tell us that the library might not work properly with esp32 anyway, so I’ll have to find a replacement for it.

Some time ago I wrote my own RotaryEncoder library. However, without the push button function.

Maybe my code will help you: RotaryEncoder · GitHub

Thanks for the tip, I’ll check it out :+1: