def attach_to_device(self):
     from csr.front_end.pydbg_front_end import PydbgFrontEnd
     print('Attaching to Device @ "trb:scar"...')
     sys.stdout.flush()
     device, _ = PydbgFrontEnd.attach({"firmware_builds" : None,
                                       "device_url" : "trb:scar"},
                                       shell=None)
     return device
Exemplo n.º 2
0
    def attach(self, image_type=None, image_path=None):
        from csr.front_end.pydbg_front_end import PydbgFrontEnd

        config = {
            "firmware_builds":
            self.get_firmware_builds(image_type, image_path),
            "device_url": self.transport_uri
        }

        device, _ = PydbgFrontEnd.attach(config)
        return device
Exemplo n.º 3
0
    def _attach_to_device(self):
        from csr.front_end.pydbg_front_end import PydbgFrontEnd

        if self._device_uri is None:
            print("Attach to Device failed, no device URI supplied")
            return None

        device_uri = self._device_uri
        target_list = device_uri.split('://')[1].split('/')[:-1]
        transport = target_list[1]
        trans_id = "trb:scar"
        if transport == "usb2tc":
            trans_id = "usb"

        print('Attaching to Device @ "%s"...' % trans_id)
        sys.stdout.flush()
        device, _ = PydbgFrontEnd.attach({"firmware_builds" : None,
                                          "device_url" : trans_id},
                                          shell=None)
        return device
Exemplo n.º 4
0
def check_device(pydbg_device_url):
    """
    Attaches to a device using pydbg and checks if the device is readable
    """
    from csr.front_end.pydbg_front_end import PydbgFrontEnd
    from csr.transport.tctrans import TcError
    try:
        device, _ = PydbgFrontEnd.attach({"device_url": pydbg_device_url},
                                         interactive=False)
    except TcError:
        print("Connection failed")
        return False

    print("Connected to device")
    print("Checking if device is readable...")
    try:
        device_is_readable = device.chip.curator_subsystem.core.data[0x8000]
        return True
    except RuntimeError:
        print("Device not readable")
        return False
Exemplo n.º 5
0
    def burn(self, image_type, image_path, reset_device=True):

        from csr.front_end.pydbg_front_end import PydbgFrontEnd

        success = False
        sys.stdout.flush()

        subsys_id = subsys_numbers.SubsystemNumbers.get_subsystem_number_from_name(
            image_type)

        if subsys_id != -1:
            firmware_builds = self.get_firmware_builds(image_type, image_path)

            device, _ = PydbgFrontEnd.attach({
                "firmware_builds": firmware_builds,
                "device_url": self.transport_uri,
                "preload": True
            })
            siflash = device.chip.curator_subsystem.siflash
            apps_fw = device.chip.apps_subsystem.p0.fw
            apps1_fw = device.chip.apps_subsystem.p1.fw

            if image_type != "curator":
                # Disable Curator USB interrupts to avoid flashing problems with USB attached
                disable_curator_usb_interrupts(device)
                # Try to disable deep sleep, unless it's the Curator itself that's being set up.
                disable_deep_sleep_if_possible(device)

            if image_type == "curator":
                print("Flash curator")
                image_dir = os.path.dirname(image_path)
                siflash.register_program_curator(dir_xuv=image_dir)
            elif image_type == "btss":
                # Special method which deals with the continuous read mode gubbins
                siflash.reprogram_bt(image_path, show_progress=True)
            elif image_type == "curator_fs":
                siflash.identify(subsys_id, 0)
                apps_fw.load_curator_fs(image_path)
            elif image_type == "p0_rw_config":
                siflash.identify(subsys_id, 0)
                apps_fw.load_rw_config(image_path)
            elif image_type == "p0_ro_cfg_fs":
                siflash.identify(subsys_id, 0)
                apps_fw.load_config_fs(image_path)
            elif image_type == "p0_ro_fs":
                siflash.identify(subsys_id, 0)
                apps_fw.load_fs(image_path)
            elif image_type == "p0_device_ro_fs":
                siflash.identify(subsys_id, 0)
                apps_fw.load_device_config_fs(image_path)
            elif image_type == "apps0":
                siflash.identify(subsys_id, 0)
                apps_fw.loader.load_custom("apps_p0", image_path)
            elif image_type == "apps1":
                siflash.identify(subsys_id, 0)
                apps1_fw.load()
            else:
                siflash.reprogram(subsys_id, 0, image_path)

            if reset_device == True:
                device.reset()

            # Give the hardware a couple of seconds prior to being run
            time.sleep(2)

            success = True

        return success