mirror of
https://git.codelinaro.org/clo/qsdk/oss/boot/u-boot-2016.git
synced 2025-12-10 07:44:53 +01:00
pack.py: Added Kernel image packing using skales
lkboot doesn't understand FIT image and requires kernel image to be packed using skales. Change-Id: I27d746b459571fe15f837f08196a219fb1fa9082 Signed-off-by: Gokul Sriram Palanisamy <gokulsri@codeaurora.org>
This commit is contained in:
parent
41eae48e0d
commit
ae79231f1e
2 changed files with 119 additions and 0 deletions
|
|
@ -69,6 +69,8 @@ from getopt import getopt
|
|||
from getopt import GetoptError
|
||||
from collections import namedtuple
|
||||
from string import Template
|
||||
from shutil import copy
|
||||
from shutil import rmtree
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
|
@ -1610,6 +1612,60 @@ class ArgParser(object):
|
|||
print " \t\tThis Argument does not take any value"
|
||||
print "Pack Version: %s" % version
|
||||
|
||||
def gen_kernelboot_img(parser):
|
||||
"""Generate kernelboot.img needed by LK bootloader"""
|
||||
|
||||
SKALES_DIR = parser.images_dname
|
||||
TMP_DIR = parser.out_dname + "tmp_dir"
|
||||
|
||||
try:
|
||||
|
||||
if os.path.exists(TMP_DIR):
|
||||
rmtree(TMP_DIR)
|
||||
os.makedirs(TMP_DIR)
|
||||
|
||||
if MODE == "64":
|
||||
KERNEL_IMG_NAME = "openwrt-" + ARCH_NAME + "_" + MODE + "-kernelboot.img"
|
||||
else:
|
||||
KERNEL_IMG_NAME = "openwrt-" + ARCH_NAME + "-kernelboot.img"
|
||||
|
||||
src = parser.images_dname + "qcom-" + ARCH_NAME + "-hk01.dtb"
|
||||
if not os.path.exists(src):
|
||||
error("%s file not found" % src)
|
||||
copy(src, TMP_DIR)
|
||||
|
||||
src = parser.images_dname + "Image"
|
||||
if not os.path.exists(src):
|
||||
error("%s file not found" % src)
|
||||
copy(src, TMP_DIR)
|
||||
|
||||
cmd = [SKALES_DIR + "dtbTool -o " + TMP_DIR + "/qcom-ipq807x-hk01-dt.img " + TMP_DIR]
|
||||
ret = subprocess.call(cmd, shell=True)
|
||||
if ret != 0:
|
||||
print ret
|
||||
error("Error executing dtbTools")
|
||||
|
||||
cmd = ["gzip -9 " + TMP_DIR + "/Image"]
|
||||
ret = subprocess.call(cmd, shell=True)
|
||||
if ret != 0:
|
||||
print ret
|
||||
error("Error executing gzip")
|
||||
|
||||
cmd = [SKALES_DIR + "mkbootimg",
|
||||
"--kernel=" + TMP_DIR + "/Image.gz",
|
||||
"--dt=" + TMP_DIR + "/qcom-ipq807x-hk01-dt.img",
|
||||
"--cmdline=\'rootfsname=rootfs rootwait nosmp\'",
|
||||
"--output=" + parser.out_dname + KERNEL_IMG_NAME,
|
||||
"--base=0x41200000"]
|
||||
ret = subprocess.call(cmd)
|
||||
if ret != 0:
|
||||
print ret
|
||||
error("Error executing mkbootimg")
|
||||
|
||||
rmtree(TMP_DIR)
|
||||
except OSError, e:
|
||||
error("error generating kernelboot.img", e)
|
||||
|
||||
def main():
|
||||
"""Main script entry point.
|
||||
|
||||
|
|
@ -1630,6 +1686,7 @@ def main():
|
|||
config = SRC_DIR + "/" + ARCH_NAME + "/config.xml"
|
||||
root = ET.parse(config)
|
||||
|
||||
|
||||
# Add nand-4k flash type, if nand flash type is specified
|
||||
if "nand" in parser.flash_type.split(","):
|
||||
if root.find(".//data[@type='NAND_PARAMETER']/entry") != None:
|
||||
|
|
@ -1645,6 +1702,8 @@ def main():
|
|||
else:
|
||||
if flash_type == "emmc" and lk == "true":
|
||||
suffix = "-single-lkboot.img"
|
||||
gen_kernelboot_img(parser)
|
||||
|
||||
else:
|
||||
suffix = "-single.img"
|
||||
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ from string import Template
|
|||
from unittest import TestCase
|
||||
from tempfile import mkdtemp
|
||||
from shutil import rmtree
|
||||
from shutil import copy
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
|
@ -85,6 +86,7 @@ import hashlib
|
|||
version = "1.1"
|
||||
lk = False
|
||||
|
||||
|
||||
TABLE_VERSION_AK = 3
|
||||
TABLE_VERSION_DK = 4
|
||||
|
||||
|
|
@ -708,6 +710,61 @@ class Pack(object):
|
|||
except KeyError, e:
|
||||
return None
|
||||
|
||||
def __gen_kernelboot_img(self, filename):
|
||||
"""Generate kernelboot.img needed by LK bootloader"""
|
||||
|
||||
KERNEL_IMG_NAME = filename
|
||||
SKALES_DIR = self.images_dname
|
||||
|
||||
try:
|
||||
if "ipq40xx" in KERNEL_IMG_NAME:
|
||||
DTB = "qcom-ipq4019-ap.dk04.1-c1.dtb"
|
||||
BASE_ADDR = "0x80200000"
|
||||
BOOT_ARGS = "\'console=ttyMSM0,115200 root=/dev/mmcblk0p12 rootwait\'"
|
||||
elif "ipq806x" in KERNEL_IMG_NAME:
|
||||
DTB = "qcom-ipq8064-ap145.dtb"
|
||||
BASE_ADDR = "0x42200000"
|
||||
BOOT_ARGS = "\'rootfsname=rootfs rootwait\'"
|
||||
if not os.path.exists(os.path.join(self.images_dname, "Image")):
|
||||
error("'Image' file not found")
|
||||
if not os.path.exists(os.path.join(self.images_dname, DTB)):
|
||||
error("%s file not found" % DTB)
|
||||
|
||||
self.tmp_dir = self.images_dname + "tmp_dir"
|
||||
if os.path.exists(self.tmp_dir):
|
||||
rmtree(self.tmp_dir)
|
||||
os.makedirs(self.tmp_dir)
|
||||
|
||||
copy(self.images_dname + DTB, self.tmp_dir)
|
||||
copy(self.images_dname + "Image", self.tmp_dir)
|
||||
|
||||
cmd = [SKALES_DIR + "dtbTool -o " + self.tmp_dir + "/" + DTB + ".img " + self.tmp_dir]
|
||||
ret = subprocess.call(cmd, shell=True)
|
||||
if ret != 0:
|
||||
print ret
|
||||
error("Error executing dtbTools")
|
||||
|
||||
cmd = ["gzip -9 " + self.tmp_dir + "/Image"]
|
||||
ret = subprocess.call(cmd, shell=True)
|
||||
if ret != 0:
|
||||
print ret
|
||||
error("Error executing gzip")
|
||||
|
||||
cmd = [SKALES_DIR + "mkbootimg",
|
||||
"--kernel=" + self.tmp_dir + "/Image.gz",
|
||||
"--dt=" + self.tmp_dir + "/" + DTB + ".img",
|
||||
"--cmdline=" + BOOT_ARGS,
|
||||
"--output=" + self.tmp_dir + "/" + KERNEL_IMG_NAME,
|
||||
"--base=" + BASE_ADDR]
|
||||
ret = subprocess.call(cmd)
|
||||
if ret != 0:
|
||||
print ret
|
||||
error("Error executing mkbootimg")
|
||||
|
||||
copy(self.tmp_dir + "/" + KERNEL_IMG_NAME, self.images_dname)
|
||||
except OSError, e:
|
||||
error("error generating kernelboot.img", e)
|
||||
|
||||
def __gen_flash_script(self, info, script, flinfo):
|
||||
"""Generate the script to flash the images.
|
||||
|
||||
|
|
@ -729,6 +786,8 @@ class Pack(object):
|
|||
filename = "openwrt-ipq40xx-kernelboot.img"
|
||||
elif "ipq806x" in filename:
|
||||
filename = "openwrt-ipq806x-kernelboot.img"
|
||||
if not os.path.exists(self.images_dname + "tmp_dir/" + filename):
|
||||
self.__gen_kernelboot_img(filename)
|
||||
partition = info.get(section, "partition")
|
||||
include = info.get(section, "include")
|
||||
except ConfigParserError, e:
|
||||
|
|
@ -1174,6 +1233,7 @@ class Pack(object):
|
|||
|
||||
images.insert(0, ImageInfo("script", "flash.scr", "script"))
|
||||
self.__mkimage(images)
|
||||
rmtree(self.tmp_dir)
|
||||
|
||||
def main(self, flinfo, images_dname, out_fname, part_fname, fconf_fname, ipq_nand):
|
||||
"""Start the packing process.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue