Skip to content

Commit c63cc53

Browse files
committed
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
1 parent af0d8a0 commit c63cc53

File tree

4 files changed

+28
-14
lines changed

4 files changed

+28
-14
lines changed

esp3d/command.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a
166166
String parameter;
167167
LOG ("Execute Command\r\n")
168168
switch (cmd) {
169+
169170
//STA SSID
170171
//[ESP100]<SSID>[pwd=<admin password>]
171172
case 100:
@@ -281,6 +282,7 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a
281282
}
282283
}
283284
break;
285+
#ifndef USE_AS_UPDATER_ONLY
284286
//AP SSID
285287
//[ESP105]<SSID>[pwd=<admin password>]
286288
case 105:
@@ -1554,6 +1556,7 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a
15541556
}
15551557
}
15561558
break;
1559+
#endif //USE_AS_UPDATER_ONLY
15571560
//Get ESP current status in plain or JSON
15581561
//[ESP420]<plain>
15591562
case 420: {
@@ -1588,6 +1591,7 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a
15881591
}
15891592
}
15901593
break;
1594+
#ifndef USE_AS_UPDATER_ONLY
15911595
//[ESP500]<gcode>
15921596
case 500: { //send GCode with check sum caching right line numbering
15931597
//be sure serial is locked
@@ -1872,6 +1876,7 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a
18721876
ESPCOM::println (CONFIG::formatBytes (SPIFFS.usedBytes() ).c_str(), output, espresponse);
18731877
#endif
18741878
break;
1879+
#endif //USE_AS_UPDATER_ONLY
18751880
//get fw version firmare target and fw version
18761881
//[ESP800]<header answer>
18771882
case 800: {
@@ -1945,6 +1950,7 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a
19451950
ESPCOM::println ("", output, espresponse);
19461951
}
19471952
break;
1953+
#ifndef USE_AS_UPDATER_ONLY
19481954
//get fw target
19491955
//[ESP801]<header answer>
19501956
case 801:
@@ -1985,7 +1991,7 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a
19851991
}
19861992
}
19871993
break;
1988-
1994+
#endif //USE_AS_UPDATER_ONLY
19891995
default:
19901996
ESPCOM::println (INCORRECT_CMD_MSG, output, espresponse);
19911997
response = false;

esp3d/config.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020

2121
//version and sources location
22-
#define FW_VERSION "2.1.1.b6"
22+
#define FW_VERSION "2.1.1.b7"
2323
#define REPOSITORY "https://github.com/luc-github/ESP3D"
2424

2525
//Customize ESP3D ////////////////////////////////////////////////////////////////////////
@@ -36,9 +36,15 @@
3636
//like ESP_XXXXXX (eg:ESP_028E41) to avoid overlap if several ESP3D
3737
#define ESP_HOST_NAME ESP_DEFAULT_NAME
3838

39+
//To allow webupdate using small updater
40+
//#define USE_AS_UPDATER_ONLY
3941

4042
//FEATURES - comment to disable //////////////////////////////////////////////////////////
4143

44+
//WEB_UPDATE_FEATURE: allow to flash fw using web UI
45+
#define WEB_UPDATE_FEATURE
46+
47+
#ifndef USE_AS_UPDATER_ONLY
4248
//Do we use async webserver or not (currntly deprecated do not enable it yet)
4349
//#define ASYNCWEBSERVER
4450

@@ -62,14 +68,11 @@
6268
#define SSDP_FEATURE
6369

6470
//NETBIOS_FEATURE: this feature is a discovery protocol, supported on Windows out of the box
65-
#define NETBIOS_FEATURE
71+
//#define NETBIOS_FEATURE
6672

6773
//CAPTIVE_PORTAL_FEATURE: In SoftAP redirect all unknow call to main page
6874
#define CAPTIVE_PORTAL_FEATURE
6975

70-
//WEB_UPDATE_FEATURE: allow to flash fw using web UI
71-
#define WEB_UPDATE_FEATURE
72-
7376
//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
7477
//#define RECOVERY_FEATURE
7578

