Avoid flash wearing by altering behavior originally introduced by Espressif (the inventor of the ESP8266)

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.

Would you like to make good-intended, but backward-incompatible changes to WiFi setup?

Poll ended at Sun Jan 08, 2017 7:55 am

Yes, I think this change is good, even though it's backward-incompatible and will confuse some users. We'll get thru it.
36
100%
No, I don't think this change is sound technically or that making backward-incompatible changes of such scale is good.
0
No votes
 
Total votes: 36

User avatar
deshipu
Posts: 1378
Joined: Thu May 28, 2015 5:54 pm

Re: Avoid flash wearing by altering behavior originally introduced by Espressif (the inventor of the ESP8266)

Post by deshipu » Wed Nov 09, 2016 12:38 pm

@pfalcon maybe if you want to learn the opinions of the thousand kickstarter backers, instead of the opinion of the community on this forum, you should make the poll on the kickstarter project, instead of doing it here and demanding from us to bring the kickstarter supporters here to vote? But then you risk that their opinion would be different from what you are putting in their mouths now.

Lysenko
Posts: 62
Joined: Wed Aug 17, 2016 1:21 pm

Re: Avoid flash wearing by altering behavior originally introduced by Espressif (the inventor of the ESP8266)

Post by Lysenko » Wed Nov 09, 2016 12:50 pm

torwag wrote: However, it is not what people expect from a microcontroller unit (at least if they have a electronic engineering background).
An ESP8622 is not an MCU, it's a SoM and I certainly don't assume that something with an EEPROM (or other persistent storage) will automagically return to fixed state on reset. If anything I would assume the opposite: the whole point of EEPROM is storing values between resets so if it exists then something is quite likely being stored. Also, since MP code is just persistent data, assuming that a reset flushes everything back to default state would mean assuming that the program itself gets wiped.

Looking at an ESP8266 as a tiny Raspberry Pi is a more accurate perspective than treating it like a PIC16.

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: Avoid flash wearing by altering behavior originally introduced by Espressif (the inventor of the ESP8266)

Post by pfalcon » Wed Nov 09, 2016 12:57 pm

deshipu wrote:
pfalcon wrote:Offtopic messages were removed.
So it has come to that.
Yes, and as a moderator, I will block users who cross the line.

But its came to much worse - you, deshipu, kfricke interfere with further progress of the Kickstarter project - instead of letting the maintainers work on the aims voted by the backers, you drive us into issues which affect only few people, but whose resolution which adversely (or at least unpleasantly) affect many more, and thus will drive the maintainers into user support swamp, again not allowing progress with real goals.

