コード例 #1
0
ファイル: uploader.py プロジェクト: sladeware/bbapp
def upload_bootloader(port="/dev/ttyUSB0", config=None, rebuild=False):
    """Upload special bootloader `MULTICOG_BOOTLOADER_BINARY_FILENAME` by using
    :class:`SPIUploader`.
    """
    if not port:
        port = raw_input("Please select port: ")
    catalina_board_configs = {
        QuickStartBoardConfig : "CUSTOM",
        DemoBoardConfig : "DEMO"
        }
    if not config:
        raise Exception("Please provide config")
    catalina_config = catalina_board_configs.get(config.__class__, None)
    if not catalina_config:
        raise Exception("Cannot find catalina config for %s" %
                        config.__class__.__name__)
    bootloader_src = os.path.join(HOME_DIR, "multicog_spi_bootloader.spin")
    bootloader_binary = os.path.join(os.path.dirname(__file__),
                                     "multicog_spi_bootloader.binary")
    if rebuild or not os.path.exists(bootloader_binary):
        spawn(["homespun", bootloader_src, "-b",
               "-L", "/usr/local/lib/catalina/target/",
               "-D", catalina_config,
               "-o", bootloader_binary], verbose=True)
    # Fix binary name, since '.binary' will be added automatically
    #bootloader_binary += ".binary"
    uploader = SPIUploader(port=port)
    if not uploader.connect():
        return None
    uploader.upload_file(bootloader_binary, eeprom=True)
    uploader.disconnect()
    return uploader
コード例 #2
0
ファイル: cc.py プロジェクト: sladeware/bbapp
 def _link(self, objects, output_dir=None, libraries=None, library_dirs=None,
             debug=False, extra_preargs=None, extra_postargs=None,
             target_lang=None):
   """Linking."""
   objects, output_dir, libraries, library_dirs = \
       self._setup_link(objects, output_dir, libraries, library_dirs)
   lib_options = self._gen_lib_options(library_dirs, libraries)
   # Finalize linker options
   ld_options = self._gen_ld_options(debug, extra_preargs)
   if extra_postargs:
     ld_options.extend(extra_postargs)
   ld_options += (objects + lib_options + ['-o', self.get_output_filename()])
   path_utils.mkpath(path_utils.dirname(self.get_output_filename()))
   try:
     linker = self.get_executable()
     # skip over environment variable settings if /usr/bin/env is used to set
     # up the linker's environment. This is needed on OSX. Note: this
     # assumes that the normal and C++ compiler have the same environment
     # settings.
     i = 0
     if path_utils.basename(linker[0]) == "env":
       i = 1
       while "=" in linker[i]:
         i = i + 1
     # TODO: resolve this
     #linker[i] = self.get_executable('compiler_cxx')[i]
     spawn.spawn([linker] + ld_options, debug=self.get_verbosity_level(),
                 dry_run=self.is_dry_run_mode_enabled())
   except Exception, e:
     raise Exception, e
コード例 #3
0
ファイル: cc.py プロジェクト: sladeware/bbapp
 def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
   compiler = self.get_executable()
   try:
     spawn.spawn([compiler] + cc_args + [src, '-o', obj] + extra_postargs,
                 debug=self.get_verbosity_level(),
                 dry_run=self.is_dry_run_mode_enabled())
   except spawn.ExecutionError, msg:
     raise Exception(msg) # CompileError
コード例 #4
0
ファイル: executable.py プロジェクト: sladeware/bbapp
 def run(self, dry_run=False):
   dry_run = self.is_dry_run_mode_enabled() or dry_run
   exe = self.get_executable()
   try:
     spawn.spawn([exe] + self.get_options(),
                 debug=self.get_verbosity_level(), dry_run=dry_run)
   except spawn.ExecutionError, msg:
     raise Exception(msg)
コード例 #5
0
ファイル: bstl.py プロジェクト: sladeware/bbapp
 def _load(self, filename, device_filename=None, program_mode=1):
   loader = self.executables['loader']
   flags = []
   if device_filename:
     self.set_device_filename(device_filename)
   # Add high speed flag
   if self.is_high_speed_enabled():
     flags.append('-f')
   # Add device flag
   if self.get_device_filename():
     flags.extend(['-d', self.get_device_filename()])
   # Add mode flag
   flags.extend(['-p', self.get_mode()])
   # Spawn!
   try:
     spawn(loader + flags + [filename], verbose=self.verbose)
   except BuilderExecutionError, msg:
     raise LoaderError, msg