From db80c0ed4678f4bacc6c7c9b67cbf26846fc21be Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 11 May 2016 16:57:29 +0100 Subject: esp8266: Enable frozen bytecode, with scripts in modules/ subdir. To start with, the critical scripts _boot.py and flashbdev.py are frozen to improve performance and reduce RAM consumption. Saves about 1000 bytes of heap RAM for a bare boot with filesystem. --- esp8266/modules/_boot.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 esp8266/modules/_boot.py (limited to 'esp8266/modules/_boot.py') diff --git a/esp8266/modules/_boot.py b/esp8266/modules/_boot.py new file mode 100644 index 000000000..c950de675 --- /dev/null +++ b/esp8266/modules/_boot.py @@ -0,0 +1,9 @@ +import uos +from flashbdev import bdev + +try: + if bdev: + vfs = uos.VfsFat(bdev, "") +except OSError: + import inisetup + vfs = inisetup.setup() -- cgit v1.2.3 From 686367dcfc6cb0a930fbfee03399b706eb76eae7 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sat, 2 Jul 2016 19:20:13 +0300 Subject: esp8266: Explicitly collect garbage in bootstrap scripts. Leads to less fragmentation at teh time user code starts. --- esp8266/modules/_boot.py | 3 +++ esp8266/scripts/inisetup.py | 2 ++ 2 files changed, 5 insertions(+) (limited to 'esp8266/modules/_boot.py') diff --git a/esp8266/modules/_boot.py b/esp8266/modules/_boot.py index c950de675..2cacb5676 100644 --- a/esp8266/modules/_boot.py +++ b/esp8266/modules/_boot.py @@ -1,3 +1,4 @@ +import gc import uos from flashbdev import bdev @@ -7,3 +8,5 @@ try: except OSError: import inisetup vfs = inisetup.setup() + +gc.collect() diff --git a/esp8266/scripts/inisetup.py b/esp8266/scripts/inisetup.py index 461690b16..7d8f6fa0a 100644 --- a/esp8266/scripts/inisetup.py +++ b/esp8266/scripts/inisetup.py @@ -40,7 +40,9 @@ def setup(): with open("/boot.py", "w") as f: f.write("""\ # This file is executed on every boot (including wake-boot from deepsleep) +import gc #import webrepl #webrepl.start() +gc.collect() """) return vfs -- cgit v1.2.3