New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 831850 link

Starred by 165 users

Issue metadata

Status: Assigned
Owner:
User never visited
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 2
Type: Bug

Restricted
  • Only users with EditIssue permission may comment.



Sign in to add a comment

Enable USB emulation in crosvm

Project Member Reported by dgreid@chromium.org, Apr 11 2018

Issue description

Allow USB devices to be accessed from VMs.

Devices must be allowed by permission broker.

This will allow things like USB JTAG and android phones w/ adb to work.
 

Comment 1 by dinv...@gmail.com, Apr 15 2018

This would be a huge bonus to using crosvm. Devices like phones, flash drives, printers, scanners, YubiKeys etc. would greatly expand use cases of these VMs.
LXD upstream here. :)
This would also work nicely with containers. LXD can dynamically add devices to running containers. Once good example are usb devices. Essentially you can tell LXD to listen for a uevent for a specific usb device or even all usb devices from a specific vendor:

lxc config device add <container-name> <device-name> usb vendorid=<id> productid=<id>

Here is a demo that dynamically adds my Android phone to my LXD container and connects to it via adb devices:

https://asciinema.org/a/171520

I've also done some kernel work to support injecting uevents into containers starting with kernel 4.17. Since LXD runs system containers you can then even setup specific udev rules in the container and have them processed by udevd or in the case of Android ueventd.
When you're running unprivileged containers you won't be able to create device nodes yourself but that is - at least on new kernels - the job of devtmpfs anyway. And for unprivileged containers LXD will take care to create and inject the devices nodes into the container.
Status: Available (was: Untriaged)
Labels: Hotlist-Crostini-Platform
Hopefully this will aso enable serial USB devices. This would be a great boost for the education market, enabling Arduino development from Chromebooks.
Would really like to be able to run the Arduino programmer and program devices on my C101!
For what it's worth, and off-topic to the discussion in general to some extent... but... to the last poster, do you know about WebUSB?

There is a Chrome app called Chromeduino that has an IDE and lets you work with an Arduino from ChromeOS natively: https://chrome.google.com/webstore/detail/chromeduino2/llclpgogfbmiicabgcfbndeokekmggpm

More details here: https://github.com/spaceneedle/Chromeduino

However, there is also an official "Web Editor" for Arduino too: 
https://create.arduino.cc/projecthub/Arduino_Genuino/getting-started-with-arduino-web-editor-on-various-platforms-4b3e4a?f=1

Anyway, it would still be good to have proper USB pass-through support for containers/VMs.

We have it for Android via this flag: chrome://flags/#arc-usb-host so maybe that will help you get by for now on your Chromebook, if it supports Android apps that is.
Need to be able to use ARM M0 and non standard board type for my boat's wind instrument.  It's a very specific use case but one of the last reasons why a Chromebook has to be set aside from time to time to use something a bit more mainstream. I really appreciate the tips and am loving the pace of advancement that chromeOS has been receiving. 
My mistake about the official editor... it needs some third party plugin: https://github.com/arduino/arduino-create-agent

So that won't work, but give Chromeduino a try!
Also it would be really cool to be able to use USB to read from dive computers on Android apps. Hopefully also there would be a way to use either the Android or Linux version of Subsurface to talk to a BLE based computer too. Unfortunately at the moment my Chromebook doesn't work with the Android version yet. That and divemate can't see the USB port at all when connecting my older dive computer. 
Also found this, if your email was visible here I'd send it separate from this thread, apologies all...

https://codebender.cc/static/plugin

There's also this thing for ARM devices: https://os.mbed.com/docs/v5.9/tools/arm-mbed-online-compiler.html
But being on a boat, I could see how you definitely might not always have reliable internet access... a native offline solution would be ideal, for sure.
It should be pointed out that Chrome packaged apps have always had access to a serial USB ÀPI and the Espruino has IDE app makes use of it to allow programming a variety of Arm M3 based boards: https://www.espruino.com/Web+IDE
Note, though, that also uses a third party server for compilation, so you need network access to use it.

https://github.com/espruino/EspruinoTools/blob/f08b6bb6556c3114758539ae1153acd58f343d28/plugins/compiler.js
No, that's only to selectively compile JS into native code, a completely optional feature, you can use Espruino to program compatible boards with your Chromebook completely offline.
Actually that's some kind of JS compiler... literally turning JS into native code, not a C++ compiler, and it's using some kind of proprietary Espurino libraries.

It might do assembly compilation though...

https://github.com/espruino/EspruinoTools/blob/f08b6bb6556c3114758539ae1153acd58f343d28/plugins/assembler.js


