Mercurial > lcfOS
view customtasks.py @ 408:ad6be5454067
Added image build task
author | Windel Bouwman |
---|---|
date | Sat, 21 Feb 2015 12:17:47 +0100 |
parents | |
children |
line wrap: on
line source
""" Custom task to create boot image. """ from ppci import tasks import struct @tasks.register_task('mkimage') class MkImageTask(tasks.Task): """ Concatenate kernel and boot data in cunning manner """ def run(self): self.logger.info('Constructing boot image') data = bytearray() # TODO: parameterize: # Read kernel: with open(self.relpath('kernel/obj/kernel.bin'), 'rb') as f: data += f.read() # Read images: with open(self.relpath('user/obj/init.bin'), 'rb') as f: init = f.read() # Construct table: table = struct.pack('<II', 0x1337, 1) data += table data += struct.pack('<I', len(init)) data += init # Produce output: with open(self.relpath('image.img'), 'wb') as f: f.write(data)