Chrome OS: Understand the command line to enable Android app debug

Torcheux Frédéric
3 min readJan 10, 2020
Command to enable Android app debug and display usb state in a Chrome shell

You have in your hand your new ChromeBook and you would like to play a little bit with it and build some Android applications on it. You followed the documentation to setup the development environement and they asked you to type a weird command:

sudo ectool usbpd <port number> dr_swap

What does that mean? We will understand it together!

<port number>?

All USB-C ports on your ChromeBook are not necessarily compatible to install and debug applications on it. You must find the one which allows it.

This link lists some devices and which ports can be used. Unfortunately this page doesn’t seem updated and you will have to find it by yourself. Generally, the port which can be used is the port with ID 0.

What is ectool?

EC means embedded controllers. Controllers term refers to the physical component of a ChromeBook like touchpad, fans, battery.

ectool is the software which control these components and that we can use to modify some component parameters.

Type sudo ectool help in a chrome shell to get more information on this command.

What is usbpd?

usbpd means USB power delivery. USB power delivery is an USB specification, only compatible with USB-C connectors, which allows to charge plugged devices with a power up to 100W.

The command usbpd allows to control USB-C ports behavior.

Here are options:

usbpd <port> <auto | [toggle|toggle-off|sink|source] [none|usb|dp|dock] [dr_swap|pr_swap|vconn_swap]>

USB-C functioning?

With previous USB specifications, devices on each side of a USB cable had a defined role. For example, a smartphone connected to a computer was always charged by this one. The smartphone is the consumer and the computer is the provider with no way to change this.

With USB-C specification, the power deliver and power consumer roles can be swaped.

Moreover, power deliver role and data role are separated. It’s possible to swap one role, the other one isn’t changed.

Regarding data transfert, there are several data roles:
- DFP (downstream facing port): a port whose role is to be the host (a computer).
- UFP (upstream facing port): a port whose role is to be connected to a USB host (a USB key).
- DRP (dual role port): a port which can change its role according to needed.

What means dr_swap?

dr_swap option allows to change the role of a USB port: DFP <-> UFP.

By default, the ChromeBook USB port has a DFP role. It’s a computer so we plug smartphones / USB keys to it more often than we connect it to another computer.

For this reason, we need to change the USB role and set our USB port role to UFP. We must be the client in order to be detected by ADB on the connected computer.

Bonus: Change power delivery direction

sudo ectool usbpd <port number> pr_swap

You can now change if the ChromeBook is the power provider or the power consumer.

This command is equivalent to going in ChromeBook settings: Device -> Power and changing power source.

On an Android device, this command does the same as if you change the setting charge connected device in USB Preferences.




Torcheux Frédéric

I’m a French Android developer at MWM. I humbly try to contribute to the developer community from which I learnt everything.