So you're saying this will let you push bytecode or compile c++ to any ARM M3 microcontroller? I am suspicious... I think you need to be running their firmware on your board for it to work, no?
AFAICT that is running JS on your microcontroller using their libraries, not compiling C++.
This thing runs an M0 so it should be possible, in theory to get your board to work: http://www.espruino.com/MicroBit

Yes, absolutely, Espruino IDE is only for communicating with boards running Espruino firmware, I was simply using it to point out the availability and usability of serial USB APIs for Chrome Packaged Apps and so hopefully means there are no big issues such as security to prevent containers getting access.
Labels: Restrict-AddIssueComment-EditIssue
sorry, but this isn't the place for getting support for using various embedded devices.  please use other forums instead.  this bug is only about USB emulation in crosvm and what it'll take to enable that.
Owner: jkwang@chromium.org
Project Member

Comment 22 by bugdroid1@chromium.org, Jul 28

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform/crosvm/+/c1ce54a9dd832ec8c71e49b09b1e4e7a67ede7b6

commit c1ce54a9dd832ec8c71e49b09b1e4e7a67ede7b6
Author: Jingkui Wang <jkwang@google.com>
Date: Sat Jul 28 02:11:15 2018

pci: Add serial bus subclass

Add serial bus subclass

BUG=chromium:831850
TEST=cargo test

Change-Id: Iffd7a27b5cb423c928f0108b16fb58558cf7bcd4
Reviewed-on: https://chromium-review.googlesource.com/1152212
Commit-Ready: Jingkui Wang <jkwang@google.com>
Tested-by: Jingkui Wang <jkwang@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>

[modify] https://crrev.com/c1ce54a9dd832ec8c71e49b09b1e4e7a67ede7b6/devices/src/pci/pci_configuration.rs

Status: Assigned (was: Available)
Project Member

Comment 24 by bugdroid1@chromium.org, Aug 3

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/785a41eaf185078abf3e1a779134356ea297e0a0

commit 785a41eaf185078abf3e1a779134356ea297e0a0
Author: Jingkui Wang <jkwang@google.com>
Date: Fri Aug 03 04:50:21 2018

crosvm: add pkg-config

Add pkg-config to crosvm ebuild.

BUG=chromium:831850
TEST=local build

Change-Id: I3886de9c290beb8192e6e59273174d022b550ae7
Reviewed-on: https://chromium-review.googlesource.com/1161220
Commit-Ready: Jingkui Wang <jkwang@google.com>
Tested-by: Jingkui Wang <jkwang@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>

[modify] https://crrev.com/785a41eaf185078abf3e1a779134356ea297e0a0/chromeos-base/crosvm/Manifest
[modify] https://crrev.com/785a41eaf185078abf3e1a779134356ea297e0a0/chromeos-base/crosvm/crosvm-9999.ebuild

Project Member

Comment 25 by bugdroid1@chromium.org, Aug 7

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform/crosvm/+/eba6e7f9bdbb521b285b676ff0c34ba79ee8e0db

commit eba6e7f9bdbb521b285b676ff0c34ba79ee8e0db
Author: Jingkui Wang <jkwang@google.com>
Date: Tue Aug 07 05:11:30 2018

sys_util: enable custom events in pollcontext

Can specify events for epoll now.

BUG=chromium:831850
TEST=local build

Change-Id: Iad418b5e9570b38fd8033276bf02ee3eb96d0d77
Reviewed-on: https://chromium-review.googlesource.com/1125293
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Jingkui Wang <jkwang@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>

[modify] https://crrev.com/eba6e7f9bdbb521b285b676ff0c34ba79ee8e0db/sys_util/src/poll.rs

Project Member

Comment 26 by bugdroid1@chromium.org, Aug 7

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform/crosvm/+/f226e28632d95c8b3c8d90fbaaef1eda8509fc74

commit f226e28632d95c8b3c8d90fbaaef1eda8509fc74
Author: Jingkui Wang <jkwang@google.com>
Date: Tue Aug 07 08:51:08 2018

bitfield: Add fmt::Debug

implements fmt::Debug for bitfield

BUG=chromium:831850
TEST=cargo test

Change-Id: I58c2211a50726aaea0ea45164ae07c7b38eddea7
Reviewed-on: https://chromium-review.googlesource.com/1147111
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Jingkui Wang <jkwang@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>

[modify] https://crrev.com/f226e28632d95c8b3c8d90fbaaef1eda8509fc74/bit_field/bit_field_derive/bit_field_derive.rs