I feel personally affected the most, as before we truly take "vacation-for-development" which was announced by Damien (https://github.com/micropython/micropython/issues/2602), I'm trying to set rails for progress in other areas, like this. In response, you turn this into personal argument and mockery. That's not good. If you're active contributors, please take a step further, we'll really need to resolve further big changes with voting and long-beforehand notifying majority of users. There's nothing funny in that, it's like real projects work. Soon, when ESP8266 KS is over (when we complete stretch goals), we will be less involved with decisions like this, so someone will need to be prepared to do that. You, as active users, can try how to do this now (we all try and learn). Or you can turn that into mockery. Good luck.

Thread is closed for cool-down for one day.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: Avoid flash wearing by altering behavior originally introduced by Espressif (the inventor of the ESP8266)

Post by pfalcon » Wed Nov 09, 2016 1:03 pm

deshipu wrote:@pfalcon maybe if you want to learn the opinions of the thousand kickstarter backers, instead of the opinion of the community on this forum, you should make the poll on the kickstarter project, instead of doing it here and demanding from us to bring the kickstarter supporters here to vote? But then you risk that their opinion would be different from what you are putting in their mouths now.
I can't do that, only Damien. I won't ask him about such things, not now - I have a lot to ask him about the real development aims set half-year ago. You can try.

I expressed my concern with this - doing it like that steals development time which belongs to our backers, for things they already have voted on. I would do the change kfricke suggest - maybe a bit differently, but would do. But only when I'm personally able to handle user support coming from this, and after notifying users months ahead of the change. In other words, just the same what I suggest to do to you, if you want to do it "now".

I'm not demanding anything of you - it's clear you won't get 1000 votes. Try to reach as many users as possible (and let the be accountable stats on how many it was, as a number of votes). That's what we try to do with Damien - as much as possible, please don't interfere with our current work. Thanks.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

torwag
Posts: 220
Joined: Fri Dec 13, 2013 9:25 am

Re: Avoid flash wearing by altering behavior originally introduced by Espressif (the inventor of the ESP8266)

Post by torwag » Wed Nov 09, 2016 1:07 pm

Since I am also an administrator, I want to say I agree with pfalcon that this thread should cool down for some time. Even if we have different opinions, it should not become personal. After all, we all love to work with or on Micropython and this experience should be enjoyable for all.
I simply write this note, to make sure that it was not only pfalcon who decided that this thread needs a break. Thus, there is no form of censure or misuse of power!

User avatar
dhylands
Posts: 3466
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Avoid flash wearing by altering behavior originally introduced by Espressif (the inventor of the ESP8266)

Post by dhylands » Wed Nov 09, 2016 5:07 pm

Lysenko wrote:
dhylands wrote:My desktop persists the SSID/password, but it doesn't re-persist it every time it connects, only when the password actually changes.
How do you know? It might be rewriting the settings each time. It just wouldn't make any difference with a HD/SSD.
On my ubuntu 16.04 system, there is a file for each SSID that my laptop connects to. Since this particular laptop hasn't left my house since I installed ubuntu 16.04, it only has my home SSIDs in it:

Code: Select all

3000 >ls -l /etc/NetworkManager/system-connections/
total 24
-rw------- 1 root root 439 Apr 24  2016 Blue-Heron
-rw------- 1 root root 449 Aug  1 18:23 Blue-Heron-Old
-rw------- 1 root root 445 May 17 18:57 Blue-Heron-S
So the last time a password was written was in Aug, over 3 months ago, even though my laptop has been rebooted several times. The first file "Blue-Heron" is the SSID I normally connect to, and it hasn't changed since I installed 16.04.

User avatar
kfricke
Posts: 342
Joined: Mon May 05, 2014 9:13 am
Location: Germany

Re: Avoid flash wearing by altering behavior originally introduced by Espressif (the inventor of the ESP8266)

Post by kfricke » Thu Nov 10, 2016 2:32 pm

I do apologize for any distraction for the core developers and maintainers of MicroPython cause by this poll and the heated banter yesterday.
I am aware of the stressful situation of you (our maintainers) and do not want to take your burden to fulfill the expectation of the whole community. My respect for your work is deep and I do not presume to be able to have your far-sightedness in this project. This is your project and I hope to be able to enjoy this community for (at least!) another two years. Keep up your good work, please!

Okay, let's stay on-topic and non-destructive!

First of all this thread is a poll and tries to discuss unnecessary and avoidable writes to flash! Sadly it does break with well known behaviors of the ESP89266 platform. I do not want to question the existence nor the usefulness of settings being persisted to flash.

The intent of my pull request is to be simple, stupid and versatile (and to serve my own egoistic need to save my personal investment from destruction).
What I do not really want is to spawn a epic discussion about how to create a final solution to everyone's issues. This thread can of course be the base to discuss other possibilities of how to implement another solution to this problem. But initially it is meant to be a poll for the introduced pull request.

Of course I can and will wait for the right moment for this pull request to fit into the development cycle.

Lysenko
Posts: 62
Joined: Wed Aug 17, 2016 1:21 pm

Re: Avoid flash wearing by altering behavior originally introduced by Espressif (the inventor of the ESP8266)

Post by Lysenko » Thu Nov 10, 2016 3:59 pm

dhylands wrote:So the last time a password was written was in Aug, over 3 months ago, even though my laptop has been rebooted several times. The first file "Blue-Heron" is the SSID I normally connect to, and it hasn't changed since I installed 16.04.
OK, but what do you get if you use -lu instead?

I admit that's not exactly the same thing, but the OS still did a filesystem[1] write (atime) when it accessed and applied the WiFi profile.

[1] Unless you mounted the filesystem with the noatime flag, but that's not the default behaviour.

User avatar
wminarik
Posts: 7
Joined: Thu Oct 27, 2016 12:03 am
Location: Montréal, Canada

Re: Avoid flash wearing by altering behavior originally introduced by Espressif (the inventor of the ESP8266)

Post by wminarik » Thu Nov 10, 2016 4:36 pm

I’m mostly ignorant on the subtleties of the network protocols. After reading through this discussion; reading the FAQ at the top, reading the documentation (docs.micropython.org/en/latest/esp8266/library/network.html) and:

also those on Github:

EPS8266: No automatic reconnect after WiFi activation #2493 (closed)

esp8266: modnetwork: add optional save_to_flash parameter to connect #2510 (open)

Store interface configuration to flash only where documented and implement
esp.save_config() to save configuration to flash on demand #2564 (open)

And referring to the Hardware-API:
https://github.com/micropython/micropyt ... wlan-class

I’m still confused.

Here is my summary of the issue -please correct my understanding!

1) The Micropython Network module used in the ESP8266 port is based on the "ESP Open SDK"
(https://github.com/pfalcon/esp-open-sdk), which is a mixture of open source and closed binary blobs from Espressif

2) On first network access, the default mode of the ESP SDK:

Stores the WiFi credentials (SSID, password) in a reserved portion of flash. In this case, every call to either
WLAN.connect()
or
WLAN.active()
writes this information to flash.

3) There is now an option to never store this information to flash (the ‘_current’ variant). This requires putting the WiFi credentials in a Python script that runs before every communication session.

4) There does not seem to be an option in the ESP SDK that allows reading WiFi credentials stored in reserved flash without also writing them.

Hence the choice between a) keeping the calls to the Micropython Network module as they are and causing flash wear, or b) changing the module calls and breaking current documentation and user scripts.

I’m not sure why this limitation exists in the ESP SDK -‘read disturb’ errors are presumably monitored by the flash controller. Perhaps this implies that Espressif stores the state of the current connection in flash rather than in a register or RAM.

****

There is a separate issue from this, and that is whether WiFi credentials should be stored anywhere in flash, whether in the ESP reserved portion or in the user’s script.

What am I missing?

User avatar
kfricke
Posts: 342
Joined: Mon May 05, 2014 9:13 am
Location: Germany

Re: Avoid flash wearing by altering behavior originally introduced by Espressif (the inventor of the ESP8266)

Post by kfricke » Thu Nov 10, 2016 4:49 pm

(skipping your correct conclusions)
wminarik wrote:...
4) There does not seem to be an option in the ESP SDK that allows reading WiFi credentials stored in reserved flash without also writing them.
Wrong. there are variants of the underlying SDK method calls that would not write to flash. They are just not used in the ESP port of MicroPython. In fact there are API calls to read and write settings and the write operations have those two variants.

(deleting the further wrong conclusions after the above)

Post Reply