New 'labman' tool

Stefano Babic sbabic at denx.de
Mon Apr 20 10:47:13 CEST 2020


Hi Simon,

On 19.04.20 20:31, Simon Glass wrote:
> Hi,
> 
> I have been fiddling with setting up a lab and have found it quite a
> pain. Lots of USB connections and things sometimes break.
> 
> The collection of pytest, udev and tbot scripts that I end up with is
> hard to manage and error-prone. I decided that I really wanted a
> central database to keep control of this.
> 
> Hubs are a pain because their internal numbering does not always
> correspond to their visible port numbers.
> 
> Also when something goes wrong with a component in the lab, it is hard
> to know which one is broken and which port it is on.
> 
> So I have started something called labman to help with this. It can
> generate simple tbot scripts, check that all components are working
> and help with simple management tasks.
> 
> Please see the README and let me know what you think.
> 
> https://github.com/sglass68/u-boot/tree/labman/tools/labman
> 

Thanks to share this - I will check this in my environment. Anyway, we
are fighting with same problems, and Wolfgang has exposed an alternative
way to do this. So I take the occasion because I have a different way,
too, and I would like to share - I am also not very fond of WiFI actors
in my network, and I mostly work with USB serial adapter.

My way is to use a Raspi as terminal server with "ser2net". Because
ttyUSB changes at each boot, I decided to detect which is the new ttyUSB
instead of trying to force it via udev rule - let's say, if you cannot
fight them, join them !

I built an Image for Raspberry based on OE
(github/sbabic/meta-swupdate-boards), the image contains:

- ser2net
- python3
- openOCD for JTAG over Ethernet
- Lua
- a tool to driver a Lab PowerSupply (Power / Power off)

I wrote a small Python daemon that returns the mapping between target
and tty. In fact, if the ttyUSBX changes, the topology is always the
same. A target "X" that is connected to port 4 of second Hub will always
be connected to that port.
The small daemon checks in a file-database as "target" <--> "topology" like:

wandboard 	usb	usb1/1-1/1-1.2/1-1.2.3/1-1.2.3:1.0
mira		usb	usb1/1-1/1-1.2/1-1.2.4/1-1.2.4:1.0
target1		usb	usb1/1-1/1-1.2/1-1.2.7/1-1.2.7:1.0
target2		usb	usb1/1-1/1-1.2/1-1.2.2/1-1.2.2:1.0
target3		usb	usb1/1-1/1-1.2/1-1.2.6/1-1.2.6:1.0
target4		usb	usb1/1-1/1-1.2/1-1.2.5/1-1.2.5:1.0

On tbot lab host, I have then just a simple script "connect":

!/bin/bash

SERVERS='raspbx.fritz.box raspberrypi3.fritz.box'
if [ "x$2" != "x" ];then
	SERVERS=$2
fi
PORT=5005

for server in ${SERVERS};do

	target=`echo $1 | nc ${server} ${PORT}`
	echo TARGET $target
	tserver=`echo $target| awk -F':'  '{print $1}'`.fritz.box
	port=`echo $target | awk -F':' '{print $2}'`

	if [ ! -z $port ];then
		telnet ${tserver} ${port}
		exit 0
	fi
done

echo "Target not found" $1


And at the end, this simplifies my board setup in tbot, because I have
the same way to connect to the board:

    def connect(self, mach):
        return mach.open_channel("connect", self.name)

Regards,
Stefano


-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================


More information about the tbot mailing list