viveris / uMTP-Responder

Lightweight USB Media Transfer Protocol (MTP) responder daemon for GNU/Linux
GNU General Public License v3.0
185 stars 49 forks source link

i.mx6 sabresd working with kernel 4.14.x #13

Closed Gibbio closed 5 years ago

Gibbio commented 5 years ago

Hello everybody, great project, thanks for sharing. Played a bit with my Freescale i.mx6 sabresd dev board and I got it running. Used Kernel 4.14.86 (not working with v4.1.5 from Freescale) My start script is:

modprobe gadgetfs
mkdir /dev/gadget
mount -t gadgetfs gadgetfs /dev/gadget
/usr/bin/umtprd

My modded conf is:

loop_on_disconnect 1
wait 1
usb_dev_path   "/dev/gadget/2184000.usb"
usb_epin_path  "/dev/gadget/ep1in"
usb_epout_path "/dev/gadget/ep2out"
usb_epint_path "/dev/gadget/ep3in"

Hope this help!

jfdelnero commented 5 years ago

Thanks for the feedback ! Have you tried the FunctionFS mode ?

Gibbio commented 5 years ago

Hello, im testing right now, but isn't working. My modded conf is:

usb_functionfs_mode 0x1

usb_dev_path   "/dev/ffs-umtp/ep0"
usb_epin_path  "/dev/ffs-umtp/ep1"
usb_epout_path "/dev/ffs-umtp/ep2"
usb_epint_path "/dev/ffs-umtp/ep3"

the umtprd-ffs.sh script give an error on line 38: ash: write error: No such device

If I start the daemon i get:

root@imx6qdlsabresd:~# umtprd
[uMTPrd - Info] uMTP Responder
[uMTPrd - Info] Version: v0.9.1 compiled the Dec  5 2018@08:37:55
[uMTPrd - Info] (c) 2018 Viveris Technologies
[uMTPrd - Debug] init_mtp_responder
[uMTPrd - Debug] init_mtp_responder : Ok !
[uMTPrd - Info] Add storage shared folder - Root Path: /data
[uMTPrd - Debug] mtp_add_storage : /data
[uMTPrd - Debug] mtp_add_storage : Storage 00000001 mapped to /data (shared folder)
[uMTPrd - Info] USB Device path : /dev/ffs-umtp/ep0
[uMTPrd - Info] USB In End point path : /dev/ffs-umtp/ep1
[uMTPrd - Info] USB Out End point path : /dev/ffs-umtp/ep2
[uMTPrd - Info] USB Event End point path : /dev/ffs-umtp/ep3
[uMTPrd - Info] USB Max packet size : 0x200 bytes
[uMTPrd - Info] Manufacturer string : Viveris Technologies
[uMTPrd - Info] Product string : The Viveris Product !
[uMTPrd - Info] Serial string : 01234567
[uMTPrd - Info] Interface string : MTP
[uMTPrd - Info] USB Vendor ID : 0x1D6B
[uMTPrd - Info] USB Product ID : 0x0100
[uMTPrd - Info] USB class ID : 0x06
[uMTPrd - Info] USB subclass ID : 0x01
[uMTPrd - Info] USB Protocol ID : 0x01
[uMTPrd - Info] USB Device version : 0x3008
[uMTPrd - Info] USB FunctionFS Mode
[uMTPrd - Info] Wait for connection : 0
[uMTPrd - Info] Loop on disconnect : 1
[uMTPrd - Info] Show hidden files : 1
[uMTPrd - Debug] fill_if_descriptor:
[uMTPrd - Debug] 09 04 00 00 03 06 01 01 01
[uMTPrd - Debug] fill_ep_descriptor:
[uMTPrd - Debug] 07 05 81 02 00 02 00
[uMTPrd - Debug] fill_ep_descriptor:
[uMTPrd - Debug] 07 05 02 02 00 02 00
[uMTPrd - Debug] fill_ep_descriptor:
[uMTPrd - Debug] 07 05 83 03 1C 00 06
[uMTPrd - Debug] fill_if_descriptor:
[uMTPrd - Debug] 09 04 00 00 03 06 01 01 01
[uMTPrd - Debug] fill_ep_descriptor:
[uMTPrd - Debug] 07 05 81 02 00 02 00
[uMTPrd - Debug] fill_ep_descriptor:
[uMTPrd - Debug] 07 05 02 02 00 02 00
[uMTPrd - Debug] fill_ep_descriptor:
[uMTPrd - Debug] 07 05 83 03 1C 00 06
[uMTPrd - Debug] init_usb_mtp_gadget :
[uMTPrd - Debug] 03 00 00 00 50 00 00 00 03 00 00 00 04 00 00 00
[uMTPrd - Debug] 04 00 00 00 09 04 00 00 03 06 01 01 01 07 05 81
[uMTPrd - Debug] 02 00 02 00 07 05 02 02 00 02 00 07 05 83 03 1C
[uMTPrd - Debug] 00 06 09 04 00 00 03 06 01 01 01 07 05 81 02 00
[uMTPrd - Debug] 02 00 07 05 02 02 00 02 00 07 05 83 03 1C 00 06
[uMTPrd - Debug] write string :
[uMTPrd - Debug] 02 00 00 00 16 00 00 00 01 00 00 00 01 00 00 00
[uMTPrd - Debug] 09 04 4D 54 50 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00
[uMTPrd - Debug] init_usb_mtp_gadget : USB config done
[uMTPrd - Debug] uMTP Responder : FunctionFS Mode - entering handle_ffs_ep0
[uMTPrd - Debug] handle_ffs_ep0 : Entering...
[uMTPrd - Debug] entering deinit_usb_mtp_gadget
[uMTPrd - Debug] Closing usb device...
[uMTPrd - Debug] leaving deinit_usb_mtp_gadget
[uMTPrd - Info] uMTP Responder : Disconnected
[uMTPrd - Debug] fill_if_descriptor:
[uMTPrd - Debug] 09 04 00 00 03 06 01 01 01
[uMTPrd - Debug] fill_ep_descriptor:
[uMTPrd - Debug] 07 05 81 02 00 02 00
[uMTPrd - Debug] fill_ep_descriptor:
[uMTPrd - Debug] 07 05 02 02 00 02 00
[uMTPrd - Debug] fill_ep_descriptor:
[uMTPrd - Debug] 07 05 83 03 1C 00 06
[uMTPrd - Debug] fill_if_descriptor:
[uMTPrd - Debug] 09 04 00 00 03 06 01 01 01
[uMTPrd - Debug] fill_ep_descriptor:
[uMTPrd - Debug] 07 05 81 02 00 02 00
[uMTPrd - Debug] fill_ep_descriptor:
[uMTPrd - Debug] 07 05 02 02 00 02 00
[uMTPrd - Debug] fill_ep_descriptor:
[uMTPrd - Debug] 07 05 83 03 1C 00 06
[uMTPrd - Debug] init_usb_mtp_gadget :
[uMTPrd - Debug] 03 00 00 00 50 00 00 00 03 00 00 00 04 00 00 00
[uMTPrd - Debug] 04 00 00 00 09 04 00 00 03 06 01 01 01 07 05 81
[uMTPrd - Debug] 02 00 02 00 07 05 02 02 00 02 00 07 05 83 03 1C
[uMTPrd - Debug] 00 06 09 04 00 00 03 06 01 01 01 07 05 81 02 00
[uMTPrd - Debug] 02 00 07 05 02 02 00 02 00 07 05 83 03 1C 00 06
[uMTPrd - Debug] write string :
[uMTPrd - Debug] 02 00 00 00 16 00 00 00 01 00 00 00 01 00 00 00
[uMTPrd - Debug] 09 04 4D 54 50 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00
[uMTPrd - Debug] init_usb_mtp_gadget : USB config done
[uMTPrd - Debug] uMTP Responder : FunctionFS Mode - entering handle_ffs_ep0
[uMTPrd - Debug] handle_ffs_ep0 : Entering...
[uMTPrd - Debug] entering deinit_usb_mtp_gadget
[uMTPrd - Debug] Closing usb device...
[uMTPrd - Debug] leaving deinit_usb_mtp_gadget
[uMTPrd - Info] uMTP Responder : Disconnected
[uMTPrd - Debug] fill_if_descriptor:
[uMTPrd - Debug] 09 04 00 00 03 06 01 01 01
[uMTPrd - Debug] fill_ep_descriptor:
[uMTPrd - Debug] 07 05 81 02 00 02 00
[uMTPrd - Debug] fill_ep_descriptor:
[uMTPrd - Debug] 07 05 02 02 00 02 00
[uMTPrd - Debug] fill_ep_descriptor:
[uMTPrd - Debug] 07 05 83 03 1C 00 06
[uMTPrd - Debug] fill_if_descriptor:
[uMTPrd - Debug] 09 04 00 00 03 06 01 01 01
[uMTPrd - Debug] fill_ep_descriptor:
[uMTPrd - Debug] 07 05 81 02 00 02 00
[uMTPrd - Debug] fill_ep_descriptor:
[uMTPrd - Debug] 07 05 02 02 00 02 00
[uMTPrd - Debug] fill_ep_descriptor:
[uMTPrd - Debug] 07 05 83 03 1C 00 06
[uMTPrd - Debug] init_usb_mtp_gadget :
[uMTPrd - Debug] 03 00 00 00 50 00 00 00 03 00 00 00 04 00 00 00
[uMTPrd - Debug] 04 00 00 00 09 04 00 00 03 06 01 01 01 07 05 81
[uMTPrd - Debug] 02 00 02 00 07 05 02 02 00 02 00 07 05 83 03 1C
[uMTPrd - Debug] 00 06 09 04 00 00 03 06 01 01 01 07 05 81 02 00
[uMTPrd - Debug] 02 00 07 05 02 02 00 02 00 07 05 83 03 1C 00 06
[uMTPrd - Debug] write string :
[uMTPrd - Debug] 02 00 00 00 16 00 00 00 01 00 00 00 01 00 00 00
[uMTPrd - Debug] 09 04 4D 54 50 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00
[uMTPrd - Debug] init_usb_mtp_gadget : USB config done
[uMTPrd - Debug] uMTP Responder : FunctionFS Mode - entering handle_ffs_ep0
[uMTPrd - Debug] handle_ffs_ep0 : Entering...

