Next stretch goal - upip running native on esp8266
Posted: Thu Oct 20, 2016 9:15 pm
The next stretch goal results we'd like to present to our Kickstarter backers and esp8266 community in general is upip package manager running natively on a ESP8266 module (see http://forum.micropython.org/viewtopic.php?f=15&t=524 if you didn't hear about upip, you've missed a lot). So, you could prepare a dependency modules snapshot on a desktop machine using unix port of MicroPython and copy over files to your module, and fairly speaking, that remains the recommended way to deploy "bigger" applications. But that's a bit too many steps for quick hacking and enjoying capabilities of your tiny wireless device. So, now you can install modules directly on a device!
Now about caveats: porting upip was integration of many features we've developed previously (and also features developed specifically to make upip porting possible): network sockets, HTTP support, SSL support, JSON parsing, etc. And doing it all together puts quite a strain on modest ESP8266 resources. So, while it definitely works for simple cases, it requires completely "clean" memory (as in: after reset) and would likely fail for more complex cases (like packages with recursive dependencies). That's why we talk about "soft launch": there are issues, but we'd like interested people to be able to play with it and share their experiences. We'll keep working on optimizing it for future releases (as well as look for ways to get more heap memory).
That's one side of the issues. Another is - what packages are available and how many of them are suitable for esp8266. Major source of package is micropython-lib project (see http://forum.micropython.org/viewtopic.php?f=15&t=70 if you didn't hear about it, you miss a lot). There're more than 150 packages in micropython-lib, but good share of them are just placeholders (i.e. yet need to be ported), and large share are intended for bigger environments, like unix port of MicroPython. But even a dozen of package (like functools, itertools) should be a good start. And this all also should be a hint for developers of MicroPython modules - now there's no excuse to not publish them on PyPI (but please make sure they're named to avoid name clashing with micropython-lib modules, to not confuse users).
Ok, so how to use it? Use 1.8.5 release (upip is not available in daily development builds). A transcript below shows how to install a pystone benchmark module optimized for low-memory devices and run it. Try it on a freshly reset module. If it fails with a memory error, retry it, sometimes it helps .
Now about caveats: porting upip was integration of many features we've developed previously (and also features developed specifically to make upip porting possible): network sockets, HTTP support, SSL support, JSON parsing, etc. And doing it all together puts quite a strain on modest ESP8266 resources. So, while it definitely works for simple cases, it requires completely "clean" memory (as in: after reset) and would likely fail for more complex cases (like packages with recursive dependencies). That's why we talk about "soft launch": there are issues, but we'd like interested people to be able to play with it and share their experiences. We'll keep working on optimizing it for future releases (as well as look for ways to get more heap memory).
That's one side of the issues. Another is - what packages are available and how many of them are suitable for esp8266. Major source of package is micropython-lib project (see http://forum.micropython.org/viewtopic.php?f=15&t=70 if you didn't hear about it, you miss a lot). There're more than 150 packages in micropython-lib, but good share of them are just placeholders (i.e. yet need to be ported), and large share are intended for bigger environments, like unix port of MicroPython. But even a dozen of package (like functools, itertools) should be a good start. And this all also should be a hint for developers of MicroPython modules - now there's no excuse to not publish them on PyPI (but please make sure they're named to avoid name clashing with micropython-lib modules, to not confuse users).
Ok, so how to use it? Use 1.8.5 release (upip is not available in daily development builds). A transcript below shows how to install a pystone benchmark module optimized for low-memory devices and run it. Try it on a freshly reset module. If it fails with a memory error, retry it, sometimes it helps .
Code: Select all
>>> import upip
>>> upip.install("micropython-pystone_lowmem")
Installing to: /lib/
Warning: pypi.python.org SSL certificate is not validated
Installing micropython-pystone_lowmem 3.4.2-3 from https://pypi.python.org/packages/8c/70/98379ddfea62d55973653fecb7bd58d7372a3e3b5510844f23260e90fbc0/micropython-pystone_lowmem-3.4.2-3.tar.gz
>>> import pystone_lowmem
>>> pystone_lowmem.main()
Pystone(1.2) time for 500 passes = 2333ms
This machine benchmarks at 214 pystones/second