Labels: -M-69 M-71
Cc: msnoxell@chromium.org
Project Member

Comment 29 by bugdroid1@chromium.org, Aug 29

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform/crosvm/+/b47c6925fb7a82696af2dae16dbde06863d584c4

commit b47c6925fb7a82696af2dae16dbde06863d584c4
Author: Jingkui Wang <jkwang@google.com>
Date: Wed Aug 29 18:16:14 2018

Remove sync requirements of pci device trait

It's not needed.

BUG=chromium:831850
TEST=cargo test

Change-Id: I7e38590271ec14db422f5f3421302e98a2ca19ab
Reviewed-on: https://chromium-review.googlesource.com/1194317
Commit-Ready: Jingkui Wang <jkwang@google.com>
Tested-by: Jingkui Wang <jkwang@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>

[modify] https://crrev.com/b47c6925fb7a82696af2dae16dbde06863d584c4/devices/src/pci/pci_device.rs

for visibility, we've got a new USBGuard feature making it's way onto CrOS systems that might intersect with this functionality:
  http://doc/1wstNeVI62Eh6Rm6zqszHpiZphbxAoVGybsvbKGpYjXQ
  http://slides/1TjoXYlkIPGIxB6xBA0Fhu5RR8eJJULwtiyHgvu3bu1Y

i don't think we need to actively design for it atm, but something to keep in mind that might crop up at some point
Project Member

Comment 31 by bugdroid1@chromium.org, Nov 16

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/45c18df6fb9b38637c58be19bc6a7556c0ae51cb

commit 45c18df6fb9b38637c58be19bc6a7556c0ae51cb
Author: Jingkui Wang <jkwang@google.com>
Date: Fri Nov 16 13:02:02 2018

app-emulation/lxd: patch lxd to allow passing all usb

Use the following command to pass in all usb:
 lxc config device add <container name> <device name> usb

BUG=chromium:831850
TEST=cargo test

Change-Id: Ib66769398b8244149669c745d4fb3d657775f843
Reviewed-on: https://chromium-review.googlesource.com/1338156
Commit-Ready: Jingkui Wang <jkwang@google.com>
Tested-by: Jingkui Wang <jkwang@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>

[rename] https://crrev.com/45c18df6fb9b38637c58be19bc6a7556c0ae51cb/app-emulation/lxd/lxd-3.0.2-r4.ebuild
[add] https://crrev.com/45c18df6fb9b38637c58be19bc6a7556c0ae51cb/app-emulation/lxd/files/lxd-3.0.2-pass-all-usb.patch
[modify] https://crrev.com/45c18df6fb9b38637c58be19bc6a7556c0ae51cb/app-emulation/lxd/lxd-3.0.2.ebuild

Project Member

Comment 32 by bugdroid1@chromium.org, Nov 17

Labels: merge-merged-chromeos-4.19
The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/kernel/+/da4ccb86ec34df92ea62f6f4c7d5315fdddcb2b8

commit da4ccb86ec34df92ea62f6f4c7d5315fdddcb2b8
Author: Jingkui Wang <jkwang@google.com>
Date: Sat Nov 17 13:25:11 2018

CHROMIUM: arch: configs: Enable xhci driver in termina

BUG=chromium:831850
TEST=local build

Change-Id: I6d563ca918d83f001ae3ded33a0d469d1631c94b
Signed-off-by: Jingkui Wang <jkwang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1332270
Reviewed-by: Stephen Barber <smbarber@chromium.org>

[modify] https://crrev.com/da4ccb86ec34df92ea62f6f4c7d5315fdddcb2b8/arch/arm64/configs/chromiumos-container-vm-arm64_defconfig
[modify] https://crrev.com/da4ccb86ec34df92ea62f6f4c7d5315fdddcb2b8/arch/x86/configs/chromiumos-container-vm-x86_64_defconfig

Project Member

Comment 33 by bugdroid1@chromium.org, Nov 29

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform/tremplin/+/03711a26cb816b03fbd544c771e4655952855167

commit 03711a26cb816b03fbd544c771e4655952855167
Author: Jingkui Wang <jkwang@google.com>
Date: Thu Nov 29 05:01:51 2018

tremplin: pass through all usb devices

add all usb devices

BUG=chromium:831850
TEST=build local image and run

Change-Id: I8fd7d7091cd6458abb423d242e70235b7dadd407
Reviewed-on: https://chromium-review.googlesource.com/1340462
Commit-Ready: Jingkui Wang <jkwang@google.com>
Tested-by: Jingkui Wang <jkwang@google.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>

