From patchwork Thu Jun 13 17:05:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Warren X-Patchwork-Id: 251118 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 84CE62C008F for ; Fri, 14 Jun 2013 03:06:27 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756774Ab3FMRGF (ORCPT ); Thu, 13 Jun 2013 13:06:05 -0400 Received: from avon.wwwdotorg.org ([70.85.31.133]:43068 "EHLO avon.wwwdotorg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756770Ab3FMRF5 (ORCPT ); Thu, 13 Jun 2013 13:05:57 -0400 Received: from severn.wwwdotorg.org (unknown [192.168.65.5]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by avon.wwwdotorg.org (Postfix) with ESMTPS id 42482635A; Thu, 13 Jun 2013 11:14:31 -0600 (MDT) Received: from swarren-lx1.nvidia.com (localhost [127.0.0.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by severn.wwwdotorg.org (Postfix) with ESMTPSA id 494CAE45FB; Thu, 13 Jun 2013 11:05:55 -0600 (MDT) From: Stephen Warren To: swarren@wwwdotorg.org Cc: linux-tegra@vger.kernel.org, Stephen Warren Subject: [PATCH flasher 1/2] Pre-calculate more in find_config_dir() Date: Thu, 13 Jun 2013 11:05:49 -0600 Message-Id: <1371143150-3935-1-git-send-email-swarren@wwwdotorg.org> X-Mailer: git-send-email 1.8.1.5 X-NVConfidentiality: public X-Virus-Scanned: clamav-milter 0.97.7 at avon.wwwdotorg.org X-Virus-Status: Clean Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org From: Stephen Warren Set more global variables in find_config_dir(). These remove duplicate lookups and/or will be re-used by a future "exec" sub-command. Signed-off-by: Stephen Warren --- tegra-uboot-flasher | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/tegra-uboot-flasher b/tegra-uboot-flasher index aae7f19..1bdf944 100755 --- a/tegra-uboot-flasher +++ b/tegra-uboot-flasher @@ -52,7 +52,7 @@ def run(dir, cmd): os.chdir(oldcwd) def gen_flashcmd_mmc(flash_image_addr, flash_img_size): - flash_id = configs[args.configname]['flash-id-uboot'] + flash_id = config['flash-id-uboot'] flash_img_size_sectors = flash_img_size / 512 flashcmd = 'mmc dev %d 1 ; ' % flash_id flashcmd += 'mmc write 0x%08x 0 0x%x ; ' % (flash_image_addr, flash_img_size_sectors) @@ -65,7 +65,7 @@ def gen_flashcmd_nand(flash_image_addr, flash_img_size): def gen_flashcmd_spi(flash_image_addr, flash_img_size): flashcmd = 'sf probe 0 ; ' - flashcmd += 'sf erase 0 0x%08x ; ' % configs[args.configname]['flash-erase-size'] + flashcmd += 'sf erase 0 0x%08x ; ' % config['flash-erase-size'] flashcmd += 'sf write 0x%08x 0 0x%08x ; ' % (flash_image_addr, flash_img_size) return flashcmd @@ -80,11 +80,15 @@ def find_config_dir(): print 'Unknown config "%s"' % args.configname sys.exit(1) - global boardname, socname, out_board_dir + global config, boardname, board, socname, soc, out_board_dir, bct - boardname = configs[args.configname]['board'] - socname = boards[boardname]['soc'] + config = configs[args.configname] + boardname = config['board'] + board = boards[boardname] + socname = board['soc'] + soc = socs[socname] out_board_dir = os.path.join(args.data_dir, boardname) + bct = os.path.join(out_board_dir, config['bct']) def func_list_configs(): for configname in sorted(configs.keys()): @@ -106,13 +110,11 @@ def func_flash(): if args.flash_image: flash_img = args.flash_img else: - flash_img = os.path.join(out_board_dir, configs[args.configname]['flash-image']) + flash_img = os.path.join(out_board_dir, config['flash-image']) flash_img_size = os.path.getsize(flash_img) if args.debug: print 'flash_img_size %d 0x%x' % (flash_img_size, flash_img_size) - bct = os.path.join(out_board_dir, configs[args.configname]['bct']) - u_boot_plus_dtb_size = u_boot_no_dtb_size + u_boot_dtb_size if args.debug: print 'u_boot_plus_dtb_size %d 0x%x' % (u_boot_plus_dtb_size, u_boot_plus_dtb_size) @@ -128,12 +130,12 @@ def func_flash(): print 'pad_size %d 0x%x' % (pad_size, pad_size) # 0x00108000 is CONFIG_SYS_TEXT_BASE in U-Boot, minus RAM base - loadaddr = socs[socname]['ram-base'] + 0x00108000 + loadaddr = soc['ram-base'] + 0x00108000 flash_image_addr = loadaddr + padded_size if args.debug: print 'flash_image_addr %d 0x%x' % (flash_image_addr, flash_image_addr) - flash_type = configs[args.configname]['flash-type'] + flash_type = config['flash-type'] if not gen_flashcmds.has_key(flash_type): print 'flash-type "%s" not yet supported' % flash_type sys.exit(1) @@ -158,8 +160,8 @@ def func_flash(): bootcmd += gen_flashcmd(flash_image_addr, flash_img_size) bootcmd += 'env default -f -a ; ' # Perhaps U-Boot should set $boardname based on the ID EEPROM; then we wouldn't need this - if configs[args.configname]['dtbfn-extra'] != '': - bootcmd += 'setenv board ' + boardname + configs[args.configname]['dtbfn-extra'] + ' ; ' + if config['dtbfn-extra'] != '': + bootcmd += 'setenv board ' + boardname + config['dtbfn-extra'] + ' ; ' bootcmd += 'saveenv ; ' # To update the bootloader, reset. # If wanting to run installer, set installer_args.configname in environment, 'run bootcmd'