USB Device Mode - jekhor/yogabook-linux GitHub Wiki
Enabling of USB Device (gadget) mode
Applies to YB1-X91F/L models.
To enable the USB device mode (allowing to connect the Yoga Book to another computer via USB), you need to change hidden BIOS setting which enables DWC3 controller enumeration on the PCI bus.
To make this, create a partition with FAT32 filesystem on a USB dongle and put a grubx64.efi file as /EFI/Boot/bootx64.efi
on the flash. Connect a keyboard and this USB dongle via the powered OTG USB hub, boot the Yoga Book from this flash and issue the command:
setup_var 0x139 1
Press Ctrl-Alt-Del to reboot.
After this, you should see the new entry in the output of lsusb
command:
00:16.0 USB controller: Intel Corporation Device 22b7 (rev 34)
To use USB device functions, load appropriate module, for example g_ether
for CDC Ethernet Gadget:
modprobe g_ether
Connect the Yoga Book to another PC and check if it found new device.
Explanation
There are many EFI settings not available to change via BIOS Setup but may be changed in the EFI storage directly. Read Hans' blogpost about OTG device mode and this article about hidden BIOS settings to understand how this works.
The 0x139 magic number is an offset for following setting value:
0x19650 One Of: USB OTG Support, VarStoreInfo (VarOffset/VarName): 0x139, VarStore: 0x1234, QuestionId: 0xB5, Size: 1, Min: 0x0, Max 0x3, Step: 0x0 {05 91 DF 00 E0 00 B5 00 34 12 39 01 10 10 00 03 00}
0x19661 One Of Option: Disabled, Value (8 bit): 0x0 {09 07 24 04 00 00 00}
0x19668 One Of Option: PCI Mode, Value (8 bit): 0x1 {09 07 BC 00 00 00 01}
0x1966F One Of Option: ACPI Mode, Value (8 bit): 0x2 {09 07 BD 00 00 00 02}
0x19676 One Of Option: AUTO Mode, Value (8 bit): 0x3 (default) {09 07 C4 04 30 00 03}
0x1967D End One Of {29 02}
It is set to AUTO Mode (0x3) mode by default for Windows version of Yoga Book. Changing this to 0x1 (PCI Mode) enables enumeration of the UDC controller at PCIE bus.