Discussion:
mtp device question
(too old to reply)
h***@crenshaw.net
2021-01-14 16:36:40 UTC
Permalink
I am running Kubuntu 20.04. I bought an ebook reader, an Onyx Boox
Poke 3. And I am using Calibre version 5.8.1 to manage my ebooks.

When I connect the usb to the ebooker reader, I can access the device
in the file manager: mtp:/Poke3/Internal shared storage/Download/

But Calibre doesn't seem to see it.

I posted a question to the MobileRead forum for help and the
developer, Kovid, told me that: On linux multiple programs cannot
connect to mtp devices simulataneously. Make sure your file
manager/desktop environment doesnt automount the device, and calibre
will be able to connect ot it.

I am not seeing a way to not automount the device.

lsusb shows the ereader Bus002 Device 002. Here is the full list

lsusb
Bus 002 Device 002: ID 18d1:4ee2 Google Inc. Nexus Device (debug)
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 005: ID 03f0:d711 HP, Inc ENVY 4520 series
Bus 001 Device 004: ID 0bda:0129 Realtek Semiconductor Corp. RTS5129
Card Reader Controller
Bus 001 Device 003: ID 413c:301a Dell Computer Corp. Dell MS116 USB
Optical Mouse
Bus 001 Device 002: ID 046d:c31d Logitech, Inc. Media Keyboard K200
Bus 001 Device 007: ID 0cf3:e005 Qualcomm Atheros Communications
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Can anyone suggest how to manage this?

Thank you.
Mike Easter
2021-01-14 18:23:50 UTC
Permalink
Post by h***@crenshaw.net
I am not seeing a way to not automount the device.
I don't know how to prevent automount, so I was going to suggest to
graphically unmount.

I'm accustomed to many file managers having an unmount in the context
menu, but I booted a Kub 20.04.1 and found that for Dolphin there was
only eject/remove which is not the same.

The advice in the forum was to use the command umount.
Post by h***@crenshaw.net
A GUI unmounting option, if you should require it, is to go to System Settings > Hardware > Storage Devices, right-click on the USB flash drive, and select “Unmount Device” - if you do this, Dolphin will still display the unmounted flash drive and will offer the “Mount” option.
--
Mike Easter
h***@crenshaw.net
2021-01-14 22:43:49 UTC
Permalink
Thank you very much Mike and Paul. You guys are amazing.

It looks like a losing battle. I can use Dolphin or Calibre. And I
need to reboot if I want to change.

if I reboot the computer, and I then plug in the device, I get a msg:
Device Notifier
Portable Media Player
SDM636-MTO_SN:4C038640
...and I don't do anything and don't open Dolphin, then I can access
the device via Calibre. It will show in Dolphin if I wait for Calibre
to access it, but Dolphin errors out and won't connect to it. I can
reboot and change, but which ever I choose I have to stick with it.
Simply unplugging the device doesn't fix it, I need to physically
reboot.

I don't really know what I am doing here, but let's try this.

/lib/udev/rules.d
The file 69-libmtp.rules has this liting when the device in plugged
into my USB port on the computer
# Google Inc Nexus/Pixel (MTP+ADB)
ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee2", SYMLINK+="libmtp-%k",
MODE="660", GROUP="audio", ENV{ID_MTP_DEVICE}="1",
ENV{ID_MEDIA_PLAYER}="1"

lsusb
this is listed: Bus 002 Device 006: ID 18d1:4ee2 Google Inc. Nexus
Device (debug)


In the System Settings under "Removable Storage" the device seems to
be listed as a Digital Camera
When I tried any of the functions, they fail saying: Could not claim
the USB device

In the Dolphin File Manager, the device is listed under "Devices" as:
SDM636-MTO_SN:4C038640
If I right-click I do not get an option to unmount it, just to Open in
New Window, Open in New Tab, Hide, Hide Section 'Devices'

It appears that I have full access to the files and directories via
Dolphin.