[modify] https://crrev.com/03711a26cb816b03fbd544c771e4655952855167/src/chromiumos/tremplin/main.go

Project Member

Comment 34 by bugdroid1@chromium.org, Nov 30

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/add5a4c3751778e5380f00b2ee6cebcb6bda48fc

commit add5a4c3751778e5380f00b2ee6cebcb6bda48fc
Author: Jingkui Wang <jkwang@google.com>
Date: Fri Nov 30 03:31:19 2018

libusb: add libusb to chromiumos overlay

This change:
    checks in upstream 1.0.21.
    adds a patch to enable libusb to take an fd as device handle. Thus we can
sandbox libusb.

BUG=chromium:831850
TEST=local build

Change-Id: I1d97171160e4bdb5b3968dd78796126696eef2e5
Reviewed-on: https://chromium-review.googlesource.com/1331019
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Jingkui Wang <jkwang@google.com>
Reviewed-by: Jingkui Wang <jkwang@google.com>
Reviewed-by: Reilly Grant <reillyg@chromium.org>

[add] https://crrev.com/add5a4c3751778e5380f00b2ee6cebcb6bda48fc/dev-libs/libusb/Manifest
[add] https://crrev.com/add5a4c3751778e5380f00b2ee6cebcb6bda48fc/dev-libs/libusb/files/libusb-1.0.21-open-fd.patch
[add] https://crrev.com/add5a4c3751778e5380f00b2ee6cebcb6bda48fc/dev-libs/libusb/libusb-1.0.21.ebuild
[add] https://crrev.com/add5a4c3751778e5380f00b2ee6cebcb6bda48fc/dev-libs/libusb/metadata.xml
[add] https://crrev.com/add5a4c3751778e5380f00b2ee6cebcb6bda48fc/dev-libs/libusb/libusb-1.0.21-r1.ebuild

Project Member

Comment 35 by bugdroid1@chromium.org, Dec 1

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform/crosvm/+/33e08312f272c863f062fffe53ea4a4ce94e6e26

commit 33e08312f272c863f062fffe53ea4a4ce94e6e26
Author: Jingkui Wang <jkwang@google.com>
Date: Sat Dec 01 09:08:35 2018

usb_util: Create libusb wrapper

This wrapper will be part of usb emulation backend.

BUG=chromium:831850
TEST=local build

Change-Id: I084b15201941e4c16c4e3ff9b967e55db09db567
Reviewed-on: https://chromium-review.googlesource.com/1124870
Commit-Ready: Jingkui Wang <jkwang@google.com>
Tested-by: Jingkui Wang <jkwang@google.com>
Reviewed-by: Jingkui Wang <jkwang@google.com>

[add] https://crrev.com/33e08312f272c863f062fffe53ea4a4ce94e6e26/usb_util/Cargo.toml
[add] https://crrev.com/33e08312f272c863f062fffe53ea4a4ce94e6e26/usb_util/build.rs
[add] https://crrev.com/33e08312f272c863f062fffe53ea4a4ce94e6e26/usb_util/src/bindings.rs
[add] https://crrev.com/33e08312f272c863f062fffe53ea4a4ce94e6e26/usb_util/src/lib.rs
[add] https://crrev.com/33e08312f272c863f062fffe53ea4a4ce94e6e26/usb_util/src/error.rs
[modify] https://crrev.com/33e08312f272c863f062fffe53ea4a4ce94e6e26/Cargo.lock
[add] https://crrev.com/33e08312f272c863f062fffe53ea4a4ce94e6e26/usb_util/src/types.rs
[modify] https://crrev.com/33e08312f272c863f062fffe53ea4a4ce94e6e26/Cargo.toml
[add] https://crrev.com/33e08312f272c863f062fffe53ea4a4ce94e6e26/usb_util/src/device_handle.rs
[add] https://crrev.com/33e08312f272c863f062fffe53ea4a4ce94e6e26/usb_util/src/libusb_device.rs
[add] https://crrev.com/33e08312f272c863f062fffe53ea4a4ce94e6e26/usb_util/src/config_descriptor.rs
[add] https://crrev.com/33e08312f272c863f062fffe53ea4a4ce94e6e26/usb_util/src/libusb_context.rs

Project Member

Comment 36 by bugdroid1@chromium.org, Dec 1

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform/crosvm/+/457ebc9d93253cc44d81baacda889ff604fb0319

commit 457ebc9d93253cc44d81baacda889ff604fb0319
Author: Jingkui Wang <jkwang@google.com>
Date: Sat Dec 01 09:08:35 2018

usb_util: Add pollfd change handler.

Allow user to hander pollfd change events.

BUG=chromium:831850
TEST=local build
CQ-DEPEND=CL:1124870

Change-Id: I013104e7dfae8f9ae94803f99f435039cd53925c
Reviewed-on: https://chromium-review.googlesource.com/1135783
Commit-Ready: Jingkui Wang <jkwang@google.com>
Tested-by: Jingkui Wang <jkwang@google.com>
Reviewed-by: Jingkui Wang <jkwang@google.com>

[modify] https://crrev.com/457ebc9d93253cc44d81baacda889ff604fb0319/usb_util/src/libusb_context.rs

Project Member

Comment 37 by bugdroid1@chromium.org, Dec 1

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform/crosvm/+/81066162c240f45fbed96ca868d69c91a40bfb0e

commit 81066162c240f45fbed96ca868d69c91a40bfb0e
Author: Jingkui Wang <jkwang@google.com>
Date: Sat Dec 01 09:08:36 2018

usb_util: Add descriptors

add config descriptors, endpoint descriptors, interface descriptors.

BUG=chromium:831850
TEST=cargo test
CQ-DEPEND=CL:1135783

Change-Id: If74c407f198725bdc6a3096b03d6fe02dcd29ec8
Reviewed-on: https://chromium-review.googlesource.com/1299716
Commit-Ready: Jingkui Wang <jkwang@google.com>
Tested-by: Jingkui Wang <jkwang@google.com>
Reviewed-by: Jingkui Wang <jkwang@google.com>

[modify] https://crrev.com/81066162c240f45fbed96ca868d69c91a40bfb0e/usb_util/src/lib.rs
[modify] https://crrev.com/81066162c240f45fbed96ca868d69c91a40bfb0e/usb_util/src/config_descriptor.rs
[add] https://crrev.com/81066162c240f45fbed96ca868d69c91a40bfb0e/usb_util/src/endpoint_descriptor.rs
[add] https://crrev.com/81066162c240f45fbed96ca868d69c91a40bfb0e/usb_util/src/interface_descriptor.rs

Project Member

Comment 38 by bugdroid1@chromium.org, Dec 1

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform/crosvm/+/b14ce22a1bab381d94be94b67c756ad7dc908f8b

commit b14ce22a1bab381d94be94b67c756ad7dc908f8b
Author: Jingkui Wang <jkwang@google.com>
Date: Sat Dec 01 09:08:50 2018

crosvm: update kokoro docker file to install libusb-1.0

Usb emulation depend on libusb. This path install libusb-1.0 to the
container.

BUG=chromium:831850
TEST=local build docker and run kokoro_simulator.sh

Change-Id: I2fa406914bf7cfe9a790ec945e15eb387e964d8e
Reviewed-on: https://chromium-review.googlesource.com/1356766
Commit-Ready: Jingkui Wang <jkwang@google.com>
Tested-by: Jingkui Wang <jkwang@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>

[modify] https://crrev.com/b14ce22a1bab381d94be94b67c756ad7dc908f8b/kokoro/Dockerfile

Project Member

Comment 39 by bugdroid1@chromium.org, Dec 4 (5 days ago)

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform2/+/eb9755c220ee03679a999c24ea32ca82150dfdcd

commit eb9755c220ee03679a999c24ea32ca82150dfdcd
Author: Fergus Dall <sidereal@google.com>
Date: Tue Dec 04 08:11:30 2018

system_api: Add DBUS constants and protobufs for vm_concierge USB commands

This CL defines AttachUsbDevice, DetachUsbDevice, and ListUsbDevices
dbus methods for vm_concierge and adds corresponding request and
response protobufs.

BUG=chromium:831850
TEST=manually tested

Change-Id: I575db1f5c684c6151339f111e2f80a77cd977bc2
Reviewed-on: https://chromium-review.googlesource.com/1343717
Commit-Ready: Fergus Dall <sidereal@google.com>
Tested-by: Fergus Dall <sidereal@google.com>
Reviewed-by: Mike Frysinger <vapier@chromium.org>

[modify] https://crrev.com/eb9755c220ee03679a999c24ea32ca82150dfdcd/system_api/dbus/vm_concierge/dbus-constants.h
[modify] https://crrev.com/eb9755c220ee03679a999c24ea32ca82150dfdcd/system_api/dbus/vm_concierge/service.proto

Sign in to add a comment