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: Add support for QCN9224 V1 & V2 flashing
From this change, by default QCN9224 V2 image will be flashed. If QCN9224 version is V1, then V1 image will be reflashed. Change-Id: I205239e1ac4d8136272858aeca784553496e324a Signed-off-by: Praveenkumar I <quic_ipkumar@quicinc.com>
This commit is contained in:
parent
c4a471eeb6
commit
07af4cfed1
1 changed files with 150 additions and 13 deletions
163
tools/pack.py
163
tools/pack.py
|
|
@ -788,7 +788,37 @@ class Pack(object):
|
|||
|
||||
return 1
|
||||
|
||||
def __gen_flash_script_wififw(self, entries, partition, filename, wifi_fw_type, flinfo, script):
|
||||
def __gen_flash_script_wififw_ubi_volume_qcn9224_v1(self, entries, fw_filename, wifi_fw_type, script):
|
||||
|
||||
script.append("detect_qcn9224", fatal=False)
|
||||
script.append('if test "$qcn9224_version" = "1" || test "$qcn9224_version" = ""; then\n', fatal=False)
|
||||
|
||||
script.start_activity("Flashing " + fw_filename[:-13] + ":")
|
||||
script.imxtract(fw_filename[:-13] + "-" + sha1(fw_filename))
|
||||
|
||||
rootfs_info = self.__get_part_info("rootfs")
|
||||
rootfs_offset = rootfs_info.offset
|
||||
rootfs_len = rootfs_info.length
|
||||
|
||||
wifi_fw_cmd = "setenv mtdids nand0=nand0\n"
|
||||
wifi_fw_cmd += "setenv mtdparts mtdparts=nand0:0x%x@0x%x(rootfs)\n" % (rootfs_len,rootfs_offset)
|
||||
wifi_fw_cmd += "ubi part rootfs\n"
|
||||
img_size = self.__get_img_size(fw_filename)
|
||||
wifi_fw_cmd += "ubi write $fileaddr wifi_fw %x" % img_size
|
||||
script.append(wifi_fw_cmd, fatal=False)
|
||||
|
||||
#Enable the below lines for debugging purpose
|
||||
"""
|
||||
script.append("mtdparts", fatal=False)
|
||||
script.append("ubi info layout", fatal=False)
|
||||
"""
|
||||
|
||||
script.finish_activity()
|
||||
script.end_if()
|
||||
|
||||
return 1
|
||||
|
||||
def __gen_flash_script_wififw(self, entries, partition, filename, wifi_fw_type, flinfo, script, skip_size_check):
|
||||
|
||||
machid_list = []
|
||||
for section in entries:
|
||||
|
|
@ -847,11 +877,14 @@ class Pack(object):
|
|||
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 (skip_size_check == "" or wifi_fw_type < skip_size_check):
|
||||
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
|
||||
else:
|
||||
print "EMMC: size check skipped for '%s'" % filename
|
||||
|
||||
if part_info == None and self.flinfo.type != 'norplusnand':
|
||||
print "Flash type is norplusemmc"
|
||||
|
|
@ -887,6 +920,94 @@ class Pack(object):
|
|||
|
||||
return 1
|
||||
|
||||
def __gen_flash_script_wififw_qcn9224_v1(self, entries, partition, filename, wifi_fw_type, flinfo, script, skip_size_check):
|
||||
|
||||
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 (skip_size_check == "" or wifi_fw_type < skip_size_check):
|
||||
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
|
||||
else:
|
||||
print "EMMC: size check skipped for '%s'" % filename
|
||||
|
||||
if part_info == None and self.flinfo.type != 'norplusnand':
|
||||
print "Flash type is norplusemmc"
|
||||
return 1
|
||||
|
||||
script.append("detect_qcn9224", fatal=False)
|
||||
script.append('if test "$qcn9224_version" = "1" || test "$qcn9224_version" = ""; then\n', fatal=False)
|
||||
|
||||
script.start_activity("Flashing %s:" % ( filename[:-13] ))
|
||||
|
||||
if img_size > 0:
|
||||
filename_pad = filename + ".padded"
|
||||
if ((self.flinfo.type == 'nand' or self.flinfo.type == 'emmc') and (size != img_size)):
|
||||
script.imxtract(filename[:-13] + "-" + sha1(filename_pad))
|
||||
else:
|
||||
script.imxtract(filename[:-13] + "-" + 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:
|
||||
|
||||
|
|
@ -1150,6 +1271,7 @@ class Pack(object):
|
|||
wifi_fw_type = ""
|
||||
wifi_fw_type_min = ""
|
||||
wifi_fw_type_max = ""
|
||||
skip_size_check = ""
|
||||
|
||||
if self.flash_type == "norplusemmc" and flinfo.type == "emmc":
|
||||
srcDir_part = SRC_DIR + "/" + ARCH_NAME + "/flash_partition/" + flinfo.type + "-partition.xml"
|
||||
|
|
@ -1379,7 +1501,7 @@ class Pack(object):
|
|||
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)
|
||||
ret = self.__gen_flash_script_wififw(entries, partition, filename, wifi_fw_type, flinfo, script, "")
|
||||
if ret == 0:
|
||||
return 0
|
||||
wifi_fw_type = ""
|
||||
|
|
@ -1420,15 +1542,24 @@ class Pack(object):
|
|||
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 'skip_size_check' in section.attrib:
|
||||
skip_size_check = section.attrib['skip_size_check']
|
||||
|
||||
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
|
||||
if wifi_fw_type < wifi_fw_type_max:
|
||||
ret = self.__gen_flash_script_wififw(entries, partition, filename, wifi_fw_type, flinfo, script, skip_size_check)
|
||||
if ret == 0:
|
||||
return 0
|
||||
elif wifi_fw_type == wifi_fw_type_max:
|
||||
ret = self.__gen_flash_script_wififw_qcn9224_v1(entries, partition, filename, wifi_fw_type, flinfo, script, skip_size_check)
|
||||
if ret == 0:
|
||||
return 0
|
||||
wifi_fw_type = ""
|
||||
|
||||
wifi_fw_type_min = ""
|
||||
|
|
@ -1472,13 +1603,19 @@ class Pack(object):
|
|||
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:
|
||||
if wifi_fw_type != None and wifi_fw_type < "7":
|
||||
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 = ""
|
||||
if wifi_fw_type == "7":
|
||||
fw_filename = fw_img.text
|
||||
if fw_filename != "":
|
||||
ret = self.__gen_flash_script_wififw_ubi_volume_qcn9224_v1(entries, fw_filename, wifi_fw_type, script)
|
||||
if ret == 0:
|
||||
return 0
|
||||
wifi_fw_type = ""
|
||||
continue
|
||||
|
||||
return 1
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue