mirror of
https://git.codelinaro.org/clo/qsdk/oss/boot/u-boot-2016.git
synced 2025-12-10 07:44:53 +01:00
pack-tool: Fix process abort issue on image size irregularity
This change adds support to skip only the specific flash type's single-image generation if the size of any of its image components does not fit into layout size, instead of exiting entire pack process of generating other single-images. Change-Id: I68486abf5950c06bc4129eedfb38f069734eaf40 Signed-off-by: Pavithra Palanisamy <pavip@codeaurora.org>
This commit is contained in:
parent
59be1ce0ee
commit
7da84bb961
1 changed files with 57 additions and 21 deletions
|
|
@ -650,12 +650,14 @@ class Pack(object):
|
|||
if count > 2:
|
||||
error("More than 2 NAND images for NOR+NAND is not allowed")
|
||||
elif img_size > part_info.length:
|
||||
error("img size is larger than part. len in '%s'" % section_conf)
|
||||
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):
|
||||
error("img size is larger than part. len in '%s'" % section_conf)
|
||||
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"
|
||||
|
|
@ -708,6 +710,8 @@ class Pack(object):
|
|||
if machid:
|
||||
script.end_if()
|
||||
|
||||
return 1
|
||||
|
||||
def __gen_flash_script_image(self, filename, soc_version, file_exists, machid, partition, flinfo, script):
|
||||
|
||||
img_size = 0
|
||||
|
|
@ -752,16 +756,18 @@ class Pack(object):
|
|||
if count > 2:
|
||||
error("More than 2 NAND images for NOR+NAND is not allowed")
|
||||
elif img_size > part_info.length:
|
||||
error("img size is larger than part. len in '%s'" % section_conf)
|
||||
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):
|
||||
error("img size is larger than part. len in '%s'" % section_conf)
|
||||
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
|
||||
return 1
|
||||
|
||||
if machid:
|
||||
script.start_if("machid", machid)
|
||||
|
|
@ -791,7 +797,7 @@ class Pack(object):
|
|||
script.append('setenv stdout serial && echo "error: binary image not found" && exit 1', fatal=False)
|
||||
if soc_version:
|
||||
script.end_if()
|
||||
return
|
||||
return 1
|
||||
|
||||
if ARCH_NAME == "ipq806x":
|
||||
script.switch_layout(layout)
|
||||
|
|
@ -826,6 +832,8 @@ class Pack(object):
|
|||
if machid:
|
||||
script.end_if()
|
||||
|
||||
return 1
|
||||
|
||||
def __gen_flash_script(self, script, flinfo, root):
|
||||
"""Generate the script to flash the images.
|
||||
|
||||
|
|
@ -958,7 +966,9 @@ class Pack(object):
|
|||
else:
|
||||
try:
|
||||
if image_type == "all" or section.attrib['image_type'] == image_type:
|
||||
self.__gen_flash_script_cdt(entries, partition, flinfo, script)
|
||||
ret = self.__gen_flash_script_cdt(entries, partition, flinfo, script)
|
||||
if ret == 0:
|
||||
return 0
|
||||
continue
|
||||
except KeyError, e:
|
||||
continue
|
||||
|
|
@ -986,7 +996,9 @@ class Pack(object):
|
|||
if 'optional' in img.attrib:
|
||||
if not os.path.exists(os.path.join(self.images_dname, filename)):
|
||||
file_exists = 0
|
||||
self.__gen_flash_script_image(filename, soc_version, file_exists, machid, partition, flinfo, script)
|
||||
ret = self.__gen_flash_script_image(filename, soc_version, file_exists, machid, partition, flinfo, script)
|
||||
if ret == 0:
|
||||
return 0
|
||||
file_exists = 1 # generating flash script is mandatory by default
|
||||
|
||||
soc_version = 0 # Clear soc_version for next iteration
|
||||
|
|
@ -1006,7 +1018,9 @@ class Pack(object):
|
|||
if section.attrib['optional']:
|
||||
if not os.path.exists(os.path.join(self.images_dname, filename)):
|
||||
file_exists = 0
|
||||
self.__gen_flash_script_image(filename, version, file_exists, machid, partition, flinfo, script)
|
||||
ret = self.__gen_flash_script_image(filename, version, file_exists, machid, partition, flinfo, script)
|
||||
if ret == 0:
|
||||
return 0
|
||||
file_exists = 1
|
||||
diff_soc_ver_files = 0 # Clear diff_soc_ver_files for next iteration
|
||||
continue
|
||||
|
|
@ -1015,7 +1029,11 @@ class Pack(object):
|
|||
pass
|
||||
|
||||
if filename != "":
|
||||
self.__gen_flash_script_image(filename, soc_version, file_exists, machid, partition, flinfo, script)
|
||||
ret = self.__gen_flash_script_image(filename, soc_version, file_exists, machid, partition, flinfo, script)
|
||||
if ret == 0:
|
||||
return 0
|
||||
|
||||
return 1
|
||||
|
||||
def __gen_script_cdt(self, images, flinfo, root, section_conf, partition):
|
||||
global ARCH_NAME
|
||||
|
|
@ -1115,7 +1133,10 @@ class Pack(object):
|
|||
diff_files = ""
|
||||
file_exists = 1
|
||||
|
||||
self.__gen_flash_script(script, flinfo, root)
|
||||
ret = self.__gen_flash_script(script, flinfo, root)
|
||||
if ret == 0:
|
||||
return 0 #Stop packing this single-image
|
||||
|
||||
if (self.flash_type == "norplusemmc" and flinfo.type == "emmc") or (self.flash_type != "norplusemmc"):
|
||||
if flinfo.type == "emmc":
|
||||
script.start_activity("Flashing rootfs_data:")
|
||||
|
|
@ -1297,6 +1318,7 @@ class Pack(object):
|
|||
|
||||
if filename != "":
|
||||
self.__gen_script_append_images(filename, soc_version, images, flinfo, root, section_conf, partition)
|
||||
return 1
|
||||
|
||||
def __mkimage(self, images):
|
||||
"""Create the multi-image blob.
|
||||
|
|
@ -1390,7 +1412,9 @@ class Pack(object):
|
|||
self.flinfo = flinfo
|
||||
|
||||
script.probe()
|
||||
self.__gen_script(script_fp, script, images, flinfo, root)
|
||||
ret = self.__gen_script(script_fp, script, images, flinfo, root)
|
||||
if ret == 0:
|
||||
return 0
|
||||
|
||||
try:
|
||||
script_fp.write(script.dumps())
|
||||
|
|
@ -1398,6 +1422,7 @@ class Pack(object):
|
|||
error("error writing to script '%s'" % script_fp.name, e)
|
||||
|
||||
script_fp.close()
|
||||
return 1
|
||||
|
||||
def __process_board_flash_emmc(self, ftype, images, root):
|
||||
"""Extract board info from config and generate the flash script.
|
||||
|
|
@ -1429,7 +1454,11 @@ class Pack(object):
|
|||
|
||||
flinfo = FlashInfo(ftype, pagesize, blocksize, chipsize)
|
||||
|
||||
self.__gen_board_script(flinfo, part_fname, images, root)
|
||||
ret = self.__gen_board_script(flinfo, part_fname, images, root)
|
||||
if ret == 0:
|
||||
return 0
|
||||
|
||||
return 1
|
||||
|
||||
def __process_board_flash(self, ftype, images, root):
|
||||
global SRC_DIR
|
||||
|
|
@ -1477,18 +1506,21 @@ class Pack(object):
|
|||
|
||||
flinfo = FlashInfo(ftype, pagesize, blocksize, chipsize)
|
||||
|
||||
self.__gen_board_script(flinfo, part_fname, images, root)
|
||||
ret = self.__gen_board_script(flinfo, part_fname, images, root)
|
||||
return ret
|
||||
|
||||
def __process_board(self, images, root):
|
||||
|
||||
try:
|
||||
if self.flash_type in [ "nand", "nand-4k", "nand-audio-2k", "nand-audio-4k", "nor", "tiny-nor", "norplusnand", "norplusnand-4k" ]:
|
||||
self.__process_board_flash(self.flash_type, images, root)
|
||||
ret = self.__process_board_flash(self.flash_type, images, root)
|
||||
elif self.flash_type == "emmc":
|
||||
self.__process_board_flash_emmc(self.flash_type, images, root)
|
||||
ret = self.__process_board_flash_emmc(self.flash_type, images, root)
|
||||
elif self.flash_type == "norplusemmc":
|
||||
self.__process_board_flash("norplusemmc", images, root)
|
||||
self.__process_board_flash_emmc("norplusemmc", images, root)
|
||||
ret = self.__process_board_flash("norplusemmc", images, root)
|
||||
if ret:
|
||||
ret = self.__process_board_flash_emmc("norplusemmc", images, root)
|
||||
return ret
|
||||
except ValueError, e:
|
||||
error("error getting board info in section '%s'" % board_section.find('machid').text, e)
|
||||
|
||||
|
|
@ -1510,9 +1542,13 @@ class Pack(object):
|
|||
pass
|
||||
|
||||
images = []
|
||||
self.__process_board(images, root)
|
||||
images.insert(0, ImageInfo("script", "flash.scr", "script"))
|
||||
self.__mkimage(images)
|
||||
ret = self.__process_board(images, root)
|
||||
if ret != 0:
|
||||
images.insert(0, ImageInfo("script", "flash.scr", "script"))
|
||||
self.__mkimage(images)
|
||||
else:
|
||||
fail_img = out_fname.split("/")
|
||||
print "Failed to pack %s" % fail_img[-1]
|
||||
|
||||
class UsageError(Exception):
|
||||
"""Indicates error in command arguments."""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue