| 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: | 17 MP3 players, mobile phones etc, look into MeeGo:s Buteo Sync: |
| 18 - MeeGo:s Buteo Sync: | 18 http://wiki.meego.com/Buteo - these guys are creating a fully |
| 19 https://github.com/nemomobile/buteo-mtp | 19 open source MTP responder. |
| 20 https://wiki.merproject.org/wiki/Buteo/MTP | 20 |
| 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 | |
| 26 | 21 |
| 27 Heritage | 22 Heritage |
| 28 -------- | 23 -------- |
| 29 | 24 |
| 30 libmtp is based on several ancestors: | 25 libmtp is based on several ancestors: |
| 31 | 26 |
| 32 * libptp2 by Mariusz Woloszyn was the starting point used | 27 * libptp2 by Mariusz Woloszyn was the starting point used |
| 33 by Richard A. Low for the initial starter port. You can | 28 by Richard A. Low for the initial starter port. You can |
| 34 find it at http://libptp.sourceforge.net/ | 29 find it at http://libptp.sourceforge.net/ |
| 35 | 30 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 please volunteer. | 131 please volunteer. |
| 137 | 132 |
| 138 | 133 |
| 139 FAQ: Common Problems | 134 FAQ: Common Problems |
| 140 -------------------- | 135 -------------------- |
| 141 | 136 |
| 142 Some MTP devices have strange pecularities. We try to work around | 137 Some MTP devices have strange pecularities. We try to work around |
| 143 these whenever we can, sometimes we cannot work around it or we | 138 these whenever we can, sometimes we cannot work around it or we |
| 144 cannot test your solution. | 139 cannot test your solution. |
| 145 | 140 |
| 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 | |
| 165 * mtp-* tools doesn't work because someone else is already hogging | 141 * mtp-* tools doesn't work because someone else is already hogging |
| 166 the device | 142 the device |
| 167 | 143 |
| 168 This is a common problem, the most common case could be that | 144 This is a common problem, the most common case could be that |
| 169 gphoto2 (which can also talk PTP/MTP) is taking over the device | 145 gphoto2 (which can also talk PTP/MTP) is taking over the device |
| 170 as soon as it's plugged in. Some distributions are configured that | 146 as soon as it's plugged in. Some distributions are configured that |
| 171 way. Counter it like this: | 147 way. Counter it like this: |
| 172 | 148 |
| 173 gvfs-mount -s gphoto2 | 149 gvfs-mount -s gphoto2 |
| 174 | 150 |
| 175 Then re-attach the device. | 151 Then re-attach the device. |
| 176 | 152 |
| 177 Sometimes some gvfs daemons are running on the | 153 Sometimes the "gvfs-gphoto2-volume-monitor" is running on the |
| 178 system and hogging the device, try stopping them | 154 system and hogging the device, try something like: |
| 179 with something like these commands: | |
| 180 | 155 |
| 181 killall gvfs-mtp-volume-monitor | 156 pkill gfvs-gphoto2-volume-monitor |
| 182 killall gvfs-gphoto2-volume-monitor | |
| 183 | 157 |
| 184 Then plug in the device and issue "mtp-detect" to figure out if | 158 Then plug in the device and issue "mtp-detect" to figure out if |
| 185 this may be the case. | 159 this may be the case. |
| 186 | 160 |
| 187 * Generic MTP/PTP disconnect misbehaviour: we have noticed that | 161 * Generic MTP/PTP disconnect misbehaviour: we have noticed that |
| 188 Windows Media Player apparently never close the session to an MTP | 162 Windows Media Player apparently never close the session to an MTP |
| 189 device. There is a daemon in Windows that "hooks" the device | 163 device. There is a daemon in Windows that "hooks" the device |
| 190 by opening a PTP session to any MTP device, whenever it is | 164 by opening a PTP session to any MTP device, whenever it is |
| 191 plugged in. This daemon proxies any subsequent transactions | 165 plugged in. This daemon proxies any subsequent transactions |
| 192 to/from the device and will never close the session, thus | 166 to/from the device and will never close the session, thus |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 such devices and you cannot expect to have command line tools | 198 such devices and you cannot expect to have command line tools |
| 225 like the mtp examples work with them. You could implement new | 199 like the mtp examples work with them. You could implement new |
| 226 example programs that just call to a mediating daemon like the | 200 example programs that just call to a mediating daemon like the |
| 227 Windows MTP stack does. (And change all programs using libmtp | 201 Windows MTP stack does. (And change all programs using libmtp |
| 228 directly today.) | 202 directly today.) |
| 229 | 203 |
| 230 If this bug in your device annoys you, contact your device | 204 If this bug in your device annoys you, contact your device |
| 231 manufacturer and ask them to test their product with some libmtp | 205 manufacturer and ask them to test their product with some libmtp |
| 232 program. | 206 program. |
| 233 | 207 |
| 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 |
| 234 * Samsung Android 2.3.x devices: these have a special MTP stack | 215 * Samsung Android 2.3.x devices: these have a special MTP stack |
| 235 with some specific bugs that we have maybe nailed down now. | 216 with some specific bugs that we have maybe nailed down now. |
| 236 It suffers from an "immediate connect" syndrome, i.e. you have | 217 It suffers from an "immediate connect" syndrome, i.e. you have |
| 237 to connect to the device within 7 seconds of plugging in, or it | 218 to connect to the device within 7 seconds of plugging in, or it |
| 238 will go numb. This also goes for command-line activity with | 219 will go numb. This also goes for command-line activity with |
| 239 the example programs, so this device is better used with a | 220 the example programs, so this device is better used with a |
| 240 GUI tool like Rhythmbox, gnomad2... | 221 GUI tool like Rhythmbox, gnomad2... |
| 241 | 222 |
| 242 * Generic USB misbehaviour: some devices behave badly under MTP | 223 * Generic USB misbehaviour: some devices behave badly under MTP |
| 243 and USB mass storage alike, even down to the lowest layers | 224 and USB mass storage alike, even down to the lowest layers |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 | 572 |
| 592 1. Plug in the device. | 573 1. Plug in the device. |
| 593 2. USB-mass storage folder will open automatically. | 574 2. USB-mass storage folder will open automatically. |
| 594 3. Unmount the device. | 575 3. Unmount the device. |
| 595 4. Run mtp-detect. It will most likely fail the first time. | 576 4. Run mtp-detect. It will most likely fail the first time. |
| 596 5. Run mtp-detect again, it might work this time, or fail. Keep running | 577 5. Run mtp-detect again, it might work this time, or fail. Keep running |
| 597 till it works. 99% it works by the third try. | 578 till it works. 99% it works by the third try. |
| 598 6. Once mtp-detect gives you an "Ok", open either Rhythmbox or Gnomad2, | 579 6. Once mtp-detect gives you an "Ok", open either Rhythmbox or Gnomad2, |
| 599 everything should work. | 580 everything should work. |
| 600 | 581 |
| 601 Linux: Try this, if you have a recent Linux kernel, | 582 Linux: Try this, if you have a recent 2.6.x Linux kernel, |
| 602 add the file (as root): | 583 run (as root) something like: |
| 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: | |
| 616 | 584 |
| 617 > rmmod usb_storage ; mtp-detect | 585 > rmmod usb_storage ; mtp-detect |
| 618 | 586 |
| 619 You can run most any command or a client like gnomad2 or | 587 You can run most any command or a client like gnomad2 or |
| 620 Amarok immediately after the rmmod command. This works | 588 Amarok immediately after the rmmod command. This works |
| 621 sometimes. Another even more brutal approach is this: | 589 sometimes. Another way: |
| 622 | 590 |
| 623 * Edit /etc/modprobe.d/blacklist | 591 * Edit /etc/modprobe.d/blacklist |
| 592 |
| 624 * Add the line "blacklist usb-storage" | 593 * Add the line "blacklist usb-storage" |
| 594 |
| 625 * Reboot. | 595 * Reboot. |
| 626 | 596 |
| 627 Now none of you USB disks, flash memory sticks etc will be | 597 Now none of you USB disks, flash memory sticks etc will be |
| 628 working (you just disabled them all). However you *can* try | 598 working (you just disabled them all). However you *can* try |
| 629 your device, and it might have started working because there | 599 your device, and it might have started working because there |
| 630 is no longer a USB mass storage driver that tries to hook onto | 600 is no longer a USB mass storage driver that tries to hook onto |
| 631 the mass storage interface of your device. | 601 the mass storage interface of your device. |
| 632 | 602 |
| 633 If not even blacklisting works (check with | 603 If not even blacklisting works (check with |
| 634 "lsmod | grep usb-storage"), there is some problem with | 604 "lsmod | grep usb-storage"), there is some problem with |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 NULL, 0); | 991 NULL, 0); |
| 1022 | 992 |
| 1023 SKETCH OF AN OVERVIEW | 993 SKETCH OF AN OVERVIEW |
| 1024 --------------------- | 994 --------------------- |
| 1025 | 995 |
| 1026 Draft agenda for a talk on MTP devices submitted for the Android | 996 Draft agenda for a talk on MTP devices submitted for the Android |
| 1027 builders summit, might come to recycle this: | 997 builders summit, might come to recycle this: |
| 1028 | 998 |
| 1029 - Protocol overview | 999 - Protocol overview |
| 1030 - Transactional filesystem - no corruption due to unplugged cables! | 1000 - 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). | |
| 1034 - libmtp interface | 1001 - libmtp interface |
| 1035 - relation to libgphoto2 | 1002 - relation to libgphoto2 |
| 1036 - User expectations fall short: | 1003 - User expectations fall short: |
| 1037 - Not really a mountable filesystem. | 1004 - Not really a mountable filesystem. |
| 1038 - Streaming does not work. (Size needs to be known beforehand due to | 1005 - Streaming does not work. (Size needs to be known beforehand due to |
| 1039 transactional nature.) | 1006 transactional nature.) |
| 1040 - GVFS MTP backend to the rescue. | |
| 1041 - Device sins | 1007 - 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. | |
| 1045 - Android bugs | 1008 - Android bugs |
| 1046 - Samsungs special Android MTP stack | 1009 - Samsungs special Android MTP stack |
| 1047 - SonyEricsson Aricent stack for Xperia Androids pre 4.0, broken headers! | 1010 - SonyEricsson Aricent stack for Xperia Androids pre 4.0, broken headers! |
| 1048 - Flat access model vs hierarchical, how Android uses MTP as an hierachical | 1011 - Flat access model vs hierarchical, how Android uses MTP as an hierachical |
| 1049 file system while it was previously a flat database. | 1012 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? | |
| 1070 - Detecting from vendor extension, can fix in newer extensions! | 1013 - Detecting from vendor extension, can fix in newer extensions! |
| 1071 - Autoprobing on Linux | 1014 - Autoprobing on Linux |
| 1072 - Color devices do not like autoprobing | 1015 - Color devices do not like autoprobing |
| 1073 - Devices need different PIDs for every alternative interface due to | 1016 - Devices need different PIDs for every alternative interface due to |
| 1074 the Windows USB stack. | 1017 the Windows USB stack. |
| 1075 - Multimode USB - one PID for each mode due to Windows limitations not | 1018 - Multimode USB - one PID for each mode due to Windows limitations not |
| 1076 applicable to Linux, SONY devices have ~5 different PIDs for a single | 1019 applicable to Linux, SONY devices have ~5 different PIDs for a single |
| 1077 device. | 1020 device. |
| 1078 - Mode switch devices? Maybe we do this wrong. | 1021 - Mode switch devices? |
| 1079 - MTPZ, came and went. Apparently deprecated by Microsoft with Windows | 1022 - MTPZ |
| 1080 Phone 8. | |
| 1081 - Ideas?? | 1023 - Ideas?? |
| 1082 | 1024 |
| OLD | NEW |