From bbf77c6b1eb3fb126004c6a2e865a285d3225239 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Thu, 28 Nov 2019 19:26:35 +0100 Subject: [PATCH] Added deploy script. --- deploy.sh | 37 +++++++++++++++++++++++++++++++++++++ platformio.ini | 21 +++++++++++++++++---- update.manifest | 5 ----- 3 files changed, 54 insertions(+), 9 deletions(-) create mode 100755 deploy.sh delete mode 100644 update.manifest diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..e13af7c --- /dev/null +++ b/deploy.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +set -x +set -e + +if ! git diff-index --quiet HEAD ; then + echo "Git isn't clean. Cant deploy." + exit 1 +fi + +read -p "Version to generate: " VERSION + +OTA_VERSION=`grep "VERSION=" bin/update.manifest | cut -d"=" -f2` +OTA_VERSION=$(( "$OTA_VERSION" + 1 )) +echo "$OTA_VERSION" > data/_version.txt + +sed -i.bak "s/#define OTA_VERSION .*/#define OTA_VERSION $OTA_VERSION/" include/config.h include/config.sample.h +rm include/config.h.bak include/config.sample.h.bak + +PLATFORMIO_BUILD_FLAGS='-DVERSION=\"$VERSION\"' pio run -e deploy -t buildprog || exit 1 +pio run -e deploy -t buildfs || exit 1 + +cp .pio/build/deploy/firmware.bin bin/firmware.bin || exit 1 +cp .pio/build/deploy/spiffs.bin bin/spiffs.bin || exit 1 + +sed -i.bak "s/VERSION=.*/VERSION=$OTA_VERSION/" bin/update.manifest +MD5=`md5sum --binary bin/firmware.bin | cut -d" " -f1` +sed -i.bak "s/IMAGE_MD5=.*/IMAGE_MD5=$MD5/" bin/update.manifest +MD5=`md5sum --binary bin/spiffs.bin | cut -d" " -f1` +sed -i.bak "s/SPIFFS_MD5=.*/SPIFFS_MD5=$MD5/" bin/update.manifest +rm bin/update.manifest.bak + +git diff +exit 99 + +git add bin/firmware.bin bin/spiffs.bin bin/update.manifest +git commit -m "Deploying version $VERSION." +git tag -a -m "Deploying version $VERSION" $VERSION diff --git a/platformio.ini b/platformio.ini index a3cfd34..f9800a5 100644 --- a/platformio.ini +++ b/platformio.ini @@ -8,16 +8,29 @@ ; Please visit documentation for the other options and examples ; https://docs.platformio.org/page/projectconf.html +[platformio] +default_envs = esp32 + +[extra] +lib_deps = + 63 ; MFRC522 + https://github.com/me-no-dev/ESPAsyncWebServer.git + ArduinoJSON + 6691 ; TinyXML + [env:esp32] platform = espressif32 board = esp-wrover-kit framework = arduino upload_speed = 512000 build_flags=!./build_version.sh -lib_deps = MFRC522 - https://github.com/me-no-dev/ESPAsyncWebServer.git - ArduinoJSON - 6691 ; TinyXML +lib_deps = ${extra.lib_deps} upload_port = /dev/cu.SLAB_USBtoUART monitor_speed = 74480 ;monitor_port = /dev/cu.wchusbserial1420 + +[env:deploy] +platform = espressif32 +board = esp-wrover-kit +framework = arduino +lib_deps = ${extra.lib_deps} diff --git a/update.manifest b/update.manifest deleted file mode 100644 index 7f0bdd5..0000000 --- a/update.manifest +++ /dev/null @@ -1,5 +0,0 @@ -VERSION=1 -IMAGE_PATH=https://files.schle.nz/esmp3/firmware.bin -IMAGE_MD5=ead8d94ae8a3c9f46e7ee65e2270fd69 -SPIFFS_PATH=https://files.schle.nz/esmp3/spiffs.bin -SPIFFS_MD5=9f3902e3312863da8326e7fbe9485c9e