def SelectFdt(self, fdt_fname): """Select an FDT to control the firmware bundling Args: fdt_fname: The filename of the fdt to use. Returns: The Fdt object of the original fdt file, which we will not modify. We make a copy of this which will include any on-the-fly changes we want to make. """ self._fdt_fname = fdt_fname self.CheckOptions() fdt = Fdt(self._tools, self._fdt_fname) # For upstream, select the correct architecture .dtsi manually. if self._board == 'link' or 'x86' in self._board: arch_dts = 'coreboot.dtsi' elif self._board == 'daisy': arch_dts = 'exynos5250.dtsi' else: arch_dts = 'tegra20.dtsi' fdt.Compile(arch_dts) self.fdt = fdt.Copy(os.path.join(self._tools.outdir, 'updated.dtb')) return fdt
def ScanDtb(self): """Scan the device tree to obtain a tree of notes and properties Once this is done, self.fdt.GetRoot() can be called to obtain the device tree root node, and progress from there. """ self.fdt = Fdt(self._dtb_fname) self.fdt.Scan()
def main(): """Main function for pack_firmware. We provide a way of packing firmware from the command line using this module directly. """ parser = optparse.OptionParser() parser.add_option('-v', '--verbosity', dest='verbosity', default=1, type='int', help='Control verbosity: 0=silent, 1=progress, 3=full, ' '4=debug') parser.add_option('-k', '--key', dest='key', type='string', action='store', help='Path to signing key directory (default to dev key)', default='##/usr/share/vboot/devkeys') parser.add_option('-d', '--dt', dest='fdt', type='string', action='store', help='Path to fdt file to use (binary ,dtb)', default='u-boot.dtb') parser.add_option('-u', '--uboot', dest='uboot', type='string', action='store', help='Executable bootloader file (U-Boot)', default='u-boot.bin') parser.add_option('-S', '--signed', dest='signed', type='string', action='store', help='Path to signed boot binary (U-Boot + BCT + FDT)', default='u-boot-fdt-signed.bin') parser.add_option('-g', '--gbb', dest='gbb', type='string', action='store', help='Path to Google Binary Block file', default='gbb.bin') parser.add_option('-o', '--outdir', dest='outdir', type='string', action='store', help='Path to directory to use for intermediate and ' 'output files', default='out') (options, args) = parser.parse_args(sys.argv) # Set up the output directory. if not os.path.isdir(options.outdir): os.makedirs(options.outdir) # Get tools and fdt. tools = Tools(options.verbosity) fdt = Fdt(tools, options.fdt) # Pack the firmware. pack = PackFirmware(_PackOutput, tools, options.verbosity) pack.SetupFiles(boot=options.uboot, signed=options.signed, gbb=options.gbb, fwid=tools.GetChromeosVersion(), keydir=options.key) pack.SelectFdt(fdt) out_fname = os.path.join(options.outdir, 'image.bin') pack.PackImage(options.outdir, out_fname) print 'Output binary is %s' % out_fname