I'm currently trying to make my Rpi Zero W act as a MTP responder. After some researchs I found out that the best way to implement it would be to use functionfs and develop a userspace driver for MTP.
I also found an open source project implementing a MTP responder in userspace at : https://github.com/pcercuei/buteo-mtp
I have absolutely no experience with driver programming or USB devices so to get used to this framework I began with configuring a mass storage gadget and then a gadget implementing both ACM and RNDIS functions.
It's now clearer but I still lacks explanation as the buteo-mtp project comes without any information on how it works or how to use it. And the README is deprecated.
If I understand well, the only thing I need is a configured function ffs and a mounted file system of type functionfs. Then the userspace driver should be able to run.
Here is my initialisation script :
However when I run this script (cloned from other gadgets and adapted) it stops at "Binding USB Device Controller" when it was running for other gadgets.
Code: Select all
#!/bin/sh set -e CONFIGFS="/sys/kernel/config" GADGET="$CONFIGFS/usb_gadget" VID="0x0525" PID="0xa4a2" SERIAL="0123456789" MANUF="Myself" PRODUCT="MyProduct" case "$1" in start) echo "Creating the USB gadget" echo "Loading composite module" modprobe libcomposite echo "Creating gadget directory g1" mkdir -p $GADGET/g1 cd $GADGET/g1 if [ $? -ne 0 ]; then echo "Error creating usb gadget in configfs" exit 1; else echo "OK" fi echo "Creating MTP responder interface" mkdir -p functions/ffs.mtp mkdir -p configs/c.1 mkdir -p configs/c.1/strings/0x409 echo "Custom configuration" > configs/c.1/strings/0x409/configuration ln -s functions/ffs.mtp configs/c.1/ mkdir -p /dev/mtp mount mtp -t functionfs /dev/mtp echo "OK" echo "Setting Vendor and Product ID's" echo $VID > idVendor echo $PID > idProduct echo "OK" echo "Setting English strings" mkdir -p strings/0x409 echo $SERIAL > strings/0x409/serialnumber echo $MANUF > strings/0x409/manufacturer echo $PRODUCT > strings/0x409/product echo "OK" echo "Binding USB Device Controller" echo `ls /sys/class/udc` > UDC echo "OK" ;;
The only Usb Device Controller I have in /sys/class/udc is 20980000.usb
Is there a reason why I can't bind this driver to the gadget when I can for mass_storage, acm and rndis?
Am I not forgetting something?
If I run the mtp responder I have the following output :
So for the Rpi it seems to be okay but on the host side no mtp device is detected with mtp-detect.
Code: Select all
pi@raspberrypi:~ $ sudo mtpd transport/usb/mtptransporterusb.cpp 57 : MTPTransporterUSB::activate transport/usb/mtptransporterusb.cpp 82 : mtp function set up
I would be glad to have some advices because I'm not able to go further by myself and I can feel that I'm not that far from having it working ^^
Thanks in advance