Hello LAVA experts,
Is it possible to expose a device path like '/dev/ttyUSB0' to lxc in job definition or device definition? I have a feature requirement to control a relay card inside LAVA lxc. I have got clues for device_info and read https://validation.linaro.org/static/docs/v2/lava-scheduler-device-dictionar... and https://validation.linaro.org/static/docs/v2/admin-lxc-deploy.html?highlight.... However I did not know how to use it to expose '/dev/ttyUSB0' to LXC.
Thanks and Best Regards, Yifan
On 19 July 2017 at 11:16, Li, Yifan2 yifan2.li@intel.com wrote:
Hello LAVA experts,
Is it possible to expose a device path like ‘/dev/ttyUSB0’ to lxc in job definition or device definition? I have a feature requirement to control a relay card inside LAVA lxc.
Yes. This is the device_info dictionary which can be part of the device dictionary.
https://staging.validation.linaro.org/scheduler/device/staging-hi6220-hikey-...
https://git.linaro.org/lava/lava-lab.git/tree/staging.validation.linaro.org/...
Also:
https://git.linaro.org/lava/lava-lab.git/tree/staging.validation.linaro.org/...
I have got clues for device_info and read https://validation.linaro.org/static/docs/v2/lava-scheduler-device-dictionar... and https://validation.linaro.org/static/docs/v2/admin-lxc-deploy.html?highlight.... However I did not know how to use it to expose ‘/dev/ttyUSB0’ to LXC.
You need 2017.6 or later for this to work.
https://staging.validation.linaro.org/static/docs/v2/admin-lxc-deploy.html
Although designed for Android testing, the support is available to any use of the LXC.
https://staging.validation.linaro.org/static/docs/v2/admin-lxc-deploy.html#a...
Hi William,
Thanks for your information. I have read this wiki and got a question. I see device_info itself only support keys 'board_id', 'usb_vendor_id' and 'usb_product_id', however I want to expose is a device path like '/dev/ttyUSB0'. I also took a look at LAVA source code on GitHub to see if it support other keys, I found it validate above device keys. Code is here: https://github.com/Linaro/lava-dispatcher/blob/release/lava_dispatcher/pipel... line: 302. There's no board_id, usb_vendor_id and usb_product_id for my DUT which is a Yocto device. So how should I use device_info to expose '/dev/ttyUSB0' to lxc? I know I can hack the code to expose, but I do prefer a solution that works on original LAVA. Could you please give me some hint?
By the way, I found a typo in https://staging.validation.linaro.org/static/docs/v2/admin-lxc-deploy.html: "{% set device_info = [{'board_id': '0123456789', 'usb_vendor_id': '0451', 'usb_vendor_id': 'd109'}] %}" => I guess this should be "{% set device_info = [{'board_id': '0123456789', 'usb_vendor_id': '0451', 'usb_product_id': 'd109'}] %}", the second 'usb_vendor_id' is typo of 'usb_product_id'.
-Yifan
-----Original Message----- From: Neil Williams [mailto:neil.williams@linaro.org] Sent: Wednesday, July 19, 2017 6:37 PM To: Li, Yifan2 yifan2.li@intel.com Cc: Lava-users@lists.linaro.org Subject: Re: [Lava-users] How to expose device path like '/dev/ttyUSB0' to LAVA-LXC?
On 19 July 2017 at 11:16, Li, Yifan2 yifan2.li@intel.com wrote:
Hello LAVA experts,
Is it possible to expose a device path like ‘/dev/ttyUSB0’ to lxc in job definition or device definition? I have a feature requirement to control a relay card inside LAVA lxc.
Yes. This is the device_info dictionary which can be part of the device dictionary.
https://staging.validation.linaro.org/scheduler/device/staging-hi6220-hikey- 03/devicedict
https://git.linaro.org/lava/lava- lab.git/tree/staging.validation.linaro.org/lava/pipeline/devices/staging- hi6220-hikey-03.jinja2
Also:
https://git.linaro.org/lava/lava- lab.git/tree/staging.validation.linaro.org/lava/pipeline/devices/staging- panda03.jinja2
I have got clues for device_info and read https://validation.linaro.org/static/docs/v2/lava-scheduler-device-dic tionary.html?highlight=device_info and https://validation.linaro.org/static/docs/v2/admin-lxc-
deploy.html?highlight=device_info.
However I did not know how to use it to expose ‘/dev/ttyUSB0’ to LXC.
You need 2017.6 or later for this to work.
https://staging.validation.linaro.org/static/docs/v2/admin-lxc-deploy.html
Although designed for Android testing, the support is available to any use of the LXC.
https://staging.validation.linaro.org/static/docs/v2/admin-lxc- deploy.html#arbitrary-usb-devices-with-lxc-support
--
Neil Williams
neil.williams@linaro.org http://www.linux.codehelp.co.uk/
On 19 July 2017 at 17:21, Li, Yifan2 yifan2.li@intel.com wrote:
Thanks for your information. I have read this wiki and got a question. I see device_info itself only support keys 'board_id', 'usb_vendor_id' and 'usb_product_id', however I want to expose is a device path like '/dev/ttyUSB0'.
The path is looked up in the udev context using the board_id so that the correct path is added - it will not always be ttyUSB0, depending on other things happening on the worker / device. Adding ttyUSB0 to the LXC is meaningless unless the actual device is added, not just a path. A path would just be a file, adding the device node allows programs in the LXC to access the real device through the running kernel.
I also took a look at LAVA source code on GitHub to see if it support other keys, I found it validate above device keys. Code is here: https://github.com/Linaro/lava-dispatcher/blob/release/lava_dispatcher/pipel... line: 302. There's no board_id, usb_vendor_id and usb_product_id for my DUT which is a Yocto device.
How does the device show up in dmesg on the worker (outside the LXC)? Load the example python code and find out how the device appears to pyudev. Note that the descriptors shown in dmesg do not necessarily match up with how udev or pyudev organises the data. In dmesg the string to use will typically be the value of Serial: or SerialNumber: but in pyudev, that will be ID_SERIAL_SHORT, so you specify that as board_id and that gets matched with the value in pyudev. Details of that pyudev device are then added to the LXC, including the list of device nodes - one of which will be ttyUSB0
So how should I use device_info to expose '/dev/ttyUSB0' to lxc? I know I can hack the code to expose, but I do prefer a solution that works on original > LAVA. Could you please give me some hint?
The device will need to be visible to udev and then you'll be able to identify it in pyudev. That's how ttyUSB0 is created in the first place - the kernel recognises the device and udev creates the device node based on the information which the device feeds to the kernel.
By the way, I found a typo in https://staging.validation.linaro.org/static/docs/v2/admin-lxc-deploy.html: "{% set device_info = [{'board_id': '0123456789', 'usb_vendor_id': '0451', 'usb_vendor_id': 'd109'}] %}" => I guess this should be "{% set device_info = [{'board_id': '0123456789', 'usb_vendor_id': '0451', 'usb_product_id': 'd109'}] %}", the second 'usb_vendor_id' is typo of 'usb_product_id'.
OK, we'll update that.
-Yifan
-----Original Message----- From: Neil Williams [mailto:neil.williams@linaro.org] Sent: Wednesday, July 19, 2017 6:37 PM To: Li, Yifan2 yifan2.li@intel.com Cc: Lava-users@lists.linaro.org Subject: Re: [Lava-users] How to expose device path like '/dev/ttyUSB0' to LAVA-LXC?
On 19 July 2017 at 11:16, Li, Yifan2 yifan2.li@intel.com wrote:
Hello LAVA experts,
Is it possible to expose a device path like ‘/dev/ttyUSB0’ to lxc in job definition or device definition? I have a feature requirement to control a relay card inside LAVA lxc.
Yes. This is the device_info dictionary which can be part of the device dictionary.
https://staging.validation.linaro.org/scheduler/device/staging-hi6220-hikey- 03/devicedict
https://git.linaro.org/lava/lava- lab.git/tree/staging.validation.linaro.org/lava/pipeline/devices/staging- hi6220-hikey-03.jinja2
Also:
https://git.linaro.org/lava/lava- lab.git/tree/staging.validation.linaro.org/lava/pipeline/devices/staging- panda03.jinja2
I have got clues for device_info and read https://validation.linaro.org/static/docs/v2/lava-scheduler-device-dic tionary.html?highlight=device_info and https://validation.linaro.org/static/docs/v2/admin-lxc-
deploy.html?highlight=device_info.
However I did not know how to use it to expose ‘/dev/ttyUSB0’ to LXC.
You need 2017.6 or later for this to work.
https://staging.validation.linaro.org/static/docs/v2/admin-lxc-deploy.html
Although designed for Android testing, the support is available to any use of the LXC.
https://staging.validation.linaro.org/static/docs/v2/admin-lxc- deploy.html#arbitrary-usb-devices-with-lxc-support
--
Neil Williams
neil.williams@linaro.org http://www.linux.codehelp.co.uk/
lava-users@lists.lavasoftware.org