@@ -90,7 +93,7 @@
9093

9194
//TIMESTAMP_FEATURE: Time stamp feature on direct SD files
9295
//#define TIMESTAMP_FEATURE
93-
96+
#endif //USE_AS_UPDATER_ONLY
9497
//Extra features /////////////////////////////////////////////////////////////////////////
9598

9699
//Workaround for Marlin 2.X coldstart

esp3d/syncwebserver.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -745,22 +745,21 @@ void WebUpdateUpload()
745745
#endif
746746
size_t flashsize = 0;
747747
#if defined ( ARDUINO_ARCH_ESP8266)
748-
flashsize = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;
748+
maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;
749749
#else
750-
751750
if (esp_ota_get_running_partition()) {
752751
const esp_partition_t* partition = esp_ota_get_next_update_partition(NULL);
753752
if (partition) {
754-
flashsize = partition->size;
753+
maxSketchSpace = partition->size;
755754
}
756755
}
757756
#endif
758757
if ((web_interface->web_server).hasArg (sizeargname.c_str()) ) {
759-
maxSketchSpace = (web_interface->web_server).arg (sizeargname).toInt();
758+
flashsize = (web_interface->web_server).arg (sizeargname).toInt();
760759
} else {
761-
maxSketchSpace = flashsize;
760+
flashsize = maxSketchSpace;
762761
}
763-
if ((flashsize > flashsize) || (flashsize == 0)) {
762+
if ((flashsize > maxSketchSpace) || (flashsize == 0)) {
764763
web_interface->_upload_status=UPLOAD_STATUS_FAILED;
765764
pushError(ESP_ERROR_NOT_ENOUGH_SPACE, "Upload rejected");
766765
}
@@ -1178,6 +1177,7 @@ void handle_web_command_silent()
11781177
//Serial SD files list//////////////////////////////////////////////////
11791178
void handle_serial_SDFileList()
11801179
{
1180+
#ifndef USE_AS_UPDATER_ONLY
11811181
//this is only for admin an user
11821182
if (web_interface->is_authenticated() == LEVEL_GUEST) {
11831183
web_interface->_upload_status=UPLOAD_STATUS_NONE;
@@ -1197,6 +1197,7 @@ void handle_serial_SDFileList()
11971197
web_interface->web_server.send(200, "application/json", jsonfile);
11981198
web_interface->blockserial = false;
11991199
web_interface->_upload_status=UPLOAD_STATUS_NONE;
1200+
#endif //USE_AS_UPDATER_ONLY
12001201
}
12011202

12021203
#define NB_RETRY 5
@@ -1205,6 +1206,7 @@ void handle_serial_SDFileList()
12051206
//SD file upload by serial
12061207
void SDFile_serial_upload()
12071208
{
1209+
#ifndef USE_AS_UPDATER_ONLY
12081210
static int32_t lineNb =-1;
12091211
static String current_line;
12101212
static bool is_comment = false;
@@ -1374,6 +1376,7 @@ void SDFile_serial_upload()
13741376
CloseSerialUpload (true, current_filename, lineNb);
13751377
cancelUpload();
13761378
}
1379+
#endif //USE_AS_UPDATER_ONLY
13771380
}
13781381

13791382
#endif

esp3d/webinterface.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@
7373

7474
long id_connection = 0;
7575

76+
#ifndef USE_AS_UPDATER_ONLY
77+
7678
uint8_t Checksum(const char * line, uint16_t lineSize)
7779
{
7880
uint8_t checksum_val =0;
@@ -290,7 +292,7 @@ void CloseSerialUpload (bool iserror, String & filename, int32_t linenb)
290292
purge_serial();
291293
web_interface->blockserial = false;
292294
}
293-
295+
#endif //USE_AS_UPDATER_ONLY
294296

295297
//constructor
296298
WEBINTERFACE_CLASS::WEBINTERFACE_CLASS (int port) : web_server (port)

0 commit comments

Comments
 (0)