├── configs ├── tegra20.soc ├── tegra114.soc ├── tegra124.soc ├── tegra30.soc ├── beaver.board ├── cardhu.board ├── dalmore.board ├── harmony.board ├── seaboard.board ├── venice2.board ├── ventana.board ├── jetson-tk1.board ├── trimslice.board ├── norrin.board ├── colibri_t20.board ├── colibri_t30.board ├── seaboard.config ├── trimslice.config ├── harmony.config ├── colibri_t20-256-hsmmc.config ├── colibri_t20-512-hsmmc.config ├── jetson-tk1.config ├── beaver.config ├── colibri_t20-256-v11-nand.config ├── colibri_t20-256-v12-nand.config ├── colibri_t20-512-v11-nand.config ├── colibri_t20-512-v12-nand.config ├── colibri_t30.config ├── dalmore-t40s-1600.config ├── dalmore-t40s-1866.config ├── dalmore-t40x-1866.config ├── ventana.config ├── cardhu-a02-1gb.config ├── cardhu-a04-1gb.config ├── norrin.config └── venice2.config ├── README.txt ├── LICENSE.txt ├── elf-get-entry ├── tegraboardconfigs.py ├── README-user.txt ├── README-developer.txt └── tegra-uboot-flasher /configs/tegra20.soc: -------------------------------------------------------------------------------- 1 | soc = { 2 | 'ram-base': 0, 3 | } 4 | -------------------------------------------------------------------------------- /configs/tegra114.soc: -------------------------------------------------------------------------------- 1 | soc = { 2 | 'ram-base': 0x80000000, 3 | } 4 | -------------------------------------------------------------------------------- /configs/tegra124.soc: -------------------------------------------------------------------------------- 1 | soc = { 2 | 'ram-base': 0x80000000, 3 | } 4 | -------------------------------------------------------------------------------- /configs/tegra30.soc: -------------------------------------------------------------------------------- 1 | soc = { 2 | 'ram-base': 0x80000000, 3 | } 4 | -------------------------------------------------------------------------------- /configs/beaver.board: -------------------------------------------------------------------------------- 1 | board = { 2 | 'vendor': 'nvidia', 3 | 'soc': 'tegra30', 4 | } 5 | -------------------------------------------------------------------------------- /configs/cardhu.board: -------------------------------------------------------------------------------- 1 | board = { 2 | 'vendor': 'nvidia', 3 | 'soc': 'tegra30', 4 | } 5 | -------------------------------------------------------------------------------- /configs/dalmore.board: -------------------------------------------------------------------------------- 1 | board = { 2 | 'vendor': 'nvidia', 3 | 'soc': 'tegra114', 4 | } 5 | -------------------------------------------------------------------------------- /configs/harmony.board: -------------------------------------------------------------------------------- 1 | board = { 2 | 'vendor': 'nvidia', 3 | 'soc': 'tegra20', 4 | } 5 | -------------------------------------------------------------------------------- /configs/seaboard.board: -------------------------------------------------------------------------------- 1 | board = { 2 | 'vendor': 'nvidia', 3 | 'soc': 'tegra20', 4 | } 5 | -------------------------------------------------------------------------------- /configs/venice2.board: -------------------------------------------------------------------------------- 1 | board = { 2 | 'vendor': 'nvidia', 3 | 'soc': 'tegra124', 4 | } 5 | -------------------------------------------------------------------------------- /configs/ventana.board: -------------------------------------------------------------------------------- 1 | board = { 2 | 'vendor': 'nvidia', 3 | 'soc': 'tegra20', 4 | } 5 | -------------------------------------------------------------------------------- /configs/jetson-tk1.board: -------------------------------------------------------------------------------- 1 | board = { 2 | 'vendor': 'nvidia', 3 | 'soc': 'tegra124', 4 | } 5 | -------------------------------------------------------------------------------- /configs/trimslice.board: -------------------------------------------------------------------------------- 1 | board = { 2 | 'vendor': 'compulab', 3 | 'soc': 'tegra20', 4 | } 5 | -------------------------------------------------------------------------------- /configs/norrin.board: -------------------------------------------------------------------------------- 1 | board = { 2 | 'vendor': 'nvidia', 3 | 'soc': 'tegra124', 4 | 'disabled': True, 5 | } 6 | -------------------------------------------------------------------------------- /configs/colibri_t20.board: -------------------------------------------------------------------------------- 1 | board = { 2 | 'vendor': 'toradex', 3 | 'soc': 'tegra20', 4 | 'disabled': True, 5 | } 6 | -------------------------------------------------------------------------------- /configs/colibri_t30.board: -------------------------------------------------------------------------------- 1 | board = { 2 | 'vendor': 'toradex', 3 | 'soc': 'tegra30', 4 | 'disabled': True, 5 | } 6 | -------------------------------------------------------------------------------- /configs/seaboard.config: -------------------------------------------------------------------------------- 1 | config = { 2 | 'bct': 'PM282_Hynix_1GB_H5PS2G83AFR-S6C_380MHz_nand.bct', 3 | 'board': 'seaboard', 4 | 'dtbfn-extra': '', 5 | 'flash-image': 'seaboard-nand.img', 6 | 'flash-type': 'nand', 7 | } 8 | -------------------------------------------------------------------------------- /configs/trimslice.config: -------------------------------------------------------------------------------- 1 | config = { 2 | 'bct': 'trimslice-spi.bct', 3 | 'board': 'trimslice', 4 | 'dtbfn-extra': '', 5 | 'flash-erase-size': 1048576, 6 | 'flash-image': 'trimslice-spi.img', 7 | 'flash-type': 'spi', 8 | } 9 | -------------------------------------------------------------------------------- /configs/harmony.config: -------------------------------------------------------------------------------- 1 | config = { 2 | 'bct': 'harmony_a02_12Mhz_H5PS1G83EFR-S6C_333Mhz_1GB_2K8Nand_HY27UF084G2B-TP.bct', 3 | 'board': 'harmony', 4 | 'dtbfn-extra': '', 5 | 'flash-image': 'harmony-nand.img', 6 | 'flash-type': 'nand', 7 | } 8 | -------------------------------------------------------------------------------- /configs/colibri_t20-256-hsmmc.config: -------------------------------------------------------------------------------- 1 | config = { 2 | 'bct': 'colibri_t20-256-hsmmc.bct', 3 | 'board': 'colibri_t20', 4 | 'dtbfn-extra': '', 5 | 'flash-id-uboot': 0, 6 | 'flash-image': 'colibri_t20-256-hsmmc.img', 7 | 'flash-type': 'emmc', 8 | } 9 | -------------------------------------------------------------------------------- /configs/colibri_t20-512-hsmmc.config: -------------------------------------------------------------------------------- 1 | config = { 2 | 'bct': 'colibri_t20-512-hsmmc.bct', 3 | 'board': 'colibri_t20', 4 | 'dtbfn-extra': '', 5 | 'flash-id-uboot': 0, 6 | 'flash-image': 'colibri_t20-512-hsmmc.img', 7 | 'flash-type': 'emmc', 8 | } 9 | -------------------------------------------------------------------------------- /configs/jetson-tk1.config: -------------------------------------------------------------------------------- 1 | config = { 2 | 'bct': 'PM375_Hynix_2GB_H5TC4G63AFR_RDA_924MHz.bct', 3 | 'board': 'jetson-tk1', 4 | 'dtbfn-extra': '', 5 | 'flash-id-uboot': 0, 6 | 'flash-image': 'jetson-tk1-emmc.img', 7 | 'flash-type': 'emmc', 8 | } 9 | -------------------------------------------------------------------------------- /configs/beaver.config: -------------------------------------------------------------------------------- 1 | config = { 2 | 'bct': 'Pm315_Hynix_2GB_H5TC4G83MFR-PBA_400MHz_120613_sdmmc4_x8.bct', 3 | 'board': 'beaver', 4 | 'dtbfn-extra': '', 5 | 'flash-id-uboot': 0, 6 | 'flash-image': 'beaver-emmc.img', 7 | 'flash-type': 'emmc', 8 | } 9 | -------------------------------------------------------------------------------- /configs/colibri_t20-256-v11-nand.config: -------------------------------------------------------------------------------- 1 | config = { 2 | 'bct': 'colibri_t20-256-v11-nand.bct', 3 | 'board': 'colibri_t20', 4 | 'dtbfn-extra': '', 5 | 'flash-id-uboot': 0, 6 | 'flash-image': 'colibri_t20-256-v11-nand.img', 7 | 'flash-type': 'nand', 8 | } 9 | -------------------------------------------------------------------------------- /configs/colibri_t20-256-v12-nand.config: -------------------------------------------------------------------------------- 1 | config = { 2 | 'bct': 'colibri_t20-256-v12-nand.bct', 3 | 'board': 'colibri_t20', 4 | 'dtbfn-extra': '', 5 | 'flash-id-uboot': 0, 6 | 'flash-image': 'colibri_t20-256-v12-nand.img', 7 | 'flash-type': 'nand', 8 | } 9 | -------------------------------------------------------------------------------- /configs/colibri_t20-512-v11-nand.config: -------------------------------------------------------------------------------- 1 | config = { 2 | 'bct': 'colibri_t20-512-v11-nand.bct', 3 | 'board': 'colibri_t20', 4 | 'dtbfn-extra': '', 5 | 'flash-id-uboot': 0, 6 | 'flash-image': 'colibri_t20-512-v11-nand.img', 7 | 'flash-type': 'nand', 8 | } 9 | -------------------------------------------------------------------------------- /configs/colibri_t20-512-v12-nand.config: -------------------------------------------------------------------------------- 1 | config = { 2 | 'bct': 'colibri_t20-512-v12-nand.bct', 3 | 'board': 'colibri_t20', 4 | 'dtbfn-extra': '', 5 | 'flash-id-uboot': 0, 6 | 'flash-image': 'colibri_t20-512-v12-nand.img', 7 | 'flash-type': 'nand', 8 | } 9 | -------------------------------------------------------------------------------- /configs/colibri_t30.config: -------------------------------------------------------------------------------- 1 | config = { 2 | 'bct': 'colibri_t30_12MHz_1GB_NT5CC256M16CP-DI_400MHz-shmoo.bct', 3 | 'board': 'colibri_t30', 4 | 'dtbfn-extra': '', 5 | 'flash-id-uboot': 0, 6 | 'flash-image': 'colibri_t30.img', 7 | 'flash-type': 'emmc', 8 | } 9 | -------------------------------------------------------------------------------- /configs/dalmore-t40s-1600.config: -------------------------------------------------------------------------------- 1 | config = { 2 | 'bct': 'E1611_Hynix_2GB_H5TC4G63MFR-PBA_792Mhz_r403_v05.bct', 3 | 'board': 'dalmore', 4 | 'dtbfn-extra': '', 5 | 'flash-id-uboot': 0, 6 | 'flash-image': 'dalmore-t40s-1600.img', 7 | 'flash-type': 'emmc', 8 | } 9 | -------------------------------------------------------------------------------- /configs/dalmore-t40s-1866.config: -------------------------------------------------------------------------------- 1 | config = { 2 | 'bct': 'E1611_Hynix_2GB_H5TC4G63AFR-RDA_792Mhz_r403_v2.bct', 3 | 'board': 'dalmore', 4 | 'dtbfn-extra': '', 5 | 'flash-id-uboot': 0, 6 | 'flash-image': 'dalmore-t40s-1866.img', 7 | 'flash-type': 'emmc', 8 | } 9 | -------------------------------------------------------------------------------- /configs/dalmore-t40x-1866.config: -------------------------------------------------------------------------------- 1 | config = { 2 | 'bct': 'E1611_Hynix_2GB_H5TC4G63AFR-RDA_792MHz_r403_v03.bct', 3 | 'board': 'dalmore', 4 | 'dtbfn-extra': '', 5 | 'flash-id-uboot': 0, 6 | 'flash-image': 'dalmore-t40x-1866.img', 7 | 'flash-type': 'emmc', 8 | } 9 | -------------------------------------------------------------------------------- /configs/ventana.config: -------------------------------------------------------------------------------- 1 | config = { 2 | 'bct': 'ventana_A03_12MHz_EDB8132B1PB6DF_300Mhz_1GB_emmc_THGBM1G6D4EBAI4.bct', 3 | 'board': 'ventana', 4 | 'dtbfn-extra': '', 5 | 'flash-id-uboot': 0, 6 | 'flash-image': 'ventana-emmc.img', 7 | 'flash-type': 'emmc', 8 | } 9 | -------------------------------------------------------------------------------- /configs/cardhu-a02-1gb.config: -------------------------------------------------------------------------------- 1 | config = { 2 | 'bct': 'E1186_Hynix_1GB_H5TC2G83BFR-PBA_375MHz_111114_317_sdmmc4_x8.bct', 3 | 'board': 'cardhu', 4 | 'dtbfn-extra': '-a02', 5 | 'flash-id-uboot': 0, 6 | 'flash-image': 'cardhu-a02-a04-1gb-emmc.img', 7 | 'flash-type': 'emmc', 8 | } 9 | -------------------------------------------------------------------------------- /configs/cardhu-a04-1gb.config: -------------------------------------------------------------------------------- 1 | config = { 2 | 'bct': 'E1186_Hynix_1GB_H5TC2G83BFR-PBA_375MHz_111114_317_sdmmc4_x8.bct', 3 | 'board': 'cardhu', 4 | 'dtbfn-extra': '-a04', 5 | 'flash-id-uboot': 0, 6 | 'flash-image': 'cardhu-a02-a04-1gb-emmc.img', 7 | 'flash-type': 'emmc', 8 | } 9 | -------------------------------------------------------------------------------- /configs/norrin.config: -------------------------------------------------------------------------------- 1 | config = { 2 | 'bct': 'PM370_Hynix_2GB_H5TC4G63AFR_PBA_924MHz_01212014.bct', 3 | 'board': 'norrin', 4 | 'dtbfn-extra': '', 5 | 'flash-erase-size': 1048576, 6 | 'flash-image': 'norrin-spi.img', 7 | 'flash-type': 'spi', 8 | 'flash-id-uboot': '1:0', 9 | } 10 | -------------------------------------------------------------------------------- /configs/venice2.config: -------------------------------------------------------------------------------- 1 | config = { 2 | 'bct': 'PM371_Hynix_2GB_H5TC4G63AFR_RDA_792MHz_0719.bct', 3 | 'board': 'venice2', 4 | 'dtbfn-extra': '', 5 | 'flash-erase-size': 1048576, 6 | 'flash-image': 'venice2-spi.img', 7 | 'flash-type': 'spi', 8 | 'flash-id-uboot': '1:0', 9 | } 10 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | Introduction 2 | ============ 3 | 4 | If you want to download the source to this tool and compile it, or submit 5 | changes to this tool, see README-developer.txt. 6 | 7 | If you want to use this tool either after having compiled it yourself, or 8 | after having received a pre-compiled version from someone else (e.g. a 9 | distribution packager), see README-user.txt 10 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Unless explicitly stated in the file, the following copyright and license 2 | applies to all files in this project: 3 | 4 | # Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved. 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a 7 | # copy of this software and associated documentation files (the "Software"), 8 | # to deal in the Software without restriction, including without limitation 9 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | # and/or sell copies of the Software, and to permit persons to whom the 11 | # Software is furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in 14 | # all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 | # DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /elf-get-entry: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | # Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved. 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a 6 | # copy of this software and associated documentation files (the "Software"), 7 | # to deal in the Software without restriction, including without limitation 8 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | # and/or sell copies of the Software, and to permit persons to whom the 10 | # Software is furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | # DEALINGS IN THE SOFTWARE. 22 | 23 | import sys 24 | import struct 25 | 26 | if len(sys.argv) != 2: 27 | print >>sys.stderr, "usage: %s filename.elf" % sys.argv[0] 28 | sys.exit(-1) 29 | 30 | f = file(sys.argv[1], 'rb') 31 | data = f.read(0x20) 32 | f.close() 33 | 34 | if data[0:4] != '\x7fELF': 35 | print >>sys.stderr, "ELF magic mismatch" 36 | sys.exit(-1) 37 | 38 | ei_class = ord(data[4]) 39 | if ei_class == 1: 40 | elf_bytes = 4 41 | struct_type = 'I' 42 | elif ei_class == 2: 43 | elf_bytes = 8 44 | struct_type = 'Q' 45 | else: 46 | print >>sys.stderr, "Bad EI_CLASS value" 47 | sys.exit(-1) 48 | 49 | ei_data = ord(data[5]) 50 | if ei_data == 1: 51 | struct_endian = '<' 52 | elif ei_data == 2: 53 | struct_endian = '>' 54 | else: 55 | print >>sys.stderr, "Bad EI_DATA value" 56 | sys.exit(-1) 57 | 58 | ei_version = ord(data[6]) 59 | if ei_version != 1: 60 | print >>sys.stderr, "Bad EI_VERSION value" 61 | sys.exit(-1) 62 | 63 | e_entry = data[0x18:0x18 + elf_bytes] 64 | ep = struct.unpack(struct_endian + struct_type, e_entry) 65 | print '0x%x' % ep 66 | -------------------------------------------------------------------------------- /tegraboardconfigs.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the "Software"), 5 | # to deal in the Software without restriction, including without limitation 6 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | # and/or sell copies of the Software, and to permit persons to whom the 8 | # Software is furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | # DEALINGS IN THE SOFTWARE. 20 | 21 | import os 22 | 23 | debug = False 24 | 25 | socs = {} 26 | boards = {} 27 | configs = {} 28 | 29 | def _load_something(path, filetype, name, saveindict): 30 | fn = os.path.join(path, name + '.' + filetype) 31 | d = {} 32 | execfile(fn, globals(), d) 33 | saveindict[name] = d[filetype] 34 | 35 | def _load_soc(path, socname): 36 | if socs.has_key(socname): 37 | return 38 | if debug: print 'load soc', socname 39 | _load_something(path, 'soc', socname, socs) 40 | 41 | def _load_board(path, boardname): 42 | if boards.has_key(boardname): 43 | return 44 | if debug: print 'load board', boardname 45 | _load_something(path, 'board', boardname, boards) 46 | _load_soc(path, boards[boardname]['soc']) 47 | 48 | def _load_config(path, configname): 49 | if configs.has_key(configname): 50 | return 51 | if debug: print 'load config', configname 52 | _load_something(path, 'config', configname, configs) 53 | _load_board(path, configs[configname]['board']) 54 | 55 | def load_configs(path): 56 | fns = os.listdir(path) 57 | for fn in fns: 58 | if not fn.endswith('.config'): 59 | continue 60 | cfgname = fn[:-7] 61 | _load_config(path, cfgname) 62 | 63 | if __name__ == '__main__': 64 | debug = True 65 | load_configs('configs') 66 | print 67 | print socs 68 | print 69 | print boards 70 | print 71 | print configs 72 | -------------------------------------------------------------------------------- /README-user.txt: -------------------------------------------------------------------------------- 1 | Introduction 2 | ============ 3 | 4 | This project provides scripts and data that provide a simple way of using 5 | tegrarcm and U-Boot to write U-Boot (or an alternative image) to the boot 6 | flash of a Tegra device. 7 | 8 | The flash images handled by this tool include just the bootloader and any 9 | other data necessary for the bootloader to execute (i.e. the BCT). Creating or 10 | flashing a root filesystem, either on the Tegra device's built-in flash, or on 11 | external storage media, is a separate step unrelated to this tool. 12 | 13 | Pre-requisites 14 | ============== 15 | 16 | This document assumes that the instructions in README-developer.txt have 17 | already been followed. Those instructions generate various files that the 18 | flashing process uses. These include host-based utilities such as tegrarcm, 19 | U-Boot binaries that run on the Tegra target device, and the flash images to 20 | write to the Tegra device. 21 | 22 | If you are using a distribution package of this tool, the development steps 23 | have likely already been followed, and you need only follow the instructions 24 | in this file. 25 | 26 | If you are working with the source code to this tool, you almost certainly 27 | need to follow the instructions in README-developer.txt first. 28 | 29 | Board Configurations 30 | ==================== 31 | 32 | Every Tegra board design has a name. Examples are Harmony or Cardhu. 33 | 34 | Each board may exist in a number of different configurations; perhaps the 35 | RAM size or speed varies, or a different type of boot flash is supported. 36 | Each of these configurations is also given a name. tegra-uboot-flasher's 37 | user-interface uses these configuration names exclusively. Examples are 38 | harmony, cardhu-a02-1gb, cardhu-a04-1gb. 39 | 40 | You may find a list of valid values for configname by executing: 41 | 42 | tegra-uboot-flasher list-configs 43 | 44 | Simple Usage - Flashing 45 | ======================= 46 | 47 | To flash a board, connect a USB cable from your host PC to the Tegra device, 48 | place that board into USB recovery mode, and execute the following as root 49 | on the host machine: 50 | 51 | tegra-uboot-flasher flash CONFIG 52 | 53 | This will download code and data to the Tegra device and execute a flashing 54 | routine. Once this is complete, the system will reboot into the freshly 55 | flashed boot image, and the system will proceed to boot normally. Depending 56 | on the board and U-Boot support, the flashing process may be observed via the 57 | debug serial port, or on a built-in LCD panel. 58 | 59 | Simple Usage - Testing U-Boot 60 | ============================= 61 | 62 | If you simply want to download an unmodified U-Boot to the Tegra device and 63 | execute it, execute the following as root on the host machine: 64 | 65 | tegra-uboot-flasher exec CONFIG 66 | 67 | This can be useful for quickly testing changes to U-Boot without writing it 68 | to flash every time. This mode of operation is a very simple wrapper around 69 | tegrarcm, which eliminates the need to remember which BCT to use for each 70 | board configuration. 71 | 72 | Advanced Options 73 | ================ 74 | 75 | A number of command-line options exist to control tegra-uboot-flasher's 76 | behaviour. For example, you may specify an alternate image to be written 77 | to boot flash, load configuration data from an alternate location, save 78 | the temporary files created during execution for later analysis, etc. 79 | Execute tegra-uboot-flasher with the --help option to see a description 80 | of these options. 81 | -------------------------------------------------------------------------------- /README-developer.txt: -------------------------------------------------------------------------------- 1 | Introduction 2 | ============ 3 | 4 | This project provides scripts and data that provide a simple way of using 5 | tegrarcm and U-Boot to write U-Boot (or an alternative image) to the boot 6 | flash of a Tegra device. 7 | 8 | This project relies on source and data provided by various other projects. 9 | 10 | cbootimage - Creates Tegra flash images. 11 | cbootimage-configs - Board-specific data for cbootimage. 12 | tegrarcm - Communicates with Tegra boot ROM over USB. 13 | dtc - Compiles device tree files, and provides utilities 14 | to manipulate device trees. 15 | U-Boot - A bootloader. Used to write to Tegra's boot flash, 16 | and is typically written to the boot flash. 17 | 18 | cbootimage, tegrarcm, and dtc are simply utilities used by this project. If 19 | your distro packages up-to-date versions of these tools, then they may be 20 | installed and used. However, this is often not the case, so a script 21 | named "build-tools" has been provided, which will build those tools and place 22 | them into a directory that the other scripts add to their $PATH. 23 | 24 | cbootimage-configs and U-Boot are actively used by the "build" script, and 25 | hence must always be available. 26 | 27 | For more details how these tools fit together, see the documentation at: 28 | 29 | ftp://download.nvidia.com/tegra-public-appnotes/index.html 30 | 31 | Obtaining the Source 32 | ==================== 33 | 34 | You are expected to use Google's repo tool to obtain the source. 35 | 36 | For more information about repo, see: 37 | 38 | http://code.google.com/p/git-repo/ 39 | 40 | To obtain repo, do the following in a directory in your $PATH: 41 | 42 | curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > repo 43 | chmod a+x repo 44 | 45 | To obtain the source of the tegra-uboot-flasher project, do: 46 | 47 | mkdir tegra-uboot-flasher 48 | cd tegra-uboot-flasher 49 | repo init -u git://github.com/NVIDIA/tegra-uboot-flasher-manifests.git 50 | repo sync 51 | 52 | The manifest includes the source to potentially distro-packaged utilities 53 | such as cbootimage and tegrarcm, and U-Boot itself. If you already have the 54 | pre-requisite tools installed, you may not want to download their source. 55 | Similarly, if you already build U-Boot yourself, you may not want another 56 | copy of the U-Boot source tree. You can request that repo not download 57 | those source trees using the -g option to repo init. For example: 58 | 59 | # Exclude just the pre-requisite tools: 60 | repo init -u ... -g default,-notools 61 | 62 | # Only include the bare minimum 63 | repo init -u ... -g default,-notools,-bootloader 64 | 65 | Submitting Changes 66 | ================== 67 | 68 | To submit patches to this project, please use the following commands: 69 | 70 | * git format-patch --subject-prefix="flasher scripts PATCH" 71 | 72 | Creates a patch file from your git commit. 73 | 74 | * git send-email --to linux-tegra@vger.kernel.org *.patch 75 | 76 | Sends the patch by email to the Tegra mailing list. 77 | 78 | Even though the primary upstream repository for this project is hosted on 79 | github, contributions aren't accepted via github pull requests. Github pull 80 | requests would bypass public code review on the project mailing list. 81 | 82 | Patches should be signed off (include a signed-off-by line) to indicate your 83 | acceptance of the code's license (see COPYING and the license header in each 84 | file). See http://developercertificate.org/ for details of what signed-off-by 85 | implies. 86 | 87 | Pre-requisites 88 | ============== 89 | 90 | A number of common tools and libraries required to build tegra-uboot-flasher. 91 | Typically, these will be provided by standard distribution packages. 92 | 93 | For recent Debian-/Ubuntu-based distributions, the following list of packages 94 | will be useful: 95 | 96 | build-essential 97 | autoconf 98 | automake 99 | libtool 100 | libusb-1.0-0-dev 101 | libcrypto++-dev 102 | 103 | Packages with similar names likely exist for other distributions too. 104 | 105 | Note: tegrarcm depends on libusb-1.0. On at least current Debian-/Ubuntu-based 106 | distributions, the default/unversioned libusb package installed contains 107 | libusb-0.1. Make sure that libusb-1.0 is installed by using the explicit 108 | versioned package name specified above. 109 | 110 | Compiling Potentially Packaged Utilities 111 | ======================================== 112 | 113 | If you have installed distro packages for the utilities mentioned above, 114 | and/or sync'd the default-notools.xml manifest, skip this step. 115 | 116 | cd to the scripts sub-directory (i.e. the directory containing this README), 117 | and execute: 118 | 119 | ./build-tools 120 | 121 | Creating Flash Images 122 | ===================== 123 | 124 | This step creates the target binaries and supporting data files necessary to 125 | run the tegra-uboot-flasher script. You will always need to perform this step. 126 | 127 | You will need an ARM cross-compiler in order to compile U-Boot. This may be 128 | obtained from a distribution package, or be a custom-built toolchain. The 129 | environment variable CROSS_COMPILE should be set to select the compiler to 130 | use. CROSS_COMPILE should contain the common prefix of all the binaries in 131 | the cross-compiler, for example if gcc is arm-linux-gnueabi-gcc, then 132 | CROSS_COMPILE should be set to arm-linux-gnueabi-, or 133 | /path/to/arm-linux-gnueabi-. If this variable is not set, then the build 134 | script assumes a value of arm-linux-gnueabi-. 135 | 136 | cd to the scripts sub-directory (i.e. the directory containing this README), 137 | and execute: 138 | 139 | ./build build 140 | 141 | Flashing Devices 142 | ================ 143 | 144 | If you wish, you may run the tegra-uboot-flasher script directly from the 145 | source tree. The script will automatically find the build results generated 146 | in the previous step. For details on running this script, please see 147 | README-user.txt in this directory. 148 | 149 | Packaging the Build Results 150 | =========================== 151 | 152 | The build script generates the directory tree ../_out. this contains all data 153 | required by the tegra-uboot-flasher script. The content of this directory 154 | should be installed into /usr/share/tegra_uboot_flasher. 155 | 156 | The tegra-uboot-flasher script itself should be installed somewhere in $PATH. 157 | 158 | The Python module tegraboardconfigs.py should be installed somewhere that 159 | Python can locate it. 160 | -------------------------------------------------------------------------------- /tegra-uboot-flasher: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | # Copyright (c) 2013-2015 NVIDIA CORPORATION. All rights reserved. 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a 6 | # copy of this software and associated documentation files (the "Software"), 7 | # to deal in the Software without restriction, including without limitation 8 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | # and/or sell copies of the Software, and to permit persons to whom the 10 | # Software is furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | # DEALINGS IN THE SOFTWARE. 22 | 23 | import argparse 24 | import binascii 25 | import os 26 | import os.path 27 | import shutil 28 | import stat 29 | import subprocess 30 | import sys 31 | import tempfile 32 | from tegraboardconfigs import * 33 | 34 | def mkdir(path): 35 | if not os.path.isdir(path): 36 | os.makedirs(path) 37 | 38 | def cp(src, dst): 39 | print '+ cp', src, dst 40 | shutil.copy(src, dst) 41 | 42 | def rmtree(path): 43 | if os.path.exists(path): 44 | shutil.rmtree(path) 45 | 46 | def run(cd, cmd): 47 | print '+ cd', cd 48 | print '+', ' '.join(cmd) 49 | subprocess.check_call(cmd, cwd=cd) 50 | 51 | def gen_flashcmd_mmc(flash_image_addr, readback_addr, flash_img_size): 52 | flash_id = config['flash-id-uboot'] 53 | flash_img_size_sectors = flash_img_size / 512 54 | flashcmd = 'echo >>> Selecting MMC device... ; ' 55 | flashcmd += 'mmc dev %d 1 ; ' % flash_id 56 | flashcmd += 'echo >>> Writing image to MMC... ; ' 57 | flashcmd += 'mmc write 0x%08x 0 0x%x ; ' % (flash_image_addr, flash_img_size_sectors) 58 | flashcmd += 'echo >>> Reading image back from MMC... ; ' 59 | flashcmd += 'mmc read 0x%08x 0 0x%x ; ' % (readback_addr, flash_img_size_sectors) 60 | return flashcmd 61 | 62 | def gen_flashcmd_nand(flash_image_addr, readback_addr, flash_img_size): 63 | flashcmd = 'echo >>> Erasing NAND... ; ' 64 | flashcmd += 'nand erase.chip ; ' 65 | flashcmd += 'echo >>> Writing image to NAND... ; ' 66 | flashcmd += 'nand write 0x%08x 0 0x%08x ; ' % (flash_image_addr, flash_img_size) 67 | flashcmd += 'echo >>> Reading image back from NAND... ; ' 68 | flashcmd += 'nand read 0x%08x 0 0x%08x ; ' % (readback_addr, flash_img_size) 69 | return flashcmd 70 | 71 | def gen_flashcmd_spi(flash_image_addr, readback_addr, flash_img_size): 72 | flash_id = config.get('flash-id-uboot', '0') 73 | flashcmd = 'echo >>> Selecting SPI device... ; ' 74 | flashcmd += 'sf probe %s ; ' % flash_id 75 | flashcmd += 'echo >>> Erasing SPI... ; ' 76 | flashcmd += 'sf erase 0 0x%08x ; ' % config['flash-erase-size'] 77 | flashcmd += 'echo >>> Writing image back to SPI... ; ' 78 | flashcmd += 'sf write 0x%08x 0 0x%08x ; ' % (flash_image_addr, flash_img_size) 79 | flashcmd += 'echo >>> Reading image back from SPI... ; ' 80 | flashcmd += 'sf read 0x%08x 0 0x%08x ; ' % (readback_addr, flash_img_size) 81 | return flashcmd 82 | 83 | gen_flashcmds = { 84 | 'emmc': gen_flashcmd_mmc, 85 | 'nand': gen_flashcmd_nand, 86 | 'spi': gen_flashcmd_spi, 87 | } 88 | 89 | def get_loadaddr(): 90 | spl_entry_fn = os.path.join(out_board_dir, 'u-boot-spl-entry') 91 | with open(spl_entry_fn, 'rt') as spl_entry_f: 92 | spl_entry_s = spl_entry_f.read().strip() 93 | spl_entry = int(spl_entry_s, 0) 94 | if args.debug: 95 | print 'spl_entry %d 0x%x' % (spl_entry, spl_entry) 96 | return spl_entry 97 | 98 | def gen_tegrarcm_cmd(bootloader, loadaddr): 99 | if type(loadaddr) != str: 100 | loadaddr = "0x%08x" % loadaddr 101 | cmd = ['tegrarcm', '--bct=' + bct, '--bootloader=' + bootloader , '--loadaddr=' + loadaddr] 102 | if args.usb_port_path: 103 | cmd.extend(['--usb-port-path', args.usb_port_path]) 104 | return cmd 105 | 106 | def find_config_dir(): 107 | if not configs.has_key(args.configname): 108 | print 'Unknown config "%s"' % args.configname 109 | sys.exit(1) 110 | 111 | global config, boardname, board, socname, soc, out_board_dir, bct 112 | 113 | config = configs[args.configname] 114 | boardname = config['board'] 115 | board = boards[boardname] 116 | socname = board['soc'] 117 | soc = socs[socname] 118 | out_board_dir = os.path.join(args.data_dir, boardname) 119 | bct = os.path.join(out_board_dir, config['bct']) 120 | 121 | def func_list_configs(): 122 | for configname in sorted(configs.keys()): 123 | print configname 124 | 125 | def func_flash(): 126 | find_config_dir() 127 | 128 | u_boot_no_dtb = os.path.join(out_board_dir, 'u-boot-nodtb-tegra.bin') 129 | u_boot_no_dtb_size = os.path.getsize(u_boot_no_dtb) 130 | if args.debug: 131 | print 'u_boot_no_dtb_size %d 0x%x' % (u_boot_no_dtb_size, u_boot_no_dtb_size) 132 | 133 | u_boot_dtb = os.path.join(out_board_dir, 'u-boot.dtb') 134 | u_boot_dtb_size = os.path.getsize(u_boot_dtb) 135 | if args.debug: 136 | print 'u_boot_dtb_size %d 0x%x' % (u_boot_dtb_size, u_boot_dtb_size) 137 | 138 | if args.flash_image: 139 | flash_img = args.flash_image 140 | else: 141 | flash_img = os.path.join(out_board_dir, config['flash-image']) 142 | flash_img_size = os.path.getsize(flash_img) 143 | if args.debug: 144 | print 'flash_img_size %d 0x%x' % (flash_img_size, flash_img_size) 145 | 146 | imgf = file(flash_img, 'rb') 147 | imgd = imgf.read() 148 | imgf.close() 149 | flash_img_crc32 = binascii.crc32(imgd) 150 | if args.debug: 151 | print 'flash_img_crc32 %x' % flash_img_crc32 152 | flash_img_crc32_bs = ( 153 | ((flash_img_crc32 & 0xff) << 24) | 154 | ((flash_img_crc32 & 0xff00) << 8) | 155 | ((flash_img_crc32 & 0xff0000) >> 8) | 156 | ((flash_img_crc32 & 0xff000000) >> 24) 157 | ) 158 | 159 | u_boot_plus_dtb_size = u_boot_no_dtb_size + u_boot_dtb_size 160 | if args.debug: 161 | print 'u_boot_plus_dtb_size %d 0x%x' % (u_boot_plus_dtb_size, u_boot_plus_dtb_size) 162 | 163 | bss_size_fn = os.path.join(out_board_dir, 'u-boot-bss-size') 164 | bss_size_f = open(bss_size_fn, 'rt') 165 | bss_size_s = bss_size_f.read() 166 | bss_size_f.close() 167 | bss_size = int(bss_size_s) 168 | if args.debug: 169 | print 'bss_size %d 0x%x' % (bss_size, bss_size) 170 | 171 | # Avoid U-Boot's BSS, so the BSS-zeroing doesn't trash the appended flash image 172 | # Add 4KB in case the DTB size changes due to fdtput 173 | # Align to 4k, so flash writes don't need a bounce buffer for DMA 174 | padded_size = (u_boot_plus_dtb_size + bss_size + (2 * 4 * 1024) - 1) & ~((4 * 1024) - 1) 175 | if args.debug: 176 | print 'padded_size %d 0x%x' % (padded_size, padded_size) 177 | 178 | pad_size = padded_size - u_boot_plus_dtb_size 179 | if args.debug: 180 | print 'pad_size %d 0x%x' % (pad_size, pad_size) 181 | 182 | loadaddr = get_loadaddr() 183 | flash_image_addr = loadaddr + padded_size 184 | if args.debug: 185 | print 'flash_image_addr %d 0x%x' % (flash_image_addr, flash_image_addr) 186 | readback_addr = flash_image_addr + flash_img_size 187 | if args.debug: 188 | print 'readback_addr %d 0x%x' % (readback_addr, readback_addr) 189 | 190 | flash_type = config['flash-type'] 191 | if not gen_flashcmds.has_key(flash_type): 192 | print 'flash-type "%s" not yet supported' % flash_type 193 | sys.exit(1) 194 | gen_flashcmd = gen_flashcmds[flash_type] 195 | 196 | if args.work_dir: 197 | mkdir(workdir) 198 | else: 199 | workdir = tempfile.mkdtemp() 200 | try: 201 | u_boot_dtb_runflash = os.path.join(workdir, 'u-boot-runflash.dtb') 202 | cp(u_boot_dtb, u_boot_dtb_runflash) 203 | 204 | # 0xfffffffe==-2; never delay or interrupt 205 | cmd = ['fdtput', '-p', '-t', 'x', u_boot_dtb_runflash, '/config', 'bootdelay', '0xfffffffe'] 206 | run(workdir, cmd) 207 | 208 | crc_addr = soc['ram-base'] + 4 209 | bootcmd = '' 210 | bootcmd += 'echo >>> Verifying image in RAM... ; ' 211 | bootcmd += 'crc32 0x%08x 0x%08x 0x%08x ; ' % (flash_image_addr, flash_img_size, crc_addr) 212 | bootcmd += 'if itest.l *0x%08x != 0x%x; then echo CRC MISMATCH of initial image; exit; fi ; ' % (crc_addr, flash_img_crc32_bs) 213 | bootcmd += gen_flashcmd(flash_image_addr, readback_addr, flash_img_size) 214 | bootcmd += 'echo >>> Verifying image from flash... ; ' 215 | bootcmd += 'crc32 0x%08x 0x%08x 0x%08x ; ' % (readback_addr, flash_img_size, crc_addr) 216 | bootcmd += 'if itest.l *0x%08x != 0x%x; then echo CRC MISMATCH of readback image; exit; fi ; ' % (crc_addr, flash_img_crc32_bs) 217 | bootcmd += 'echo >>> Setting up environment... ; ' 218 | bootcmd += 'env default -f -a ; ' 219 | # Perhaps U-Boot should set $boardname based on the ID EEPROM; then we wouldn't need this 220 | if config['dtbfn-extra'] != '': 221 | bootcmd += 'setenv board ' + boardname + config['dtbfn-extra'] + ' ; ' 222 | if args.env: 223 | for (var, value) in args.env: 224 | bootcmd += 'setenv %s \'%s\' ; ' % (var, value) 225 | bootcmd += 'saveenv ; ' 226 | bootcmd += 'echo >>> Flashing OK, rebooting... ; ' 227 | # To update the bootloader, reset. 228 | # If wanting to run installer, set installer_args.configname in environment, 'run bootcmd' 229 | if args.post_flash_cmd: 230 | bootcmd += args.post_flash_cmd 231 | else: 232 | bootcmd += 'reset' 233 | print 'bootcmd:', bootcmd 234 | cmd = ['fdtput', '-p', '-t', 's', u_boot_dtb_runflash, '/config', 'bootcmd', bootcmd] 235 | run(workdir, cmd) 236 | 237 | u_boot_dtb_runflash_size = os.path.getsize(u_boot_dtb_runflash) 238 | if args.debug: 239 | print 'u_boot_dtb_runflash_size %d 0x%x' % (u_boot_dtb_runflash_size, u_boot_dtb_runflash_size) 240 | pad_size -= (u_boot_dtb_runflash_size - u_boot_dtb_size) 241 | if args.debug: 242 | print 'pad_size %d 0x%x' % (pad_size, pad_size) 243 | 244 | uboot_flasher = os.path.join(workdir, 'u-boot-flasher.bin') 245 | f = open(uboot_flasher, 'wb') 246 | shutil.copyfileobj(open(u_boot_no_dtb, 'rb'), f) 247 | shutil.copyfileobj(open(u_boot_dtb_runflash, 'rb'), f) 248 | f.write(chr(0) * pad_size) 249 | shutil.copyfileobj(open(flash_img, 'rb'), f) 250 | f.close() 251 | 252 | cmd = gen_tegrarcm_cmd(uboot_flasher, loadaddr) 253 | 254 | flasher_sh = os.path.join(workdir, 'flasher.sh') 255 | f = open(flasher_sh, 'wt') 256 | os.fchmod(f.fileno(), stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) 257 | f.write("#!/bin/sh\n") 258 | f.write("\n") 259 | f.write(' '.join(cmd)) 260 | f.write("\n") 261 | f.close() 262 | 263 | if not args.gen_only: 264 | run(workdir, [flasher_sh]) 265 | except: 266 | raise 267 | finally: 268 | if args.save_work_dir: 269 | print 'Not removing work directory:', workdir 270 | else: 271 | rmtree(workdir) 272 | 273 | def func_exec(): 274 | find_config_dir() 275 | 276 | if args.bootloader: 277 | bootloader = args.bootloader 278 | else: 279 | bootloader = os.path.join(out_board_dir, 'u-boot-dtb-tegra.bin') 280 | 281 | if args.loadaddr: 282 | loadaddr = args.loadaddr 283 | else: 284 | loadaddr = get_loadaddr() 285 | 286 | cmd = gen_tegrarcm_cmd(bootloader, loadaddr) 287 | run(scripts_dir, cmd) 288 | 289 | parser = argparse.ArgumentParser(description='Execute a bootloader on a ' + 290 | 'Tegra board, possibly modifying it prior to download so as to execute ' + 291 | 'commands, such as writing an image to flash.') 292 | 293 | parser.add_argument('--debug', action='store_true', 294 | help='Turn on debugging prints') 295 | parser.add_argument('--data-dir', type=str, 296 | help='The directory containing board data') 297 | parser.add_argument('--force-no-out-dir', action='store_true', 298 | help='Don\'t check for ../_out* directories used in source tree') 299 | 300 | subparsers = parser.add_subparsers() 301 | 302 | parser_list_configs = subparsers.add_parser('list-configs', 303 | help='List known board configurations') 304 | parser_list_configs.set_defaults(func = func_list_configs) 305 | 306 | parser_flash = subparsers.add_parser('flash', 307 | help='Write an image, usually U-Boot itself, to flash on the device') 308 | parser_flash.set_defaults(func = func_flash) 309 | parser_flash.add_argument('--work-dir', type=str, 310 | help='The temporary directory used during operation') 311 | parser_flash.add_argument('--save-work-dir', action='store_true', 312 | help='Don\'t delete the work-dir after execution') 313 | parser_flash.add_argument('--flash-image', type=str, 314 | help='The flash image to write, instead of U-Boot itself') 315 | parser_flash.add_argument('--gen-only', action='store_true', 316 | help='Just create the work-dir; don\'t actually flash the image') 317 | parser_flash.add_argument('--env', type=str, nargs=2, action='append', 318 | metavar=("VAR", "VALUE"), 319 | help='Set a U-Boot environment variable after flashing. This option ' + 320 | 'may be given multiple times') 321 | parser_flash.add_argument('--post-flash-cmd', type=str, 322 | help='The U-Boot command to run after flashing, defaults to \'reset\'') 323 | 324 | parser_exec = subparsers.add_parser('exec', 325 | help='Download and execute an unmodified bootloader binary, named ' + 326 | 'u-boot-dtb-tegra.bin by default. This can be useful to simply test ' + 327 | 'a U-Boot build without flashing it, or to download something other ' + 328 | 'than U-Boot') 329 | parser_exec.set_defaults(func = func_exec) 330 | parser_exec.add_argument('--bootloader', type=str, 331 | help='The bootloader to download. Defaults to u-boot-dtb-tegra.bin in ' + 332 | 'the data directory') 333 | parser_exec.add_argument('--loadaddr', type=str, 334 | help='Load address for the bootloader binary') 335 | 336 | for p in (parser_flash, parser_exec): 337 | p.add_argument('--usb-port-path', metavar='USBPORTPATH', type=str, 338 | help='The USB port path of the Tegra device') 339 | p.add_argument('configname', metavar='CONFIG', type=str, 340 | help='The configuration name of the board') 341 | 342 | args = parser.parse_args() 343 | if args.debug: print args 344 | 345 | scripts_dir = os.path.dirname(os.path.abspath(__file__)) 346 | scripts_parent_dir = os.path.dirname(scripts_dir) 347 | 348 | path_args = ( 349 | 'bootloader', 350 | 'data_dir', 351 | 'flash_image', 352 | 'work_dir', 353 | ) 354 | for path_arg in path_args: 355 | if args.__dict__.has_key(path_arg) and args.__dict__[path_arg]: 356 | args.__dict__[path_arg] = os.path.abspath(args.__dict__[path_arg]) 357 | 358 | if not args.force_no_out_dir: 359 | out_tools_dir = os.path.join(scripts_parent_dir, '_out_tools') 360 | if os.path.exists(out_tools_dir): 361 | if args.debug: print 'Detected build tree; adding ' + out_tools_dir + ' to $PATH' 362 | os.environ['PATH'] = out_tools_dir + ':' + os.environ['PATH'] 363 | 364 | if not args.data_dir and not args.force_no_out_dir: 365 | out_data_dir = os.path.join(scripts_parent_dir, '_out') 366 | if os.path.exists(out_data_dir): 367 | if args.debug: print 'Detected build tree; using ' + out_data_dir + ' as data dir' 368 | args.data_dir = out_data_dir 369 | if not args.data_dir: 370 | args.data_dir = '/usr/share/tegra_uboot_flasher' 371 | 372 | load_configs(os.path.join(args.data_dir, 'configs')) 373 | 374 | args.func() 375 | --------------------------------------------------------------------------------