Power on vs. reset?
Harald Seiler
hws at denx.de
Thu Apr 30 14:26:03 CEST 2020
Hello Simon,
On Thu, 2020-04-30 at 06:22 -0600, Simon Glass wrote:
> Hi Harald,
>
> On Thu, 30 Apr 2020 at 02:45, Harald Seiler <hws at denx.de> wrote:
> > Hello Simon,
> >
> > On Wed, 2020-04-29 at 14:17 -0600, Simon Glass wrote:
> > > Hi,
> > >
> > > When I use interactive_board, in some cases by board poweron() method
> > > will reset the board and in some cases will not.
> > >
> > > Really, I suppose it should not, unless U-Boot has been updated.
> > >
> > > So how should I indicate that a reset is required (e.g. to boot U-Boot
> > > from scratch)?
> >
> > Not sure if I entirely understand what you mean ...
> >
> > Your poweron() method should just perform a 'power on' operation.
> > A powercycle/reset is essentially calling poweroff() and then poweron()
> > again.
> >
> > For resetting the board in a testcase, you want to use the following
> > pattern:
> >
> > @tbot.testcase
> > @tbot.with_lab
> > def reset_test(lh):
> > with tbot.acquire_board(lh) as b:
> > with tbot.acquire_uboot(b) as ub:
> > # This is before the reset, U-Boot is running
> > ...
> >
> > # Board is now off again
> >
> > with tbot.acquire_board(lh) as b:
> > with tbot.acquire_uboot(b) as ub:
> > # This is after the reset, U-Boot is (hopefully)
> > # running again
> > ...
> >
> > # Board is now off
> >
> > I have been thinking about adding a generic reset() or reinit() method to
> > machines which first unwinds the entire context and then rebuilds it but
> > doing this is not trivial and I'll have to put a few more thoughts into
> > how this can be done safely ...
>
> Yes I think that would be useful. The way I see it is that reset may
> result in U-Boot booting, or not ,if it is not present. But typically
> if I have just built U-Boot and want to get it on the board I should
> reset it.
>
> >
> >
> > If you were instead talking about wanting to not reset the board on every
> > tbot run, Heikos response goes in the right direction. The current
> > solution for this isn't as flexible as I would like and I'll definitely
> > work on this some more but right now what you can do is this:
> >
> > In you board config, make the poweron() and poweroff() stubs if a certain
> > flag is present:
> >
> > class MyBoard(connector.ConsoleConnector, board.PowerControl, board.Board):
> > name = "my-board"
> >
> > def poweron():
> > if "no-reset" not in tbot.flags:
> > self.host.exec0("...")
> >
> > def poweroff():
> > if "no-reset" not in tbot.flags:
> > self.host.exec0("...")
> >
> > And in your boards U-Boot class, remove the autoboot intercept like this:
> >
> > class MyBoardUBoot(board.Connector, board.UBootAutobootIntercept, board.UBootShell):
> > if "no-reset" in tbot.flags:
> > autoboot_prompt = None
> >
> > For Linux it is more difficult, you need to have two separate classes:
> >
> > class MyBoardLinuxWithBoot(board.LinuxUbootConnector, board.LinuxBootLogin, linux.Ash):
> > ...
> >
> > class MyBoardLinuxWithoutBoot(board.Connector, linux.Ash):
> > # This class expects Linux to have already booted and the serial
> > # console is waiting at a shell prompt.
> > ...
> >
> > if "no-reset" in tbot.flags:
> > MyBoardLinux = MyBoardLinuxWithoutBoot
> > else:
> > MyBoardLinux = MyBoardLinuxWithBoot
> >
> > I know this isn't pretty and it means you'll have to manually power on the
> > board initially, but as I said, I hope to improve on this.
>
> That seems OK for now. I an guessing I need to add a new flag in flags
> in main.py
Flags are passed on the commandline with -f. E.g. for the code above you add
-fno-reset
> Regards,
> Simon
--
Harald
More information about the tbot
mailing list