diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7fd8bb87..45d78e4e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -45,6 +45,8 @@ jobs: run: pio lib install - name: PlatformIO run run: pio run + - name: Create zip files + run: /bin/sh scripts/mkzip.sh - name: Create Release id: create_release uses: actions/create-release@v1.0.0 @@ -55,6 +57,35 @@ jobs: release_name: Release ${{ github.ref }} draft: false prerelease: false + + - name: Upload esp8266 zip to release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: esp8266.zip + asset_name: ams2mqtt-esp8266-${{ steps.release_tag.outputs.tag }}.zip + asset_content_type: application/zip + - name: Upload esp32 zip to release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: esp32.zip + asset_name: ams2mqtt-esp32-${{ steps.release_tag.outputs.tag }}.zip + asset_content_type: application/zip + - name: Upload esp32s2 zip to release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: esp32s2.zip + asset_name: ams2mqtt-esp32s2-${{ steps.release_tag.outputs.tag }}.zip + asset_content_type: application/zip + - name: Upload esp8266 binary to release uses: actions/upload-release-asset@v1 env: @@ -73,12 +104,12 @@ jobs: asset_path: .pio/build/esp32/firmware.bin asset_name: ams2mqtt-esp32-${{ steps.release_tag.outputs.tag }}.bin asset_content_type: application/octet-stream - - name: Upload esp32 partitions to release + - name: Upload esp32s2 binary to release uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: .pio/build/esp32/partitions.bin - asset_name: ams2mqtt-esp32-partitions-${{ steps.release_tag.outputs.tag }}.bin + asset_path: .pio/build/esp32s2/firmware.bin + asset_name: ams2mqtt-esp32s2-${{ steps.release_tag.outputs.tag }}.bin asset_content_type: application/octet-stream diff --git a/.gitignore b/.gitignore index 7086ece5..8fa788c6 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ platformio-user.ini /web/test.html /sdkconfig /.tmp +/*.zip diff --git a/platformio.ini b/platformio.ini index 68a9ed37..76125a2b 100755 --- a/platformio.ini +++ b/platformio.ini @@ -7,45 +7,43 @@ lib_ignore = OneWire [env:esp8266] platform = espressif8266@3.2.0 +framework = arduino board = esp12e board_build.ldscript = eagle.flash.4m2m.ld -framework = arduino +build_flags = -D WEBSOCKET_DISABLED=1 lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} extra_scripts = pre:scripts/addversion.py scripts/makeweb.py -build_flags = - -D WEBSOCKET_DISABLED=1 [env:esp32] -platform = https://github.com/platformio/platform-espressif32.git#feature/arduino-upstream -board = esp32dev +platform = https://github.com/tasmota/platform-espressif32.git#v2.0.3 +platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.2 framework = arduino +board = esp32dev +board_build.f_cpu = 160000000L +build_flags = -D WEBSOCKET_DISABLED=1 lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} extra_scripts = pre:scripts/addversion.py scripts/makeweb.py -build_flags = - -D WEBSOCKET_DISABLED=1 -board_build.f_cpu = 160000000L [env:esp32s2] -platform = https://github.com/tasmota/platform-espressif32/releases/download/v3.4.1/Tasmota-platform-espressif32.zip +platform = https://github.com/tasmota/platform-espressif32.git#v2.0.3 platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.2 +framework = arduino board = esp32dev board_build.mcu = esp32s2 board_build.variant = esp32s2 board_build.flash_mode = qio board_build.f_cpu = 160000000L board_build.f_flash = 40000000L -framework = arduino +build_flags = -D WEBSOCKET_DISABLED=1 lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} extra_scripts = pre:scripts/addversion.py scripts/makeweb.py -build_flags = - -D WEBSOCKET_DISABLED=1 diff --git a/scripts/esp32/flash.sh b/scripts/esp32/flash.sh new file mode 100755 index 00000000..cc776839 --- /dev/null +++ b/scripts/esp32/flash.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +if [ -z "$1" ];then + echo "Usage: " + echo " Flashing first time : $0 flash /dev/ttyUSB0" + echo " When upgrading to new version : $0 upgrade /dev/ttyUSB0" + echo " NOTE: Replace /dev/ttyUSB0 with correct port" + exit 1 +fi + +if [ -z "$2" ];then + echo "Please specify port" + exit 1 +fi + +esptool=`which esptool` +if [ -z "$esptool" ];then + esptool=`which esptool.py` +fi +if [ -z "$esptool" ];then + if [ -f esptool.py ];then + esptool="esptool.py" + fi +fi +if [ -z "$esptool" ];then + echo "esptool.py not available to run following command: " + esptool="echo esptool.py" +fi + +if [ "$1" = "flash" ];then + $esptool --chip esp32 --port $2 --baud 460800 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect \ + 0x1000 bootloader_dio_40m.bin \ + 0x8000 partitions.bin \ + 0xe000 boot_app0.bin \ + 0x10000 firmware.bin + exit $? +elif [ "$1" = "upgrade" ];then + $esptool --chip esp32 --port $2 --baud 460800 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x10000 firmware.bin + exit $? +fi diff --git a/scripts/esp32/mkzip.sh b/scripts/esp32/mkzip.sh new file mode 100755 index 00000000..a15f70a0 --- /dev/null +++ b/scripts/esp32/mkzip.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +env="esp32" +build_dir=".pio/build/$env/" + +if [ ! -d $build_dir ];then + echo "No build directory" + exit 1 +fi + +cp ~/.platformio/packages/framework-arduinoespressif32/tools/sdk/$env/bin/bootloader_dio_40m.bin $build_dir +cp ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin $build_dir +chmod +x scripts/$env/flash.sh +zip -j $env.zip $build_dir/*.bin scripts/$env/flash.sh diff --git a/scripts/esp32s2/flash.sh b/scripts/esp32s2/flash.sh new file mode 100755 index 00000000..d017e826 --- /dev/null +++ b/scripts/esp32s2/flash.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +if [ -z "$1" ];then + echo "Usage: " + echo " Flashing first time : $0 flash /dev/ttyUSB0" + echo " When upgrading to new version : $0 upgrade /dev/ttyUSB0" + echo " NOTE: Replace /dev/ttyUSB0 with correct port" + exit 1 +fi + +if [ -z "$2" ];then + echo "Please specify port" + exit 1 +fi + +esptool=`which esptool` +if [ -z "$esptool" ];then + esptool=`which esptool.py` +fi +if [ -z "$esptool" ];then + if [ -f esptool.py ];then + esptool="esptool.py" + fi +fi +if [ -z "$esptool" ];then + echo "esptool.py not available to run following command: " + esptool="echo esptool.py" +fi + +if [ "$1" = "flash" ];then + $esptool --chip esp32s2 --port $2 --baud 460800 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect \ + 0x1000 bootloader_qio_40m.bin \ + 0x8000 partitions.bin \ + 0xe000 boot_app0.bin \ + 0x10000 firmware.bin + exit $? +elif [ "$1" = "upgrade" ];then + $esptool --chip esp32s2 --port $2 --baud 460800 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x10000 firmware.bin + exit $? +fi diff --git a/scripts/esp32s2/mkzip.sh b/scripts/esp32s2/mkzip.sh new file mode 100755 index 00000000..3cbf0a41 --- /dev/null +++ b/scripts/esp32s2/mkzip.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +env="esp32s2" +build_dir=".pio/build/$env/" + +if [ ! -d $build_dir ];then + echo "No build directory" + exit 1 +fi + +cp ~/.platformio/packages/framework-arduinoespressif32/tools/sdk/$env/bin/bootloader_qio_40m.bin $build_dir +cp ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin $build_dir +chmod +x scripts/$env/flash.sh +zip -j $env.zip $build_dir/*.bin scripts/$env/flash.sh diff --git a/scripts/esp8266/flash.sh b/scripts/esp8266/flash.sh new file mode 100755 index 00000000..d2c71d9a --- /dev/null +++ b/scripts/esp8266/flash.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +if [ -z "$1" ];then + echo "Usage: " + echo " Flashing first time : $0 flash /dev/ttyUSB0" + echo " When upgrading to new version : $0 upgrade /dev/ttyUSB0" + echo " NOTE: Replace /dev/ttyUSB0 with correct port" + exit 1 +fi + +if [ -z "$2" ];then + echo "Please specify port" + exit 1 +fi + +esptool=`which esptool` +if [ -z "$esptool" ];then + esptool=`which esptool.py` +fi +if [ -z "$esptool" ];then + if [ -f esptool.py ];then + esptool="esptool.py" + fi +fi +if [ -z "$esptool" ];then + echo "esptool.py not available to run following command: " + esptool="echo esptool.py" +fi + +$esptool --before default_reset --after hard_reset --chip esp8266 --port $2 --baud 115200 write_flash 0x0 firmware.bin +exit $? diff --git a/scripts/esp8266/mkzip.sh b/scripts/esp8266/mkzip.sh new file mode 100755 index 00000000..04ecdf11 --- /dev/null +++ b/scripts/esp8266/mkzip.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +env="esp8266" +build_dir=".pio/build/$env/" + +if [ ! -d $build_dir ];then + echo "No build directory" + exit 1 +fi + +chmod +x scripts/$env/flash.sh +zip -j $env.zip $build_dir/*.bin scripts/$env/flash.sh diff --git a/scripts/mkzip.sh b/scripts/mkzip.sh new file mode 100644 index 00000000..440e1bf4 --- /dev/null +++ b/scripts/mkzip.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +find -name firmware.bin | while read firmware;do + dir=`dirname $firmware` + env=`basename $dir` + if [ -f scripts/$env/mkzip.sh ];then + echo "Building zip for env '$env'" + chmod +x scripts/$env/mkzip.sh + scripts/$env/mkzip.sh + fi +done \ No newline at end of file