-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathmain.py
More file actions
39 lines (29 loc) · 1.31 KB
/
main.py
File metadata and controls
39 lines (29 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# This file is the only one that can't be overridden for development (without rebuilding) because it's not in lib/, so keep it minimal.
# Make sure the storage partition's lib/ is first in the path, so whatever is placed there overrides frozen libraries.
# This allows any build to be used for development as well, just by overriding the libraries in lib/
# Copy this file to / on the device's internal storage to have it run automatically instead of relying on the frozen-in files.
import gc
import os
import sys
sys.path.insert(0, "lib")
print(f"{sys.version=}")
print(f"{sys.implementation=}")
print("Free space on root filesystem:")
stat = os.statvfs("/")
total_space = stat[0] * stat[2]
free_space = stat[0] * stat[3]
used_space = total_space - free_space
print(f"{total_space=} / {used_space=} / {free_space=} bytes")
gc.collect()
print(
f"RAM: {gc.mem_free()} free, {gc.mem_alloc()} allocated, {gc.mem_alloc() + gc.mem_free()} total"
)
print("Passing execution over to mpos.main")
try:
import mpos.main # noqa: F401
except Exception as e:
print("Error importing mpos.main, sleeping 5 seconds...")
import time
time.sleep(5) # sleep so the user has time to connect to serial console
sys.print_exception(e) # print it after the sleep so user can see it on serial console
print("MicroPythonOS exiting.")