I am reading the Gadget Configuration Documentation. I am also using a working Android device to reference and copy configurations in /config/usb_gadget/g1. I am now booting an initramfs and trying to start the device as an adb device without running any Linux flavor. I extracted the kernel from the device's boot.img, changed the ramdisk.cpio.gz with the following init script

mount -a #mount dev sys proc and configfs
create_devices #make all necessary nodes
mkdir -p /config/usb_gadget/g1/strings/0x409
mkdir -p /config/usb_gadget/g1/functions/ffs.adb
mkdir -p /config/usb_gadget/g1/functions/configs/b.1/strings/0x409
ln -s /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1
echo "0x0e8d" > /config/usb_gadget/g1/idVendor
echo "0x201c" > /config/usb_gadget/g1/idProduct
echo "0123456789101112" > /config/usb_gadget/g1/strings/0x409/serialnumber
echo "TECNO" > /config/usb_gadget/g1/strings/0x409/manufacturer
echo "TECNO KI7" > /config/usb_gadget/g1/strings/0x409/product
echo adb > /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration
echo "0x80" > /config/usb_gadget/g1/configs/b.1/bmAttributes
echo musb-hdrc > /config/usb_gadget/g1/UDC
echo "0x00" > /config/usb_gadget/g1/bDeviceClass
echo "0x00" > /config/usb_gadget/g1/bDeviceProtocol
echo "0x00" > /config/usb_gadget/g1/bDeviceSubClasss
echo "0x0404" > /config/usb_gadget/g1/bcdDevice
echo "0x0200" > /config/usb_gadget/g1/bcdUSB
echo "0x40" > /config/usb_gadget/g1/bMaxPacketSize0

The device boots fine but won't start the ADB USB Gadget. Here is an init log

[1.550749] (7) [1:init] gadgets_make name=g1
[1.552088] (7) [1:init] function_make name=ffs.adb
[1.552104] (7) [1:init] file system registered
[1.558890] (1) [1:init] function_make name=configs
[1.558911] (1) [1:init] Unable to locate . in FUNC.INSTANCE
[1.562824] (2) [1:init] gadget_dev_desc_UDC_store write musb-hdrc
[1.562839] (2) [1:init] configfs_composite_bind
[1.562852] (2) [1:init] composite_dev_prepare 0000000037341456
[1.562870] (2) [1:init] Need at least one configuration in g1.
[1.562878] (2) [1:init] composite_dev_cleanup os_desc_req[0]=(null)cdev>req[0]=0000000037341456
[1.562892] (2) [1:init] configfs-gadget musb-hdrc: failed to start g1: -22

I suspected maybe I didn't link the configs folder right but the following has the same result

ln -s /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/ffs.adb

It keeps on stating Need at least one configuration in g1. When I run find /config/usb_gadget/g1 it doesn't find any files in /config/usb_gadget/g1/configs but it does list /config/usb_gadget/g1/configs as a possible path. This means any files I try to write to configs aren't being written since /config/usb_gadget/g1/configs/b.1 doesn't exist when I try to find it. How can I write files to /config/usb_gadget/g1/configs?

1 Answer 1


It turns out I needed to split up making those directories

    mkdir -p "$GADGET"
    mkdir -p "$GADGET"/strings/0x409
    mkdir -p "$GADGET"/configs/b.1
    mkdir -p "$GADGET"/configs/b.1/strings/0x409
    mkdir -p "$GADGET"/functions/ffs.adb

Probably it was because configfs needed to automatically populate template files

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .