From dcaefbccac3d469e57bdac5a8b1825d00f2cb2aa Mon Sep 17 00:00:00 2001 From: ZanzyTHEbar Date: Fri, 9 Sep 2022 22:49:11 +0100 Subject: [PATCH] Major Update - Added proper Automated naming scheme for firmware files. Looks awesome now :) - changed "easynetwork" to "openiris" in project_config.cpp --- ESP/lib/src/data/config/project_config.cpp | 4 +-- ESP/platformio.ini | 29 ++++++++++++++-------- ESP/tools/customname.py | 23 +++++++++++++++++ ESP/tools/git_rev.py | 25 +++++++++++++++++++ 4 files changed, 68 insertions(+), 13 deletions(-) create mode 100644 ESP/tools/customname.py create mode 100644 ESP/tools/git_rev.py diff --git a/ESP/lib/src/data/config/project_config.cpp b/ESP/lib/src/data/config/project_config.cpp index 55e5ebd..0d38d6c 100644 --- a/ESP/lib/src/data/config/project_config.cpp +++ b/ESP/lib/src/data/config/project_config.cpp @@ -119,7 +119,7 @@ void ProjectConfig::load() } /* Device Config */ - this->config.device.name = getString("deviceName", "easynetwork").c_str(); + this->config.device.name = getString("deviceName", "openiris").c_str(); this->config.device.OTAPassword = getString("OTAPassword", "12345678").c_str(); this->config.device.OTAPort = getInt("OTAPort", 3232); //! No need to load the JSON strings or bools, they are generated and used on the fly @@ -155,7 +155,7 @@ void ProjectConfig::load() } /* AP Config */ - this->config.ap_network.ssid = getString("apSSID", "easynetwork").c_str(); + this->config.ap_network.ssid = getString("apSSID", "openiris").c_str(); this->config.ap_network.password = getString("apPass", "12345678").c_str(); this->config.ap_network.channel = getUInt("apChannel", 1); diff --git a/ESP/platformio.ini b/ESP/platformio.ini index 66cbc4c..86ad2e5 100644 --- a/ESP/platformio.ini +++ b/ESP/platformio.ini @@ -75,6 +75,8 @@ monitor_filters = time default esp32_exception_decoder + +release_version = 0.0.1 ; increase this value every release build build_flags = @@ -102,18 +104,20 @@ build_flags = -DCORE_DEBUG_LEVEL=4 + !python tools\git_rev.py ; add git revision to build as preprocessor defines + -DBOARD_HAS_PSRAM - - -DASYNCWEBSERVER_REGEX ; add regex support to AsyncWebServer + + -DASYNCWEBSERVER_REGEX -mfix-esp32-psram-cache-issue + build_unflags = -Os ; board_build.partitions = min_spiffs.csv board_build.partitions = huge_app.csv lib_ldf_mode = deep+ upload_speed = 921600 -release_version = 0.0.1 ; increase this value every release build lib_deps = esp32-camera leftcoast/LC_baseTools@^1.5 @@ -123,6 +127,7 @@ lib_deps = https://github.com/bblanchon/ArduinoJson.git build_type = debug +extra_scripts = pre:tools/customname.py [env:esp32Cam] platform = ${common.platform} @@ -153,6 +158,7 @@ build_flags = ${common.build_flags} -DPCLK_GPIO_NUM=${pinoutsESPCAM.PCLK_GPIO_NUM} ; Set the PCLK pin -DDEBUG_MODE=1 ; Set the debug mode + -DVERSION=0 build_unflags = ${common.build_unflags} board_build.partitions = ${common.board_build.partitions} @@ -160,6 +166,7 @@ lib_ldf_mode = ${common.lib_ldf_mode} upload_speed = ${common.upload_speed} lib_deps = ${common.lib_deps} build_type = ${common.build_type} +extra_scripts = ${common.extra_scripts} [env:esp32Cam_release] platform = ${common.platform} @@ -179,6 +186,7 @@ lib_ldf_mode = ${common.lib_ldf_mode} upload_speed = ${common.upload_speed} lib_deps = ${common.lib_deps} build_type = release +extra_scripts = ${common.extra_scripts} ; Experimental OTA Environment - do not select unless you know what you are doing [env:esp32Cam_OTA] @@ -191,13 +199,11 @@ build_flags = -DCORE_DEBUG_LEVEL=1 -DDEBUG_ESP_OTA -DVERSION=${common.release_version} -lib_deps = - ${common.lib_deps} +lib_deps = ${common.lib_deps} upload_speed = ${common.upload_speed} monitor_speed = ${common.monitor_speed} monitor_rts = ${common.monitor_rts} monitor_dtr = ${common.monitor_dtr} -; extra_scripts = ${common.extra_scripts} board_build.partitions = ${common.board_build.partitions} lib_ldf_mode = ${common.lib_ldf_mode} upload_port = 192.168.1.38 @@ -206,6 +212,7 @@ upload_flags = --port=3232 --auth=12345678 build_type = release +extra_scripts = ${common.extra_scripts} [env:wrover] platform = ${common.platform} @@ -242,10 +249,10 @@ build_unflags = ${common.build_unflags} board_build.partitions = ${common.board_build.partitions} lib_ldf_mode = ${common.lib_ldf_mode} upload_speed = ${common.upload_speed} -lib_deps = - ${common.lib_deps} +lib_deps = ${common.lib_deps} ;upload_port = COM6 build_type = ${common.build_type} +extra_scripts = ${common.extra_scripts} [env:wrover_release] platform = ${common.platform} @@ -266,6 +273,7 @@ upload_speed = ${common.upload_speed} lib_deps = ${common.lib_deps} upload_port = COM6 build_type = release +extra_scripts = ${common.extra_scripts} ; Experimental OTA Environment - do not select unless you know what you are doing [env:wrover_OTA] @@ -278,13 +286,11 @@ build_flags = -DCORE_DEBUG_LEVEL=1 -DDEBUG_ESP_OTA -DVERSION=${common.release_version} -lib_deps = - ${common.lib_deps} +lib_deps = ${common.lib_deps} upload_speed = ${common.upload_speed} monitor_speed = ${common.monitor_speed} monitor_rts = ${common.monitor_rts} monitor_dtr = ${common.monitor_dtr} -; extra_scripts = ${common.extra_scripts} board_build.partitions = ${common.board_build.partitions} lib_ldf_mode = ${common.lib_ldf_mode} upload_port = 192.168.1.38 @@ -293,3 +299,4 @@ upload_flags = --port=3232 --auth=12345678 build_type = release +extra_scripts = ${common.extra_scripts} \ No newline at end of file diff --git a/ESP/tools/customname.py b/ESP/tools/customname.py new file mode 100644 index 0000000..9d465e7 --- /dev/null +++ b/ESP/tools/customname.py @@ -0,0 +1,23 @@ +# Description: Custom name for firmware + +Import("env") + +my_flags = env.ParseFlags(env['BUILD_FLAGS']) +defines = dict() +for x in my_flags.get("CPPDEFINES"): + if type(x) is tuple: + (k,v) = x + defines[k] = v + elif type(x) is list: + k = x[0] + v = x[1] + defines[k] = v + else: + defines[x] = "" # empty value +# defines.get("PIO_SRC_TAG") - tag name +# strip quotes needed for shell escaping +s = lambda x: x.replace('"', "") +env.Replace( + PROGNAME="%s-%s-%s-%s-%s" % + (s(defines.get("PIO_SRC_NAM")), s(defines.get("VERSION")), str(env["BOARD"]), + s(defines.get("PIO_SRC_REV")), s(defines.get("PIO_SRC_BRH")))) diff --git a/ESP/tools/git_rev.py b/ESP/tools/git_rev.py new file mode 100644 index 0000000..90dc59a --- /dev/null +++ b/ESP/tools/git_rev.py @@ -0,0 +1,25 @@ +import subprocess + +# Get Git project name +projcmd = "git rev-parse --show-toplevel" +project = subprocess.check_output(projcmd, shell=True).decode().strip() +project = project.split("/") +project = project[len(project)-1] + +# Get 0.0.0 version from latest Git tag +# tagcmd = "git describe --tags --abbrev=0" +# version = subprocess.check_output(tagcmd, shell=True).decode().strip() + +# Get latest commit short from Git +revcmd = "git log --pretty=format:'%h' -n 1" +commit = subprocess.check_output(revcmd, shell=True).decode().strip() + +# Get branch name from Git +branchcmd = "git rev-parse --abbrev-ref HEAD" +branch = subprocess.check_output(branchcmd, shell=True).decode().strip() + +# Make all available for use in the macros +print("-DPIO_SRC_NAM={0}".format(project)) +# print("-DPIO_SRC_TAG={0}".format(version)) +print("-DPIO_SRC_REV={0}".format(commit)) +print("-DPIO_SRC_BRH={0}".format(branch)) \ No newline at end of file