flash directory corrupted with \x00\x00\x00\x00\x00\x00\x00\x00.\x00\x00\x00

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: flash directory corrupted with \x00\x00\x00\x00\x00\x00\x00\x00.\x00\x00\x00

Post by pythoncoder » Sun Jul 01, 2018 12:42 pm

It seems you've uncovered another problem.

It's perhaps worth pointing out that running tests which hammer the filesystem will reduce the life of the chip's flash memory: a lot of sector erasing and re-writing is going on behind the scenes.

But it shouldn't crash. I've raised a comment to the GitHub issue.
Peter Hinch
Index to my micropython libraries.

kurt
Posts: 20
Joined: Sun Feb 11, 2018 7:45 pm

Re: flash directory corrupted with \x00\x00\x00\x00\x00\x00\x00\x00.\x00\x00\x00

Post by kurt » Sun Jul 01, 2018 1:16 pm

Hi Peter,
you are absolutly right, hammering the flash may destroy it some time.
I tested the above example and after five or sometimes only one round turn the crash happens.
Hopefully the reason can be found and fixed. If something can be done on my side, please don't hesitate to contact me.
Many thanks for your great help
Kurt

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: flash directory corrupted with \x00\x00\x00\x00\x00\x00\x00\x00.\x00\x00\x00

Post by Roberthh » Sun Jul 01, 2018 2:06 pm

I just tried the same, adding a cycle counter. After a few cycles the crash happens. Before that happens, it show a kind of warning.

Code: Select all

>>>import write
0          
1         
2         
ets_post: task 31 queue full  
3                                                                                       
(IllegalInstructionCause):
epc1=0x402776b4, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000
MicroPython v1.9.4-227-gab02abe9-dirty on 2018-07-01; ESP module with ESP8266
Type "help()" for more information.
>>
This log may note be complete. After the crash many non.-printable characters pollute the screen. The file system survived.
Device used for testing.- ESP01 with flash extended to 16MByte.

Damien
Site Admin
Posts: 647
Joined: Mon Dec 09, 2013 5:02 pm

Re: flash directory corrupted with \x00\x00\x00\x00\x00\x00\x00\x00.\x00\x00\x00

Post by Damien » Mon Jul 02, 2018 2:13 am

I couldn't reproduce this new error. I used the firmware downloaded from https://micropython.org/download/#esp8266, the esp8266-20180630-v1.9.4-227-gab02abe9 version. I ran the read+write test 50 times without a problem; the test was:

Code: Select all

for i in range(50):
    print(i)
    with open('syslog', 'r') as f2: 
        with open('syslog.1', 'w') as output:
            for line in f2: 
                output.write(line)

The device was connected to an AP during the test.
Fatal exception 0(IllegalInstructionCause):
epc1=0x40276fb4, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000
@kurt: if you are using the firmware from the download page, then this crash happens at the start of printf. So all I can guess is that there is some code executing on an interrupt that calls printf. What is your exact set-up, do you use WebREPL? Do you have any other code running?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: flash directory corrupted with \x00\x00\x00\x00\x00\x00\x00\x00.\x00\x00\x00

Post by Roberthh » Mon Jul 02, 2018 5:58 am

The error varies with the board and version
ESP01 with 16MB flash: error after 3-8 cycles, v1.9.4-227-gab02abe9-dirty on 2018-07-01
WEMOS D1: error after 158 cycles, build with today's repo, v1.9.4-234-g8f86fbfd on 2018-07-02;
ESP01 with 1 MB flash: Manually stopped after 1000 cycles (causing the Ctrl-C crash). v1.9.1-216-g63edc2e-dirty on 2017-08-10

kurt
Posts: 20
Joined: Sun Feb 11, 2018 7:45 pm

Re: flash directory corrupted with \x00\x00\x00\x00\x00\x00\x00\x00.\x00\x00\x00

Post by kurt » Mon Jul 02, 2018 8:52 am

Hi Damien,
I tried to make the test scenario as simple as possiible by:
1. flashed esp8266-20180702-v1.9.4-227-gab02abe9.bin
2. connected my ESP8266 nodemcu with 4 MByte comparable to https://www.exp-tech.de/en/platforms/in ... ed-esp8266 using PuTTY version 0.65 from my Windows 10 PC
3. edit

Code: Select all

with open('syslog', 'w') as f3:
    for _ in range(10):
        f3.write('testdata\n')
4. run it and got the file 'syslog'
5. edit

Code: Select all

