[tbot] Problem with context exit (and serial transmission)

Lukasz Majewski lukma at denx.de
Mon Feb 4 08:38:14 UTC 2019


Hi Harald,

> Hi Lukasz,
> 
> On Sat, 2019-02-02 at 23:57 +0100, Lukasz Majewski wrote:
> > def kernel_active_update(
> >     lab: typing.Optional[linux.LabHost] = None,
> > ) -> None:
> >      linux_falcon_boot(falcon_status="disable")
> > # --------- Problem / why do I need this code ?
> >      with lab or tbot.acquire_lab() as lh:
> >          lh.exec0("pkill", "-9", "picocom")
> >          time.sleep(3)
> > # ---------
> >      uboot_kernel_write(reset=True, serverip="192.168.2.222")  
> 
> Unrelated to your issue I have noticed something:  While your code
> works, you have a hidden performance cost:  Each testcase will create
> its own connection to the lab-host.  In case of a local lab this will
> not be noticeable but with ssh connections it will be a few seconds
> each time.
> 
> You can easily fix this though!  The testcases you listed in the end
> already have a `lab` parameter where you can supply an existing
> lab-host connection:
> 
> 	def kernel_active_update(
> 	    lab: typing.Optional[linux.LabHost] = None,
> 	) -> None:
> 	    with lab or tbot.acquire_lab() as lh:
> 	        linux_falcon_boot(lab=lh, falcon_status="disable")
> 
> 	        uboot_kernel_write(lab=lh, reset=True, serverip="...")
> 
> One more note:
> 
> > if reset:
> >     ub.exec0("reset")  
> 
> Executing `reset` with `exec0` is not really portable.  If your board
> has autoboot enabled, tbot would hang indefinitely waiting for the
> U-Boot prompt to reappear.  If you absolutely have to execute reset,
> I'd do so manually and then wait for the U-Boot header string to
> reappear before exiting the board context (not tested, sorry):
> 
> 	if reset:
> 	    ub.channel.send("reset\n")
> 	    ub.channel.read_until_prompt(
> 	        # U-Boot Header
> 	        prompt="U-Boot",
> 	        # Because the header can appear anywhere in the stream
> 	        must_end=False,
> 	    )
> 	# Actually power off the board now by exiting its context
> 
> 
> > The linux_falcon_boot() and uboot_kernel_write() works without
> > problems when executed as standalone tests (and I only expect them
> > to be run one by one).
> > 
> > The question is - why do I need to kill manually the picocom process
> > and put some sleep between invocation of those two tests?  
> 
> It looks like picocom doesn't like the way tbot ends a session.  I
> found a workaround:  Add the following function in your board-config
> (where the call to picocom is defined):
> 
> 	def cleanup(self) -> None:
> 	    # Send ^A^Q to quit picocom
> 	    if self.channel is not None:
> 	        self.channel.send("\x01\x11")
> 

Yes, this seems to do the trick. Thanks for help :-).

> Docs for cleanup can be found here:
> 
> 	https://rahix.de/tbot/module-board.html#tbot.machine.board.Board.cleanup
> 
> > From the doc I thought that when we exit context (from one test with
> > disabling power) and start the context again (and power up in
> > another test), the "channel" would be put into default state (I
> > mean the picocom would be killed and re-spawned accordingly).  
> 
> Yes, you got that correctly.  Apparently picocom does not exit
> cleanly by default ... I'll see if I can somehow fix this without the
> solution mentioned above.
> 




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/tbot/attachments/20190204/265d568a/attachment.sig>


More information about the tbot mailing list