示例#1
0
    def link(self, arguments, inf, local_external_setting, variant):
        # Run the linker
        base.ToolChain.link(self, arguments, inf, local_external_setting,
                            variant)

        # switch to the build variant output directory
        vardir = '_' + self._bld
        utils.push_dir(vardir)

        # Output Banner message
        self._printer.output("= Creating EEPROM (eep) file ...")

        # construct objcopy command
        options = '-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0'
        objcpy = '{} {} {} {}'.format(self._objcpy, options,
                                      self._final_output_name + '.elf',
                                      self._final_output_name + '.eep')

        # Generate the .HEX file
        if (arguments['-v']):
            self._printer.output(objcpy)
        if (utils.run_shell(self._printer, objcpy)):
            self._printer.output("=")
            self._printer.output(
                "= Build Failed: Failed to create .EEP file from the .ELF")
            self._printer.output("=")
            sys.exit(1)

        # Output Banner message
        self._printer.output("= Creating HEX file ...")

        # construct objcopy command
        options = '-O ihex -R .eeprom'
        objcpy = '{} {} {} {}'.format(self._objcpy, options,
                                      self._final_output_name + '.elf',
                                      self._final_output_name + '.hex')

        # Generate the .HEX file
        if (arguments['-v']):
            self._printer.output(objcpy)
        if (utils.run_shell(self._printer, objcpy)):
            self._printer.output("=")
            self._printer.output(
                "= Build Failed: Failed to create .HEX file from the .ELF")
            self._printer.output("=")
            sys.exit(1)

        # Return to project dir
        utils.pop_dir()
    def link(self, arguments, inf, local_external_setting, variant):
        # Run the linker
        base.ToolChain.link(self, arguments, inf, local_external_setting,
                            variant)

        # switch to the build variant output directory
        vardir = '_' + self._bld
        utils.push_dir(vardir)

        # Output Banner message
        self._printer.output("= Creating HEX file ...")

        # construct objcopy command
        options = '-O ihex '
        objcpy = '{} {} {} {}'.format(self._objcpy, options,
                                      self._final_output_name + '.elf',
                                      self._final_output_name + '.hex')

        # Generate the .HEX file
        if (arguments['-v']):
            self._printer.output(objcpy)
        if (utils.run_shell(self._printer, objcpy)):
            self._printer.output("=")
            self._printer.output(
                "= Build Failed: Failed to create .HEX file from the .ELF")
            self._printer.output("=")
            sys.exit(1)

        # Output Banner message
        self._printer.output("= Creating the download (.ZIP) file ...")

        # construct zip command
        options = 'dfu genpkg --dev-type 0x0052 --application'
        nrfutil = '{} {} {} {}'.format(self._nrfutil, options,
                                       self._final_output_name + '.hex',
                                       self._final_output_name + '.zip')

        # Generate the download file (aka the ZIP file)
        if (arguments['-v']):
            self._printer.output(nrfutil)
        if (utils.run_shell(self._printer, nrfutil)):
            self._printer.output("=")
            self._printer.output(
                "= Build Failed: Failed to create .ZIP file from the .HEX")
            self._printer.output("=")
            sys.exit(1)

        # Return to project dir
        utils.pop_dir()
示例#3
0
    def link(self, arguments, inf, local_external_setting, variant):
        # Run the linker
        base.ToolChain.link(self, arguments, inf, local_external_setting,
                            variant)

        # switch to the build variant output directory
        vardir = '_' + self._bld
        utils.push_dir(vardir)

        # Output Banner message
        self._printer.output("= Creating BIN file ...")

        # construct objcopy command
        options = '-O binary '
        objcpy = '{} {} {} {}'.format(self._objcpy, options,
                                      self._final_output_name + '.elf',
                                      self._final_output_name + '.bin')

        # Generate the .HEX file
        if (arguments['-v']):
            self._printer.output(objcpy)
        if (utils.run_shell(self._printer, objcpy)):
            self._printer.output("=")
            self._printer.output(
                "= Build Failed: Failed to create .BIN file from the .ELF")
            self._printer.output("=")
            sys.exit(1)

        # Output Banner message
        self._printer.output("= Running Print Size...")

        # construct zip command
        options = '--format=berkeley'
        printsz = '{} {} {}'.format(self._printsz, options,
                                    self._final_output_name + '.elf')

        # Run the 'size' command
        if (arguments['-v']):
            self._printer.output(printsz)
        utils.run_shell(self._printer, printsz)

        # Return to project dir
        utils.pop_dir()
