Solved Mounting Samsung Phone

All roads on following problem have terminated in more questions than answers. This means it has to be something simple!
PROBLEM: Galaxy S4 active not accessible from desktop or from any where.
EXPECTED BEHAVIOR: Plug up phone and either find mounted drive in "Dolphin Places" or at the very least be notified by desktop and be able to mount drive via console command.
WHAT I GOT: No notifications in desktop after plugging in. There is some o/p on vt1 as follows:
Code:
ugen0.8: <SAMSUNG SAMSUNGAndroid> at usbus0

umodem0 on uhub2

umodem0: <CDC Abstract Control Model (ACM)> on usbus0

umodem0: data interface 2, has no CM over data, has no break
Hmm' is that two devices, or just one device, being misinterpreted as a serial port instead of a umass device? <<<P.S (this is my best guess right now)
HISTORY/other factoids: This problem shows up on two different boxes both of which dual boot with another O.S. One with win7 and the other with win10. Both windows platforms happily munch their way through this, mount the phone and give notification. That takes care of confirming the hardware.
The older box has been around since FreeBSD 9.2 and this functionality disappeared with the advent of FreeBSD 11. It's been upgraded to 12.1 the whole way. The new box has a just received a virgin install of 12.1, Xorg, and of course KDE5 desktop or whatever its known by. From root on up its a shiny new box stock kernel on a relatively newer model laptop. All these years I've been hunting around in my environment for the culprit. So that pretty much rules out the environment. The behavior of this operation is exactly the same on both machines, right down to the notifications.
Included below is what TRUSS is able to see after attempting to mount using truss -o simpmtpfs.out -d -D -S simple-mtpfs -o allow_other /media/phon. You can see mtp hunting around for its family of executables, finding them all, and then something happens? I cant understand this trace. If you would like some other trace give me your code and it will happen. Please be patient. I am committed to resolving this. The other attached file # mtp-detect is a unexpected surprise. If mtp can cull this much info, why is this thing not mounting? See what I mean, "It's got to be simple." Also have tried sysutils/automount, and mtpfs in all manner of incantations.
SYMPTOMS OF MOUNT FAILURE: Using almost any mtp method results in file browser 'Dolphin' apparently locking up but only after migrating to /media/phon. Since at that point things were already untenable I unmounted, unpluged, restarted everything and did a truss -p <pid of mtp process> in a vt since truss complained when trying to do this from a console. It was a blank check, but after migrating to /media/phon there were zillions of these:
Code:
ioctl(8,USB_FS_COMPLETE, 0x7fffffffd608)        ERR#16 'Device busy'

