OLD | NEW |
1 Building and Installing | 1 Building and Installing |
2 ----------------------- | 2 ----------------------- |
3 | 3 |
4 See the "INSTALL" file. | 4 See the "INSTALL" file. |
5 | 5 |
6 | 6 |
7 Initiator and Responder | 7 Initiator and Responder |
8 ----------------------- | 8 ----------------------- |
9 | 9 |
10 libmtp implements an MTP initiator, which means it initiate | 10 libmtp implements an MTP initiator, which means it initiate |
11 MTP sessions with devices. The devices responding are known | 11 MTP sessions with devices. The devices responding are known |
12 as MTP responders. libmtp runs on something with a USB host | 12 as MTP responders. libmtp runs on something with a USB host |
13 controller interface, using libusb to access the host | 13 controller interface, using libusb to access the host |
14 controller. | 14 controller. |
15 | 15 |
16 If you're more interested in the MTP responders, gadgets like | 16 If you're more interested in the MTP responders, gadgets like |
17 MP3 players, mobile phones etc, look into MeeGo:s Buteo Sync: | 17 MP3 players, mobile phones etc, look into: |
18 http://wiki.meego.com/Buteo - these guys are creating a fully | 18 - MeeGo:s Buteo Sync: |
19 open source MTP responder. | 19 https://github.com/nemomobile/buteo-mtp |
20 | 20 https://wiki.merproject.org/wiki/Buteo/MTP |
| 21 - Android has an MTP responder implementation: |
| 22 https://android.googlesource.com/platform/frameworks/base/+/master/media/jni/ |
| 23 - Ubuntu/Ricardo Salveti has mtp-server and libmtp-server going: |
| 24 https://code.launchpad.net/~phablet-team/mtp/trunk |
| 25 http://bazaar.launchpad.net/~phablet-team/mtp/trunk/files |
21 | 26 |
22 Heritage | 27 Heritage |
23 -------- | 28 -------- |
24 | 29 |
25 libmtp is based on several ancestors: | 30 libmtp is based on several ancestors: |
26 | 31 |
27 * libptp2 by Mariusz Woloszyn was the starting point used | 32 * libptp2 by Mariusz Woloszyn was the starting point used |
28 by Richard A. Low for the initial starter port. You can | 33 by Richard A. Low for the initial starter port. You can |
29 find it at http://libptp.sourceforge.net/ | 34 find it at http://libptp.sourceforge.net/ |
30 | 35 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 please volunteer. | 136 please volunteer. |
132 | 137 |
133 | 138 |
134 FAQ: Common Problems | 139 FAQ: Common Problems |
135 -------------------- | 140 -------------------- |
136 | 141 |
137 Some MTP devices have strange pecularities. We try to work around | 142 Some MTP devices have strange pecularities. We try to work around |
138 these whenever we can, sometimes we cannot work around it or we | 143 these whenever we can, sometimes we cannot work around it or we |
139 cannot test your solution. | 144 cannot test your solution. |
140 | 145 |
| 146 * Android locked screen: some devices just report zero files |
| 147 and no storages when the device screen is locked, it looks like |
| 148 so: |
| 149 |
| 150 mtp-detect |
| 151 Device 0 (VID=04e8 and PID=6860) is a Samsung Galaxy models (MTP). |
| 152 Attempting to connect device(s) |
| 153 Error 1: Get Storage information failed. |
| 154 Device: SHV-E210K |
| 155 LIBMTP_Get_Storage(): No data available |
| 156 OK. |
| 157 |
| 158 This is probably so as not to allow the MTP access to be used |
| 159 as a "backdoor" into the device. Unlock the device before listing |
| 160 files, set the autolock to some large value or disabled if it |
| 161 disturbs you, you are causing this to yourself, or should we say |
| 162 that your vendor is prioritizing security and privacy over |
| 163 ease-of-use. (You may talk to your vendor about this.) |
| 164 |
141 * mtp-* tools doesn't work because someone else is already hogging | 165 * mtp-* tools doesn't work because someone else is already hogging |
142 the device | 166 the device |
143 | 167 |
144 This is a common problem, the most common case could be that | 168 This is a common problem, the most common case could be that |
145 gphoto2 (which can also talk PTP/MTP) is taking over the device | 169 gphoto2 (which can also talk PTP/MTP) is taking over the device |
146 as soon as it's plugged in. Some distributions are configured that | 170 as soon as it's plugged in. Some distributions are configured that |
147 way. Counter it like this: | 171 way. Counter it like this: |
148 | 172 |
149 gvfs-mount -s gphoto2 | 173 gvfs-mount -s gphoto2 |
150 | 174 |
151 Then re-attach the device. | 175 Then re-attach the device. |
152 | 176 |
153 Sometimes the "gvfs-gphoto2-volume-monitor" is running on the | 177 Sometimes some gvfs daemons are running on the |
154 system and hogging the device, try something like: | 178 system and hogging the device, try stopping them |
| 179 with something like these commands: |
155 | 180 |
156 pkill gfvs-gphoto2-volume-monitor | 181 killall gvfs-mtp-volume-monitor |
| 182 killall gvfs-gphoto2-volume-monitor |
157 | 183 |
158 Then plug in the device and issue "mtp-detect" to figure out if | 184 Then plug in the device and issue "mtp-detect" to figure out if |
159 this may be the case. | 185 this may be the case. |
160 | 186 |
161 * Generic MTP/PTP disconnect misbehaviour: we have noticed that | 187 * Generic MTP/PTP disconnect misbehaviour: we have noticed that |
162 Windows Media Player apparently never close the session to an MTP | 188 Windows Media Player apparently never close the session to an MTP |
163 device. There is a daemon in Windows that "hooks" the device | 189 device. There is a daemon in Windows that "hooks" the device |
164 by opening a PTP session to any MTP device, whenever it is | 190 by opening a PTP session to any MTP device, whenever it is |
165 plugged in. This daemon proxies any subsequent transactions | 191 plugged in. This daemon proxies any subsequent transactions |
166 to/from the device and will never close the session, thus | 192 to/from the device and will never close the session, thus |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 such devices and you cannot expect to have command line tools | 224 such devices and you cannot expect to have command line tools |
199 like the mtp examples work with them. You could implement new | 225 like the mtp examples work with them. You could implement new |
200 example programs that just call to a mediating daemon like the | 226 example programs that just call to a mediating daemon like the |
201 Windows MTP stack does. (And change all programs using libmtp | 227 Windows MTP stack does. (And change all programs using libmtp |
202 directly today.) | 228 directly today.) |
203 | 229 |
204 If this bug in your device annoys you, contact your device | 230 If this bug in your device annoys you, contact your device |
205 manufacturer and ask them to test their product with some libmtp | 231 manufacturer and ask them to test their product with some libmtp |
206 program. | 232 program. |
207 | 233 |
208 * Android locked screen: some devices just report zero files | |
209 and no storages when the device is locked, probably so as not | |
210 to allow the MTP access to be used as a "backdoor" into the | |
211 device. Unlock the device before listing files, set the autolock | |
212 to some large value or disabled if it disturbs you, you are | |
213 causing this to yourself. | |
214 | |
215 * Samsung Android 2.3.x devices: these have a special MTP stack | 234 * Samsung Android 2.3.x devices: these have a special MTP stack |
216 with some specific bugs that we have maybe nailed down now. | 235 with some specific bugs that we have maybe nailed down now. |
217 It suffers from an "immediate connect" syndrome, i.e. you have | 236 It suffers from an "immediate connect" syndrome, i.e. you have |
218 to connect to the device within 7 seconds of plugging in, or it | 237 to connect to the device within 7 seconds of plugging in, or it |
219 will go numb. This also goes for command-line activity with | 238 will go numb. This also goes for command-line activity with |
220 the example programs, so this device is better used with a | 239 the example programs, so this device is better used with a |
221 GUI tool like Rhythmbox, gnomad2... | 240 GUI tool like Rhythmbox, gnomad2... |
222 | 241 |
223 * Generic USB misbehaviour: some devices behave badly under MTP | 242 * Generic USB misbehaviour: some devices behave badly under MTP |
224 and USB mass storage alike, even down to the lowest layers | 243 and USB mass storage alike, even down to the lowest layers |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 | 591 |
573 1. Plug in the device. | 592 1. Plug in the device. |
574 2. USB-mass storage folder will open automatically. | 593 2. USB-mass storage folder will open automatically. |
575 3. Unmount the device. | 594 3. Unmount the device. |
576 4. Run mtp-detect. It will most likely fail the first time. | 595 4. Run mtp-detect. It will most likely fail the first time. |
577 5. Run mtp-detect again, it might work this time, or fail. Keep running | 596 5. Run mtp-detect again, it might work this time, or fail. Keep running |
578 till it works. 99% it works by the third try. | 597 till it works. 99% it works by the third try. |
579 6. Once mtp-detect gives you an "Ok", open either Rhythmbox or Gnomad2, | 598 6. Once mtp-detect gives you an "Ok", open either Rhythmbox or Gnomad2, |
580 everything should work. | 599 everything should work. |
581 | 600 |
582 Linux: Try this, if you have a recent 2.6.x Linux kernel, | 601 Linux: Try this, if you have a recent Linux kernel, |
583 run (as root) something like: | 602 add the file (as root): |
| 603 |
| 604 /etc/modprobe.d/no-usb-storage.conf |
| 605 |
| 606 With the contents: |
| 607 |
| 608 options usb-storage quirks=1234:4321:i |
| 609 |
| 610 This will tell usb-storage to ignore this device when it's inserted |
| 611 so it is not hogged by the mass storage interfaces. Remove and re-insert |
| 612 the device and see if it works. Usually this does the trick. |
| 613 |
| 614 For older systems, or as a bigger hammer, run (as root) something |
| 615 like: |
584 | 616 |
585 > rmmod usb_storage ; mtp-detect | 617 > rmmod usb_storage ; mtp-detect |
586 | 618 |
587 You can run most any command or a client like gnomad2 or | 619 You can run most any command or a client like gnomad2 or |
588 Amarok immediately after the rmmod command. This works | 620 Amarok immediately after the rmmod command. This works |
589 sometimes. Another way: | 621 sometimes. Another even more brutal approach is this: |
590 | 622 |
591 * Edit /etc/modprobe.d/blacklist | 623 * Edit /etc/modprobe.d/blacklist |
592 | |
593 * Add the line "blacklist usb-storage" | 624 * Add the line "blacklist usb-storage" |
594 | |
595 * Reboot. | 625 * Reboot. |
596 | 626 |
597 Now none of you USB disks, flash memory sticks etc will be | 627 Now none of you USB disks, flash memory sticks etc will be |
598 working (you just disabled them all). However you *can* try | 628 working (you just disabled them all). However you *can* try |
599 your device, and it might have started working because there | 629 your device, and it might have started working because there |
600 is no longer a USB mass storage driver that tries to hook onto | 630 is no longer a USB mass storage driver that tries to hook onto |
601 the mass storage interface of your device. | 631 the mass storage interface of your device. |
602 | 632 |
603 If not even blacklisting works (check with | 633 If not even blacklisting works (check with |
604 "lsmod | grep usb-storage"), there is some problem with | 634 "lsmod | grep usb-storage"), there is some problem with |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 NULL, 0); | 1021 NULL, 0); |
992 | 1022 |
993 SKETCH OF AN OVERVIEW | 1023 SKETCH OF AN OVERVIEW |
994 --------------------- | 1024 --------------------- |
995 | 1025 |
996 Draft agenda for a talk on MTP devices submitted for the Android | 1026 Draft agenda for a talk on MTP devices submitted for the Android |
997 builders summit, might come to recycle this: | 1027 builders summit, might come to recycle this: |
998 | 1028 |
999 - Protocol overview | 1029 - Protocol overview |
1000 - Transactional filesystem - no corruption due to unplugged cables! | 1030 - Transactional filesystem - no corruption due to unplugged cables! |
| 1031 - The host and the device can access the files simultaneously, the |
| 1032 device will always "own" the physical file system and proxy the |
| 1033 host (MTP initiator). |
1001 - libmtp interface | 1034 - libmtp interface |
1002 - relation to libgphoto2 | 1035 - relation to libgphoto2 |
1003 - User expectations fall short: | 1036 - User expectations fall short: |
1004 - Not really a mountable filesystem. | 1037 - Not really a mountable filesystem. |
1005 - Streaming does not work. (Size needs to be known beforehand due to | 1038 - Streaming does not work. (Size needs to be known beforehand due to |
1006 transactional nature.) | 1039 transactional nature.) |
| 1040 - GVFS MTP backend to the rescue. |
1007 - Device sins | 1041 - Device sins |
| 1042 - Using the same VID/PID for several modes, some of which are not MTP. |
| 1043 HTC Zopo, HD2, Bird (0x0bb4/0x0c02). Thanks for that, now we cannot |
| 1044 detect the protocol from just VID+PID but have to examine the interfaces. |
1008 - Android bugs | 1045 - Android bugs |
1009 - Samsungs special Android MTP stack | 1046 - Samsungs special Android MTP stack |
1010 - SonyEricsson Aricent stack for Xperia Androids pre 4.0, broken headers! | 1047 - SonyEricsson Aricent stack for Xperia Androids pre 4.0, broken headers! |
1011 - Flat access model vs hierarchical, how Android uses MTP as an hierachical | 1048 - Flat access model vs hierarchical, how Android uses MTP as an hierachical |
1012 file system while it was previously a flat database. | 1049 file system while it was previously a flat database. |
| 1050 - Old paradigm: scan the entire non-hierarchical storage for all content, |
| 1051 build a cache to speed up the (USB 1.1!) link. Usually all files were |
| 1052 stored in the root folder or a single folder named "/Music" or similar. |
| 1053 - Android introduced deeply nested folder hierarchies, not seen before |
| 1054 on MTP devices. |
| 1055 - Microsoft not using the complete metadata dump feature of the MTP |
| 1056 protocol (once introduced by creative) instead they walk directories |
| 1057 separately. |
| 1058 - So caching a big device will take long time and/or timeout. |
| 1059 - Go-MTPFS (FUSE) and GVFS MTP - doing the partial directory walk rather |
| 1060 than caching all files. |
| 1061 - Especially Android devices nowadays assume that |
| 1062 you want to index a folder at the time, whereas older MTP devices (such |
| 1063 as those from Creative) would assume that you wanted to index the entire |
| 1064 device as it was plugged in, and device firmware is now ever more tailored |
| 1065 toward per-folder filetree walking. This makes it harder for the library |
| 1066 to provide the right abstractions: do we provide an API for indexing the |
| 1067 whole device which is unacceptably slow on new devices, or do we provide |
| 1068 an API for indexing a directory at the time which will somehow work on |
| 1069 older devices too? Shall we deprecate the older API? |
1013 - Detecting from vendor extension, can fix in newer extensions! | 1070 - Detecting from vendor extension, can fix in newer extensions! |
1014 - Autoprobing on Linux | 1071 - Autoprobing on Linux |
1015 - Color devices do not like autoprobing | 1072 - Color devices do not like autoprobing |
1016 - Devices need different PIDs for every alternative interface due to | 1073 - Devices need different PIDs for every alternative interface due to |
1017 the Windows USB stack. | 1074 the Windows USB stack. |
1018 - Multimode USB - one PID for each mode due to Windows limitations not | 1075 - Multimode USB - one PID for each mode due to Windows limitations not |
1019 applicable to Linux, SONY devices have ~5 different PIDs for a single | 1076 applicable to Linux, SONY devices have ~5 different PIDs for a single |
1020 device. | 1077 device. |
1021 - Mode switch devices? | 1078 - Mode switch devices? Maybe we do this wrong. |
1022 - MTPZ | 1079 - MTPZ, came and went. Apparently deprecated by Microsoft with Windows |
| 1080 Phone 8. |
1023 - Ideas?? | 1081 - Ideas?? |
1024 | 1082 |
OLD | NEW |