diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..3d86c08 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,118 @@ +name: Build Workflow + +on: [push, pull_request] + +jobs: + build-windows: + runs-on: windows-latest + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Install Python + uses: actions/setup-python@v1 + with: + python-version: '3.7' + architecture: 'x64' + - name: Print Versions + run: | + python --version + pip --version + - name: Install requirements + run: | + pip install -r requirements_build.txt + pip install -e . + - name: Run PyInstaller + run: | + python -m PyInstaller.__main__ -F -w -n ESPHome-Flasher -i icon.ico esphomeflasher\__main__.py + - name: See dist directory + run: ls dist + - uses: actions/upload-artifact@master + with: + name: Windows + path: dist/ESPHome-Flasher.exe + build-windows-x86: + runs-on: windows-latest + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Install Python + uses: actions/setup-python@v1 + with: + python-version: '3.7' + architecture: 'x86' + - name: Print Versions + run: | + python --version + pip --version + - name: Install requirements + run: | + pip install -r requirements_build.txt + pip install -e . + - name: Run PyInstaller + run: | + python -m PyInstaller.__main__ -F -w -n ESPHome-Flasher -i icon.ico esphomeflasher\__main__.py + - name: See dist directory + run: ls dist + - uses: actions/upload-artifact@master + with: + name: Windows-x86 + path: dist/ESPHome-Flasher.exe + + #build-ubuntu: + # runs-on: ubuntu-latest + # steps: + # - name: Checkout + # uses: actions/checkout@v1 + # - name: Install Python + # uses: actions/setup-python@v1 + # with: + # python-version: '3.7' + # - name: Install dependencies + # run: | + # sudo apt install python-wxgtk3.0 build-essential libgtk-3-dev + # - name: Print Versions + # run: | + # python --version + # pip --version + # - name: Install requirements + # run: | + # pip install pathlib2 + # pip install -r requirements_build.txt + # pip install -e . + # - name: Run PyInstaller + # run: | + # python -m PyInstaller.__main__ -F -w -n ESPHome-Flasher -i icon.ico esphomeflasher/__main__.py + # - name: See dist directory + # run: ls dist + # - uses: actions/upload-artifact@master + # with: + # name: Ubuntu + # path: dist + + + build-macos: + runs-on: macOS-latest + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Install Python + uses: actions/setup-python@v1 + with: + python-version: '3.7' + - name: Print Versions + run: | + python --version + pip --version + - name: Install requirements + run: | + pip install -r requirements_build.txt + pip install -e . + - name: Run PyInstaller + run: | + python -m PyInstaller.__main__ -F -w -n ESPHome-Flasher -i icon.icns esphomeflasher/__main__.py + - name: See dist directory + run: ls dist + - uses: actions/upload-artifact@master + with: + name: MacOS + path: dist/ESPHome-Flasher.app diff --git a/esphomeflasher/__main__.py b/esphomeflasher/__main__.py index 0276de8..d45bc26 100644 --- a/esphomeflasher/__main__.py +++ b/esphomeflasher/__main__.py @@ -3,6 +3,7 @@ from __future__ import print_function import argparse from datetime import datetime import sys +import time import esptool import serial @@ -22,6 +23,8 @@ def parse_args(argv): group = parser.add_mutually_exclusive_group(required=False) group.add_argument('--esp8266', action='store_true') group.add_argument('--esp32', action='store_true') + group.add_argument('--upload-baud-rate', type=int, default=460800, + help="Baud rate to upload with (not for logging)") parser.add_argument('--bootloader', help="(ESP32-only) The bootloader to flash.", default=ESP32_DEFAULT_BOOTLOADER_FORMAT) @@ -110,6 +113,12 @@ def run_esphomeflasher(argv): stub_chip = chip_run_stub(chip) + if args.upload_baud_rate != 115200: + try: + stub_chip.change_baud(args.upload_baud_rate) + except esptool.FatalError as err: + raise EsphomeflasherError("Error changing ESP upload baud rate: {}".format(err)) + flash_size = detect_flash_size(stub_chip) print(" - Flash Size: {}".format(flash_size)) @@ -142,6 +151,11 @@ def run_esphomeflasher(argv): print("Done! Flashing is complete!") print() + if args.upload_baud_rate != 115200: + stub_chip._port.baudrate = 115200 + time.sleep(0.05) # get rid of crap sent during baud rate change + stub_chip._port.flushInput() + show_logs(stub_chip._port) diff --git a/esphomeflasher/common.py b/esphomeflasher/common.py index 4df5ed6..a1c906c 100644 --- a/esphomeflasher/common.py +++ b/esphomeflasher/common.py @@ -22,6 +22,7 @@ class MockEsptoolArgs(object): self.no_stub = False self.verify = False self.erase_all = False + self.encrypt = False class ChipInfo(object): diff --git a/esphomeflasher/const.py b/esphomeflasher/const.py index 3ce3b20..09dff6b 100644 --- a/esphomeflasher/const.py +++ b/esphomeflasher/const.py @@ -4,7 +4,7 @@ __version__ = "1.1.0" ESP32_DEFAULT_OTA_DATA = 'https://raw.githubusercontent.com/espressif/arduino-esp32/1.0.0/tools/partitions/boot_app0.bin' ESP32_DEFAULT_BOOTLOADER_FORMAT = 'https://raw.githubusercontent.com/espressif/arduino-esp32/' \ - '1.0.0/tools/sdk/bin/bootloader_$FLASH_MODE$_$FLASH_FREQ$.bin' + '1.0.4/tools/sdk/bin/bootloader_$FLASH_MODE$_$FLASH_FREQ$.bin' ESP32_DEFAULT_PARTITIONS = 'https://raw.githubusercontent.com/esphome/esphomeflasher/master/partitions.bin' # https://stackoverflow.com/a/3809435/8924614 diff --git a/requirements_build.txt b/requirements_build.txt new file mode 100644 index 0000000..2b1607b --- /dev/null +++ b/requirements_build.txt @@ -0,0 +1,4 @@ +wxpython>=4.0,<5.0 +esptool==2.8 +requests>=2.0,<3 +pyinstaller diff --git a/setup.py b/setup.py index d8a17a7..8e53d62 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ DOWNLOAD_URL = '{}/archive/{}.zip'.format(GITHUB_URL, const.__version__) REQUIRES = [ 'wxpython>=4.0,<5.0', - 'esptool==2.6', + 'esptool==2.8', 'requests>=2.0,<3', ]