In my previous post about running MicroPython on ESP8266, I mentioned that ESP8266 boards may have different amount of flash. Similarly there are two versions of MicroPython: limited version for 512K, and full version for boards which have more than 512K of flash. In that post, I played with ESP-07 which had only 512K, so I had to use a limited version of MicroPython. This limited MicroPython version was enough just to turn on/off an LED, but it turned out that it actually doesn’t work well.

[peg-image src=”” href=”” caption=”” type=”image” alt=”ESP8266” image_size=”4096x2304”]

After successful flashing ESP8266 with limited MicroPython, I tried to upload a simple script which just turns on/off an LED in a loop:

import time
from machine import Pin

pin = Pin(13, Pin.OUT)
while True:

I tried a couple of tools, but nothing worked.

rshell reported the following error:

$ sudo rshell --port /dev/ttyUSB0 
Connecting to /dev/ttyUSB0 ...
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/rshell/", line 1184, in connect
    ip_address = socket.gethostbyname(port)
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/rshell", line 9, in 
    load_entry_point('rshell==0.0.9', 'console_scripts', 'rshell')()
  File "/usr/local/lib/python3.5/dist-packages/rshell/", line 4, in main
  File "/usr/local/lib/python3.5/dist-packages/rshell/", line 2644, in main
  File "/usr/local/lib/python3.5/dist-packages/rshell/", line 2606, in real_main
    connect(args.port, baud=args.baud, wait=args.wait, user=args.user, password=args.password)
  File "/usr/local/lib/python3.5/dist-packages/rshell/", line 1190, in connect
    connect_serial(port, baud=baud, wait=wait)
  File "/usr/local/lib/python3.5/dist-packages/rshell/", line 1214, in connect_serial
    dev = DeviceSerial(port, baud, wait)
  File "/usr/local/lib/python3.5/dist-packages/rshell/", line 1434, in __init__
    Device. __init__ (self, pyb)
  File "/usr/local/lib/python3.5/dist-packages/rshell/", line 1269, in __init__
    self.root_dirs = ['/{}/'.format(dir) for dir in self.remote_eval(listdir, '/')]
  File "/usr/local/lib/python3.5/dist-packages/rshell/", line 1351, in remote_eval
    return eval(self.remote(func, *args, **kwargs))
  File "", line 0
SyntaxError: unexpected EOF while parsing

And mpfshell reported this:

$ sudo mpfshell

**Micropython File Shell v0.7.6,** 
-- Running on Python 3.5 using PySerial 3.2.1 --

mpfs [/]> open ttyUSB0
Connected to esp8266
mpfs [/]> ls
Traceback (most recent call last):
  File "/usr/local/bin/mpfshell", line 8, in 
  File "/usr/local/lib/python3.5/dist-packages/mp/", line 687, in main
  File "/usr/lib/python3.5/", line 138, in cmdloop
    stop = self.onecmd(line)
  File "/usr/lib/python3.5/", line 217, in onecmd
    return func(arg)
  File "/usr/local/lib/python3.5/dist-packages/mp/", line 205, in do_ls
    files =
  File "/usr/local/lib/python3.5/dist-packages/mp/", line 503, in ls
    files =, add_files, add_dirs, add_details)
  File "/usr/local/lib/python3.5/dist-packages/mp/", line 43, in f_retry
    return f(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/mp/", line 169, in ls
    res = self.eval("os.listdir('%s')" % self.dir)
  File "/usr/local/lib/python3.5/dist-packages/mp/", line 150, in eval
    ret = self.exec_('print({})'.format(expression))
  File "/usr/local/lib/python3.5/dist-packages/mp/", line 157, in exec_
    raise PyboardError('exception', ret, ret_err)
mp.pyboard.PyboardError: ('exception', b'', b'Traceback (most recent call last):\r\n File "", line 1, in \r\nAttributeError: \'module\' object has no attribute \'listdir\'\r\n')

WebREPL didn’t work either. After connecting to the board via USB-Serial adapter, and trying to start WebREPL, it reported the following error:

could not open file '' for reading
could not open file '' for reading

MicroPython v1.8.7-292-g3d739eb on 2017-02-18; ESP module with ESP8266
Type "help()" for more information.
>>> import webrepl_setup
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 111, in 
  File "", line 80, in main
  File "", line 49, in get_daemon_status
AttributeError: 'NoneType' object has no attribute ' __exit__'

I have not looked into the problems above, but looks like that limited MicroPython doesn’t contain something which is required for those tools. Or, this may be just a bug.

Finally, I found an ESP8266 board with 1M of flash, so that I could use full MicroPython (in my case, it was v1.8.7). And it worked! I was able to upload a Python script to the board. Here is how it can be done with mpfshell:

$ sudo mpfshell

**Micropython File Shell v0.7.6,** 
-- Running on Python 3.5 using PySerial 3.2.1 --

mpfs [/]>; open ttyUSB0
Connected to esp8266
mpfs [/]>; ls

Remote files in '/':

mpfs [/]> put
mpfs [/]> ls

Remote files in '/':
mpfs [/]>

After resetting the board, I was happy to see that the LED was blinking.

The conclusion is obvious:

  • Buy ESP8266 with more than 512K of flash
  • Use full version of MicroPython