def transition(self, status, *, step): if not isinstance(status, Status): status = Status[status] if status == Status.unknown: raise StrategyError("can not transition to {}".format(status)) elif status == self.status: step.skip("nothing to do") return # nothing to do elif status == Status.barebox: self.target.activate(self.power) self.target.activate(self.sdmux) # power off self.power.off() # configure sd-mux self.sdmux.set_mode('dut') # cycle power self.power.on() # interrupt barebox self.target.activate(self.barebox) elif status == Status.shell: # tansition to barebox self.transition(Status.barebox) self.barebox.boot("") self.barebox.await_boot() self.target.activate(self.shell) else: raise StrategyError("no transition found from {} to {}".format( self.status, status)) self.status = status
def transition(self, status, *, step): if not isinstance(status, Status): status = Status[status] if status == Status.unknown: raise StrategyError("can not transition to {}".format(status)) elif status == self.status: step.skip("nothing to do") return # nothing to do elif status == Status.flashed_xload: self.target.activate(self.power) self.power.cycle() self.target.activate(self.quartushps) # flash bootloader xload image to 0x0 self.quartushps.flash(self.image_xload, 0x0) elif status == Status.flashed: self.transition(Status.flashed_xload) # flash bootloader image to 0x40000 self.quartushps.flash(self.image, 0x40000) self.power.cycle() # activate serial in order to make 'labgrid-client -s $STATE con' work self.target.activate(self.serial) else: raise StrategyError( "no transition found from {} to {}". format(self.status, status) ) self.status = status
def transition(self, new_status, *, step): if not isinstance(new_status, Status): new_status = Status[new_status] if new_status == Status.unknown: raise StrategyError("can not transition to {}".format(new_status)) elif self.status == new_status: step.skip("nothing to do") return elif self.status == Status.unknown: # unknown state after initialization, cycle power self.target.activate(self.power) self.power.cycle() # we can then let the according driver do the rest to get us into a barebox or shell: if new_status == Status.barebox: self.target.activate(self.barebox) elif new_status == Status.shell: # (this assumes that barebox will autoboot to the shell after a timeout) self.target.activate(self.shell) elif self.status == Status.barebox and new_status == Status.shell: # in barebox: boot the default target and hope it will get us to a shell :-> self.barebox.boot("") self.barebox.await_boot() self.target.activate(self.shell) elif self.status == Status.shell and new_status == Status.barebox: # in shell: we can simply reboot to get a barebox # make sure run() reads the shell prompt and returns self.shell.run("(sleep 1;reboot)&") self.target.activate(self.barebox) else: raise StrategyError( "no transition found from {} to {}". format(self.status, new_status) ) self.status = new_status