poll({5|POLLIN 8|POLLOUT|POLLRDNORM},2,-1=1 (0x1) read(5,0x7fffffffd69f,1) ERR#35 'Resource temporarily unavailable'
.
If the above is not interrupted with cntrl+c system will become unresponsive i.e. 'lock-up' and at that point the only thing to do is pull plug on phone and were back in business. I can't help but think that something is going on with fstab but have not dithered with it for fear of breaking some vital mechanism and regressing even further to a blue or black screen. Below is o/p from mount without phone:
Code:
# mount

/dev/ada0s3a on / (ufs, local, journaled soft-updates)

devfs on /dev (devfs, local, multilabel)

/dev/ada0s3b on /var (ufs, local, journaled soft-updates)

/dev/ada0s3d on /tmp (ufs, local, journaled soft-updates)

/dev/ada0s3e on /usr (ufs, local, journaled soft-updates)

procfs on /proc (procfs, local)

fdescfs on /dev/fd (fdescfs)

tmpfs on /tmp (tmpfs, local)

/dev/fuse on /mnt/windows (fusefs)

/dev/fuse on /var/run/user/1001/gvfs (fusefs)
On a more happy note FreeBSD 12.1 was a welcome switch and in most all other aspects definitely outperforms 11. I was happy to leave 11 behind.
Merry Christmas!
simple-mtpfs.out
mtp-detect
 
On Android, your phone can be set to multiple USB modes. You are probably on a modem mode, and should slide down when plugged in and switch to a USB mass driver mode.

Android vendors are different, and I haven't had a Samsung phone in a while, I switched to Google Pixel devices. I root, and it's easier to manage a rooted Pixel on FreeBSD than a rooted Samsung (custom ROM or not).
 
You are correct. On this model 7 different protocols along with two modes are accessible to the user. Its a phone dial keypad sequence "*#0808#" sans the quotes. On entering this user can change to control port CP mode, or, AP access port mode. Then below those two are seven different sets of protocols as follows MTP, MTP+ADB, PTP, PTP+ADB, RNIDS+DM+MODEM, RMNET+DM+MODEM, DM+MODEM+ADB. The correct settings for this phone are AP usb mode using MTP+ADB. I have tried all the protocols using the AP mode. I believe Samsung is using android as a platform which is a modified Linux kernel afaik. I have not really dove into specifics on the phone though. This is another reason why the mtp-detect output looks weird. I would have expected a lot of Linux devices not Windows devices.
The mere fact that mtp-detect returns data pretty much indicates a phone link exists. Something in the filesystem/mount process is not being handled correctly, or putting it another way they are confused. Arrg, did not even look close enough at my own truss. Line 696 in truss o/p file is whats happening here. That might point to a driver problem. If you check truss after line 696 things go down hill from there. Thanks.
 
Attached files have my comments enclosed with lots of these #####<comment>#####. Not knowing what is normal behavior for this interface and calls to ioctl(1,2,3)makes it difficult to understand what is happening here. The comments right at this point are my best guess. Opening these files with an editor that displays line numbers will help. Attached file simplemtpfs.threads_env.out.txt has some commented highlights at lines 219, 243, 600, 697. This file is another more readable truss output file. There is a highly suspect call to open a file above line 600 which is tried 4 times. And then nothing else about the call. The same open file call is at line 536 which eventually reports success but after a small effort. No clue what is going on here.
File usbconfig_show_iface.txt shows everthing that is connected right now and the last two entries appear when phone is plugged in. File ugen0.8_iface_config_descriptors.txt is the outward facing side of phone i/f. Some how it looks like the mtp i/f is getting ignored/failing and ioctl gets bombarded with failed calls and never closes chardev 8. I think it my be time to leave here and go to bug city. Anybody care to comment on that.
 

Attachments

  • usbconfig_show_iface.txt
    1.9 KB · Views: 145
  • ugen08_iface_config_descriptors.txt
    4.8 KB · Views: 116
  • simpmtpfs.threads_env.out.txt
    81.7 KB · Views: 129
To mount a phone, I use simple-mtpfs (port is called fusefs-simple-mtpfs). Then I do it at command line. You have to have the fuse module loaded. sudo kldload fuse (if you use sudo). Then I can do as root or with sudo simple-mtpfs /mnt

At that point. on a Samsung, which must be unlocked when you do this, you get a message asking if you'll allow it. (At least that's how it was on my Samsung, which I haven't used in awhile. I have a Google phone now, when you plug it in by USB, you can tap for more options and one of them is file transfer.) Anyway, this works quite well for me.[/cmd]
 
I'm on 12.0 and 12.1 RELEASE, I have the same problems as you have accessing a Samsung Galaxy S6 phone, or any other Android device. I tried sysutils/fusefs-simple-mtpfs. For a brief period I could mount and had access to androids file system with no problems.

After some time ( I'm not sure if this is correlated, but it happend after a few package upgrades) I could mount the device, but could not access the file system. A ls /device_mountpoint (or any other command trying to access the devices filesystem) would result the command hanging until it times out. At the same time the executed command would consume about 100% WCPU (top(1)).

I also tried sysutils/android-file-transfer-qt5, same here, a few times it worked as expected, then it stoped. I tried to debug sysutils/fusefs-simple-mtpfs, but gave up.

I need access to the phone/tablet mostly for backup purposes, sometimes to copy temporary files, for that I'm using now net/syncthing.

If you need or prefere a cable connected access, try the recently added port sysutils/fusefs-jmtpfs. For details see https://github.com/kiorky/jmtpfs/blob/master/README.rst.

What cought my attention was one of the projects statement :"The goal is to create a well behaved filesystem, allowing tools like find and rsync to work as expected." A working net/rsync is exactly what I would need.

I can confirm access to the Android file system works as expected (for now), reading, writing, moving.

The only downside I have detected is after the first mount and allowing access at the devices confirmation dialog, a umount /device_mountpoint and second device mount is necessary.

To allow normal users access: jmtpfs -o allow_other /device_mountpoint.
 
Wow. I just did a fresh install of 12.1 and found that simple-mtpfs was not working for me either. I would mount the phone and when I tried to list the mountpoint, it just hung. So, I just installed jmtpfs and it works beautifully. Thank you.
 
Appreciate both your responses. I'll try not to rope you into a time consumption vortex. Fuse is loaded on boot.
Code:
# kldstat
Id Refs Address                Size Name
 1   72 0xffffffff80200000  2448ef8 kernel
 2    1 0xffffffff82649000     6358 ichsmb.ko
 3    2 0xffffffff82650000     2f18 smbus.ko
 4    1 0xffffffff82654000    262b0 fuse.ko
 5    1 0xffffffff8267b000     8210 acpi_video.ko
 6    1 0xffffffff82821000     1aa0 fdescfs.ko
 7    1 0xffffffff82823000     88d8 tmpfs.ko
 8    1 0xffffffff8282c000   12cab0 i915kms.ko
 9    1 0xffffffff82959000    76570 drm.ko
10    4 0xffffffff829d0000    10eb0 linuxkpi.ko
11    3 0xffffffff829e1000    12f30 linuxkpi_gplv2.ko
12    2 0xffffffff829f4000      6d0 debugfs.ko
13    1 0xffffffff829f5000     4260 ng_ubt.ko
14    6 0xffffffff829fa000     9e30 netgraph.ko
15    2 0xffffffff82a04000     91b8 ng_hci.ko
16    3 0xffffffff82a0e000      9c0 ng_bluetooth.ko
17    1 0xffffffff82a0f000     cad0 ng_l2cap.ko
18    1 0xffffffff82a1c000    1ba00 ng_btsocket.ko
19    1 0xffffffff82a38000     21c0 ng_socket.ko
20    1 0xffffffff82a3b000     1420 ulpt.ko
21    1 0xffffffff82a3d000     18a0 uhid.ko
22    1 0xffffffff82a3f000     2928 ums.ko
23    1 0xffffffff82a42000      1ae msdosfs_iconv.ko
24    1 0xffffffff82a43000     3000 libiconv.ko
25    1 0xffffffff82a46000     2940 nullfs.ko
All other external hardware seems to be fine and this includes x2 external usb drives with all sorts of partitions and filesystems. I believe there are two SearX instances completley devastated by my searches as it relates to simple-mtpfs. Ha Ha! Time to shift gears.
I can definitively confirm FreeBSD-11.*'s fragility when it comes to user-land upgrades from a laptop user perspective. FreeBSD-11 and KDE5 arrived at about the same time, and that was definitely a interesting time. I just noticed something interesting about devd and am going to hunt their a while before trying sysutils/fusefs-jmtpfs that sounds like it will work. Got to go holidays and all. Thanks again.
 
IMO it's not worth fighting with those funky technologies.
In my Android devices I install Termux («Terminal Unix»), then install an SSH server in it (I prefer openssh):
Code:
$ pkg install openssh
$ # now run it:
$ sshd
$ # set a password:
$ passwd
By default it listens on port 8022, but you can edit ../usr/etc/ssh/sshd_config (relative to virtual home) to use any unprivileged port (unless your device is rooted to use 22).
Now you can use scp and rsync to copy files (install rsync in Termux first). You can also use public key instead of password. You may need to grant storage access to Termux in your phone's security settings.

The phone's IP address can be found by running:
Code:
$ ip a | grep wlan0
You may try ifconfig too, but in some devices it's not allowed for unprivileged users. I believe, the username is ignored, if not, you can always find it by running whoami in Termux.
 
I just have a minute here between Christmas outings. Scottro I would like to know if you can confirm that only devd was running in background or if hald was also running. I have been only working on my older machine and forgot completley about hald daemon. So i thought okay thats got to be it and disabled it. Rebooted and stopped background devd process. Put devd in foreground and plugged in>>>>> nothing, zilch, nada!!
At this point since now there are two confirmed failures of media transfer protocol of two Freebsd-12.1 fresh installs i think its time for the bug masters to have a look as well. Its nice that there is a work around but this type of failure requires hunting and rectifying on another level. Ports or base system bug????
 
I don't have hal installed so only devd is running. As for reporting, you can often start with an email to the port maintainer. (I am guessing you're talking about simple-mtpfs? I've only tried--and failed--with it on one machine).
 
Firstly, thanks to all. The alternatives suggested by everyone are probably all feasible depending on your personal preferences/prerequisites. Knowing what I know about the little java processors inside the sim cards in these phones I personally don't trust the domain space where ALL your user info is being dumped. I enable this phone to text and talk. Pretty much everything else is deleted or disabled. I secure one and only one connected device which is this computer running FreeBSD. It's connected with a cat6 cable. That means I need a usb port to get my information from my phone, which in my opinion does not belong to any one else. Get the drift. That eliminates everything, for me, except sysutils/jmtpfs which connected flawlessly. Give it a minute to index a 32Gb SD card and from then on everything was great.
So I eat crow on the simplicity of why, how this type of situation arises. I recant my earlier statement "it's got to be something simple".
IT'S NOT FREEBSD AND ITS NOT A BUG. It's the phone. More specifically a protocol 'mtp' paired with 'adb' is not a protocol. Follow the $$$$$. As usual. When this rant is blasted into the matrix you can expect jmtpfs to stop working in say about a month. That's what I'm talking about. Sorry for the paranoia.
RE-CAP: You can connect to a Galaxy S4 active that has been disabled in every way except for being rooted. The directory/folder permissions
Code:
drwxr-xr-x   6 root  wheel       512 Dec 25 21:26 media
and my user is in the wheel group.

The settings on the phone are AP over MTP+ADB. Plug it in and $ jmtpfs <mount point> and get YOUR info. Good bye to hald daemon as well.
 
Back
Top