mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-08-12 06:59:02 +08:00
Fix random webupdate failed on ESP01 due to wrong sketch size
Add #define USE_AS_UPDATER_ONLY option in config.h to build small updater
This commit is contained in:
parent
af0d8a0a9d
commit
c63cc535c5
@ -166,6 +166,7 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a
|
|||||||
String parameter;
|
String parameter;
|
||||||
LOG ("Execute Command\r\n")
|
LOG ("Execute Command\r\n")
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
|
|
||||||
//STA SSID
|
//STA SSID
|
||||||
//[ESP100]<SSID>[pwd=<admin password>]
|
//[ESP100]<SSID>[pwd=<admin password>]
|
||||||
case 100:
|
case 100:
|
||||||
@ -281,6 +282,7 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#ifndef USE_AS_UPDATER_ONLY
|
||||||
//AP SSID
|
//AP SSID
|
||||||
//[ESP105]<SSID>[pwd=<admin password>]
|
//[ESP105]<SSID>[pwd=<admin password>]
|
||||||
case 105:
|
case 105:
|
||||||
@ -1554,6 +1556,7 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif //USE_AS_UPDATER_ONLY
|
||||||
//Get ESP current status in plain or JSON
|
//Get ESP current status in plain or JSON
|
||||||
//[ESP420]<plain>
|
//[ESP420]<plain>
|
||||||
case 420: {
|
case 420: {
|
||||||
@ -1588,6 +1591,7 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#ifndef USE_AS_UPDATER_ONLY
|
||||||
//[ESP500]<gcode>
|
//[ESP500]<gcode>
|
||||||
case 500: { //send GCode with check sum caching right line numbering
|
case 500: { //send GCode with check sum caching right line numbering
|
||||||
//be sure serial is locked
|
//be sure serial is locked
|
||||||
@ -1872,6 +1876,7 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a
|
|||||||
ESPCOM::println (CONFIG::formatBytes (SPIFFS.usedBytes() ).c_str(), output, espresponse);
|
ESPCOM::println (CONFIG::formatBytes (SPIFFS.usedBytes() ).c_str(), output, espresponse);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
#endif //USE_AS_UPDATER_ONLY
|
||||||
//get fw version firmare target and fw version
|
//get fw version firmare target and fw version
|
||||||
//[ESP800]<header answer>
|
//[ESP800]<header answer>
|
||||||
case 800: {
|
case 800: {
|
||||||
@ -1945,6 +1950,7 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a
|
|||||||
ESPCOM::println ("", output, espresponse);
|
ESPCOM::println ("", output, espresponse);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#ifndef USE_AS_UPDATER_ONLY
|
||||||
//get fw target
|
//get fw target
|
||||||
//[ESP801]<header answer>
|
//[ESP801]<header answer>
|
||||||
case 801:
|
case 801:
|
||||||
@ -1985,7 +1991,7 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif //USE_AS_UPDATER_ONLY
|
||||||
default:
|
default:
|
||||||
ESPCOM::println (INCORRECT_CMD_MSG, output, espresponse);
|
ESPCOM::println (INCORRECT_CMD_MSG, output, espresponse);
|
||||||
response = false;
|
response = false;
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//version and sources location
|
//version and sources location
|
||||||
#define FW_VERSION "2.1.1.b6"
|
#define FW_VERSION "2.1.1.b7"
|
||||||
#define REPOSITORY "https://github.com/luc-github/ESP3D"
|
#define REPOSITORY "https://github.com/luc-github/ESP3D"
|
||||||
|
|
||||||
//Customize ESP3D ////////////////////////////////////////////////////////////////////////
|
//Customize ESP3D ////////////////////////////////////////////////////////////////////////
|
||||||
@ -36,9 +36,15 @@
|
|||||||
//like ESP_XXXXXX (eg:ESP_028E41) to avoid overlap if several ESP3D
|
//like ESP_XXXXXX (eg:ESP_028E41) to avoid overlap if several ESP3D
|
||||||
#define ESP_HOST_NAME ESP_DEFAULT_NAME
|
#define ESP_HOST_NAME ESP_DEFAULT_NAME
|
||||||
|
|
||||||
|
//To allow webupdate using small updater
|
||||||
|
//#define USE_AS_UPDATER_ONLY
|
||||||
|
|
||||||
//FEATURES - comment to disable //////////////////////////////////////////////////////////
|
//FEATURES - comment to disable //////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
//WEB_UPDATE_FEATURE: allow to flash fw using web UI
|
||||||
|
#define WEB_UPDATE_FEATURE
|
||||||
|
|
||||||
|
#ifndef USE_AS_UPDATER_ONLY
|
||||||
//Do we use async webserver or not (currntly deprecated do not enable it yet)
|
//Do we use async webserver or not (currntly deprecated do not enable it yet)
|
||||||
//#define ASYNCWEBSERVER
|
//#define ASYNCWEBSERVER
|
||||||
|
|
||||||
@ -62,14 +68,11 @@
|
|||||||
#define SSDP_FEATURE
|
#define SSDP_FEATURE
|
||||||
|
|
||||||
//NETBIOS_FEATURE: this feature is a discovery protocol, supported on Windows out of the box
|
//NETBIOS_FEATURE: this feature is a discovery protocol, supported on Windows out of the box
|
||||||
#define NETBIOS_FEATURE
|
//#define NETBIOS_FEATURE
|
||||||
|
|
||||||
//CAPTIVE_PORTAL_FEATURE: In SoftAP redirect all unknow call to main page
|
//CAPTIVE_PORTAL_FEATURE: In SoftAP redirect all unknow call to main page
|
||||||
#define CAPTIVE_PORTAL_FEATURE
|
#define CAPTIVE_PORTAL_FEATURE
|
||||||
|
|
||||||
//WEB_UPDATE_FEATURE: allow to flash fw using web UI
|
|
||||||
#define WEB_UPDATE_FEATURE
|
|
||||||
|
|
||||||
//RECOVERY_FEATURE: allow to use GPIO2 pin as hardware reset for EEPROM, add 8s to boot time to let user to jump GPIO2 to GND
|
//RECOVERY_FEATURE: allow to use GPIO2 pin as hardware reset for EEPROM, add 8s to boot time to let user to jump GPIO2 to GND
|
||||||
//#define RECOVERY_FEATURE
|
//#define RECOVERY_FEATURE
|
||||||
|
|
||||||
@ -90,7 +93,7 @@
|
|||||||
|
|
||||||
//TIMESTAMP_FEATURE: Time stamp feature on direct SD files
|
//TIMESTAMP_FEATURE: Time stamp feature on direct SD files
|
||||||
//#define TIMESTAMP_FEATURE
|
//#define TIMESTAMP_FEATURE
|
||||||
|
#endif //USE_AS_UPDATER_ONLY
|
||||||
//Extra features /////////////////////////////////////////////////////////////////////////
|
//Extra features /////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//Workaround for Marlin 2.X coldstart
|
//Workaround for Marlin 2.X coldstart
|
||||||
|
@ -745,22 +745,21 @@ void WebUpdateUpload()
|
|||||||
#endif
|
#endif
|
||||||
size_t flashsize = 0;
|
size_t flashsize = 0;
|
||||||
#if defined ( ARDUINO_ARCH_ESP8266)
|
#if defined ( ARDUINO_ARCH_ESP8266)
|
||||||
flashsize = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;
|
maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
if (esp_ota_get_running_partition()) {
|
if (esp_ota_get_running_partition()) {
|
||||||
const esp_partition_t* partition = esp_ota_get_next_update_partition(NULL);
|
const esp_partition_t* partition = esp_ota_get_next_update_partition(NULL);
|
||||||
if (partition) {
|
if (partition) {
|
||||||
flashsize = partition->size;
|
maxSketchSpace = partition->size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if ((web_interface->web_server).hasArg (sizeargname.c_str()) ) {
|
if ((web_interface->web_server).hasArg (sizeargname.c_str()) ) {
|
||||||
maxSketchSpace = (web_interface->web_server).arg (sizeargname).toInt();
|
flashsize = (web_interface->web_server).arg (sizeargname).toInt();
|
||||||
} else {
|
} else {
|
||||||
maxSketchSpace = flashsize;
|
flashsize = maxSketchSpace;
|
||||||
}
|
}
|
||||||
if ((flashsize > flashsize) || (flashsize == 0)) {
|
if ((flashsize > maxSketchSpace) || (flashsize == 0)) {
|
||||||
web_interface->_upload_status=UPLOAD_STATUS_FAILED;
|
web_interface->_upload_status=UPLOAD_STATUS_FAILED;
|
||||||
pushError(ESP_ERROR_NOT_ENOUGH_SPACE, "Upload rejected");
|
pushError(ESP_ERROR_NOT_ENOUGH_SPACE, "Upload rejected");
|
||||||
}
|
}
|
||||||
@ -1178,6 +1177,7 @@ void handle_web_command_silent()
|
|||||||
//Serial SD files list//////////////////////////////////////////////////
|
//Serial SD files list//////////////////////////////////////////////////
|
||||||
void handle_serial_SDFileList()
|
void handle_serial_SDFileList()
|
||||||
{
|
{
|
||||||
|
#ifndef USE_AS_UPDATER_ONLY
|
||||||
//this is only for admin an user
|
//this is only for admin an user
|
||||||
if (web_interface->is_authenticated() == LEVEL_GUEST) {
|
if (web_interface->is_authenticated() == LEVEL_GUEST) {
|
||||||
web_interface->_upload_status=UPLOAD_STATUS_NONE;
|
web_interface->_upload_status=UPLOAD_STATUS_NONE;
|
||||||
@ -1197,6 +1197,7 @@ void handle_serial_SDFileList()
|
|||||||
web_interface->web_server.send(200, "application/json", jsonfile);
|
web_interface->web_server.send(200, "application/json", jsonfile);
|
||||||
web_interface->blockserial = false;
|
web_interface->blockserial = false;
|
||||||
web_interface->_upload_status=UPLOAD_STATUS_NONE;
|
web_interface->_upload_status=UPLOAD_STATUS_NONE;
|
||||||
|
#endif //USE_AS_UPDATER_ONLY
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NB_RETRY 5
|
#define NB_RETRY 5
|
||||||
@ -1205,6 +1206,7 @@ void handle_serial_SDFileList()
|
|||||||
//SD file upload by serial
|
//SD file upload by serial
|
||||||
void SDFile_serial_upload()
|
void SDFile_serial_upload()
|
||||||
{
|
{
|
||||||
|
#ifndef USE_AS_UPDATER_ONLY
|
||||||
static int32_t lineNb =-1;
|
static int32_t lineNb =-1;
|
||||||
static String current_line;
|
static String current_line;
|
||||||
static bool is_comment = false;
|
static bool is_comment = false;
|
||||||
@ -1374,6 +1376,7 @@ void SDFile_serial_upload()
|
|||||||
CloseSerialUpload (true, current_filename, lineNb);
|
CloseSerialUpload (true, current_filename, lineNb);
|
||||||
cancelUpload();
|
cancelUpload();
|
||||||
}
|
}
|
||||||
|
#endif //USE_AS_UPDATER_ONLY
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -73,6 +73,8 @@
|
|||||||
|
|
||||||
long id_connection = 0;
|
long id_connection = 0;
|
||||||
|
|
||||||
|
#ifndef USE_AS_UPDATER_ONLY
|
||||||
|
|
||||||
uint8_t Checksum(const char * line, uint16_t lineSize)
|
uint8_t Checksum(const char * line, uint16_t lineSize)
|
||||||
{
|
{
|
||||||
uint8_t checksum_val =0;
|
uint8_t checksum_val =0;
|
||||||
@ -290,7 +292,7 @@ void CloseSerialUpload (bool iserror, String & filename, int32_t linenb)
|
|||||||
purge_serial();
|
purge_serial();
|
||||||
web_interface->blockserial = false;
|
web_interface->blockserial = false;
|
||||||
}
|
}
|
||||||
|
#endif //USE_AS_UPDATER_ONLY
|
||||||
|
|
||||||
//constructor
|
//constructor
|
||||||
WEBINTERFACE_CLASS::WEBINTERFACE_CLASS (int port) : web_server (port)
|
WEBINTERFACE_CLASS::WEBINTERFACE_CLASS (int port) : web_server (port)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user