Skip to content

Commit a8fd5e0

Browse files
committed
Fix the ESP crash after first flash
seems wifi_set_phy_mode need to be set before anything
1 parent 511be0e commit a8fd5e0

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

esp8266/esp8266.ino

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,21 @@ void setup() {
8484
if(breset_config)
8585
{
8686
//update EEPROM with default settings
87+
Serial.begin(9600);
88+
delay(2000);
89+
Serial.println("M117 Reset requested");
8790
CONFIG::reset_config();
8891
delay(1000);
89-
//use default baud rate and ports
90-
baud_rate=DEFAULT_BAUD_RATE;
91-
wifi_config.iweb_port=DEFAULT_WEB_PORT;
92-
wifi_config.idata_port=DEFAULT_DATA_PORT;
92+
//put some default value to a void some exception at first start
93+
WiFi.mode(WIFI_AP);
94+
wifi_set_phy_mode(PHY_MODE_11G);
95+
Serial.flush();
96+
delay(500);
97+
Serial.swap();
98+
delay(100);
99+
//restart once reset config is done
100+
ESP.restart();
101+
while (1){delay(1);};
93102
}
94103
//setup serial
95104
Serial.begin(baud_rate);

0 commit comments

Comments
 (0)