mirror of
https://git.codelinaro.org/clo/qsdk/oss/boot/u-boot-2016.git
synced 2025-12-10 07:44:53 +01:00
tools: pack.py: Support ATF and tiny-nor single image
Change-Id: Ib3a132105d325f8f840a73811a2214a4bd8a618a Signed-off-by: Prasanna Kumar Thoorvas Samyrao Muralidharan <ptsm@codeaurora.org>
This commit is contained in:
parent
76d4b7de87
commit
26cfdff7c1
1 changed files with 423 additions and 48 deletions
471
tools/pack.py
471
tools/pack.py
|
|
@ -88,6 +88,15 @@ image_type = "all"
|
|||
memory_size = "default"
|
||||
lk = "false"
|
||||
skip_4k_nand = "false"
|
||||
atf = "false"
|
||||
qcn9100 = "false"
|
||||
tiny_16m = "false"
|
||||
|
||||
# Note: ipq806x didn't expose any relevant version */
|
||||
soc_hw_version_ipq40xx = { 0x20050100 };
|
||||
soc_hw_version_ipq807x = { 0x200D0100, 0x200D0101, 0x200D0102, 0x200D0200 };
|
||||
soc_hw_version_ipq6018 = { 0x20170100 };
|
||||
soc_hw_version_ipq5018 = { 0x20180100, 0x20180101 };
|
||||
|
||||
#
|
||||
# Python 2.6 and earlier did not have OrderedDict use the backport
|
||||
|
|
@ -430,6 +439,25 @@ class FlashScript(object):
|
|||
self.append('if test "$%s" = "%s"; then\n' % (var, value),
|
||||
fatal=False)
|
||||
|
||||
def start_if_or(self, var, val_list):
|
||||
"""Generate code, to check an environment variable.
|
||||
|
||||
var -- string, variable to check
|
||||
value -- string, the list of values to compare with
|
||||
"""
|
||||
|
||||
n_val = len(val_list)
|
||||
item = 1
|
||||
cmd_str = "if "
|
||||
for val in val_list:
|
||||
cmd_str = cmd_str + str('test "$%s" = "%s"' % (var, val))
|
||||
#cmd_str = cmd_str + "\"$" + var + "\"" + "=" + "\"" + val + "\""
|
||||
if item <= (n_val - 1):
|
||||
cmd_str = cmd_str + " || "
|
||||
item = item + 1
|
||||
|
||||
self.append('%s; then\n' % cmd_str, fatal=False)
|
||||
|
||||
def end_if(self):
|
||||
"""Generate code, to end if statement."""
|
||||
|
||||
|
|
@ -595,7 +623,6 @@ class Pack(object):
|
|||
def __gen_flash_script_cdt(self, entries, partition, flinfo, script):
|
||||
global ARCH_NAME
|
||||
for section in entries:
|
||||
|
||||
machid = int(section.find(".//machid").text, 0)
|
||||
machid = "%x" % machid
|
||||
board = section.find(".//board").text
|
||||
|
|
@ -712,6 +739,132 @@ class Pack(object):
|
|||
script.end_if()
|
||||
|
||||
return 1
|
||||
def __gen_flash_script_wififw_ubi_volume(self, entries, fw_filename, wifi_fw_type, script):
|
||||
|
||||
machid_list = []
|
||||
for section in entries:
|
||||
|
||||
wififw_type = section.find('.//wififw_type')
|
||||
if wififw_type == None:
|
||||
continue
|
||||
wififw_type = str(section.find(".//wififw_type").text)
|
||||
|
||||
if str(wifi_fw_type) != str(wififw_type):
|
||||
continue
|
||||
|
||||
machid = int(section.find(".//machid").text, 0)
|
||||
machid = "%x" % machid
|
||||
|
||||
machid_list.append(machid)
|
||||
|
||||
script.start_if_or("machid", machid_list)
|
||||
script.start_activity("Flashing wifi_fw volume:")
|
||||
script.imxtract("wifi_fw_" + wifi_fw_type + "-" + sha1(fw_filename))
|
||||
script.append('flash wifi_fw', fatal=False)
|
||||
|
||||
script.finish_activity()
|
||||
script.end_if()
|
||||
|
||||
return 1
|
||||
|
||||
def __gen_flash_script_wififw(self, entries, partition, filename, wifi_fw_type, flinfo, script):
|
||||
|
||||
machid_list = []
|
||||
for section in entries:
|
||||
|
||||
wififw_type = section.find('.//wififw_type')
|
||||
if wififw_type == None:
|
||||
continue
|
||||
wififw_type = str(section.find(".//wififw_type").text)
|
||||
|
||||
if str(wifi_fw_type) != str(wififw_type):
|
||||
continue
|
||||
|
||||
machid = int(section.find(".//machid").text, 0)
|
||||
machid = "%x" % machid
|
||||
|
||||
machid_list.append(machid)
|
||||
|
||||
img_size = self.__get_img_size(filename)
|
||||
part_info = self.__get_part_info(partition)
|
||||
|
||||
section_label = partition.split(":")
|
||||
if len(section_label) != 1:
|
||||
section_conf = section_label[1]
|
||||
else:
|
||||
section_conf = section_label[0]
|
||||
section_conf = section_conf.lower()
|
||||
|
||||
if self.flinfo.type == 'nand':
|
||||
size = roundup(img_size, flinfo.pagesize)
|
||||
tr = ' | tr \"\\000\" \"\\377\"'
|
||||
|
||||
if self.flinfo.type == 'emmc':
|
||||
size = roundup(img_size, flinfo.blocksize)
|
||||
tr = ''
|
||||
|
||||
if ((self.flinfo.type == 'nand' or self.flinfo.type == 'emmc') and (size != img_size)):
|
||||
pad_size = size - img_size
|
||||
filename_abs = os.path.join(self.images_dname, filename)
|
||||
filename_abs_pad = filename_abs + ".padded"
|
||||
cmd = 'cat %s > %s' % (filename_abs, filename_abs_pad)
|
||||
ret = subprocess.call(cmd, shell=True)
|
||||
if ret != 0:
|
||||
error("failed to copy image")
|
||||
cmd = 'dd if=/dev/zero count=1 bs=%s %s >> %s' % (pad_size, tr, filename_abs_pad)
|
||||
cmd = '(' + cmd + ') 1>/dev/null 2>/dev/null'
|
||||
ret = subprocess.call(cmd, shell=True)
|
||||
if ret != 0:
|
||||
error("failed to create padded image from script")
|
||||
|
||||
if self.flinfo.type != "emmc":
|
||||
if part_info == None:
|
||||
if self.flinfo.type == 'norplusnand':
|
||||
if count > 2:
|
||||
error("More than 2 NAND images for NOR+NAND is not allowed")
|
||||
elif img_size > part_info.length:
|
||||
print "img size is larger than part. len in '%s'" % section_conf
|
||||
return 0
|
||||
else:
|
||||
if part_info != None:
|
||||
if (img_size > 0):
|
||||
if img_size > (part_info.length * self.flinfo.blocksize):
|
||||
print "img size is larger than part. len in '%s'" % section_conf
|
||||
return 0
|
||||
|
||||
if part_info == None and self.flinfo.type != 'norplusnand':
|
||||
print "Flash type is norplusemmc"
|
||||
return 1
|
||||
|
||||
script.start_if_or("machid", machid_list)
|
||||
script.start_activity("Flashing %s_%s:" % ( section_conf, wifi_fw_type ))
|
||||
|
||||
if img_size > 0:
|
||||
filename_pad = filename + ".padded"
|
||||
if ((self.flinfo.type == 'nand' or self.flinfo.type == 'emmc') and (size != img_size)):
|
||||
script.imxtract(section_conf + "_" + wifi_fw_type + "-" + sha1(filename_pad))
|
||||
else:
|
||||
script.imxtract(section_conf + "_" + wifi_fw_type + "-" + sha1(filename))
|
||||
|
||||
part_size = Pack.norplusnand_rootfs_img_size
|
||||
if part_info == None:
|
||||
if self.flinfo.type == 'norplusnand':
|
||||
offset = count * Pack.norplusnand_rootfs_img_size
|
||||
script.nand_write(offset, part_size, img_size, spi_nand)
|
||||
count = count + 1
|
||||
else:
|
||||
if part_info.which_flash == 0:
|
||||
offset = part_info.offset
|
||||
script.erase(offset, part_info.length)
|
||||
script.write(offset, img_size)
|
||||
else:
|
||||
offset = part_info.offset
|
||||
script.nand_write(offset, part_info.length, img_size, spi_nand)
|
||||
|
||||
script.finish_activity()
|
||||
script.end_if()
|
||||
|
||||
return 1
|
||||
|
||||
def __gen_flash_script_bootldr(self, entries, partition, flinfo, script):
|
||||
for section in entries:
|
||||
|
|
@ -725,7 +878,10 @@ class Pack(object):
|
|||
if tiny_image == None:
|
||||
continue
|
||||
|
||||
filename = "bootldr1_" + board + "_" + memory + ".mbn"
|
||||
if memory_size != "default":
|
||||
filename = "bootldr1_" + board + "_" + memory + "_LM" + memory_size + ".mbn"
|
||||
else:
|
||||
filename = "bootldr1_" + board + "_" + memory + ".mbn"
|
||||
|
||||
img_size = self.__get_img_size(filename)
|
||||
part_info = self.__get_part_info(partition)
|
||||
|
|
@ -940,7 +1096,7 @@ class Pack(object):
|
|||
|
||||
return 1
|
||||
|
||||
def __gen_flash_script(self, script, flinfo, root):
|
||||
def __gen_flash_script(self, script, flinfo, root, testmachid=False):
|
||||
"""Generate the script to flash the images.
|
||||
|
||||
info -- ConfigParser object, containing image flashing info
|
||||
|
|
@ -956,6 +1112,9 @@ class Pack(object):
|
|||
soc_version = 0
|
||||
diff_soc_ver_files = 0
|
||||
file_exists = 1
|
||||
wifi_fw_type = ""
|
||||
wifi_fw_type_min = ""
|
||||
wifi_fw_type_max = ""
|
||||
|
||||
if self.flash_type == "norplusemmc" and flinfo.type == "emmc":
|
||||
srcDir_part = SRC_DIR + "/" + ARCH_NAME + "/flash_partition/" + flinfo.type + "-partition.xml"
|
||||
|
|
@ -978,6 +1137,53 @@ class Pack(object):
|
|||
parts_length = len(parts)
|
||||
entries = root.findall(".//data[@type='MACH_ID_BOARD_MAP']/entry")
|
||||
|
||||
# Note: Skipping validation for ipq806x. It didn't expose any relevant ID. */
|
||||
if ARCH_NAME == "ipq40xx":
|
||||
soc_hw_versions = soc_hw_version_ipq40xx
|
||||
if ARCH_NAME == "ipq807x" or ARCH_NAME == "ipq807x_64":
|
||||
soc_hw_versions = soc_hw_version_ipq807x
|
||||
if ARCH_NAME == "ipq6018" or ARCH_NAME == "ipq6018_64":
|
||||
soc_hw_versions = soc_hw_version_ipq6018
|
||||
if ARCH_NAME == "ipq5018" or ARCH_NAME == "ipq5018_64":
|
||||
soc_hw_versions = soc_hw_version_ipq5018
|
||||
|
||||
chip_count = 0
|
||||
for soc_hw_version in soc_hw_versions:
|
||||
chip_count = chip_count + 1
|
||||
if chip_count == 1:
|
||||
script.script.append('if test -n $soc_hw_version')
|
||||
script.script.append('; then\n')
|
||||
script.script.append('if test "$soc_hw_version" = "%x" ' % soc_hw_version)
|
||||
else:
|
||||
script.script.append('|| test "$soc_hw_version" = "%x" ' % soc_hw_version)
|
||||
if chip_count >= 1:
|
||||
script.script.append('; then\n')
|
||||
script.script.append('echo \'soc_hw_version : Validation success\'\n')
|
||||
script.script.append('else\n')
|
||||
script.script.append('echo \'soc_hw_version : did not match, aborting upgrade\'\n')
|
||||
script.script.append('exit 1\n')
|
||||
script.script.append('fi\n')
|
||||
script.script.append('else\n')
|
||||
script.script.append('echo \'soc_hw_version : unknown, skipping validation\'\n')
|
||||
script.script.append('fi\n')
|
||||
|
||||
if testmachid:
|
||||
machid_count = 0
|
||||
for section in entries:
|
||||
machid = int(section.find(".//machid").text, 0)
|
||||
machid = "%x" % machid
|
||||
machid_count = machid_count + 1
|
||||
if machid_count == 1:
|
||||
script.script.append('if test "$machid" = "%s" ' % machid)
|
||||
else:
|
||||
script.script.append('|| test "$machid" = "%s" ' % machid)
|
||||
if machid_count >= 1:
|
||||
script.script.append('; then\n')
|
||||
script.script.append('echo \'machid : Validation success\'\n')
|
||||
script.script.append('else\n')
|
||||
script.script.append('echo \'machid : unknown, aborting upgrade\'\n')
|
||||
script.script.append('exit 1\n')
|
||||
script.script.append('fi\n')
|
||||
first = False
|
||||
section = None
|
||||
part_index = 0
|
||||
|
|
@ -1041,17 +1247,21 @@ class Pack(object):
|
|||
try:
|
||||
diff_soc_ver_files = section.attrib['diff_soc_ver_files']
|
||||
except KeyError, e:
|
||||
try:
|
||||
if image_type == "all" or section.attrib['image_type'] == image_type:
|
||||
filename = section.attrib['filename']
|
||||
if lk == "true" and "u-boot" in filename:
|
||||
filename = filename.replace("u-boot", "lkboot")
|
||||
partition = section.attrib['label']
|
||||
if filename == "":
|
||||
continue
|
||||
except KeyError, e:
|
||||
print "Skipping partition '%s'" % section.attrib['label']
|
||||
pass
|
||||
if (qcn9100 == "true" or tiny_16m == "true") and 'wififw_type_min' in section.attrib:
|
||||
wifi_fw_type_min = section.attrib['wififw_type_min']
|
||||
wifi_fw_type_max = section.attrib['wififw_type_max']
|
||||
else:
|
||||
try:
|
||||
if image_type == "all" or section.attrib['image_type'] == image_type:
|
||||
filename = section.attrib['filename']
|
||||
if filename == "":
|
||||
continue
|
||||
partition = section.attrib['label']
|
||||
if lk == "true" and "u-boot" in filename:
|
||||
filename = filename.replace("u-boot", "lkboot")
|
||||
except KeyError, e:
|
||||
print "Skipping partition '%s'" % section.attrib['label']
|
||||
pass
|
||||
|
||||
if diff_files == "true":
|
||||
try:
|
||||
|
|
@ -1101,10 +1311,26 @@ class Pack(object):
|
|||
error("invalid layout in '%s'" % section)
|
||||
|
||||
if flinfo.type != "emmc":
|
||||
|
||||
img = section.find('img_name')
|
||||
if img != None and 'soc_version' in img.attrib:
|
||||
|
||||
if img != None and 'wififw_type' in img.attrib and (qcn9100 == "true" or tiny_16m == "true"):
|
||||
imgs = section.findall('img_name')
|
||||
try:
|
||||
for img in imgs:
|
||||
filename = img.text
|
||||
if 'optional' in img.attrib:
|
||||
if not os.path.exists(os.path.join(self.images_dname, filename)):
|
||||
continue
|
||||
wifi_fw_type = img.get('wififw_type')
|
||||
ret = self.__gen_flash_script_wififw(entries, partition, filename, wifi_fw_type, flinfo, script)
|
||||
if ret == 0:
|
||||
return 0
|
||||
wifi_fw_type = ""
|
||||
continue
|
||||
except KeyError, e:
|
||||
continue
|
||||
|
||||
if img != None and 'soc_version' in img.attrib:
|
||||
imgs = section.findall('img_name')
|
||||
try:
|
||||
for img in imgs:
|
||||
|
|
@ -1123,7 +1349,35 @@ class Pack(object):
|
|||
except KeyError, e:
|
||||
continue
|
||||
|
||||
imgs = section.findall('img_name')
|
||||
for img in imgs:
|
||||
memory_attr = img.get('memory')
|
||||
if memory_attr != None and memory_attr == memory_size:
|
||||
filename = img.text;
|
||||
|
||||
atf_image = img.get('atf')
|
||||
if atf_image != None and atf == "true":
|
||||
filename = img.text;
|
||||
|
||||
else:
|
||||
if wifi_fw_type_min:
|
||||
partition = section.attrib['label']
|
||||
|
||||
for fw_type in range(int(wifi_fw_type_min), int(wifi_fw_type_max) + 1):
|
||||
if image_type == "all" or section.attrib['image_type'] == image_type:
|
||||
filename = section.attrib['filename_img' + str(fw_type)]
|
||||
if filename == "":
|
||||
continue
|
||||
wifi_fw_type = str(fw_type)
|
||||
ret = self.__gen_flash_script_wififw(entries, partition, filename, wifi_fw_type, flinfo, script)
|
||||
if ret == 0:
|
||||
return 0
|
||||
wifi_fw_type = ""
|
||||
|
||||
wifi_fw_type_min = ""
|
||||
wifi_fw_type_max = "" # Clear for next partition
|
||||
continue
|
||||
|
||||
if diff_soc_ver_files:
|
||||
try:
|
||||
for version in range(1, int(diff_soc_ver_files)+1):
|
||||
|
|
@ -1132,7 +1386,7 @@ class Pack(object):
|
|||
partition = section.attrib['label']
|
||||
if filename == "":
|
||||
continue
|
||||
if section.attrib['optional']:
|
||||
if 'optional' in section.attrib:
|
||||
if not os.path.exists(os.path.join(self.images_dname, filename)):
|
||||
file_exists = 0
|
||||
ret = self.__gen_flash_script_image(filename, version, file_exists, machid, partition, flinfo, script)
|
||||
|
|
@ -1145,11 +1399,31 @@ class Pack(object):
|
|||
print "Skipping partition '%s'" % section.attrib['label']
|
||||
pass
|
||||
|
||||
if section != None and filename != "" and section.get('filename_mem' + memory_size) != None:
|
||||
filename = section.get('filename_mem' + memory_size)
|
||||
|
||||
if section != None and atf == "true" and section.get('filename_atf') != None:
|
||||
filename = section.get('filename_atf')
|
||||
|
||||
if filename != "":
|
||||
ret = self.__gen_flash_script_image(filename, soc_version, file_exists, machid, partition, flinfo, script)
|
||||
if ret == 0:
|
||||
return 0
|
||||
|
||||
if self.flash_type in [ "nand", "nand-4k", "norplusnand", "norplusnand-4k" ] and partition == "rootfs" and qcn9100 == "true":
|
||||
|
||||
fw_imgs = section.findall('img_name')
|
||||
for fw_img in fw_imgs:
|
||||
wifi_fw_type = fw_img.get('wififw_type')
|
||||
if wifi_fw_type != None:
|
||||
fw_filename = fw_img.text
|
||||
if fw_filename != "":
|
||||
ret = self.__gen_flash_script_wififw_ubi_volume(entries, fw_filename, wifi_fw_type, script)
|
||||
if ret == 0:
|
||||
return 0
|
||||
wifi_fw_type = ""
|
||||
continue
|
||||
|
||||
return 1
|
||||
|
||||
def __gen_script_cdt(self, images, flinfo, root, section_conf, partition):
|
||||
|
|
@ -1216,7 +1490,7 @@ class Pack(object):
|
|||
memory = "128M16"
|
||||
|
||||
if memory_size != "default":
|
||||
filename = "bootldr1_" + board + "_" + memory + "_LM" + memory_size + ".bin"
|
||||
filename = "bootldr1_" + board + "_" + memory + "_LM" + memory_size + ".mbn"
|
||||
else:
|
||||
filename = "bootldr1_" + board + "_" + memory + ".mbn"
|
||||
file_info = "bootldr1_" + board + "_" + memory
|
||||
|
|
@ -1246,7 +1520,7 @@ class Pack(object):
|
|||
images.append(image_info)
|
||||
|
||||
|
||||
def __gen_script_append_images(self, filename, soc_version, images, flinfo, root, section_conf, partition):
|
||||
def __gen_script_append_images(self, filename, soc_version, wifi_fw_type, images, flinfo, root, section_conf, partition):
|
||||
|
||||
global QCN9000
|
||||
|
||||
|
|
@ -1276,6 +1550,8 @@ class Pack(object):
|
|||
section_conf = "ubi"
|
||||
elif section_conf == "wififw" and self.flash_type in ["nand", "nand-4k", "nand-audio", "nand-audio-4k", "norplusnand", "norplusnand-4k"]:
|
||||
section_conf = "wififw_ubi"
|
||||
elif section_conf == "wififw" and wifi_fw_type:
|
||||
section_conf = section_conf + "_" + wifi_fw_type
|
||||
|
||||
if soc_version:
|
||||
section_conf = section_conf + "_v" + str(soc_version)
|
||||
|
|
@ -1286,6 +1562,14 @@ class Pack(object):
|
|||
if image_info not in images:
|
||||
images.append(image_info)
|
||||
|
||||
def __gen_script_append_images_wififw_ubi_volume(self, fw_filename, wifi_fw_type, images):
|
||||
|
||||
image_info = ImageInfo("wifi_fw_" + wifi_fw_type + "-" + sha1(fw_filename),
|
||||
fw_filename, "firmware")
|
||||
if fw_filename.lower() != "none":
|
||||
if image_info not in images:
|
||||
images.append(image_info)
|
||||
|
||||
def __gen_script(self, script_fp, script, images, flinfo, root):
|
||||
"""Generate the script to flash the multi-image blob.
|
||||
|
||||
|
|
@ -1300,10 +1584,13 @@ class Pack(object):
|
|||
|
||||
soc_version = 0
|
||||
diff_soc_ver_files = 0
|
||||
wifi_fw_type = ""
|
||||
wifi_fw_type_min = ""
|
||||
wifi_fw_type_max = ""
|
||||
diff_files = ""
|
||||
file_exists = 1
|
||||
|
||||
ret = self.__gen_flash_script(script, flinfo, root)
|
||||
ret = self.__gen_flash_script(script, flinfo, root, True)
|
||||
if ret == 0:
|
||||
return 0 #Stop packing this single-image
|
||||
|
||||
|
|
@ -1328,6 +1615,7 @@ class Pack(object):
|
|||
srcDir_part = SRC_DIR + "/" + ARCH_NAME + "/flash_partition/" + flinfo.type + "-partition.xml"
|
||||
else:
|
||||
srcDir_part = SRC_DIR + "/" + ARCH_NAME + "/flash_partition/" + self.flash_type.lower() + "-partition.xml"
|
||||
|
||||
root_part = ET.parse(srcDir_part)
|
||||
if self.flash_type != "emmc" and flinfo.type != "emmc":
|
||||
parts = root_part.findall(".//partitions/partition")
|
||||
|
|
@ -1392,26 +1680,31 @@ class Pack(object):
|
|||
except KeyError, e:
|
||||
continue
|
||||
partition = section[0].text
|
||||
else:
|
||||
|
||||
else:
|
||||
try:
|
||||
diff_files = section.attrib['diff_files']
|
||||
except KeyError, e:
|
||||
try:
|
||||
try:
|
||||
diff_soc_ver_files = section.attrib['diff_soc_ver_files']
|
||||
partition = section.attrib['label']
|
||||
except KeyError, e:
|
||||
try:
|
||||
if image_type == "all" or section.attrib['image_type'] == image_type:
|
||||
filename = section.attrib['filename']
|
||||
if lk == "true" and "u-boot" in filename:
|
||||
filename = filename.replace("u-boot", "lkboot")
|
||||
partition = section.attrib['label']
|
||||
if filename == "":
|
||||
continue
|
||||
except KeyError, e:
|
||||
print "Skipping partition '%s'" % section.attrib['label']
|
||||
pass
|
||||
if (qcn9100 == "true" or tiny_16m == "true") and 'wififw_type_min' in section.attrib:
|
||||
wifi_fw_type_min = section.attrib['wififw_type_min']
|
||||
wifi_fw_type_max = section.attrib['wififw_type_max']
|
||||
partition = section.attrib['label']
|
||||
else:
|
||||
try:
|
||||
if image_type == "all" or section.attrib['image_type'] == image_type:
|
||||
filename = section.attrib['filename']
|
||||
if filename == "":
|
||||
continue
|
||||
partition = section.attrib['label']
|
||||
if lk == "true" and "u-boot" in filename:
|
||||
filename = filename.replace("u-boot", "lkboot")
|
||||
except KeyError, e:
|
||||
print "Skipping partition '%s'" % section.attrib['label']
|
||||
pass
|
||||
|
||||
if diff_files == "true":
|
||||
try:
|
||||
|
|
@ -1461,6 +1754,22 @@ class Pack(object):
|
|||
if flinfo.type != "emmc":
|
||||
|
||||
img = section.find('img_name')
|
||||
|
||||
if img != None and 'wififw_type' in img.attrib and (qcn9100 == "true" or tiny_16m == "true"):
|
||||
imgs = section.findall('img_name')
|
||||
try:
|
||||
for img in imgs:
|
||||
wifi_fw_type = img.get('wififw_type')
|
||||
filename = img.text
|
||||
if 'optional' in img.attrib:
|
||||
if not os.path.exists(os.path.join(self.images_dname, filename)):
|
||||
continue
|
||||
self.__gen_script_append_images(filename, soc_version, wifi_fw_type, images, flinfo, root, section_conf, partition)
|
||||
wififw_type = ""
|
||||
continue
|
||||
except KeyError, e:
|
||||
continue
|
||||
|
||||
if img != None and 'soc_version' in img.attrib:
|
||||
|
||||
imgs = section.findall('img_name')
|
||||
|
|
@ -1472,41 +1781,68 @@ class Pack(object):
|
|||
filename_qcn9000 = filename.replace("wifi_fw_ubi", "wifi_fw_ipq8074_qcn9000_ubi")
|
||||
if os.path.exists(os.path.join(self.images_dname, filename_qcn9000)):
|
||||
section_conf_qcn9000 = section_conf + "_ubi_qcn9000"
|
||||
self.__gen_script_append_images(filename_qcn9000, soc_version, images, flinfo, root, section_conf_qcn9000, partition)
|
||||
self.__gen_script_append_images(filename_qcn9000, soc_version, wifi_fw_type, images, flinfo, root, section_conf_qcn9000, partition)
|
||||
if 'optional' in img.attrib:
|
||||
if not os.path.exists(os.path.join(self.images_dname, filename)):
|
||||
file_exists = 0
|
||||
|
||||
if file_exists == 1:
|
||||
self.__gen_script_append_images(filename, soc_version, images, flinfo, root, section_conf, partition)
|
||||
self.__gen_script_append_images(filename, soc_version, wifi_fw_type, images, flinfo, root, section_conf, partition)
|
||||
file_exists = 1
|
||||
soc_version = 0 # Clear soc_version for next iteration
|
||||
continue
|
||||
except KeyError, e:
|
||||
continue
|
||||
|
||||
imgs = section.findall('img_name')
|
||||
for img in imgs:
|
||||
memory_attr = img.get('memory')
|
||||
if memory_attr != None and memory_attr == memory_size:
|
||||
filename = img.text;
|
||||
|
||||
atf_image = img.get('atf')
|
||||
if atf_image != None and atf == "true":
|
||||
filename = img.text;
|
||||
|
||||
# system-partition specific for HK+PINE
|
||||
if section_conf == "mibib" and QCN9000:
|
||||
img = section.find('img_name')
|
||||
filename_qcn9000 = img.text[:-4] + "-qcn9000.bin"
|
||||
section_conf_qcn9000 = section_conf + "_qcn9000"
|
||||
self.__gen_script_append_images(filename_qcn9000, soc_version, images, flinfo, root, section_conf_qcn9000, partition)
|
||||
|
||||
self.__gen_script_append_images(filename_qcn9000, soc_version, wifi_fw_type, images, flinfo, root, section_conf_qcn9000, partition)
|
||||
else:
|
||||
# wififw images specific for RDP based on machid
|
||||
if wifi_fw_type_min:
|
||||
|
||||
for fw_type in range(int(wifi_fw_type_min), int(wifi_fw_type_max) + 1):
|
||||
if image_type == "all" or section.attrib['image_type'] == image_type:
|
||||
filename = section.attrib['filename_img' + str(fw_type)]
|
||||
if filename == "":
|
||||
continue
|
||||
if 'optional' in section.attrib:
|
||||
if not os.path.exists(os.path.join(self.images_dname, filename)):
|
||||
continue
|
||||
wifi_fw_type = str(fw_type)
|
||||
self.__gen_script_append_images(filename, soc_version, wifi_fw_type, images, flinfo, root, section_conf, partition)
|
||||
wifi_fw_type = ""
|
||||
|
||||
wifi_fw_type_min = ""
|
||||
wifi_fw_type_max = "" # Clean for next partition
|
||||
continue
|
||||
|
||||
if diff_soc_ver_files:
|
||||
try:
|
||||
for version in range(1, int(diff_soc_ver_files)+1):
|
||||
if image_type == "all" or section.attrib['image_type'] == image_type:
|
||||
filename = section.attrib['filename_v' + str(version)]
|
||||
partition = section.attrib['label']
|
||||
if filename == "":
|
||||
continue
|
||||
if section.attrib['optional']:
|
||||
if 'optional' in section.attrib:
|
||||
if not os.path.exists(os.path.join(self.images_dname, filename)):
|
||||
file_exists = 0
|
||||
|
||||
if file_exists == 1:
|
||||
self.__gen_script_append_images(filename, version, images, flinfo, root, section_conf, partition)
|
||||
self.__gen_script_append_images(filename, version, wifi_fw_type, images, flinfo, root, section_conf, partition)
|
||||
file_exists = 1
|
||||
|
||||
diff_soc_ver_files = 0 # Clear diff_soc_ver_files for next iteration
|
||||
|
|
@ -1515,8 +1851,31 @@ class Pack(object):
|
|||
print "Skipping partition '%s'" % section.attrib['label']
|
||||
pass
|
||||
|
||||
if section != None and filename != "" and section.get('filename_mem' + memory_size) != None:
|
||||
filename = section.get('filename_mem' + memory_size)
|
||||
|
||||
if section != None and atf == "true" and section.get('filename_atf') != None:
|
||||
filename = section.get('filename_atf')
|
||||
|
||||
if filename != "":
|
||||
self.__gen_script_append_images(filename, soc_version, images, flinfo, root, section_conf, partition)
|
||||
self.__gen_script_append_images(filename, soc_version, wifi_fw_type, images, flinfo, root, section_conf, partition)
|
||||
|
||||
if self.flash_type in [ "nand", "nand-4k", "norplusnand", "norplusnand-4k" ] and section_conf == "rootfs" and qcn9100 == "true":
|
||||
|
||||
fw_imgs = section.findall('img_name')
|
||||
try:
|
||||
for fw_img in fw_imgs:
|
||||
wifi_fw_type = fw_img.get('wififw_type')
|
||||
if wifi_fw_type != None:
|
||||
fw_filename = fw_img.text
|
||||
ret = self.__gen_script_append_images_wififw_ubi_volume(fw_filename, wifi_fw_type, images)
|
||||
if ret == 0:
|
||||
return 0
|
||||
wifi_fw_type = ""
|
||||
continue
|
||||
except KeyError, e:
|
||||
continue
|
||||
|
||||
return 1
|
||||
|
||||
def __mkimage(self, images):
|
||||
|
|
@ -1616,7 +1975,7 @@ class Pack(object):
|
|||
self.partitions = mibib_qcn9000.get_parts()
|
||||
|
||||
script.append('if test "$machid" = "801000e" || test "$machid" = "801010e" || test "$machid" = "8010012" || test "$machid" = "8010013" || test "$machid" = "8010500"; then\n', fatal=False)
|
||||
ret = self.__gen_flash_script(script, flinfo, root)
|
||||
ret = self.__gen_flash_script(script, flinfo, root, True)
|
||||
if ret == 0:
|
||||
return 0 #Issue in packing hk+pine single-image
|
||||
|
||||
|
|
@ -1691,7 +2050,7 @@ class Pack(object):
|
|||
global QCN9000
|
||||
|
||||
try:
|
||||
if ftype == "tiny-nor":
|
||||
if ftype == "tiny-nor" or ftype == "tiny-nor-debug":
|
||||
part_info = root.find(".//data[@type='" + "NOR_PARAMETER']")
|
||||
elif ftype in ["nand", "nand-4k", "nand-audio", "nand-audio-4k"]:
|
||||
if root.find(".//data[@type='NAND_PARAMETER']/entry") != None:
|
||||
|
|
@ -1766,7 +2125,7 @@ class Pack(object):
|
|||
if ARCH_NAME == "ipq807x" and (ftype == "norplusnand" or ftype == "nand"):
|
||||
QCN9000 = True
|
||||
|
||||
if ftype in ["tiny-nor", "norplusnand", "norplusnand-4k", "norplusemmc"]:
|
||||
if ftype in ["tiny-nor", "norplusnand", "norplusnand-4k", "norplusemmc", "tiny-nor-debug"]:
|
||||
ftype = "nor"
|
||||
if ftype in ["nand-4k", "nand-audio", "nand-audio-4k"]:
|
||||
ftype = "nand"
|
||||
|
|
@ -1788,7 +2147,7 @@ class Pack(object):
|
|||
|
||||
QCN9000 = False
|
||||
try:
|
||||
if self.flash_type in [ "nand", "nand-4k", "nand-audio", "nand-audio-4k", "nor", "tiny-nor", "norplusnand", "norplusnand-4k" ]:
|
||||
if self.flash_type in [ "nand", "nand-4k", "nand-audio", "nand-audio-4k", "nor", "tiny-nor", "norplusnand", "norplusnand-4k", "tiny-nor-debug" ]:
|
||||
ret = self.__process_board_flash(self.flash_type, images, root)
|
||||
elif self.flash_type == "emmc":
|
||||
ret = self.__process_board_flash_emmc(self.flash_type, images, root)
|
||||
|
|
@ -1849,7 +2208,9 @@ class ArgParser(object):
|
|||
global image_type
|
||||
global memory_size
|
||||
global lk
|
||||
global atf
|
||||
global skip_4k_nand
|
||||
global qcn9100
|
||||
|
||||
"""Start the parsing process, and populate members with parsed value.
|
||||
|
||||
|
|
@ -1859,7 +2220,7 @@ class ArgParser(object):
|
|||
cdir = os.path.abspath(os.path.dirname(""))
|
||||
if len(sys.argv) > 1:
|
||||
try:
|
||||
opts, args = getopt(sys.argv[1:], "", ["arch=", "fltype=", "srcPath=", "inImage=", "outImage=", "image_type=", "memory=", "lk", "skip_4k_nand"])
|
||||
opts, args = getopt(sys.argv[1:], "", ["arch=", "fltype=", "srcPath=", "inImage=", "outImage=", "image_type=", "memory=", "lk", "skip_4k_nand", "atf", "qcn9100"])
|
||||
except GetoptError, e:
|
||||
raise UsageError(e.msg)
|
||||
|
||||
|
|
@ -1888,9 +2249,14 @@ class ArgParser(object):
|
|||
elif option =="--lk":
|
||||
lk = "true"
|
||||
|
||||
elif option =="--atf":
|
||||
atf = "true"
|
||||
|
||||
elif option =="--skip_4k_nand":
|
||||
skip_4k_nand = "true"
|
||||
|
||||
elif option == "--qcn9100":
|
||||
qcn9100 = "true"
|
||||
|
||||
#Verify Arguments passed by user
|
||||
|
||||
|
|
@ -1914,7 +2280,7 @@ class ArgParser(object):
|
|||
if self.flash_type == None:
|
||||
self.flash_type = ArgParser.DEFAULT_TYPE
|
||||
for flash_type in self.flash_type.split(","):
|
||||
if flash_type not in [ "nand", "nor", "tiny-nor", "emmc", "norplusnand", "norplusemmc" ]:
|
||||
if flash_type not in [ "nand", "nor", "tiny-nor", "emmc", "norplusnand", "norplusemmc", "tiny-nor-debug" ]:
|
||||
raise UsageError("invalid flash type '%s'" % flash_type)
|
||||
|
||||
# Verify src Path
|
||||
|
|
@ -1942,7 +2308,7 @@ class ArgParser(object):
|
|||
print "options:"
|
||||
print " --arch \tARCH_TYPE [ipq40xx/ipq806x/ipq807x/ipq807x_64/ipq6018/ipq6018_64/ipq5018/ipq5018_64]"
|
||||
print
|
||||
print " --fltype \tFlash Type [nor/tiny-nor/nand/emmc/norplusnand/norplusemmc]"
|
||||
print " --fltype \tFlash Type [nor/tiny-nor/nand/emmc/norplusnand/norplusemmc/tiny-nor-debug]"
|
||||
print " \t\tMultiple flashtypes can be passed by a comma separated string"
|
||||
print " \t\tDefault is all. i.e If \"--fltype\" is not passed image for all the flash-type will be created.\n"
|
||||
print " --srcPath \tPath to the directory containg the meta scripts and configs"
|
||||
|
|
@ -1956,6 +2322,7 @@ class ArgParser(object):
|
|||
print " \t\tIf specified, CDTs created with specified memory size will be used for single-image.\n"
|
||||
print
|
||||
print " --lk \t\tReplace u-boot with lkboot for appsbl"
|
||||
print " --atf \t\tReplace tz with atf for QSEE partition"
|
||||
print " --skip_4k_nand \tskip generating 4k nand images"
|
||||
print " \t\tThis Argument does not take any value"
|
||||
print "Pack Version: %s" % version
|
||||
|
|
@ -2040,6 +2407,8 @@ def main():
|
|||
|
||||
Created to avoid polluting the global namespace.
|
||||
"""
|
||||
|
||||
global tiny_16m
|
||||
try:
|
||||
parser = ArgParser()
|
||||
parser.parse(sys.argv)
|
||||
|
|
@ -2068,6 +2437,12 @@ def main():
|
|||
|
||||
# Format the output image name from Arch, flash type and mode
|
||||
for flash_type in parser.flash_type.split(","):
|
||||
|
||||
if ARCH_NAME == "ipq5018" and (flash_type == "tiny-nor" or flash_type == "tiny-nor-debug"):
|
||||
tiny_16m = "true"
|
||||
else:
|
||||
tiny_16m = "false"
|
||||
|
||||
if image_type == "hlos":
|
||||
if MODE == "64":
|
||||
parser.out_fname = flash_type + "-" + ARCH_NAME + "_" + MODE + "-apps.img"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue