-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpi-eeprom-update
More file actions
executable file
·48 lines (39 loc) · 1.19 KB
/
pi-eeprom-update
File metadata and controls
executable file
·48 lines (39 loc) · 1.19 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
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/python
import sys, time
import eeprom
with open(sys.argv[1], 'rb') as f:
image = eeprom.Reader(f)
w = image.create_writer()
for chunk in image:
if chunk.name == 'bootconf.txt':
w.append(eeprom.ChunkConf.create('bootconf.txt').set_text(u"""
[all]
BOOT_UART=0
WAKE_ON_GPIO=1
POWER_OFF_ON_HALT=0
MAX_RESTARTS=200
ENABLE_SELF_UPDATE=1
DISABLE_HDMI=0
BOOT_ORDER=0xf1
"""))
elif chunk.name == 'updatetime':
w.append(chunk.set_updatetime(int(time.time())))
else:
w.append(chunk)
if image.image_type == 'pi5':
w.append(eeprom.ChunkConf.create('example.txt').set_text(u"""
This is a test chunk
"""))
if image.ab_capable:
# XXX: find out if this is actually required
w.fill_until(image.partitions.get('A').end)
w.fill_until(image.partitions.get('B').end)
with open(sys.argv[2], "wb") as f:
w.write_img(f)
with open(sys.argv[3], 'wb') as f:
w.write_sig(f)
with open(sys.argv[4], 'wb') as f:
f.write(image.version.encode('utf8'))
if image.ab_capable:
with open(sys.argv[5], 'wb') as f:
w.write_partition_img(f, 'A')