示例#4
0
def run( argv ):

    # Parse command line
    args = docopt(__doc__, version="0.1")

    # Get environment variable for where the arduino tools are located
    ARDUINO_TOOLS = os.environ.get( 'ARDUINO_TOOLS' )
    if ( ARDUINO_TOOLS == None ):
        print("The environment variable - ARDUINO_TOOLS - is NOT set.")
        sys.exit(1)
    ARDUINO_BSP_VER = os.environ.get( 'ARDUINO_BSP_VER' )
    if ( ARDUINO_BSP_VER == None ):
        print("The environment variable - ARDUINO_BSP_VER - is NOT set.")
        sys.exit(1)
    ARDUINO_NRF_UTIL_VER = os.environ.get( 'ARDUINO_NRF_UTIL_VER' )
    if ( ARDUINO_NRF_UTIL_VER == None ):
        print("The environment variable - ARDUINO_NRF_UTIL_VER - is NOT set.")
        sys.exit(1)

    # Default tool stuff
    nrfutil    = os.path.join(ARDUINO_TOOLS, 'hardware', 'nrf52', ARDUINO_BSP_VER, 'tools', ARDUINO_NRF_UTIL_VER, 'binaries', 'win32', 'nrfutil' )
            
    # Get hex file to program
    zipfile = get_default_zipfile_name();
    if ( args['<zipfile>'] ):
        zipfile = args['<zipfile>'] 
    if ( zipfile == None ):
        print("No ZIP file was specified OR multiple ZIP files exist in the default directory")
        sys.exit(1)

    # build options....
    verbose = ' --verbose ' if args['-v'] else ''
    comport = ' --port '+args['-p']
    baud    = ' -b '+args['-b']
    command = ''
    if (  not args['--nozip'] ):
        target  = ' dfu serial -pkg {}'.format(zipfile)
        command = target + comport + baud
    extra   = '' if not args['--extra'] else ' ' + args['--extra']
    options = verbose + command + extra
    
    # Run NRFUTIL
    printer = Printer()
    cmd = nrfutil + ' ' + options
    if ( args['-v'] ):
        print(cmd)
    if (utils.run_shell(printer, cmd, False) ):
        print()
        print('** A FAILURE occurred while attempting to run nrfutil')
        print()
        sys.exit(1)
示例#5
0
def run(argv):

    # Parse command line
    args = docopt(__doc__, version="0.1")

    # Get environment variable for where the arduino tools are located
    ARDUINO_TOOLS = os.environ.get('ARDUINO_TOOLS')
    if (ARDUINO_TOOLS == None):
        print("The environment variable - ARDUINO_TOOLS - is NOT set.")
        sys.exit(1)

    # Default tool stuff
    avrdude = os.path.join(ARDUINO_TOOLS, 'hardware', 'tools', 'avr', 'bin',
                           'avrdude')
    dudeconfig = os.path.join(ARDUINO_TOOLS, 'hardware', 'tools', 'avr', 'etc',
                              'avrdude.conf')

    # Get hex file to program
    hexfile = get_default_hexfile_name()
    if (args['<hexfile>']):
        hexfile = args['<hexfile>']
    if (hexfile == None):
        print(
            "No HEX file was specified OR multiple HEX files exist in the default directory"
        )
        sys.exit(1)

    # build options....
    verbose = ' -v' if args['-v'] else ''
    comport = '' if not args['-p'] else ' -P ' + args['-p']
    baud = '' if not args['-b'] else ' -b ' + args['-b']
    config = ' -C ' + dudeconfig if not args[
        '-c'] else ' -C "' + args['-c'] + '"'
    mcu = ' -p ' + args['-m']
    target = '' if args['--nohex'] else '-U flash:w:{}:i'.format(hexfile)
    extra = '' if not args['--extra'] else ' ' + args['--extra']
    options = config + comport + verbose + mcu + ' -c arduino -D ' + target + extra

    # Run AVRDUDE
    printer = Printer()
    cmd = avrdude + ' ' + options
    if (args['-v']):
        print(cmd)
    if (utils.run_shell(printer, cmd, False)):
        print()
        print('** A FAILURE occurred while attempting to run avrdude')
        print()
        sys.exit(1)
示例#6
0
            # process all entries in the file
            for line in inf:

                # drop comments and blank lines
                line = line.strip()
                if (line.startswith('#')):
                    continue
                if (line == ''):
                    continue

                # 'normalize' the file entries
                line = utils.standardize_dir_sep(line.strip())

                # Process 'add' entries
                cmd = "bob.py " + line
                utils.run_shell(cmd, args['-v'],
                                "ERROR: Build from File failed.")

            inf.close()

        except Exception as ex:
            exit("ERROR: Unable to open build list: {}".format(args['--file']))

    # The project list is from the command line
    else:
        # Only build the projects that match the pattern
        pattern = args['PATTERN']
        if (args['here']):
            pattern = '*'

        jobs = _filter_prj_list(all_prjs, pattern, pkgroot, args['--exclude'],
                                args['--e2'], args['--e3'], args['--p2'],