return output
class SdFusingTarget:
+ params = (('reboot-param.bin', 'norm'),
+ ('reboot-param.info', 'norm'),
+ ('upgrade-status.info', '0'))
+
def __init__(self, device, ltype):
# TODO: make a copy of a sublcass part_table
self.with_super = False
sys.exit(1)
return [self.binaries.get(binary, None)]
- params = ()
def initialize_parameters(self):
pass
+ def write_parameters(self, params = None):
+ pass
+
+ def update_parameters(self):
+ self.write_parameters()
+
class SdFusingTargetAB(SdFusingTarget):
def __init__(self, device, ltype):
super().__init__(device, ltype)
return [self.binaries.get(binary, None)]
+ def update_parameters(self):
+ part_ab = 'a' if self.update in [None, '', 'a', 'ab'] else 'b'
+ part_cloned = '1' if self.update == 'ab' else '0'
+ params = [('partition-ab.info', part_ab),
+ ('partition-ab-cloned.info', part_cloned)]
+ if not self.update in [None, '', 'a', 'ab']:
+ params.append(('partition-a-status.info', 'ok'))
+ if self.update in ['b', 'ab']:
+ params.append(('partition-b-status.info', 'ok'))
+ self.write_parameters(self.params + tuple(params))
+
class InitParams:
- def initialize_parameters(self):
- logging.debug("Initializing parameterss")
+ def find_inform(self):
n = None
for i, p in enumerate(self.part_table):
if p['name'] == 'inform':
n = i + 1;
break
d = "/dev/" + get_partition_device(self.device, n)
+ return d
+
+ def initialize_parameters(self):
+ logging.debug("Initializing parameters")
+ d = self.find_inform()
argv = ['tune2fs', '-O', '^metadata_csum', d]
logging.debug(" ".join(argv))
stdin=subprocess.DEVNULL,
stdout=None, stderr=None)
+ def write_parameters(self, params = None):
+ d = self.find_inform()
+ logging.debug(f"Writing parameters to {d}")
with tempfile.TemporaryDirectory() as mnt:
argv = ['mount', '-t', 'ext4', d, mnt]
logging.debug(" ".join(argv))
if proc.returncode != 0:
logging.error(f"Failed to mount {d} in {mnt} (Has the device been initialized with --format?)")
return
- for param, value in self.params:
+ parameters = self.params if params is None else params
+ for param, value in parameters:
with open(os.path.join(mnt, param), 'w') as f:
+ logging.debug(f"Writing parameter {param}={value}")
f.write(value + '\n')
argv = ['umount', d]
logging.debug(" ".join(argv))
"binaries": "hal.img"},
{"size": 125, "fstype": "ext4", "name": "reserved2"},
]
- params = (('reboot-param.bin', ''),)
def __init__(self, device, args):
self.reserved_space = 12
{"size": 64, "fstype": "ext4", "name": "reserved1"},
{"size": 125, "fstype": "ext4", "name": "reserved2"}
]
- params = (('reboot-param.bin', 'norm'),
- ('reboot-param.info', 'norm'),
- ('partition-ab.info', 'a'),
- ('partition-ab-cloned.info', '1'),
- ('upgrade-status.info', '0'),
- ('partition-a-status.info', 'ok'),
- ('partition-b-status.info', 'ok'))
def __init__(self, device, args):
self.reserved_space = 8
{"size": 64, "fstype": "ext4", "name": "reserved1"},
{"size": 125, "fstype": "ext4", "name": "reserved2"},
]
- params = (('reboot-param.bin', 'norm'),
- ('reboot-param.info', 'norm'),
- ('partition-ab.info', 'a'),
- ('partition-ab-cloned.info', '1'),
- ('upgrade-status.info', '0'),
- ('partition-a-status.info', 'ok'),
- ('partition-b-status.info', 'ok'))
def __init__(self, device, args):
self.reserved_space = 5
{"size": 64, "fstype": "ext4", "name": "reserved1"},
{"size": 125, "fstype": "ext4", "name": "reserved2"},
]
- params = (('reboot-param.bin', 'norm'),
- ('reboot-param.info', 'norm'),
- ('partition-ab.info', 'a'),
- ('partition-ab-cloned.info', '1'),
- ('upgrade-status.info', '0'),
- ('partition-a-status.info', 'ok'),
- ('partition-b-status.info', 'ok'))
def __init__(self, device, args):
self.reserved_space = 5
{"size": 64, "fstype": "raw", "name": "reserved1"},
{"size": 125, "fstype": "raw", "name": "reserved2"},
]
- params = (('reboot-param.bin', 'norm'),
- ('reboot-param.info', 'norm'))
def __init__(self, device, args):
self.user_partition = 6
{"size": 64, "fstype": "raw", "name": "reserved1"},
{"size": 125, "fstype": "raw", "name": "reserved2"},
]
- params = (('reboot-param.bin', 'norm'),
- ('reboot-param.info', 'norm'),
- ('partition-ab.info', 'a'),
- ('partition-ab-cloned.info', '1'),
- ('upgrade-status.info', '0'),
- ('partition-a-status.info', 'ok'),
- ('partition-b-status.info', 'ok'))
def __init__(self, device, args):
self.user_partition = 6
{"size": 64, "fstype": "raw", "name": "reserved1"},
{"size": 125, "fstype": "raw", "name": "reserved2"},
]
- params = (('reboot-param.bin', 'norm'),
- ('reboot-param.info', 'norm'),
- ('partition-ab.info', 'a'),
- ('partition-ab-cloned.info', '1'),
- ('upgrade-status.info', '0'),
- ('partition-a-status.info', 'ok'),
- ('partition-b-status.info', 'ok'))
def __init__(self, device, args):
self.user_partition = 6
{"size": 64, "fstype": "raw", "name": "reserved1"},
{"size": 125, "fstype": "raw", "name": "reserved2"},
]
- params = (('reboot-param.bin', 'norm'),
- ('reboot-param.info', 'norm'),
- ('partition-ab.info', 'a'),
- ('partition-ab-cloned.info', '1'),
- ('upgrade-status.info', '0'),
- ('partition-a-status.info', 'ok'),
- ('partition-b-status.info', 'ok'))
# bootcode written to the protective MBR, aka RV64 'J 0x4400' (sector 34)
bootcode = b'\x6f\x40\x00\x40'
{"size": 64, "fstype": "ext4", "name": "reserved1"},
{"size": 125, "fstype": "ext4", "name": "reserved2"}
]
- params = (('reboot-param.bin', 'norm'),
- ('reboot-param.info', 'norm'),
- ('partition-ab.info', 'a'),
- ('partition-ab-cloned.info', '1'),
- ('upgrade-status.info', '0'),
- ('partition-a-status.info', 'ok'),
- ('partition-b-status.info', 'ok'))
# bootcode written to the protective MBR, aka RV64 'J 0x4400' (sector 34)
bootcode = b'\x6f\x40\x00\x40'
if target.with_super and not SuperDelivered:
do_fuse_image_super(tmpd, target)
+ target.update_parameters()
def logger_notice(self, msg, *args, **kws):
if self.isEnabledFor(LOGGING_NOTICE):