Page 1 of 1

How-to: Building esptool.py into esptool.exe in Windows

Posted: Mon Jan 23, 2017 9:37 am
by MartyMacGyver
Today I was working on mitigating a vexing serial issue with esptool when flashing the Core Board. In the process I learned how to rebuild the esptool.exe to try out my fix with Arduino-ESP32.

Here's how it's done:
  • Install Windows Python 2.7 or 3.5 (the packager doesn't work right with Python 3.6 yet) along with with esptool.py's usual dependencies (e.g., pyserial)
  • Install pyinstaller (adjust for your Python version):

    Code: Select all

    pip3.5 install pyinstaller
  • Build the exe (your paths may vary):
    • Example in MSYS2 shell:

      Code: Select all

      rm -rf build_tmp
      mkdir build_tmp
      /c/python35/scripts/pyinstaller \
          --onefile \
          --specpath build_tmp \
          --workpath build_tmp/build \
          --distpath build_tmp/dist \
          /c/esp-idf/components/esptool_py/esptool/esptool.py
          
      # Output: build_tmp/dist/esptool.exe
      
      # Typical esptool.exe location used by Arduino-ESP32:
      #   /c/Users/$USER/Documents/Arduino/hardware/espressif/esp32/tools/esptool.exe
      
    • Example in Windows cmd shell:

      Code: Select all

      rmdir /s /q build_tmp
      mkdir build_tmp
      C:\Python35\scripts\pyinstaller ^
          --onefile ^
          --specpath build_tmp ^
          --workpath build_tmp\build ^
          --distpath build_tmp\dist ^
          C:\esp-idf\components\esptool_py\esptool\esptool.py
          
      # Output: build_tmp\dist\esptool.exe
      
      # Typical esptool.exe location used by Arduino-ESP32:
      #   C:\Users\%USERNAME%\Documents\Arduino\hardware\espressif\esp32\tools\esptool.exe
      

Re: How-to: Building esptool.py into esptool.exe in Windows

Posted: Mon Jun 05, 2017 1:36 am
by don.vukovic
>>(the packager doesn't work right with Python 3.6 yet)

Is this still a problem with 3.6.1 ?

Re: How-to: Building esptool.py into esptool.exe in Windows

Posted: Mon Jun 05, 2017 7:03 am
by MartyMacGyver
don.vukovic wrote:>>(the packager doesn't work right with Python 3.6 yet)
Is this still a problem with 3.6.1 ?
Evidently pyinstaller is taking a long time getting up-to-date:

https://github.com/pyinstaller/pyinstaller/issues/2331

However... as I have MS Visual C 2010 installed from some long-ago project, I was able to clone their 'develop' branch from https://github.com/pyinstaller/pyinstaller, do the bootloader build and then install it (all as described on their README). That appears to work OK, for the very limited smoke test I just ran. Your mileage may vary. If in doubt, use Python 3.5 for now.

Edit: Actually, it's somewhat easier as the binary parts appear to be precompiled despite their disclaimer. So, just clone the repo (make sure you're on the 'develop' branch though you should be by default for that repo). Then give `python setup.py install` a shot (using Python 3.6 of course).