Exemplo n.º 1
0
def main(args):
  # query device
  dev = usbctrl.poll_hf_ctrl_device_loader()
  print (dev.info())
  #print (dev.status())
  config = dev.config()
  print (config)
  #print (dev.name())
  for module in range(config.modules):
    print (dev.version(module))
    print (dev.serial(module))
    print (dev.flash_size(module))
    #print (dev.power(module))
    #print (dev.fan(module))

  if args.fan is not None:
    module, fan, speed = args.fan
    dev.fan_set(module, fan, speed)

  if args.name is not None:
    name = args.name
    dev.name_set(name)

  if args.power is not None:
    power = args.power
    dev.power_set(0, power)

  if args.reboot_app is not None:
    module = args.reboot_app
    dev.reboot(module, 0x0000)

  if args.reboot_load is not None:
    module = args.reboot_load
    dev.reboot(module, 0x0001)

  if args.voltage is not None:
    module, die, mvolts = args.voltage
    dev.voltage_set(module, die, mvolts)

  if args.cores:
    print (dev.core_overview())

  if args.core_enable is not None:
    core, persist = args.core_enable
    dev.core_enable(core, persist)

  if args.core_disable is not None:
    core, persist = args.core_disable
    dev.core_disable(core, persist)

  if args.core_clear is not None:
    persist = args.core_clear
    dev.core_clear(persist)

  if args.core_status is not None:
    core = args.core_status
    print (dev.core_status(core))

  if args.die_status is not None:
    die = args.die_status
    t = dev.core_die_status(die)
    print (t)

  if args.asic_status is not None:
    asic = args.asic_status
    print (dev.core_asic_status(asic))

  if args.debug_stream:
    print (dev.debug_stream())
def main(args):
  if args.debug:
    print("WARNING - Debug builds are experimental!")
    print("HashFast is not responsible for damage resulting from debug builds.")

  updater = HF_Updater()

  ####################
  # BOOTLOADER       #
  ####################
  if args.bootloader:
    # doing a load, wait for a valid HashFast device
    dev = util.poll_hf_device()
    if dev is util.USB_DEV_DFU:
      # found a device that needs a bootloader
      print("Bootloader not detected.")
      for flash_size in [512, 128]:
        try:
          dfu = updater.fetch_release_bootloader(flash=flash_size)
          updater.load_firmware_dfu(dfu, flash=flash_size)
          break
        except:
          pass
      # wait for device to reboot
      util.poll_hf_device()
      return

    elif dev is util.USB_DEV_HF:
      # found device in application mode
      updater.dev = usbctrl.poll_hf_ctrl_device(printer=printme)
      #updater.enumerate_modules()
      updater.enter_loader()

    # load firmware
    updater.dev_loader = usbctrl.poll_hf_ctrl_device_loader(printer=printme)
    updater.enumerate_modules_loader()
    # get flash size
    loader_version = updater.read_version_loader().version
    if loader_version >= 4:
      flash_size = int(updater.read_flash_size_loader().flash_size / 1024)
    else:
      flash_size = 512
    print("Using flash_size of: {}k".format(flash_size))
    # fetch file
    hfu = updater.fetch_release_bootloader_update(flash=flash_size)
    updater.load_firmware_hfu(hfu, force=False)
    updater.enter_app()


  ####################
  # LIST             #
  ####################
  elif args.list:
    # list releases/builds
    if args.debug:
      updater.list_debug_builds()
    else:
      updater.list_release_firmwares()


  ####################
  # FIRMWARE         #
  ####################
  else:
    # doing a load, wait for a valid HashFast device
    dev = util.poll_hf_device()
    if dev is util.USB_DEV_DFU:
      # found a device that needs a bootloader
      print("Bootloader not detected.")
      for flash_size in [512, 128]:
        try:
          # if no release specified, then latest will be loaded
          dfu = updater.fetch_release_bootloader(args.release, flash=flash_size)
          updater.load_firmware_dfu(dfu, flash=flash_size)
          break
        except:
          pass
      # wait for device to reboot
      util.poll_hf_device()

    elif dev is util.USB_DEV_HF:
      # found device in application mode
      updater.dev = usbctrl.poll_hf_ctrl_device(printer=printme)
      #updater.enumerate_modules()
      updater.enter_loader()

    # load firmware
    if args.debug or args.build:
      if args.build:
        updater.dev_loader = usbctrl.poll_hf_ctrl_device_loader(printer=printme)
        updater.enumerate_modules_loader()
        # get flash size
        loader_version = updater.read_version_loader().version
        if loader_version >= 4:
          flash_size = int(updater.read_flash_size_loader().flash_size / 1024)
        else:
          flash_size = 512
        print("Using flash_size of: {}k".format(flash_size))
        # fetch file
        hfu = updater.fetch_debug_build(args.build, flash=flash_size)
        updater.load_firmware_hfu(hfu)
        updater.enter_app()
      else:
        raise HF_UpdateError("You must specify a debug build with --build BUILD")

    else:
      # if no release specified, then latest will be loaded
      updater.dev_loader = usbctrl.poll_hf_ctrl_device_loader(printer=printme)
      updater.enumerate_modules_loader()
      # get flash size
      loader_version = updater.read_version_loader().version
      if loader_version >= 4:
        flash_size = int(updater.read_flash_size_loader().flash_size / 1024)
      else:
        flash_size = 512
      print("Using flash_size of: {}k".format(flash_size))
      # fetch file
      # if no release specified, then latest will be loaded
      hfu = updater.fetch_release_firmware(args.release, flash=flash_size)
      updater.load_firmware_hfu(hfu)
      updater.enter_app()