Skip to content
This repository was archived by the owner on Apr 25, 2021. It is now read-only.

Commit 70cdda9

Browse files
committed
oprom modules 업데이트 (bios.py 제외한 나머지 정리)
1 parent 791e16e commit 70cdda9

6 files changed

Lines changed: 71 additions & 432 deletions

File tree

src/modules/_bios.py

Lines changed: 0 additions & 137 deletions
This file was deleted.

src/modules/_boot.py

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/modules/bios.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
def bios():
2+
globals().pop('bios')
3+
4+
from machine import invoke, components, crash
5+
6+
eeproms = components("eeprom")
7+
if not eeproms:
8+
crash("no bios found; install a configured EEPROM with Python")
9+
10+
eeprom = eeproms[0]
11+
if True:
12+
invoke(eeprom, 'setLabel', "EEPROM (micropython)")
13+
invoke(eeprom, 'set', b"""python = []
14+
from machine import invoke, components, crash
15+
from uio import FileIO
16+
17+
18+
init = '/init.py'
19+
20+
21+
filesystems = components("filesystem")
22+
def check_bootable(address):
23+
return address and address in filesystems and invoke(address, 'exists', init)
24+
25+
26+
def load(address):
27+
file = invoke(address, 'open', init, 'r')
28+
29+
try:
30+
buffer = []
31+
while True:
32+
buf = invoke(address, 'read', file, 4096)
33+
if not buf: break
34+
buffer.append(buf)
35+
finally:
36+
invoke(address, 'close', file)
37+
38+
content = b"".join(buffer)
39+
return content.decode()
40+
41+
42+
def main():
43+
address = invoke(__path__, 'getData').decode()
44+
if not check_bootable(address):
45+
invoke(__path__, 'setData', b'')
46+
for address in filesystems:
47+
if check_bootable(address):
48+
break
49+
else:
50+
crash("no bootable medium found")
51+
52+
content = load(address)
53+
context = {'__name__': '__main__', '__path__': address}
54+
func = compile(content, "<init>", "exec")
55+
exec(content, context)
56+
57+
58+
if __name__ == '__main__':
59+
main()
60+
""")
61+
62+
data = invoke(eeprom, 'get')
63+
context = {'__name__': '__main__', '__path__': eeprom}
64+
65+
try:
66+
exec(data, context)
67+
except BaseException as e:
68+
print(type(e), e)
69+
70+
71+
bios()

src/modules/component.py

Lines changed: 0 additions & 106 deletions
This file was deleted.

src/modules/handler.py

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)