cnt = 0
while True:
    cnt += 1
    with open('syslog', 'r') as f2:
        with open('syslog.1', 'w') as output:
            for line in f2:
                output.write(line)
    print('cnt: ', cnt)
6. got the following:
9
9
9
9
9
9
9
9
9
9
cnt: 1
9
9
9
9
9
9
9
9
9
9
cnt: 2
9
9
9
9
9
9
9
9
9
9
cnt: 3
9
9
9
9
9
9
9
9
9
9
cnt: 4
9
9
9
9
9
Fatal exception 0(IllegalInstructionCause):
epc1=0x40276fb4, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x40100000, len 30904, room 16
tail 8
chksum 0x74
load 0x3ffe8000, len 1092, room 0
tail 4
chksum 0xdd
load 0x3ffe8450, len 3252, room 4
tail 0
chksum 0x94
csum 0x94
▒▒▒▒n▒r▒▒n|▒
l
lll`▒▒r▒l▒l▒
l`▒▒r▒l▒l▒
l`▒▒r▒l
▒▒▒
ll`rl▒▒rl▒▒▒b
▒▒b▒b
br▒r
b▒▒n▒nn▒
l▒▒
l

l▒▒ll▒▒▒▒▒▒l▒n▒▒▒▒b
l
l▒rp
▒▒▒b
l
▒brlrlr▒n▒▒▒▒OSError: [Errno 2] ENOENT

MicroPython v1.9.4-227-gab02abe9 on 2018-07-02; ESP module with ESP8266
Type "help()" for more information.
>>>

As you see, no Webrepl is used. No other task is running as I understand.

Regards
Kurt

Damien
Site Admin
Posts: 647
Joined: Mon Dec 09, 2013 5:02 pm

Re: flash directory corrupted with \x00\x00\x00\x00\x00\x00\x00\x00.\x00\x00\x00

Post by Damien » Mon Jul 02, 2018 12:27 pm

Ok, I can now reproduce the "new" problem. I used @kurt's test proceduce just above.

I reproduced it on both a Huzzah Feather board with ESP-12 (4MiB flash), and on a Wemos D1 mini pro (16MiB flash but only using 4MiB of it).

BUT, it only crashes (for me at least) with the AP active. With AP active I get the crash very quickly, after about 4 iterations of the loop. I rolled back to the commit just before the fix for ctrl-C (d8dc918deb8d4b13b8919706f9f208542c9ef2e6) and it also had the same problem, so I guess the issue has been there for some time but only shows when the flash is writen to a lot AND the AP is enabled.

It consistently crashes at the start of printf(). I don't know what is calling printf().

@kurt can you retry your code with the AP disabled? Do network.WLAN(1).active(0).

It doesn't seem to matter if STA is active or not.

Damien
Site Admin
Posts: 647
Joined: Mon Dec 09, 2013 5:02 pm

Re: flash directory corrupted with \x00\x00\x00\x00\x00\x00\x00\x00.\x00\x00\x00

Post by Damien » Mon Jul 02, 2018 12:36 pm

It seems that disabling interrupts around all calls to spi_flash_read, spi_flash_write and spi_flash_erase fixes the issue. And it seems necessary to protect all 3 of these functions.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: flash directory corrupted with \x00\x00\x00\x00\x00\x00\x00\x00.\x00\x00\x00

Post by Roberthh » Mon Jul 02, 2018 12:43 pm

I had made all tests with AP disbled, STA enabled

kurt
Posts: 20
Joined: Sun Feb 11, 2018 7:45 pm

Re: flash directory corrupted with \x00\x00\x00\x00\x00\x00\x00\x00.\x00\x00\x00

Post by kurt » Mon Jul 02, 2018 2:17 pm

Hi Damien,
I can confirm the behavior as you described.
First, I reflashed the chip with the same bin file to get a clear starting point.
Then I created the syslog file with the code as above.
After that, I disabled the AP mode with: network.WLAN(1).active(0)
Created the test app as above and run the scetch 50 times without any problem. Then I stopped it with ctrl-C also without any problem.
After then, I activated AP mode with: network.WLAN(1).active(1)
Rerun the same scetch and got a crash in the fourth round turn.

So, I think I can confirm the problem is related to AP mode.

In my final scetch, I need the AP mode to give the user a chance to enter the wifi data like SSID and Password. This activity, I like to write down into syslog. This means, it would be great to solve the crash problem anyway.

Many thanks for your help
Kurt

Post Reply