lsmod:

root@imx6qdlsabresd:~# lsmod
    Not tainted
usb_f_acm 16384 2 - Live 0xbf036000
u_serial 20480 1 usb_f_acm, Live 0xbf02d000
usb_f_fs 32768 3 - Live 0xbf020000
libcomposite 40960 12 usb_f_acm,usb_f_fs, Live 0xbf00e000
configfs 32768 4 usb_f_acm,usb_f_fs,libcomposite, Live 0xbf000000

Nothing appears on dmesg on both host/client

Just edited to let you know that im using a very customized kernel/os so maybe something is missing.

jfdelnero commented 5 years ago

Replace the line 38 in umtprd-ffs.sh with this one :

ls  /sys/class/udc/ > cfg/usb_gadget/g1/UDC

then restart the system and retry.

Gibbio commented 5 years ago

Yes, it's working, I just have to put a sleep 1 after starting the daemon before line 38. So the script looks like:

modprobe libcomposite

mkdir cfg
mount none cfg -t configfs

mkdir cfg/usb_gadget/g1
cd cfg/usb_gadget/g1

mkdir configs/c.1

mkdir functions/ffs.umtp
mkdir functions/acm.usb0

mkdir strings/0x409
mkdir configs/c.1/strings/0x409

echo 0x0100 > idProduct
echo 0x1D6B > idVendor

echo "01234567" > strings/0x409/serialnumber
echo "Viveris Technologies" > strings/0x409/manufacturer
echo "The Viveris Product !" > strings/0x409/product

echo "Conf 1" > configs/c.1/strings/0x409/configuration
echo 120 > configs/c.1/MaxPower

ln -s functions/acm.usb0 configs/c.1
ln -s functions/ffs.umtp configs/c.1

mkdir /dev/ffs-umtp
mount -t functionfs umtp /dev/ffs-umtp
/usr/bin/umtprd &

cd ../../..

sleep 1

ls /sys/class/udc/ > cfg/usb_gadget/g1/UDC

debug output is now:

