From 6507683909c52a011e13f806c7029528e736a430 Mon Sep 17 00:00:00 2001 From: Ihor Nehrutsa Date: Fri, 25 Nov 2022 15:17:24 +0200 Subject: [PATCH 1/9] Squashed commit of the following: commit c8d1bcf04fae5f7ac5b639ddd15a738045014c95 Author: Ihor Nehrutsa Date: Fri Nov 25 15:11:18 2022 +0200 Revert "variants\tbeam\variant.h: Use LORA_CS instead of RF95_NSS" This reverts commit 8d225ced9cbccb44d0b58451029b4bd073a8510e. commit 1c37097448393ea9364c2b9bf10522802c61d5c4 Author: Ihor Nehrutsa Date: Fri Nov 25 15:04:09 2022 +0200 Some little debugs added commit f1b55e11afb11df414969924a1d84f8fa72fbf62 Author: Ihor Nehrutsa Date: Wed Nov 23 15:24:58 2022 +0200 Update variant.h commit 8d225ced9cbccb44d0b58451029b4bd073a8510e Author: Ihor Nehrutsa Date: Wed Nov 23 13:06:49 2022 +0200 variants\tbeam\variant.h: Use LORA_CS instead of RF95_NSS --- src/main.cpp | 9 +++++---- src/mesh/RadioInterface.cpp | 11 ++++++----- src/mesh/SX126xInterface.cpp | 25 +++++++++++++------------ src/modules/esp32/RangeTestModule.cpp | 4 ++-- src/platform/esp32/main-esp32.cpp | 2 +- variants/tbeam/variant.h | 2 +- 6 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index f83909869..98f22ecf1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -140,8 +140,9 @@ bool ButtonThread::shutdown_on_long_stop = false; #endif static Periodic *ledPeriodic; -static OSThread *powerFSMthread, *buttonThread; +static OSThread *powerFSMthread; #if HAS_BUTTON +static OSThread *buttonThread; uint32_t ButtonThread::longPressTime = 0; #endif @@ -269,7 +270,7 @@ void setup() #ifdef HAS_SDCARD setupSDCard(); #endif - + #ifdef RAK4630 // scanEInkDevice(); #endif @@ -303,11 +304,11 @@ void setup() nodeDB.init(); playStartMelody(); - + // fixed screen override? if (config.display.oled != Config_DisplayConfig_OledType_OLED_AUTO) screen_model = config.display.oled; - + // Init our SPI controller (must be before screen and lora) initSPI(); #ifndef ARCH_ESP32 diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index 0c68b59a2..4a40c6600 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -177,7 +177,7 @@ uint32_t RadioInterface::getRetransmissionMsec(const MeshPacket *p) static uint8_t bytes[MAX_RHPACKETLEN]; size_t numbytes = pb_encode_to_bytes(bytes, sizeof(bytes), Data_fields, &p->decoded); uint32_t packetAirtime = getPacketTime(numbytes + sizeof(PacketHeader)); - // Make sure enough time has elapsed for this packet to be sent and an ACK is received. + // Make sure enough time has elapsed for this packet to be sent and an ACK is received. // DEBUG_MSG("Waiting for flooding message with airtime %d and slotTime is %d\n", packetAirtime, slotTimeMsec); float channelUtil = airTime->channelUtilizationPercent(); uint8_t CWsize = map(channelUtil, 0, 100, CWmin, CWmax); @@ -189,7 +189,7 @@ uint32_t RadioInterface::getRetransmissionMsec(const MeshPacket *p) uint32_t RadioInterface::getTxDelayMsec() { /** We wait a random multiple of 'slotTimes' (see definition in header file) in order to avoid collisions. - The pool to take a random multiple from is the contention window (CW), which size depends on the + The pool to take a random multiple from is the contention window (CW), which size depends on the current channel utilization. */ float channelUtil = airTime->channelUtilizationPercent(); uint8_t CWsize = map(channelUtil, 0, 100, CWmin, CWmax); @@ -225,7 +225,7 @@ uint32_t RadioInterface::getTxDelayMsecWeighted(float snr) void printPacket(const char *prefix, const MeshPacket *p) { - DEBUG_MSG("%s (id=0x%08x Fr0x%02x To0x%02x, WantAck%d, HopLim%d Ch0x%x", prefix, p->id, p->from & 0xff, p->to & 0xff, + DEBUG_MSG("%s (id=0x%08x fr=0x%02x to=0x%02x, WantAck=%d, HopLim=%d Ch=0x%x", prefix, p->id, p->from & 0xff, p->to & 0xff, p->want_ack, p->hop_limit, p->channel); if (p->which_payload_variant == MeshPacket_decoded_tag) { auto &s = p->decoded; @@ -432,7 +432,7 @@ void RadioInterface::applyModemConfig() // Set final tx_power back onto config loraConfig.tx_power = (int8_t)power; // cppcheck-suppress assignmentAddressToInteger - + // Calculate the number of channels uint32_t numChannels = floor((myRegion->freqEnd - myRegion->freqStart) / (myRegion->spacing + (bw / 1000))); @@ -449,8 +449,9 @@ void RadioInterface::applyModemConfig() saveChannelNum(channel_num); saveFreq(freq + config.lora.frequency_offset); + DEBUG_MSG("Radio freq=%.3f, config.lora.frequency_offset=%.3f\n", freq, config.lora.frequency_offset); DEBUG_MSG("Set radio: region=%s, name=%s, config=%u, ch=%d, power=%d\n", myRegion->name, channelName, loraConfig.modem_preset, channel_num, power); - DEBUG_MSG("Radio myRegion->freqStart / myRegion->freqEnd: %f -> %f (%f mhz)\n", myRegion->freqStart, myRegion->freqEnd, myRegion->freqEnd - myRegion->freqStart); + DEBUG_MSG("Radio myRegion->freqStart -> myRegion->freqEnd: %f -> %f (%f mhz)\n", myRegion->freqStart, myRegion->freqEnd, myRegion->freqEnd - myRegion->freqStart); DEBUG_MSG("Radio myRegion->numChannels: %d x %.3fkHz\n", numChannels, bw); DEBUG_MSG("Radio channel_num: %d\n", channel_num); DEBUG_MSG("Radio frequency: %f\n", getFreq()); diff --git a/src/mesh/SX126xInterface.cpp b/src/mesh/SX126xInterface.cpp index 20c8056e2..5559a7063 100644 --- a/src/mesh/SX126xInterface.cpp +++ b/src/mesh/SX126xInterface.cpp @@ -12,6 +12,7 @@ SX126xInterface::SX126xInterface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, SPIClass &spi) : RadioLibInterface(cs, irq, rst, busy, spi, &lora), lora(&module) { + DEBUG_MSG("SX126xInterface(cs=%d, irq=%d, rst=%d, busy=%d)\n", cs, irq, rst, busy); } /// Initialise the Driver transport hardware and software. @@ -56,9 +57,9 @@ bool SX126xInterface::init() // \todo Display actual typename of the adapter, not just `SX126x` DEBUG_MSG("SX126x init result %d\n", res); - DEBUG_MSG("Frequency set to %f\n", getFreq()); - DEBUG_MSG("Bandwidth set to %f\n", bw); - DEBUG_MSG("Power output set to %d\n", power); + DEBUG_MSG("Frequency set to %f\n", getFreq()); + DEBUG_MSG("Bandwidth set to %f\n", bw); + DEBUG_MSG("Power output set to %d\n", power); // current limit was removed from module' ctor // override default value (60 mA) @@ -81,11 +82,11 @@ bool SX126xInterface::init() //if(crcLSB != 0x0f) // RECORD_CRITICALERROR(CriticalErrorCode_SX1262Failure); - + crcLSB = 0x5a; err = lora.writeRegister(SX126X_REG_CRC_POLYNOMIAL_LSB, &crcLSB, 1); if(err != RADIOLIB_ERR_NONE) - RECORD_CRITICALERROR(CriticalErrorCode_SX1262Failure); + RECORD_CRITICALERROR(CriticalErrorCode_SX1262Failure); err = lora.readRegister(SX126X_REG_CRC_POLYNOMIAL_LSB, &crcLSB, 1); if(err != RADIOLIB_ERR_NONE) @@ -146,7 +147,7 @@ bool SX126xInterface::reconfigure() if (power > SX126X_MAX_POWER) // This chip has lower power limits than some power = SX126X_MAX_POWER; - + err = lora.setOutputPower(power); assert(err == RADIOLIB_ERR_NONE); @@ -165,7 +166,7 @@ template void SX126xInterface::setStandby() { checkNotification(); // handle any pending interrupts before we force standby - + int err = lora.standby(); if (err != RADIOLIB_ERR_NONE) @@ -229,7 +230,7 @@ void SX126xInterface::startReceive() #if defined(SX126X_TXEN) && (SX126X_TXEN != RADIOLIB_NC) digitalWrite(SX126X_TXEN, LOW); #endif - + // int err = lora.startReceive(); int err = lora.startReceiveDutyCycleAuto(); // We use a 32 bit preamble so this should save some power by letting radio sit in // standby mostly. @@ -249,13 +250,13 @@ bool SX126xInterface::isChannelActive() // check if we can detect a LoRa preamble on the current channel int16_t result; - setStandby(); + setStandby(); result = lora.scanChannel(); - if (result == RADIOLIB_PREAMBLE_DETECTED) + if (result == RADIOLIB_PREAMBLE_DETECTED) return true; - + assert(result != RADIOLIB_ERR_WRONG_MODEM); - + return false; } diff --git a/src/modules/esp32/RangeTestModule.cpp b/src/modules/esp32/RangeTestModule.cpp index b4cd9254e..d706f8ed3 100644 --- a/src/modules/esp32/RangeTestModule.cpp +++ b/src/modules/esp32/RangeTestModule.cpp @@ -155,8 +155,8 @@ ProcessMessage RangeTestModuleRadio::handleReceived(const MeshPacket &mp) DEBUG_MSG("mp.from %d\n", mp.from); DEBUG_MSG("mp.rx_snr %f\n", mp.rx_snr); DEBUG_MSG("mp.hop_limit %d\n", mp.hop_limit); - DEBUG_MSG("mp.decoded.position.latitude_i %d\n", mp.decoded.position.latitude_i); // Depricated - DEBUG_MSG("mp.decoded.position.longitude_i %d\n", mp.decoded.position.longitude_i); // Depricated + // DEBUG_MSG("mp.decoded.position.latitude_i %d\n", mp.decoded.position.latitude_i); // Depricated + // DEBUG_MSG("mp.decoded.position.longitude_i %d\n", mp.decoded.position.longitude_i); // Depricated DEBUG_MSG("---- Node Information of Received Packet (mp.from):\n"); DEBUG_MSG("n->user.long_name %s\n", n->user.long_name); DEBUG_MSG("n->user.short_name %s\n", n->user.short_name); diff --git a/src/platform/esp32/main-esp32.cpp b/src/platform/esp32/main-esp32.cpp index aaa4f4efe..21df018d8 100644 --- a/src/platform/esp32/main-esp32.cpp +++ b/src/platform/esp32/main-esp32.cpp @@ -24,7 +24,7 @@ void getMacAddr(uint8_t *dmac) } void setBluetoothEnable(bool on) { - + if (!isWifiAvailable() && config.bluetooth.enabled == true) { if (!nimbleBluetooth) { nimbleBluetooth = new NimbleBluetooth(); diff --git a/variants/tbeam/variant.h b/variants/tbeam/variant.h index fab210683..268e9ef96 100644 --- a/variants/tbeam/variant.h +++ b/variants/tbeam/variant.h @@ -12,7 +12,7 @@ // TTGO uses a common pinout for their SX1262 vs RF95 modules - both can be enabled and we will probe at runtime for RF95 and if // not found then probe for SX1262 -#define USE_RF95 +#define USE_RF95 // RFM95/SX127x #define USE_SX1262 #define USE_SX1268 From 0dff4538f3c18b4aa792183864a63e6b2ebcea59 Mon Sep 17 00:00:00 2001 From: lewis Date: Sat, 26 Nov 2022 00:17:54 +0800 Subject: [PATCH 2/9] Add t-echo to the operation after the flash operation fails --- src/mesh/NodeDB.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index c548b0acc..5009a2697 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -475,6 +475,15 @@ bool saveProto(const char *filename, size_t protoSize, size_t objSize, const pb_ DEBUG_MSG("Error: can't rename new pref file\n"); } else { DEBUG_MSG("Can't write prefs\n"); +#ifdef ARCH_NRF52 + static uint8_t failedCounter = 0; + failedCounter++; + if(failedCounter >= 2){ + FSCom.format(); + //After formatting, the device needs to be restarted + nodeDB.resetRadioConfig(); + } +#endif } #else DEBUG_MSG("ERROR: Filesystem not implemented\n"); From 32a1e8ef0dfc099a92283d87ae193ca42046a930 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Fri, 25 Nov 2022 09:44:26 -0800 Subject: [PATCH 3/9] Create feature.yml --- .github/ISSUE_TEMPLATE/feature.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/feature.yml diff --git a/.github/ISSUE_TEMPLATE/feature.yml b/.github/ISSUE_TEMPLATE/feature.yml new file mode 100644 index 000000000..2b6ffce0a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature.yml @@ -0,0 +1,27 @@ +name: Feature Request +description: Request a new feature +title: "[Feature Request]: " +labels: ["enhancement"] +body: + - type: markdown + attributes: + value: | + Thanks for your request this will not gurantee that we will implement it, but it will be reviewed. + - type: dropdown + id: soc + attributes: + label: Platform + description: What device platform will support your feature? + multiple: true + options: + - NRF52 + - ESP32 + validations: + required: true + - type: textarea + id: body + attributes: + label: Description + description: Please provide details about your enhancement. + validations: + required: true From cdd499f1472d5bef2d301917ad5246d72cea817f Mon Sep 17 00:00:00 2001 From: lewis Date: Sat, 26 Nov 2022 12:10:10 +0800 Subject: [PATCH 4/9] Add missing restart parameters --- src/mesh/NodeDB.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 5009a2697..6b2d5bfb3 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -481,7 +481,7 @@ bool saveProto(const char *filename, size_t protoSize, size_t objSize, const pb_ if(failedCounter >= 2){ FSCom.format(); //After formatting, the device needs to be restarted - nodeDB.resetRadioConfig(); + nodeDB.resetRadioConfig(true); } #endif } From c5fe878a6f57e9a9ca0bdd16d890e47270f85053 Mon Sep 17 00:00:00 2001 From: lewis Date: Sat, 26 Nov 2022 21:37:32 +0800 Subject: [PATCH 5/9] Fix the format of t-echo Bluetooth pairing display page --- src/graphics/Screen.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 277127d53..eac78dd64 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -283,27 +283,27 @@ static void drawModuleFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int static void drawFrameBluetooth(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) { + int x_offset = display->width() / 2; + int y_offset = display->height() == 64 ? 0 : 32; display->setTextAlignment(TEXT_ALIGN_CENTER); display->setFont(FONT_MEDIUM); - display->drawString(64 + x, y, "Bluetooth"); + display->drawString(x_offset + x, y_offset + y, "Bluetooth"); display->setFont(FONT_SMALL); - display->drawString(64 + x, FONT_HEIGHT_SMALL + y + 2, "Enter this code"); + y_offset = display->height() == 64 ? y_offset + FONT_HEIGHT_MEDIUM -4 : y_offset + FONT_HEIGHT_MEDIUM + 5; + display->drawString(x_offset + x, y_offset + y, "Enter this code"); display->setFont(FONT_LARGE); + String displayPin(btPIN); + String pin = displayPin.substring(0, 3) + " " + displayPin.substring(3, 6); + y_offset = display->height() == 64 ? y_offset + FONT_HEIGHT_SMALL - 5 : y_offset + FONT_HEIGHT_SMALL + 5; + display->drawString(x_offset + x, y_offset + y, pin); - auto displayPin = new String(btPIN); - display->setTextAlignment(TEXT_ALIGN_LEFT); - display->drawString(12 + x, 26 + y, displayPin->substring(0, 3)); - display->drawString(72 + x, 26 + y, displayPin->substring(3, 6)); - - display->setTextAlignment(TEXT_ALIGN_CENTER); display->setFont(FONT_SMALL); - char buf[30]; - const char *name = "Name: "; - strcpy(buf, name); - strcat(buf, getDeviceName()); - display->drawString(64 + x, 48 + y, buf); + String deviceName = "Name: "; + deviceName.concat(getDeviceName()); + y_offset = display->height() == 64 ? y_offset + FONT_HEIGHT_LARGE - 6 : y_offset + FONT_HEIGHT_LARGE + 5; + display->drawString(x_offset + x, y_offset + y, deviceName); } static void drawFrameShutdown(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) From 71c0cf9b9a5e0d1f8a7b1c4249950f1717629dc3 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 26 Nov 2022 08:11:32 -0600 Subject: [PATCH 6/9] Don't set DIO2 switch if TXEN is defined --- src/mesh/SX126xInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/SX126xInterface.cpp b/src/mesh/SX126xInterface.cpp index 5559a7063..ea7600dfc 100644 --- a/src/mesh/SX126xInterface.cpp +++ b/src/mesh/SX126xInterface.cpp @@ -70,7 +70,7 @@ bool SX126xInterface::init() #if defined(SX126X_TXEN) && (SX126X_TXEN != RADIOLIB_NC) // lora.begin sets Dio2 as RF switch control, which is not true if we are manually controlling RX and TX if (res == RADIOLIB_ERR_NONE) - res = lora.setDio2AsRfSwitch(true); + res = lora.setDio2AsRfSwitch(false); #endif #if 0 From a5ba3dd44567d96b92596a5c63d347b386a4fdf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 26 Nov 2022 16:03:17 +0100 Subject: [PATCH 7/9] revert protobuf change to develop --- .gitmodules | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 238eda7de..e6f376a0b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,3 @@ [submodule "protobufs"] path = protobufs url = https://github.com/meshtastic/protobufs.git - branch = develop From 7c9cada50e4ac77937c10661d4413cc84a5cdec9 Mon Sep 17 00:00:00 2001 From: caveman99 Date: Sat, 26 Nov 2022 15:04:12 +0000 Subject: [PATCH 8/9] [create-pull-request] automated change --- protobufs | 2 +- src/mesh/generated/localonly.pb.h | 2 +- src/mesh/generated/module_config.pb.h | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/protobufs b/protobufs index 3aca01ac8..afa460569 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 3aca01ac82487de8aa3d5eefdd907b4d80714501 +Subproject commit afa4605699e9ba9e2d0f0407bbc32dcd133f76af diff --git a/src/mesh/generated/localonly.pb.h b/src/mesh/generated/localonly.pb.h index f2c12b104..054cae4db 100644 --- a/src/mesh/generated/localonly.pb.h +++ b/src/mesh/generated/localonly.pb.h @@ -151,7 +151,7 @@ extern const pb_msgdesc_t LocalModuleConfig_msg; /* Maximum encoded size of messages (where known) */ #define LocalConfig_size 385 -#define LocalModuleConfig_size 296 +#define LocalModuleConfig_size 361 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/module_config.pb.h b/src/mesh/generated/module_config.pb.h index d4e54642a..12018203e 100644 --- a/src/mesh/generated/module_config.pb.h +++ b/src/mesh/generated/module_config.pb.h @@ -96,8 +96,8 @@ typedef struct _ModuleConfig_ExternalNotificationConfig { typedef struct _ModuleConfig_MQTTConfig { bool enabled; char address[32]; - char username[32]; - char password[32]; + char username[64]; + char password[64]; bool encryption_enabled; bool json_enabled; } ModuleConfig_MQTTConfig; @@ -386,12 +386,12 @@ extern const pb_msgdesc_t ModuleConfig_CannedMessageConfig_msg; #define ModuleConfig_AudioConfig_size 22 #define ModuleConfig_CannedMessageConfig_size 49 #define ModuleConfig_ExternalNotificationConfig_size 22 -#define ModuleConfig_MQTTConfig_size 105 +#define ModuleConfig_MQTTConfig_size 169 #define ModuleConfig_RangeTestConfig_size 10 #define ModuleConfig_SerialConfig_size 26 #define ModuleConfig_StoreForwardConfig_size 22 #define ModuleConfig_TelemetryConfig_size 18 -#define ModuleConfig_size 107 +#define ModuleConfig_size 172 #ifdef __cplusplus } /* extern "C" */ From 082aa07e7fa069ba9daadebee1c67e0f1022a73e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 26 Nov 2022 17:00:33 +0100 Subject: [PATCH 9/9] update batch scripts to further check filename. --- bin/device-install.bat | 5 ++++- bin/device-install.sh | 5 +++-- bin/device-update.bat | 5 ++++- bin/device-update.sh | 7 ++++--- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/bin/device-install.bat b/bin/device-install.bat index 419e8d6bd..15c2db352 100755 --- a/bin/device-install.bat +++ b/bin/device-install.bat @@ -26,7 +26,7 @@ IF "__%FILENAME%__" == "____" ( echo "Missing FILENAME" goto HELP ) -IF EXIST %FILENAME% ( +IF EXIST %FILENAME% IF x%FILENAME:update=%==x%FILENAME% ( echo Trying to flash update %FILENAME%, but first erasing and writing system information" %PYTHON% -m esptool --baud 115200 erase_flash %PYTHON% -m esptool --baud 115200 write_flash 0x00 %FILENAME% @@ -37,6 +37,9 @@ IF EXIST %FILENAME% ( ) else ( echo "Invalid file: %FILENAME%" goto HELP +) else ( + echo "Invalid file: %FILENAME%" + goto HELP ) :EOF diff --git a/bin/device-install.sh b/bin/device-install.sh index a55e553c7..bc14d440b 100755 --- a/bin/device-install.sh +++ b/bin/device-install.sh @@ -14,6 +14,7 @@ Flash image file to device, but first erasing and writing system information" -p ESPTOOL_PORT Set the environment variable for ESPTOOL_PORT. If not set, ESPTOOL iterates all ports (Dangerous). -P PYTHON Specify alternate python interpreter to use to invoke esptool. (Default: "$PYTHON") -f FILENAME The .bin file to flash. Custom to your device type and region. + EOF } @@ -44,7 +45,7 @@ shift "$((OPTIND-1))" shift } -if [ -f "${FILENAME}" ]; then +if [ -f "${FILENAME}" ] && [ "${FILENAME}" != *"update"* ]; then echo "Trying to flash ${FILENAME}, but first erasing and writing system information" "$PYTHON" -m esptool erase_flash "$PYTHON" -m esptool write_flash 0x00 ${FILENAME} @@ -52,8 +53,8 @@ if [ -f "${FILENAME}" ]; then "$PYTHON" -m esptool write_flash 0x300000 littlefs-*.bin else - echo "Invalid file: ${FILENAME}" show_help + echo "Invalid file: ${FILENAME}" fi exit 0 diff --git a/bin/device-update.bat b/bin/device-update.bat index 103fbad6e..2ac649be4 100755 --- a/bin/device-update.bat +++ b/bin/device-update.bat @@ -26,12 +26,15 @@ IF "__%FILENAME%__" == "____" ( echo "Missing FILENAME" goto HELP ) -IF EXIST %FILENAME% ( +IF EXIST %FILENAME% IF NOT x%FILENAME:update=%==x%FILENAME% ( echo Trying to flash update %FILENAME% %PYTHON% -m esptool --baud 115200 write_flash 0x10000 %FILENAME% ) else ( echo "Invalid file: %FILENAME%" goto HELP +) else ( + echo "Invalid file: %FILENAME%" + goto HELP ) :EOF diff --git a/bin/device-update.sh b/bin/device-update.sh index bd06fb25a..0959f0e3c 100755 --- a/bin/device-update.sh +++ b/bin/device-update.sh @@ -12,6 +12,7 @@ Flash image file to device, leave existing system intact." -p ESPTOOL_PORT Set the environment variable for ESPTOOL_PORT. If not set, ESPTOOL iterates all ports (Dangerrous). -P PYTHON Specify alternate python interpreter to use to invoke esptool. (Default: "$PYTHON") -f FILENAME The *update.bin file to flash. Custom to your device type. + EOF } @@ -42,12 +43,12 @@ shift "$((OPTIND-1))" shift } -if [ -f "${FILENAME}" ]; then - echo "Trying to flash update ${FILENAME}." +if [ -f "${FILENAME}" ] && [ $FILENAME == *"update"* ]; then + printf "Trying to flash update ${FILENAME}" $PYTHON -m esptool --baud 115200 write_flash 0x10000 ${FILENAME} else - echo "Invalid file: ${FILENAME}" show_help + echo "Invalid file: ${FILENAME}" fi exit 0