Left here for archival purposes.

User avatar
By brig
#6505 Despite improvements in the new firmware NodeMcu 0.9.5 build 20150106 problems with files not diminished.

Try this script:

Code: Select allfor j=1,50 do
  print("20K"..j)
  file.open("20K"..j..".txt", "w")
  for i=1,1280 do
    file.writeline('0123456789ABCDE')
  end
  file.close()
end

Will be written to files...

20K3.txt size: 14080
20K2.txt size: 20480
20K1.txt size: 20480

...after which the module is restarted.

An attempt to remove any of these files...
Code: Select allfile.remove("20K1.txt")

...also resets the module (file is not deleted).

What to do?
User avatar
By zeroday
#6509 works ok, any body else give this a test?

anyway I will add some boundary check in the next build.

Code: Select all> for k, v in pairs(file.list()) do print('file:'..k..' len:'..v) end
file:20K6.txt len:2304
file:20K1.txt len:20480
file:20K5.txt len:6400
file:20K3.txt len:20480
file:20K2.txt len:20480
file:20K4.txt len:20480
> file.remove("20K4.txt")
> for k, v in pairs(file.list()) do print('file:'..k..' len:'..v) end
file:20K6.txt len:2304
file:20K1.txt len:20480
file:20K5.txt len:6400
file:20K3.txt len:20480
file:20K2.txt len:20480
User avatar
By yes8s
#6518 I can confrm file issue is still present in latest 0.9.5 nodemcu binary.

I'm still not sure when or why it happens but when it does, usually calling the file throws an error and file.remove() of file will trigger reset.

Only way to fix is to reflash binary.

It's been discussed several times before but I can't remember where on the forum.
User avatar
By ThomasW
#6553 Same here (build 20150106). Looks like the problem occurs after a certain amount of blocks(?) has been written.
Code: Select allfor i=1,200,1
do
        print(i)
        file.open("test.dat","w+")
        -- 256
        file.writeline("123456789012345678901234567890123456789012345678901234567890123")
        file.writeline("123456789012345678901234567890123456789012345678901234567890123")
        file.writeline("123456789012345678901234567890123456789012345678901234567890123")
        file.writeline("123456789012345678901234567890123456789012345678901234567890123")
        -- 512
        file.writeline("123456789012345678901234567890123456789012345678901234567890123")
        file.writeline("123456789012345678901234567890123456789012345678901234567890123")
        file.writeline("123456789012345678901234567890123456789012345678901234567890123")
        file.writeline("123456789012345678901234567890123456789012345678901234567890123")
        file.close()
        tmr.delay(1000000)
end

on a reflashed module, this code reliably crashes at iteration 45. Just writing 256 bytes/iteration increases this number to 75 and
first tests with an even smaller size reached ~115.

Thomas