[uMTPrd - Info] uMTP Responder
[uMTPrd - Info] Version: v0.9.1 compiled the Dec  5 2018@10:40:46
[uMTPrd - Info] (c) 2018 Viveris Technologies
[uMTPrd - Debug] init_mtp_responder
[uMTPrd - Debug] init_mtp_responder : Ok !
[uMTPrd - Info] Add storage shared folder - Root Path: /data
[uMTPrd - Debug] mtp_add_storage : /data
[uMTPrd - Debug] mtp_add_storage : Storage 00000001 mapped to /data (shared folder)
[uMTPrd - Info] USB Device path : /dev/ffs-umtp/ep0
[uMTPrd - Info] USB In End point path : /dev/ffs-umtp/ep1
[uMTPrd - Info] USB Out End point path : /dev/ffs-umtp/ep2
[uMTPrd - Info] USB Event End point path : /dev/ffs-umtp/ep3
[uMTPrd - Info] USB Max packet size : 0x200 bytes
[uMTPrd - Info] Manufacturer string : Viveris Technologies
[uMTPrd - Info] Product string : The Viveris Product !
[uMTPrd - Info] Serial string : 01234567
[uMTPrd - Info] Interface string : MTP
[uMTPrd - Info] USB Vendor ID : 0x1D6B
[uMTPrd - Info] USB Product ID : 0x0100
[uMTPrd - Info] USB class ID : 0x06
[uMTPrd - Info] USB subclass ID : 0x01
[uMTPrd - Info] USB Protocol ID : 0x01
[uMTPrd - Info] USB Device version : 0x3008
[uMTPrd - Info] USB FunctionFS Mode
[uMTPrd - Info] Wait for connection : 1
[uMTPrd - Info] Loop on disconnect : 1
[uMTPrd - Info] Show hidden files : 1
[uMTPrd - Debug] fill_if_descriptor:
[uMTPrd - Debug] 09 04 00 00 03 06 01 01 01
[uMTPrd - Debug] fill_ep_descriptor:
[uMTPrd - Debug] 07 05 81 02 00 02 00
[uMTPrd - Debug] fill_ep_descriptor:
[uMTPrd - Debug] 07 05 02 02 00 02 00
[uMTPrd - Debug] fill_ep_descriptor:
[uMTPrd - Debug] 07 05 83 03 1C 00 06
[uMTPrd - Debug] fill_if_descriptor:
[uMTPrd - Debug] 09 04 00 00 03 06 01 01 01
[uMTPrd - Debug] fill_ep_descriptor:
[uMTPrd - Debug] 07 05 81 02 00 02 00
[uMTPrd - Debug] fill_ep_descriptor:
[uMTPrd - Debug] 07 05 02 02 00 02 00
[uMTPrd - Debug] fill_ep_descriptor:
[uMTPrd - Debug] 07 05 83 03 1C 00 06
[uMTPrd - Debug] init_usb_mtp_gadget :
[uMTPrd - Debug] 03 00 00 00 50 00 00 00 03 00 00 00 04 00 00 00
[uMTPrd - Debug] 04 00 00 00 09 04 00 00 03 06 01 01 01 07 05 81
[uMTPrd - Debug] 02 00 02 00 07 05 02 02 00 02 00 07 05 83 03 1C
[uMTPrd - Debug] 00 06 09 04 00 00 03 06 01 01 01 07 05 81 02 00
[uMTPrd - Debug] 02 00 07 05 02 02 00 02 00 07 05 83 03 1C 00 06
[uMTPrd - Debug] write string :
[uMTPrd - Debug] 02 00 00 00 16 00 00 00 01 00 00 00 01 00 00 00
[uMTPrd - Debug] 09 04 4D 54 50 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[uMTPrd - Debug] 00 00
[uMTPrd - Debug] init_usb_mtp_gadget : USB config done
[uMTPrd - Debug] uMTP Responder : FunctionFS Mode - entering handle_ffs_ep0
[uMTPrd - Debug] handle_ffs_ep0 : Entering...
[uMTPrd - Debug] 1 event(s)
[uMTPrd - Debug] EP0 FFS BIND
[uMTPrd - Debug] Select without timeout
[uMTPrd - Debug] 1 event(s)
[uMTPrd - Debug] EP0 FFS ENABLE
[uMTPrd - Debug] Init end point /dev/ffs-umtp/ep1 (0)
[uMTPrd - Debug] init_ep (0):
[uMTPrd - Debug] 01 00 00 00 07 05 81 02 00 02 00 07 05 81 02 00
[uMTPrd - Debug] 02 00
[uMTPrd - Debug] init_ep (0): FunctionFS Mode - Don't write the endpoint descriptor.
[uMTPrd - Debug] Init end point /dev/ffs-umtp/ep2 (1)
[uMTPrd - Debug] init_ep (1):
[uMTPrd - Debug] 01 00 00 00 07 05 02 02 00 02 00 07 05 02 02 00
[uMTPrd - Debug] 02 00
[uMTPrd - Debug] init_ep (1): FunctionFS Mode - Don't write the endpoint descriptor.
[uMTPrd - Debug] Init end point /dev/ffs-umtp/ep3 (2)
[uMTPrd - Debug] init_ep (2):
[uMTPrd - Debug] 01 00 00 00 07 05 83 03 1C 00 06 07 05 83 03 1C
[uMTPrd - Debug] 00 06
[uMTPrd - Debug] init_ep (2): FunctionFS Mode - Don't write the endpoint descriptor.
[uMTPrd - Debug] Select without timeout

Thanks for helping!

jfdelnero commented 5 years ago

Thanks for the tests & feedbacks. The startup scripts and config files are now updated.

Gibbio commented 5 years ago

Great, thank you!