junhuanchen / mpfshell-lite

👾 The lightweight version of the mpfshell is for pure CUI drivers.
https://github.com/wendlers/mpfshell
MIT License
35 stars 8 forks source link

Memory allocation error when trying to upload a file #3

Open barbudor opened 4 years ago

barbudor commented 4 years ago

Hi I get a memory allocation error when trying to upload a file to my ESP8266 mini-D1. This seems to occur for file larger than 4800 bytes

Host:

Target:

Let me know if you need more details

Best regards

Console log:

** Micropython File Shell v1.0.1, sw@kaltpost.de & junhuanchen@qq.com **
-- Running on Python 3.7 using PySerial 3.4 --

mpfs [/]> put uwebsvr.py
       uwebsvr.py
Traceback (most recent call last):
  File "C:\Users\Jean-Michel\AppData\Roaming\Python\Python37\Scripts\mpfs-script.py", line 11, in <module>
    load_entry_point('mpfshell-lite==1.0.1', 'console_scripts', 'mpfs')()
  File "C:\Users\Jean-Michel\AppData\Roaming\Python\Python37\site-packages\mp\mpfshell.py", line 888, in main
    mpfs.cmdloop()
  File "c:\program files\python37\lib\cmd.py", line 138, in cmdloop
    stop = self.onecmd(line)
  File "c:\program files\python37\lib\cmd.py", line 217, in onecmd
    return func(arg)
  File "C:\Users\Jean-Michel\AppData\Roaming\Python\Python37\site-packages\mp\mpfshell.py", line 441, in do_put
    self.fe.put(lfile_name, rfile_name)
  File "C:\Users\Jean-Michel\AppData\Roaming\Python\Python37\site-packages\mp\mpfexp.py", line 545, in put
    MpFileExplorer.put(self, src, dst)
  File "C:\Users\Jean-Michel\AppData\Roaming\Python\Python37\site-packages\mp\retry.py", line 43, in f_retry
    return f(*args, **kwargs)
  File "C:\Users\Jean-Michel\AppData\Roaming\Python\Python37\site-packages\mp\mpfexp.py", line 309, in put
    raise e
  File "C:\Users\Jean-Michel\AppData\Roaming\Python\Python37\site-packages\mp\mpfexp.py", line 296, in put
    self.exec_("f.write(ubinascii.unhexlify('%s'))" % c.decode('utf-8'))
  File "C:\Users\Jean-Michel\AppData\Roaming\Python\Python37\site-packages\mp\pyboard.py", line 155, in exec_
    raise PyboardError('exception', ret, ret_err)
mp.pyboard.PyboardError: ('exception', b'', b'MemoryError: memory allocation failed, allocating 11144 bytes\r\n')
junhuanchen commented 4 years ago

Maybe that's too big for esp8266.

It will request about 2 times of memory during communication, maybe you can split the file and upload it.

barbudor commented 4 years ago

Hi @junhuanchen 4800 bytes is pretty much small. My webserver module is 14KB as py and 8KB as mpy. Both upload fine with original but none with mpfshell lite. Issue is only in your fork. Best regards

junhuanchen commented 4 years ago

In one case, there is coding problem(utf-8) in the code, and in the other case, gc.collect() is needed before uploading.

junhuanchen commented 4 years ago

look this 图片