Can't upload to ESP32 (Spark Fun Thing Plus C)

When I try to upload anything to a ESP32-WROOM Thing Plus C I get the following error:

Sketch uses 259809 bytes (19%) of program storage space. Maximum is 1310720 bytes.
Global variables use 16400 bytes (5%) of dynamic memory, leaving 311280 bytes for local variables. Maximum is 327680 bytes.
esptool.py v3.3
Serial port /dev/cu.usbserial-14120
Connecting..........Traceback (most recent call last):
File "esptool.py", line 5387, in
File "esptool.py", line 5380, in _main
File "esptool.py", line 4802, in main
File "esptool.py", line 1056, in flash_set_parameters
File "esptool.py", line 495, in check_command
File "esptool.py", line 468, in command
File "esptool.py", line 413, in read
StopIteration
[64004] Failed to execute script 'esptool' due to unhandled exception!

The code really doesn't matter. I believe the exception is raising in this function:

def read(self):
"""Read a SLIP packet from the serial port"""
return next(self._slip_reader)

in the loader.py file. It doesn't seem like this should fail but I am no Python expert. Does anybody know why this would fail? Am I the only one seeing this? Does anybody know how I take the esptool github tool and make the executable Arduino IDE uses?

Thanks!

You can see the build commands here in the GitHub Actions workflow Espressif uses to automatically generate builds:

https://github.com/espressif/esptool/blob/v4.2.1/.github/workflows/build_esptool.yml

I'll point out the relevant parts:

Set some environment variables that are used in the build command:

https://github.com/espressif/esptool/blob/v4.2.1/.github/workflows/build_esptool.yml#L13-L15

        - os: macos-latest
          TARGET: macos
          SEPARATOR: ':'

https://github.com/espressif/esptool/blob/v4.2.1/.github/workflows/build_esptool.yml#L23-L25

    env:
      DISTPATH: esptool-${{ matrix.TARGET }}
      STUBS_DIR: /esptool/targets/stub_flasher/

Install the dependencies, including the pyinstaller tool:

https://github.com/espressif/esptool/blob/v4.2.1/.github/workflows/build_esptool.yml#L35-L37

python -m pip install --upgrade pip
pip install pyinstaller
pip install --user -e .

Build esptool:

https://github.com/espressif/esptool/blob/master/.github/workflows/build_esptool.yml#L40

pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=build_tools/espressif.ico --add-data=".${{ env.STUBS_DIR }}*.json${{ matrix.SEPARATOR }}${{ env.STUBS_DIR }}" esptool.py

But if you are messing around with it, you are probably better off to just run the Python script directly. The only reason they convert it to an executable is because otherwise Python would be a dependency of using the ESP32 boards platform and the average Arduino user on macOS (and Windows) finds it very challenging to install the right Python version and add it to the system path.

Thank you!! This is perfect!!

You are welcome. I'm glad if I was able to be of assistance.

Regards,
Per

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.