diff --git "a/HiHope_DAYU200/\347\203\247\345\206\231\345\267\245\345\205\267\345\217\212\346\214\207\345\215\227/linux/flash.py" "b/HiHope_DAYU200/\347\203\247\345\206\231\345\267\245\345\205\267\345\217\212\346\214\207\345\215\227/linux/flash.py" index dd7360584f3d1b99cb8382e839ca1d49f9b85199..2d2629b21297d3884bad062caad05c3d4769c203 100644 --- "a/HiHope_DAYU200/\347\203\247\345\206\231\345\267\245\345\205\267\345\217\212\346\214\207\345\215\227/linux/flash.py" +++ "b/HiHope_DAYU200/\347\203\247\345\206\231\345\267\245\345\205\267\345\217\212\346\214\207\345\215\227/linux/flash.py" @@ -12,12 +12,14 @@ import math import getopt class FlashTool: - def __init__(self, arch): - self.rootDir = os.getcwd() - self.outDir = '%s/out/ohos-%s-release' % (self.rootDir, arch) - self.imageDir = '%s/packages/phone/images' % self.outDir - self.toolDir = '%s/device/hihope/rk3568/tools' % self.rootDir - self.flashTool = '%s/linux/bin/flash.%s' % (self.toolDir, os.uname().machine) + def __init__(self, arch="arm", imageDir=""): + if imageDir == "": + self.outDir = '%s/out/ohos-%s-release' % (os.getcwd(), arch) + self.imageDir = '%s/packages/phone/images' % self.outDir + else: + self.imageDir = imageDir + self.toolDir = os.path.split(os.path.realpath(__file__))[0] + self.flashTool = '%s/bin/flash.%s' % (self.toolDir, os.uname().machine) def QueryFlashMode(self): cmd = '%s LD' % self.flashTool @@ -58,6 +60,7 @@ def help(argv): text += ' -d, --userdata Flash userdata image\n' text += ' -r, --resource Flash resource image\n' text += ' -a, --all Flash all images\n' + text += ' -i, --image Specify image dir\n' text += '\n' text += 'e.g.\n' text += ' ' + argv[0] + ' -sv\n' @@ -67,7 +70,7 @@ def help(argv): print(text) try: - options,args = getopt.getopt(sys.argv[1:], 'hquksvdra', ['help', 'query', 'uboot', 'kernel', 'system', 'vendor', 'userdata', 'resource', 'all']) + options,args = getopt.getopt(sys.argv[1:], 'hquksvdrai:', ['help', 'query', 'uboot', 'kernel', 'system', 'vendor', 'userdata', 'resource', 'all', 'image=']) except getopt.GetoptError: help(sys.argv) @@ -77,8 +80,13 @@ if len(options) == 0: help(sys.argv) sys.exit() +imageDir="" +for option, param in options: + if option in ('-i', '--image'): + imageDir = param + break +tool = FlashTool('arm', imageDir) partList = ['uboot', 'boot_linux', 'system', 'vendor', 'userdata', 'resource'] -tool = FlashTool('arm') cmds = [] cmds.append(tool.FlashLoader())