Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flash failure from Wifi writing credentials #34

Closed
sctanf opened this issue Nov 4, 2021 · 9 comments
Closed

Flash failure from Wifi writing credentials #34

sctanf opened this issue Nov 4, 2021 · 9 comments
Labels
Status: Unlabeled A maintainer has not yet labeled this

Comments

@sctanf
Copy link
Contributor

sctanf commented Nov 4, 2021

Wifi.begin() writes credentials to flash every time it is called, on some boards this causes the flash to fail quickly, resulting in Wifi.begin() resetting the board.

Calling Wifi.persistent(false) before Wifi.begin() (and potentially other wifi functions) stops the credentials from being written. On boards with failing flash, this will continue working.

@deiteris
Copy link
Member

deiteris commented Nov 4, 2021

Related issue: esp8266/Arduino#1054

@Kamilake
Copy link
Contributor

Kamilake commented Nov 6, 2021

That's interesting. It doesn't seem to happen on ESP32.

Does that cause the whole board to boot fail? Or does it only corrupt credentials?
Do I(that board) need to Wifi.persistent(false) on every run except when performing a write operation?

@deiteris
Copy link
Member

deiteris commented Nov 6, 2021

Similar issue seems to be occurred on Wemos D1 Mini when powered via micro-USB port, but works ok on battery. Though Wifi.persistent(false) didn't help.
https://discord.com/channels/817184208525983775/823930029070876736/905833475741982721

@sctanf
Copy link
Contributor Author

sctanf commented Nov 6, 2021

@Kamilake No, the board resets if you try to access damaged flash, so credentials can no longer be written. Not sure if it can still be read. Otherwise it appears to work fine

@Eirenliel
Copy link
Member

Need to review Wifi.begin() code for different frameworks and see how to start wifi properly without it being re-written, but still being able to read it on begin and write on credentials change.

@Vyolex
Copy link
Member

Vyolex commented Nov 16, 2021

On the espressif8266 platform this should not be the case. Only when SSID and the passphrase are provided will Wifi.begin() write to flash if persistence is not set to false. When not providing these parameters it should only read from flash (code below).

wl_status_t ESP8266WiFiSTAClass::begin() {

    if(!WiFi.enableSTA(true)) {
        // enable STA failed
        return WL_CONNECT_FAILED;
    }

    ETS_UART_INTR_DISABLE();
    wifi_station_connect();
    ETS_UART_INTR_ENABLE();

    if(!_useStaticIp) {
        wifi_station_dhcpc_start();
    }
    return status();
}```

@TheButlah TheButlah added the Status: Unlabeled A maintainer has not yet labeled this label Oct 5, 2022
@Vyolex
Copy link
Member

Vyolex commented Jun 16, 2023

Can this be closed? Neither esp32 nor esp8266 does any writing to memory when wifi.begin() is called without arguments. (In fact the function does not even reference if persistence is set to true or false in either function.)

@Eirenliel
Copy link
Member

Did we used to use WiFi.begin(SSID, pass)? Or was this open on error, @Vyolex?

@Vyolex
Copy link
Member

Vyolex commented Jun 17, 2023

IDK if it used to be different but atm we only call WiFi.begin(SSID, pass) in setWiFiCredentials and in upkeep (the latter only when the ssid and pass are defined in code). So default behaviour should not cause data to be written to flash every single boot, only on sending credentials from server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unlabeled A maintainer has not yet labeled this
Projects
None yet
Development

No branches or pull requests

6 participants