Calibre reports about my device detection: (long so I put it at the
end)
calibre 5.8.1 embedded-python: True is64bit: True
Linux-5.4.0-60-generic-x86_64-with-glibc2.2.5 Linux ('64bit', 'ELF')
('Linux', '5.4.0-60-generic', '#67-Ubuntu SMP Tue Jan 5 18:31:36 UTC
2021')
Python 3.8.5
Interface language: None
Successfully initialized third party plugins: DeDRM (7, 0, 0) &&
EpubSplit (3, 0, 0)
USB devices on system:
[['0x46d', '0xc31d', '0x6601', 'Logitech', 'USB Keyboard', ''],
['0xbda', '0x129', '0x3960', 'Generic', 'USB2.0-CRW',
'20100201396000000'],
['0x18d1', '0x4ee2', '0x404', 'ONYX', 'SDM636-MTP _SN:4C038640',
'ac47ca16'],
['0xcf3', '0xe005', '0x2', '', '', ''],
['0x413c', '0x301a', '0x100', 'PixArt', 'Dell MS116 USB Optical
Mouse', ''],
['0x3f0', '0xd711', '0x100', 'HP', 'ENVY 4520 series',
'TH7684H22G0660']]

No disabled plugins
Looking for devices of type: MTP_DEVICE
MTP devices connected:
USBDevice(busnum=2, devnum=7, vendor_id=0x18d1, product_id=0x4ee2,
bcd=0x0404, manufacturer=ONYX, product=SDM636-MTP _SN:4C038640,
serial=ac47ca16)

Trying to open: USBDevice(busnum=2, devnum=7, vendor_id=0x18d1,
product_id=0x4ee2, bcd=0x0404, manufacturer=ONYX, product=SDM636-MTP
_SN:4C038640, serial=ac47ca16)
Opening device failed:
Traceback (most recent call last):
File "calibre/devices/mtp/unix/driver.py", line 217, in open
File "calibre/devices/mtp/base.py", line 25, in synchronizer
File "calibre/devices/mtp/unix/driver.py", line 168, in
create_device
libmtp.MTPError: Unable to open MTP device with busnum=2 and devnum=7,
tried 1 such devices

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "calibre/devices/mtp/unix/driver.py", line 146, in
debug_managed_device_detection
File "calibre/devices/mtp/driver.py", line 128, in open
File "calibre/devices/mtp/base.py", line 25, in synchronizer
File "calibre/devices/mtp/unix/driver.py", line 220, in open
calibre.devices.errors.OpenFailed: Failed to open USBDevice(busnum=2,
devnum=7, vendor_id=0x18d1, product_id=0x4ee2, bcd=0x0404,
manufacturer=ONYX, product=SDM636-MTP _SN:4C038640, serial=ac47ca16):
Error: Unable to open MTP device with busnum=2 and devnum=7, tried 1
such devices


Looking for devices of type: SMART_DEVICE_APP
All IP addresses {'lo': [{'addr': '127.0.0.1', 'netmask': '255.0.0.0',
'peer': '127.0.0.1'}], 'wlp2s0': [{'addr': '192.168.1.153', 'netmask':
'255.255.255.0', 'broadcast': '192.168.1.255'}], 'wgpia0': [{'addr':
'10.55.220.116', 'netmask': '255.255.255.255', 'peer':
'10.55.220.116'}]}
No device is connected

Looking for devices...

Devices possibly connected: None
azigni
2021-01-14 23:57:57 UTC
Permalink
All you should need to do is, right click on drive and right click unmount
(In Thunar at least) If not, you should have a desktop icon when it
mounts. Just right click the desktop icon and unmount.

Paul
2021-01-14 18:41:39 UTC
Permalink
Post by h***@crenshaw.net
I am running Kubuntu 20.04. I bought an ebook reader, an Onyx Boox
Poke 3. And I am using Calibre version 5.8.1 to manage my ebooks.
When I connect the usb to the ebooker reader, I can access the device
in the file manager: mtp:/Poke3/Internal shared storage/Download/
But Calibre doesn't seem to see it.
I posted a question to the MobileRead forum for help and the
developer, Kovid, told me that: On linux multiple programs cannot
connect to mtp devices simulataneously. Make sure your file
manager/desktop environment doesnt automount the device, and calibre
will be able to connect ot it.
I am not seeing a way to not automount the device.
lsusb shows the ereader Bus002 Device 002. Here is the full list
lsusb
Bus 002 Device 002: ID 18d1:4ee2 Google Inc. Nexus Device (debug)
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 005: ID 03f0:d711 HP, Inc ENVY 4520 series
Bus 001 Device 004: ID 0bda:0129 Realtek Semiconductor Corp. RTS5129
Card Reader Controller
Bus 001 Device 003: ID 413c:301a Dell Computer Corp. Dell MS116 USB
Optical Mouse
Bus 001 Device 002: ID 046d:c31d Logitech, Inc. Media Keyboard K200
Bus 001 Device 007: ID 0cf3:e005 Qualcomm Atheros Communications
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Can anyone suggest how to manage this?
Thank you.
So a developer pushed a tech question, back onto a user ?
WTF kind of response is this ?

In the beginning, MTP existed as a protocol without direct OS support.
There might have been cases, where a developer wrote their own
private interface to an MTP device and carried out transactions.

At the current time, there is a FUSE filesystem. Once an MTP
device is mounted by MTPFS (more than one package for this),
it's a filesystem, and anyone can use it. It "looks like a disk drive",
if you will.

At that point, calibre should be able to read/write to it
like any other disk.

MTP started out as a clunky protocol, and is still clunky today.
However, it did have a change made to it. It started out at
Microsoft, as a "file by file" protocol. You could read an entire
file. You could write an entire file. That was the level of
granularity. This is fine if exchanging 64KB JPG files, not
so nice if exchanging 10GB movie files. I was reading stories
about the software having to read an entire 10GB file, change
4KB of it locally, then write the entire damn 10GB file back.
That's not an efficient means of making changes.

Google made a change to the protocol (as embodied in Android),
to supporting transactions of "chunks of files". But this idea,
if you think about it, it doesn't make sense unless the intention
is to support allowing multiple files to be in the write state
at the same time. You don't support operation on chunks of
files, unless the plan is to interleave them.

And, if that is the case today, if that's how it works, then
the "straw man" proposal that "someone else is using it",
is horsepucky.

You could use udev rules and a RUN key to bind the presence
(fresh plugin of a device), to the usage of a specific program.
This would allow calibre to be first to the feeding trough.
But I also have to feel that this idea is just *wrong*.
We should not be asking users to sit around doing
stuff that developers should be doing.

https://lists.debian.org/debian-user/2013/12/msg00796.html

https://superuser.com/questions/1206664/disable-mtp-udev-rules-for-specific-device-so-it-can-be-mount-as-a-usb-mass-stor

ATTR{idVendor}=="093a", ATTR{idProduct}=="2516", GOTO="libmtp_rules_end"

Some of the problems with MTP, are related to freshly
created kernel bugs. Such that if you do regression
testing, you'll find one kernel version works, another
one has this-or-that issue with MTP. It might be very hard
for users to triangulate the exact issue, if you
were to say, "insist on doing things a stupid way" when
doing program development.

I hope you aren't being sent on a wild goose chase.

*******

Summary: Check udev rules, to see if a rule has *already*
been placed there, which is screwing up the
normal automation.

Paul
Mike Easter
2021-01-14 19:39:01 UTC
Permalink
Post by h***@crenshaw.net
I posted a question to the MobileRead forum for help and the
developer, Kovid, told me that: On linux multiple programs cannot
connect to mtp devices simulataneously. Make sure your file
manager/desktop environment doesnt automount the device, and calibre
will be able to connect ot it.
Besides Paul's input, the archwiki has a useful discussion.

https://wiki.archlinux.org/index.php/Media_Transfer_Protocol
Post by h***@crenshaw.net
The Media Transfer Protocol (MTP) can be used to transfer media files to and from many mobile phones (all Windows Phone 7/8/10 devices, most newer Android devices) and media players (e.g. Creative Zen).
1 Connecting
2 FUSE filesystems
3 libmtp
4 Media players
5 File manager integration
5.1 gvfs-mtp
6 Troubleshooting
6.1 libmtp (gvfs-mtp): filemanager (nautilus, pcmanfm, vifm and etc) hangs on accessing DCIM/Camera of Android device
6.2 jmtpfs: Input/output error upon first access
6.3 kio-mtp: cannot use "Open with File Manager" action
6.4 kio-mtp being called simultaneously by different services
6.5 Android File Transfer: connect failed: no MTP device found
--
Mike Easter
Loading...