Left here for archival purposes.

User avatar
By zeroday
#6559
brig wrote: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?


I have half of this issue too.
when I re-flash firmware, without bank the flash chip, also can't remove the file.
so I add a file.format() api in the build 20150107, to clean a flash(delete everything in filesystem)

until now, no reboot spotted.
User avatar
By brig
#6623
zeroday wrote:.....I add a file.format() api in the build 20150107, to clean a flash(delete everything in filesystem)
until now, no reboot spotted.

Yes, with firmware build 20150107 situation has improved, but not completely solved.

file.format() works.
On module with 512K flash is performed for 1 ... 1.5 seconds.
On module with 4M flash is performed for 27 seconds.

I tested again with a script (added control heap):
Code: Select allfor j=1,50 do
  print("20K"..j.."  heap = "..node.heap())
  file.open("20K"..j..".txt", "w")
  for i=1,1280 do
    file.writeline('0123456789ABCDE')
  end
  file.close()
end

The result for module 512K flash:

20K1 heap = 21728
20K2 heap = 21552
20K3 heap = 21552
20K4 heap = 21552
20K5 heap = 21552
20K6 heap = 21552
20K7 heap = 21552
stdin:5: open a file first
> for n,s in pairs(file.list()) do print(n.." size: "..s) end
20K6.txt size: 2304
20K1.txt size: 20480
20K5.txt size: 7168
20K3.txt size: 20480
20K2.txt size: 20480
20K4.txt size: 20480

The recording process is interrupted when the total files size is ~90 KB (for files of different sizes (10KB, 15KB, 20KB) are slightly different results).

The result for module 4M flash:

200K1 heap = 21768
200K2 heap = 21592
200K3 heap = 21592
200K4 heap = 21592
200K5 heap = 21592
200K6 heap = 21592
200K7 heap = 21592
200K8 heap = 21592
200K9 heap = 21592
ь! ¤<
жЗ!„ю1д)m†1¤сBCб
NodeMCU 0.9.5 build 20150107 powered by Lua 5.1.4
lua: cannot open init.lua
> for n,s in pairs(file.list()) do print(n.." size: "..s) end
200K8.txt size: 204800
200K4.txt size: 204800
200K7.txt size: 204800
200K9.txt size: 105216
200K1.txt size: 204800
200K2.txt size: 204800
200K6.txt size: 204800
200K3.txt size: 204800
200K5.txt size: 204800

The recording process is interrupted and reboot of the module when the total file size is exactly 1743616 bytes (for files of different sizes (100 KB, 200 KB) the results are the same).

Interesting: the total size of the recorded files + firmware size approximately equal to half the size of the flash. Incorrectly determined the type and size of the flash memory?
User avatar
By raz123
#7332 I also had a similar issue today. I'm using an ESP8266-01 with 512kb flash, and NodeMCU 0.9.5 build 20150107.

I tried uploading a single file of size :

- 18999 bytes: Works fine.
- 19000 bytes: Crash*. Size then reports as 14986. Unable to remove file using file.remove(). Module doesn't do much.

*PANIC: unprotected error in call to Lua API (stdin:1: open a file first)

file.format() works.


I was also able to upload up to 4 files of 18999 bytes, and that worked fine.
The 5th file got clipped to 11684 bytes.
The 6th file got clipped to 2540 bytes.
The 7th file got clipped to 0 bytes.

In total, I was able to upload (4*18999)+11684+2540 = 90220 bytes (div by 1024 = 88 kbytes).

Since the flash memory is 512 kbytes and the firmware is 365 kb, I was expecting to have about 147 kbytes to play with. I understand that some size is reserved for the flash system, but we are talking about 59 kbytes that are unaccounted for here.

Can someone shed light on what's going on?