Giter Site home page Giter Site logo

viveris / umtp-responder Goto Github PK

View Code? Open in Web Editor NEW
190.0 16.0 51.0 400 KB

Lightweight USB Media Transfer Protocol (MTP) responder daemon for GNU/Linux

License: GNU General Public License v3.0

Makefile 0.42% Shell 0.91% C 98.67%
c linux mtp raspberry-pi file-transfer file-transmission transfer ptp embedded-systems usb-functionfs

umtp-responder's Introduction

uMTP-responder logo

uMTP-Responder

Lightweight USB Media Transfer Protocol (MTP) responder daemon for GNU/Linux

The uMTP-Responder allows files to be transferred to and from devices through the devices USB port.

Main characteristics and features

  • Implemented in C.

  • Lightweight implementation.

  • User space implementation.

  • As few dependencies as possible.

  • Hook to the FunctionFS/libcomposite or the GadgetFS Linux layer.

  • Dynamic handles allocation (No file-system pre-scan).

  • Unicode support.

  • (Optional) Syslog support.

Current status

What is working

  • Folder listing.

  • Folder creation.

  • Files & Folders upload.

  • Files & Folders download.

  • Files & Folders deletion.

  • Files & Folders renaming.

  • Files / folders changes async events.

  • Up to 16 storage instances supported.

  • Storages mount / unmount.

  • Storages lock / unlock.

  • Global and Storages GID/UID override options.

  • GadgetFS and FunctionFS/libcomposite modes supported.

Which platforms are supported ?

Any board with a USB device port should be compatible. The only requirement is to have the USB FunctionFS (CONFIG_USB_FUNCTIONFS) or GadgetFS (CONFIG_USB_GADGETFS) support enabled in your Linux kernel. You also need to enable the board-specific USB device port driver (eg. dwc2 for the RaspberryPi Zero).

uMTP-Responder was tested on various Linux kernel versions (4.x.x / 5.x.x / 6.x.x ...) . This may work with earlier kernels (v3.x.x and some v2.6.x versions) but without any guarantee.

Successfully tested boards

  • Atmel Sama5D2 Xplained.

  • Raspberry PI Zero (W).

  • BeagleBone Black.

  • Allwinner SoC based board.

  • Freescale i.MX6 SabreSD. (Kernel v4.14)

  • Samsung Artik710. (FunctionFS mode)

  • Ultra96-V2 (Zynq UltraScale+, FunctionFS mode, SuperSpeed USB)

Successfully tested client operating systems

  • Windows 7, Windows 10, Windows 11, Linux, Android.

How to build it ?

A simple "make" should be enough if you build uMTPrd directly on the target.

If you are using a cross-compile environment, set the "CC" variable to your GCC cross compiler.

You can also enable the syslog support with the C flag "USE_SYSLOG" and the verbose/debug output with the "DEBUG" C flag.

examples:

On a cross-compile environment :

make CC=armv6j-hardfloat-linux-gnueabi-gcc

On a cross-compile environment with both syslog support and debug output options enabled :

make CC=armv6j-hardfloat-linux-gnueabi-gcc USE_SYSLOG=1 DEBUG=1

Note: syslog support and debug output options can be enabled separately.

(replace "armv6j-hardfloat-linux-gnueabi-gcc" with your target gcc cross-compiler)

If you want to use it on a Kernel version < 3.15 you need to compile uMTPrd with old-style FunctionFS descriptors support :

make CC=armv6j-hardfloat-linux-gnueabi-gcc OLD_FUNCTIONFS_DESCRIPTORS=1

To enable the systemd notify event support when the endpoint setup is done :

make CC=armv6j-hardfloat-linux-gnueabi-gcc SYSTEMD=1

To get the current flags/options available :

make help

How to set it up ?

A config file should copied into the folder /etc/umtprd/umtprd.conf This file defines the storage entries (host path and name), the MTP device name, the USB vendor & product IDs and the USB device configuration. Check the file umtprd.conf file for details on available options.

How to launch it ?

Once you have configured the correct settings in umtprd.conf, you can use umtprd_ffs.sh or umtprd_gfs.sh to launch it in FunctionFS/GadgetFS mode or use udev to launch the deamon when the usb device port is connected.

Runtime operations

uMTP-Responder supports dynamic commands to add/mount/umount/remove storage and lock/unlock storage.

Examples:

Unlock all locked storage (set with the 'locked' option in the configuration file) :

umtprd -cmd:unlock

Lock all lockable storage (set with the 'locked' option in the configuration file) :

umtprd -cmd:lock

"addstorage"/"rmstorage" commands to dynamically add/remove storage :

umtprd '-cmd:addstorage:/tmp Tmp rw'
umtprd '-cmd:rmstorage:Tmp'

Use double-quotes when arguments have spaces in them:

umtprd '-cmd:addstorage:/path "My Path" rw,removable'
umtprd '-cmd:rmstorage:"My Path"'

"mount"/"unmount" commands to dynamically mount/unmount storage.

umtprd '-cmd:mount:"Storage name"'
umtprd '-cmd:unmount:"Storage name"'

License

This project is licensed under the GNU General Public License version 3 - see the LICENSE file for details

umtp-responder's People

Contributors

gmman avatar jackmitch avatar jameshilliard avatar jean--michel avatar jfdelnero avatar maschwarzer avatar oldmanyellsatcloud avatar osctobe avatar pcercuei avatar scorbeau avatar studiofuga avatar surg0r avatar tysm-msab avatar woshizhy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

umtp-responder's Issues

Spamming gadgetfs: suspended from state 3

Hi,

I have an issue with the release 0.9.7.
I have configured the option with loop_on_disconnect 1 and start umtprd at boot in my init.d

This is working fine, but when I remove the usb device, I got a very fast spamming on the syslog with the message : gadgetfs: suspended from state 3

I tried with UDEV, but in some times this cause problem, since the charging and other functions are on the same port...

I suppose this is due to the re-connection attempt.
Does it's normal ?

How can I change this to avoid flooding my log ?

Thanks for help.
Sylvain

i.mx6 sabresd working with kernel 4.14.x

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!

Adding an option to not show hidden files

Here is the patch:

diff --git a/inc/mtp.h b/inc/mtp.h
index 4ffa91f..3b226b7 100644
--- a/inc/mtp.h
+++ b/inc/mtp.h
@@ -67,6 +67,7 @@ typedef struct mtp_usb_cfg_

int wait_connection;
int loop_on_disconnect;
  • int show_hidden_files;

}mtp_usb_cfg;

diff --git a/src/fs_handles_db.c b/src/fs_handles_db.c
index 695f353..161e9ba 100644
--- a/src/fs_handles_db.c
+++ b/src/fs_handles_db.c
@@ -376,7 +376,7 @@ int scan_and_add_folder(fs_handles_db * db, char * base, uint32_t parent, uint32
PRINT_DEBUG("IsDir: %d",fileinfo.isdirectory);
PRINT_DEBUG("---------------------");

  •   	if( strcmp(fileinfo.filename,"..") && strcmp(fileinfo.filename,".") )
    
  •   	if( strcmp(fileinfo.filename,"..") && strcmp(fileinfo.filename,".") && (((mtp_ctx *)db->mtp_ctx)->usb_cfg.show_hidden_files || fileinfo.filename[0] != '.') )
      	{
      		add_entry(db, &fileinfo, parent, storage_id);
      	}
    

diff --git a/src/mtp_cfg.c b/src/mtp_cfg.c
index 4ee460b..604e681 100644
--- a/src/mtp_cfg.c
+++ b/src/mtp_cfg.c
@@ -72,7 +72,8 @@ enum
INTERFACE_STRING_CMD,

WAIT_CONNECTION,
  • LOOP_ON_DISCONNECT
  • LOOP_ON_DISCONNECT,
  • SHOW_HIDDEN_FILES
    };

typedef struct kw_list_
@@ -283,6 +284,9 @@ int get_hex_param(mtp_ctx * context, char * line,int cmd)
case LOOP_ON_DISCONNECT:
context->usb_cfg.loop_on_disconnect = param_value;
break;

  •   	case SHOW_HIDDEN_FILES:
    
  •   		context->usb_cfg.show_hidden_files = param_value;
    
  •   	break;
      }
    
    }

@@ -360,6 +364,7 @@ kw_list kwlist[] =

{"wait",                get_hex_param,      WAIT_CONNECTION},
{"loop_on_disconnect",  get_hex_param,      LOOP_ON_DISCONNECT},
  • {"show_hidden_files", get_hex_param, SHOW_HIDDEN_FILES},
    { 0, 0, 0 }
    };

@@ -434,6 +439,7 @@ int mtp_load_config_file(mtp_ctx * context)

context->usb_cfg.wait_connection = 0;
context->usb_cfg.loop_on_disconnect = 0;
  • context->usb_cfg.show_hidden_files = 1;

    f = fopen(UMTPR_CONF_FILE,"r");
    if(f)
    @@ -482,6 +488,7 @@ int mtp_load_config_file(mtp_ctx * context)

    PRINT_MSG("Wait for connection : %i",context->usb_cfg.wait_connection);
    PRINT_MSG("Loop on disconnect : %i",context->usb_cfg.loop_on_disconnect);

  • PRINT_MSG("Show hidden files : %i",context->usb_cfg.show_hidden_files);

    return err;
    }

Bug: Canceling a copy operation (Windows 10) will result in a crash (using BeagleBoneBlack - gadgetfs)

I mentioned this Bug while checking the speed of the connection.
I use the actual source-code from the master Branch

I copied a large File (170Mb) to test the speed of umtprd.
After about 10 seconds i canceled (as it had copied approx 50%).
Now the MTP-Device disappears. (not showing again, even with usb-cable out and in)
in linux screen nothing happened
i quit umtprd with CTRL-C (no output about the error)
the already copied part of the file is still there
Can restart umtprd without problems.

segfault after cancelling transfer

I'm using windows 10 and the device run latest master version of uMTP-Responder with functionfs on a 4.14.78 kernel.
Here are the steps to reproduce :

  • Connect the device
  • Copy from the device a file
  • During the copy cancel the transfer
  • Try to copy another file from the device -> segfault

In attachement you have the output of umtprd since I request the cancel (umtprd_log.txt) and the backtrace output of the coredump (umtprd_backtrace.txt).

It seems that after the cancel, the session is closed and on the new session we never pass through the MTP_OPERATION_OPEN_SESSION operation to create the 'fs_db' of the session.

Add connection authorization?

Currently umtp-responder is very permissive and allows connections without any authorization (if I am mistaken please correct me). Can authorization functionality be added similarly to how Android handles it, by requiring some sort of "Allow This Device To Connect" dialogue on the host?

V0.10.1 MTP Chrome-os folder view wrong and file deletion not working

OS used for test : Chrome-os 74.4.58

The folder listing is very weird, a infinite folder recursive list appear.
The root of the storage is present and I can drop file on it, but I can't delete some files

The same device is running perfectly under Ubuntu18, Windows 10 and MAC 10.14.5

Also, the Name of the media folder doesn't appear under the device name. Instead there is a no-name folder that contains another no-name folder that contain.... you see where I go...

how to enable mtp&adb at same time

Hi, thanks for your project! I've run MTP on my board. But I met some trouble when I tried to enable mtp&adb at same time.

My script for adb is:
adb.txt
And it runs pretty well without function MTP.
However, it doesn't work when I tried to enable both of them.

When goes to these lines
mkdir /dev/ffs-mtp
mount -t functionfs mtp /dev/ffs-mtp
mkdir /dev/usb-ffs
mkdir /dev/usb-ffs/adb
mount -o uid=2000,gid=2000 -t functionfs adb /dev/usb-ffs

According to logs,
mount: mounting adb on /dev/ffs-mtp failed: No such file or directory

Do you have any ideas about this?

Thanks!

The MTP responder side renames the file, but the MTP Initiator side does not update it

Hello.

As shown in the title, I found that MTP responder did not listen for rename events. (for example: mv hello.c hello.java)
(Only the events of adding/modifying and deleting files are monitored for your uMTP-Responder)

So when renaming a file on the MTP responder side, no event occurred, and no event was reported to MTP Initiator .

If want to support this function( renames the file on the MTP responder side, and the MTP Initiator also can update)
I find it possible to do this:

  1. Add events to listen for renamed files: (modify file: src/inotify.c )
int inotify_handler_addwatch( mtp_ctx * ctx, char * path )
 {
...
            if ( !ctx->no_inotify )
            {
--                   return inotify_add_watch( ctx->inotify_fd, path, IN_CREATE | IN_DELETE | IN_MODIFY );
++                 return inotify_add_watch( ctx->inotify_fd, path, IN_CREATE | IN_DELETE | IN_MODIFY | 
++                                                                                            IN_MOVED_FROM |  IN_MOVED_TO );
            }
...
 }
  1. Handling events: (modify file: src/inotify.c )
void *inotify_gotsig(int sig, siginfo_t *info, void *ucontext)
{
...
--              if ( event->mask & IN_CREATE )
++            if ( event->mask & IN_CREATE || event->mask & IN_MOVED_TO )
      
--              if ( event->mask & IN_DELETE )
++            if ( event->mask & IN_DELETE || event->mask & IN_MOVED_FROM )
...
 }

And I I tested it and it worked.
(The MTP Initiator tested are: win7 and win 10)

But I just passed the preliminary verification, and I don't know if there are any bugs.

Do you argee?

Thanks, I wish you a happy life.

Beaglebone Green Compile Error

Hi Team:
I have BBG running kernel 3.8.13 (default kernel comming with the product). I have checkted that FUNCTIONFS and GADGETFS are compiled as a module in kernel.
When I compile uMTP, I got fallowing errors:

cc -o obj/usb_gadget.o src/usb_gadget.c -c -I./inc -lpthread -Wall -O3
src/usb_gadget.c: In function โ€˜init_usb_mtp_gadgetโ€™:
src/usb_gadget.c:706:36: error: โ€˜FUNCTIONFS_DESCRIPTORS_MAGIC_V2โ€™ undeclared (first use in this function)
src/usb_gadget.c:706:36: note: each undeclared identifier is reported only once for each function it appears in
src/usb_gadget.c:707:36: error: โ€˜FUNCTIONFS_HAS_FS_DESCโ€™ undeclared (first use in this function)
src/usb_gadget.c:707:36: error: โ€˜FUNCTIONFS_HAS_HS_DESCโ€™ undeclared (first use in this function)
make: *** [obj/usb_gadget.o] Error 1

Any idea about this errors.
Best regards.

File renaming

It would be nice to implement file renaming.

If I understood correctly how it works, that means adding support for the "object set/get property value" codes, and then add code handling for the "file name" property?

inotify of new file uploaded?

I see that inotify is being used. I'm looking to get notified anytime a new file has been added to the MTP. Is this functionality currently added, or is this something I'll need to add separately.

Password protection

I am looking on how to protect some files with password? Is this possible, or if not, can you please give me some guidelines on how and where to implement this?
So for example, I would like to leave /home/root folder visible to everybody and /home/restricted visible only to the ones who fill in the correct password.

Fresh Pi Zero install problem

Hi,

I am trying to get uMTP-Rseponder on the Pi Zero W. With the latest Raspbian there is no USB driver file to be found. Is there a workaround for it? I use the solder-on USB connector from waveshare to connect with computer.
unable to open /dev/gadget/20980000.usb.
Init_usb_mtp_gadget error.

Would be great if there is a step-by-step guide for novices like me. ^^

modified file on the mtp responder side, but the PC can not refresh at the same time.(maybe I solved this problem by change the code)

for example:
1๏ผ‰create a file on mtp responder๏ผš
echo hello1 > hello.txt

2๏ผ‰watch the file on PC๏ผŒit's good to find the hello.txt and it's content is : hello1.

3๏ผ‰append some content to the hello.txt file on mtp responder๏ผš
echo hello2 >> hello.txt

4๏ผ‰watch the file on PC๏ผŒbut the content is keep to : hello1.

5๏ผ‰append some content to the hello.txt file on mtp responder๏ผš
echo hello3 >> hello.txt

6๏ผ‰watch the file on PC๏ผŒand the content is change to : hello. hello2.

....

can you verification this problem please?

Thank you, good life to you.


Hello
maybe I sovled this problem by change the source code(just add one line):

the file: src/mtp_properties.c

and the function:
int build_objectproplist_dataset(mtp_ctx * ctx, void * buffer, int maxsize,fs_entry * entry, uint32_t handle,uint32_t format_id, uint32_t prop_code, uint32_t prop_group_code, uint32_t depth)
{
...

if(path)
{
	ret = stat64(path, &entrystat);
}

if(ret)
{
	if(path)
		free(path);
	return 0;
}

++ /* update the file size infomation */
++ entry->size = entrystat.st_size;

...
}

Are you agree?

Thanks๏ผŒ wish you a happy life.

creating and deleting ".." folder wipes storage

Creating a folder with the name of ".." (without quotes), and then deleting it will delete the shared storage.

Reproduction:

  1. Connect the device to a Windows PC, and open the shared folder (could work in Linux/Mac also, not sure. Haven't tried.). Have some random files/folders in the storage.
  2. On the Windows machine, in the root folder of the MTP device create a directory called ".." (without quotes). This will create a folder called "New Folder".
  3. Delete the newly created folder in Windows.

Result: the whole content of storage is wiped, including the random files you created in step 1.

SuperSpeedPlus support?

Hello,
First let me tell you that I love your work! I have a question however? Is there any ambition as to be compatible with the SuperSpeedPlus protocol? I wish to work with the responder on a pi4 (USB-C). With as much speed as possible...
Sincerely,
Bram Nijenkamp

Incoming_packet : Read Error (-1)! on v1.0.0

Seems like v1.0.0 offers much improvements over previous versions, nice going!

I've tried running v1.0.0 on our iMX.6 based product, but there is an USB read error.

UMTP outputs this information:

Oct 21 10:35:25 Voyagerk46xOO sudo[475]: [uMTPrd - 10:35:25 - Info] uMTP Responder
Oct 21 10:35:25 Voyagerk46xOO sudo[475]: [uMTPrd - 10:35:25 - Info] Version: v1.0.0 compiled the Oct 21 2019@11:34:59
Oct 21 10:35:25 Voyagerk46xOO sudo[475]: [uMTPrd - 10:35:25 - Info] (c) 2018 - 2019 Viveris Technologies
Oct 21 10:35:25 Voyagerk46xOO sudo[475]: [uMTPrd - 10:35:25 - Info] Add storage Projects - Root Path: /Voyager/Projects - Flags: 0x00000000
Oct 21 10:35:25 Voyagerk46xOO sudo[475]: [uMTPrd - 10:35:25 - Info] Add storage Licenses - Root Path: /Voyager/Licenses - Flags: 0x00000000
Oct 21 10:35:25 Voyagerk46xOO sudo[475]: [uMTPrd - 10:35:25 - Info] USB Device path : /dev/umtp/ep0
Oct 21 10:35:25 Voyagerk46xOO sudo[475]: [uMTPrd - 10:35:25 - Info] USB In End point path : /dev/umtp/ep1
Oct 21 10:35:25 Voyagerk46xOO sudo[475]: [uMTPrd - 10:35:25 - Info] USB Out End point path : /dev/umtp/ep2
Oct 21 10:35:25 Voyagerk46xOO sudo[475]: [uMTPrd - 10:35:25 - Info] USB Event End point path : /dev/umtp/ep3
Oct 21 10:35:25 Voyagerk46xOO sudo[475]: [uMTPrd - 10:35:25 - Info] USB Max packet size : 0x200 bytes
Oct 21 10:35:25 Voyagerk46xOO sudo[475]: [uMTPrd - 10:35:25 - Info] Manufacturer string : Microflown Technologies B.V.
Oct 21 10:35:25 Voyagerk46xOO sudo[475]: [uMTPrd - 10:35:25 - Info] Product string : Voyager
Oct 21 10:35:25 Voyagerk46xOO sudo[475]: [uMTPrd - 10:35:25 - Info] Serial string : 0000000
Oct 21 10:35:25 Voyagerk46xOO sudo[475]: [uMTPrd - 10:35:25 - Info] Interface string : MTP
Oct 21 10:35:25 Voyagerk46xOO sudo[475]: [uMTPrd - 10:35:25 - Info] USB Vendor ID : 0x1D6B
Oct 21 10:35:25 Voyagerk46xOO sudo[475]: [uMTPrd - 10:35:25 - Info] USB Product ID : 0x0100
Oct 21 10:35:25 Voyagerk46xOO sudo[475]: [uMTPrd - 10:35:25 - Info] USB class ID : 0x06
Oct 21 10:35:25 Voyagerk46xOO sudo[475]: [uMTPrd - 10:35:25 - Info] USB subclass ID : 0x01
Oct 21 10:35:25 Voyagerk46xOO sudo[475]: [uMTPrd - 10:35:25 - Info] USB Protocol ID : 0x01
Oct 21 10:35:25 Voyagerk46xOO sudo[475]: [uMTPrd - 10:35:25 - Info] USB Device version : 0x3008
Oct 21 10:35:25 Voyagerk46xOO sudo[475]: [uMTPrd - 10:35:25 - Info] USB FunctionFS Mode
Oct 21 10:35:25 Voyagerk46xOO sudo[475]: [uMTPrd - 10:35:25 - Info] Wait for connection : 0
Oct 21 10:35:25 Voyagerk46xOO sudo[475]: [uMTPrd - 10:35:25 - Info] Loop on disconnect : 1
Oct 21 10:35:25 Voyagerk46xOO sudo[475]: [uMTPrd - 10:35:25 - Info] Show hidden files : 1
Oct 21 10:35:25 Voyagerk46xOO sudo[475]: [uMTPrd - 10:35:25 - Info] inotify : yes
Oct 21 10:35:25 Voyagerk46xOO sudo[476]: pam_unix(sudo:session): session closed for user root
Oct 21 10:35:25 Voyagerk46xOO systemd[1]: Started umtp startup.
Oct 21 10:35:31 Voyagerk46xOO sudo[475]: [uMTPrd - 10:35:31 - Error] incoming_packet : Read Error (-1)!
Oct 21 10:47:07 Voyagerk46xOO sudo[475]: [uMTPrd - 10:47:07 - Error] incoming_packet : Read Error (-1)!
Oct 21 10:47:14 Voyagerk46xOO sudo[475]: [uMTPrd - 10:47:14 - Error] incoming_packet : Read Error (-1)!

Was previously working on v0.14.1
Device does show up on both Windows 10 and Debian, but neither of them can see the mounted storage.
Our host device runs kernel 5.2.19 with an realtime patch.

MTP Driver load, but no device appear in explorer

Hi,

I'm trying to run the server on my dev board and I have an issue with the MTP device. The umtpd start correctly, the driver appear in my W10 home device manager correctly (no error in all fields), but no device appear in the file explorer.

I use Buildroot to build umtpd, by using the package : https://stackoverflow.com/questions/54131103/buildroot-github-package-re-extracted-at-every-build

My kernel is : 4.14.73-linux4sam_6.0
My cpu is a : Atmel Sama5D3

I have enabled gadgetfs in the kernel.

I kept the default config file except for the driver at the end, I comment the linux driver and un-comment the GadgetFS driver for the Sama5D2 (it`s the same for D3 I suppose)

I run manually after the boot up the script : /usr/bin/umtprd_gfs.sh to start the server and it runs without any error. When connected it show :

gadgetfs: bound to atmel_usba_udc driver
gadgetfs: suspended from state 2
gadgetfs: connected
gadgetfs: configuration #1

Anyone had a similar issue ? Any way to help me debugging this more deeply ?

Thanks a lot,
Sylvain

MTP_Responder in Raspbery Pi Zero

Hi Team
I am able to successfully configure MTP-Responder in RPI Zero W, File Transaction b/w Windows and RPI Zero W happening fine.
if i delete a file in RPI sdcard from Windows over MTP , file is deleted successfully. But if i delete a file in RPI, still i can see the Deleted file in Windows. only after stopping and restarting MTP-Responder File deletion is updated in Windows PC. How can i solve this issue ?

5.x.x kernels not supported?

I know release notes have 4.x.x testing, just asking.
Also, in mtp_incoming_packet(), if the buffer doesn't match header, the buffer size is used rather than the header size, (I know this because the 5.4 kernel packets are coming out mismatched. This induces errors.
IMO
size = mtp_packet_hdr->length;
when this condition occurs...

wish I had time to help, I'll ask the boss...

File created on PI not showing on Mac Drive

I am using the uMTP-Responder on a PI4 that has a USB Flash Drive. The PI is connected to a Mac through the USB-c connection.

I am able to see the drive on both side. I have a mounted drive on the PI and a mounted drive on the MAC. When I create a file on the MAC, I can see it on the drive of the PI.

When I create a file on the PI, it does not show up on the drive of the MAC.

Any idea what is going on ?

Thank you,

Christian

Folder creation ignores umask config

In case umask config is specified in the config, it is only applied on newly created files, but not on folders.

Reproduction:

  1. Run uMTP-responder with a umask config. I used 111.
  2. Connect to a host, and create a folder on the storage.
  3. In the newly created folder create a new file.
  4. On the Linux host where uMTP-responder is running, check the newly created folder and file.

Expected result: both the folder and the file inside the folder have the same permissions, specified by the umask config.

Actual result: the file has correct permissions, but the folder comes with 700 permissions. Using a different Linux user the file might be accessible on its own, but the folder that contains it is not accessible.

libcomposite support

First off, fantastic project; I've deployed this sucessfully on an Allwinner based platform without issue so great work!

What is the current status of the libcomposite support and if nothing has been started yet, how complex is the transition?

Add option to force uid/gid

There should be a configurable option in umtprd.conf to force uid/gid for files written to mount loops, such as samba does with the force user and force group directives. As in, if I specify force user = 1000 for the /home loop, then any files written via to /home via umtp should have 1000:1000 ownership (which would translate to a user/group on the host system)

v0.9.7. Windows 10 can't see changes on the device.

This issue was reported by UHU-ger previously but was closed.

Steps to reproduce:

  • Make sure Windows 10 can see the content of a folder on the device running umtprd.
  • On the device, create a new file called "tmp.txt".
  • "tmp.txt" doesn't show up on Windows 10. Refreshes don't help. Leaving/re-entering the folder doesn't help.
  • Unplug/Replug USB. Windows 10 can now see "tmp.txt".

With a Linux host, Linux Mint 19 Tara XFCE specifically, "tmp.txt" shows up after a refresh.

By the way, in "umtprd-ffs.sh", "mtp" should be replaced by "umtp" in line "mount -t functionfs mtp /dev/ffs-umtp". At least, I had to do that.

GadgetFS Looping does not reconnect when removed

Hi,

On Compute Module 4, when you have a stable connection with a windows machine. If you remove the connection. Then plug it into a new pc or back into the same machine it will not reconnect.

I've traced it to in here handle_ep0(usb_gadget * ctx). It seems to be going in an infinite loop on trying to reconnect with the timeout.tv_sec

dwc2

Hi, I have built umtprd on beaglebone black running their default Debian image (Debian 9.5 2018-08-30 4GB SD IoT), and put it under /usr/bin. I have gadgetfs, but got an error when running umtprd.sh:
modprobe: FATAL: Module dwc2 not found in directory /lib/modules/4.14.67-ti-r73

Looks like the script is trying to invoke modprobe on dwc2. What is the latter - is it necessary and what should I do to get it?

Files bigger than 1,9 GB do not show up for transfer in the PC

Files that have a size larger than 1,9 Gigabyte do not show up on the client.
We've seen this happen on machines running on Windows 10 and Debian 10.
Our host machine is a IMX6 based board. We run kernel version 5.0.5 with the realtime patch applied. The filesystem on the host where the files are stored is EXT4.

Problem with multipe storages a pointed to folder on the same partition.

Hi.
I use last software at master branch. Revision. b38b8fb Device imx6 (Linux 4.14.98).
When I use two or three storage for example:

storage "/media/extern/update/"      "update" "rw"
storage "/media/extern/media/video/"      "video" "rw"
storage "/media/extern/media/photo"      "photo" "rw"

It is the same partition. But different folders:

cat /proc/mounts |grep extern
/dev/mmcblk0p6 **/media/extern** vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 0 0

My host is ubuntu 18.
How to reproduce:

  1. Copy big file (90Mb) on device. Sometimes I see the problem on this step.
  2. Copy the file again to the same folder (replace):
    the file is coppied but I see the windows with text which means: "There is a copy error" and "Connection lost".

There is no errors on umrtpd side. But on the PC side:
[ 7472.130669] pool[22616]: segfault at 0 ip 00007ff7a2cdca37 sp 00007ff79e740b70 error 4 in libmtp.so.9.3.0[7ff7a2ca5000+5e000]
[ 7472.130714] Code: 85 11 03 00 00 48 81 c4 88 00 00 00 5b 5d 41 5c 41 5d 41 5e 41 5f c3 0f 1f 40 00 41 80 7c 24 04 0f 48 8b 5c 24 48 8b 6c 24 40 <8b> 03 74 02 0f c8 89 44 24 30 48 8b 44 24 08 45 31 db c7 44 24 44
image
The problem now only with the "update" storage. Whe I try to copy the file to "photo" storage the problem is not appearing.

Another strange point with WinDev2021Eval on VirtualBox. I see high cpu and mem load when connecting device. May be it is not related.

Copy from Nautilus' Recent files

Nautilus has a "Recent files" tab on the left panel.
When copying one file from this panel directly to a MTP volume, I get PTP_OC_ANDROID_BeginEditObject not supported and the copy fails.
When copying the file from the Recent tab to another folder (e.g. /tmp) then from that folder to the MTP volume, it works.

[BBB.IO] new to MTP, File (Create/Save) access issues?

Thanks for this wonderful project, i just discovered it today while trying to solve one of our age old, "out of box" configuration problems we have at BeagleBoard.org..

I've got things mostly working, just really a quick question on MTP or maybe my config is messed up.. With a Windows 10 host, we can correctly create Folders, Drag Drop Files and Rename Files..

But i can't seem to "create" a new file (or open, edit and "save" as the same file name), is this normal in MTP or did i mess things up?

My Default config for uMTP is:

https://github.com/rcn-ee/repos/blob/master/bb-usb-gadgets/suite/bullseye/debian/bbb-umtprd.conf

Our gadget "mess" is this script for reference:

https://github.com/rcn-ee/repos/blob/master/bb-usb-gadgets/suite/bullseye/debian/bb-start-acm-ncm-rndis-old-gadget

Using:

[uMTPrd - 21:44:14 - Info] Version: v1.4.3 compiled the Oct 8 2021@18:04:33

and daily builds for BeagleBone Users:

https://rcn-ee.net/rootfs/debian-armhf/ (any date on or after: 21-10-08/ has MTP enabled by default..)

I'm working on polishing our Bullseye release..

Thanks!

Run log:

Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] uMTP Responder
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] Version: v1.4.3 compiled the Oct  8 2021@18:04:33
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] (c) 2018 - 2020 Viveris Technologies
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] Add storage /boot/ (RW) - Root Path: /boot - Flags: 0x00000000
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] Add storage WiFi Credentials (RW) - Root Path: /etc/wpa_supplicant/ - Flags: 0x00000000
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] Add storage Network Configuration (RW) - Root Path: /etc/systemd/network/ - Flags: 0x00000000
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] Add storage /opt/mtp/ Examples (RW) - Root Path: /opt/mtp - Flags: 0x00000000
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] USB Device path : /dev/ffs-mtp/ep0
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] USB In End point path : /dev/ffs-mtp/ep1
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] USB Out End point path : /dev/ffs-mtp/ep2
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] USB Event End point path : /dev/ffs-mtp/ep3
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] USB Max packet size : 0x200 bytes
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] USB Max write buffer size : 0x200 bytes
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] USB Max read buffer size : 0x200 bytes
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] Read file buffer size : 0x4000 bytes
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] Manufacturer string : BeagleBoard.org
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] Product string : BeagleBoard.org
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] Serial string : 01234567
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] Firmware Version string : Rev A
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] Interface string : MTP
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] USB Vendor ID : 0x1D6B
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] USB Product ID : 0x0100
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] USB class ID : 0x06
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] USB subclass ID : 0x01
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] USB Protocol ID : 0x01
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] USB Device version : 0x3008
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] USB FunctionFS Mode
Oct 08 22:12:39 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] Wait for connection : 0
Oct 08 22:12:38 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] Loop on disconnect : 1
Oct 08 22:12:38 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] Show hidden files : 1
Oct 08 22:12:38 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] File creation umask : 022
Oct 08 22:12:38 BeagleBone bb-start-usb-gadgets[344]: [uMTPrd - 22:12:39 - Info] inotify : yes

Lack of any out of bounds checks in helper functions

It seems some of the build dataset functions take a max size, but it's never checked downstream because none of the helper functions takes max length. This is particularly a problem when it comes to strings, and I've had to sort out my stack getting smashed because of this while developing some new code.

Windows notify of new files

I'm just testing this and find that when I add new files on the Linux side, they don't show up on the Windows side.

I've enabled debug & found that the inotify does fire and uMTPrd tries to send the push even but it seems to get stuck writing the event...

non-blocking writes...
[uMTPrd - 19:49:05 - Debug] add_entry : File not present - add entry (xxxxxxxxxx.jpg)
[uMTPrd - 19:49:05 - Debug] mtp_push_event : Event packet buffer - 16 Bytes :
[uMTPrd - 19:49:05 - Debug] 10 00 00 00 04 00 02 40 01 00 00 00 1A 00 00 00 .......@........
[uMTPrd - 19:49:05 - Debug] write_usb: channel 2
[uMTPrd - 19:49:05 - Debug] write_usb: non blocking write
[uMTPrd - 19:49:05 - Debug] write_usb: polling
[uMTPrd - 19:49:05 - Debug] write_usb: writing

or for blocking writes...
[uMTPrd - 20:03:18 - Debug] add_entry : File not present - add entry (xxxxxxxxxxx.jpg)
[uMTPrd - 20:03:18 - Debug] mtp_push_event : Event packet buffer - 16 Bytes :
[uMTPrd - 20:03:18 - Debug] 10 00 00 00 04 00 02 40 01 00 00 00 1B 00 00 00 .......@........
[uMTPrd - 20:03:18 - Debug] write_usb: channel 2
[uMTPrd - 20:03:18 - Debug] write_usb: blocking write

Excuse more debugging that I added. :)

This is on Raspberry Pi. I've tested with both FunctionFS and GadgetFS with same result.

I've got a usb capture running on Windows side & am currently trying to debug to see what actually comes through

Changes made in the Filesystem (from within the device running umtprd) not updated

running master Branch on BeagleBoneBlack.

If i create/copy/delete something on a connected Windows 10 Computer the changes are visible from the Beagle. If i change something from the Beagle (create/rename/delete) the changes are not visible on the Windows 10 Device.

(I wanted to test to take a File copied from Windows to one "storage entry point" and move it with the linux running on the device (and later change something in) it to another "storage entry Point".)

P.S. I don't want to criticize, i am happy to have found a working mtp. I just want to let you know about the bugs i find while testing.

Add file permissions option

At the moment files are created with r/w for the owner only. In my use-case I need the files to be readable by other users. Right now I've hacked the code but I think it might be useful to have the file permissions settable from the config file.

Spaces in Storage File Path Issue

Hi,

When we have a space in the file path in the .conf file like either of these
storage "/home/pi/Data Storage" "Data" "rw"
storage "/home/pi/'Data Storage'" "Data" "rw"

It still connects to the machine and pops up as a flashdrive, but when you go in on windows you aren't able to add any files to the folder.

It gives the following Warning & Error codes:
Warning] Failed to get statvfs for /home/pi/'Data Storage'
Warning] MTP_OPERATION_GET_OBJECT_HANDLES : FOLDER ACCESS ERROR !

As soon as we remove the space and just make it Data_Storage or DataStorage or something it works fine with no issues.

uMTP on Raspberry Pi 4 Freezing/Crashing Issues While Running Camera Scripts

I am working with uMTP on a Raspberry Pi 4 model B, and having some issues with freezing/failing in early operation. I am attempting to access files from a uMTP connected Windows machine while running a image capture/camera script on the Pi. I have found that unless I go very slowly with the first couple of sequences (boot-capture image-access image via uMTP-capture next image-access next image via uMTP...) uMTP will freeze or fail entirely on the second file access. Once I've gotten past the first few captures, everything works as expected and I can capture/copy images as quickly as they are produced. I have had more severe issues when working with other image capture libraries (raspiraw causes uMTP to fail regularly, but I am able to get things generally functioning in my current setup using libcamera-vid).

I am not sure what is causing this, and would greatly appreciate any insight. To give you some idea of the exact setup I'm using, here is a complete list of steps I took to arrange everything: (note that I am using Linux 11 (Bullseye))

#Create sd card w/ Imager 1.6.2

#Select 'update' during install, compelte install/update

reboot

#uMTP-responder

sudo git clone https://github.com/viveris/uMTP-Responder
cd uMTP-Responder
sudo make
cd conf

sudo nano umtprd.conf
#comment out all 'Function FS' lines
#uncomment all 'Gadget FS' lines
#modify 20980000.usb to fe980000.usb

sudo cp umtprd.conf /etc/umtprd/umtprd.conf
sudo cp /home/pi/uMTP-Responder/umtprd /usr/bin/umtprd

sudo nano /boot/config.txt
#append 'dtoverlay=dwc2'

sudo nano /etc/modules
#append 'dwc2'

reboot

#uMTP all setup, launch by running /conf/umtprd.init

#Run uMTP at boot using rc.local

sudo nano /etc/rc.local
#add 'sudo ./home/pi/uMTP-Responder/conf/umtprd.init start &' right before 'exit 0'

#modify rc.local to call script which performs touch/rm files, triggered by GPIO. Works perfectly.

#Now to get the camera setup alongside

sudo raspi-config >> enable camera

reboot

#modify rc.local to call the following script:
::::::::::::::::::::::::::::::::::::::::::

sudo nice -n -20 /home/pi/uMTP-Responder/conf/umtprd.init start
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/pi:/home/pi/capture_imx:/home/pi/raspiraw:/home/pi/raspiraw/tools

echo "22" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio22/direction
while true
do
sleep 0.1
controlstate=$(cat /sys/class/gpio/gpio22/value)
if [ "$controlstate" -eq 1 ] || [ -f /dev/shm/trigger.txt ]; then

libcamera-vid -t 1000 --docec mjpeg --segment 1 -o /dev/shm/test$05d.jpeg

fi

done

:::::::::::::::::::::::::::::::::::::::

#Now uMTP has a significant change of lock/failure on the first couple captures taken and accessed. If it makes it through the first ~3 runs, it is stable.

umtprd + functions fs Read Error (-64480) v1.3.6

Hi, I'm getting this error when trying to run umtprd with ffs: incoming_packet : Read Error (-64480)!

This is the stripped down config:

loop_on_disconnect 1
storage "/home"  "home folder" "rw"

manufacturer "test"
product "test"
serial "123456"
interface "MTP"

usb_vendor_id   0x1234
usb_product_id  0x5678
usb_class       0x6
usb_subclass    0x1     
usb_protocol    0x1     
usb_dev_version 0x3008

usb_functionfs_mode 0x1
usb_dev_path   "/dev/ffs-mtp/ep0"
usb_epin_path  "/dev/ffs-mtp/ep1"
usb_epout_path "/dev/ffs-mtp/ep2"
usb_epint_path "/dev/ffs-mtp/ep3"
usb_max_packet_size 0x200

And this is the script I use to setup the gadget and start umtprd (basically the umtprd-ffs.sh examples) I run it from /home/

#!/bin/sh

mkdir cfg
mount none cfg -t configfs

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

mkdir configs/c.1

mkdir functions/ffs.mtp

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/ffs.mtp configs/c.1

mkdir /dev/ffs-mtp
mount -t functionfs mtp /dev/ffs-mtp

# Start the umtprd service
umtprd > /home/umtp_log 2>&1 &

cd /

sleep 1

# enable the usb functions
ls /sys/class/udc/ > /home/cfg/usb_gadget/g1/UDC

dmesg output on the host when the device is connected:

[ 2138.381204] usb 1-6: new high-speed USB device number 39 using xhci_hcd
[ 2138.398729] usb 1-6: New USB device found, idVendor=1d6b, idProduct=0100, bcdDevice= 4.19
[ 2138.398735] usb 1-6: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 2138.398738] usb 1-6: Product: The Viveris Product !
[ 2138.398741] usb 1-6: Manufacturer: Viveris Technologies
[ 2138.398743] usb 1-6: SerialNumber: 01234567

The output from running mtpfs on the host:

Listing raw device(s)
Device 0 (VID=1d6b and PID=0100) is UNKNOWN in libmtp v1.1.17.
Please report this VID/PID and the device model to the libmtp development team
   Found 1 device(s):
   1d6b:0100 @ bus 1, dev 39
Attempting to connect device
error returned by libusb_claim_interface() = -6LIBMTP PANIC: Unable to initialize device
Unable to open raw device 0

I have also attached the umtprd debug output (compiled with -DDEBUG)... Am I doing anything wrong ? Please let me know if I can help debug this better.
umtp_log.txt

libmtp copy files error. Rock Pi 4.

Hi,

Thank you for this project! I am currently trying to use it in a Rock Pi 4. First of all I had to do some kernel tweaking but FunctionFS is working with the rockchip-dwc3 / dwc3 drivers.

UBUNTU host

Now I have two problems. The first one is that when copying files into the device from an Ubuntu computer I am unable to do so. I will attach the umtpmd log with verbose output first:
log.txt

On the host side, the libmtp errors I get:

e@e:~$ mtp-sendfile testsend /
libmtp version: 1.1.13
Device 0 (VID=1d6b and PID=0100) is UNKNOWN in libmtp v1.1.13.
Please report this VID/PID and the device model to the libmtp development team
Android device detected, assigning default bug flags
Sending testsend to /
type: , 44
Sending file...
Progress: 29 of 29 (100%)
Error sending file.
Error 2: PTP Layer error 2002: get_suggested_storage_id(): could not get storage id from parent id.
Error 2: Error 2002: PTP General Error
Error 2: PTP Layer error 02ff: add_object_to_cache(): couldn't add object to cache
Error 2: Error 02ff: PTP I/O Error
Error 1: LIBMTP_Send_File_From_File_Descriptor(): Could not retrieve updated metadata.
ERROR: Could not close session!

Mind you this was compiled using the SS_SUPPORT flags. The rest of the operations work as expected and superspeed is enabled AFAIK judging by the transfer speed and the output of:

root@rockpi4b:/home/rock/UMTP3# cat /sys/class/udc/fe800000.dwc3/maximum_speed 
super-speed

kernel crash with Samsung Artik710

I'm trying to make work uMPT-Responder on Samsung Artik710 via the USB OTG port.

I have "CONFIG_USB_GADGETFS=m" in the kernel 4.4:
https://github.com/SamsungARTIK/linux-artik/tree/A710_os_2.2.0

root@a:/uMTP-Responder# insmod gadgetfs.ko
root@a:
/uMTP-Responder# mkdir /dev/gadget
root@a:/uMTP-Responder# mount -t gadgetfs gadgetfs /dev/gadget
root@a:
/uMTP-Responder# ls /dev/gadget/
c0040000.dwc2otg

Note that there is no ep* in /dev/gadget

root@a:~/uMTP-Responder# ./umtprd
[Info] uMTP Responder
[Info] Version: v0.8.6 compiled the Nov 24 2018@04:56:45
[Info] (c) 2018 Viveris Technologies
[Info] Add storage root folder - Root Path: /
[Info] Add storage home folder - Root Path: /home/
[Info] USB Device path : /dev/gadget/c0040000.dwc2otg
[Info] USB In End point path : /dev/gadget/ep1
[Info] USB Out End point path : /dev/gadget/ep2
[Info] USB Event End point path : /dev/gadget/ep3
[Info] USB Max packet size : 0x200 bytes
[Info] Manufacturer string : Viveris Technologies
[Info] Product string : The Viveris Product !
[Info] Serial string : 01234567
[Info] Interface string : MTP
[Info] USB Vendor ID : 0x1D6B
[Info] USB Product ID : 0x0100
[Info] USB class ID : 0x06
[Info] USB subclass ID : 0x01
[Info] USB Protocol ID : 0x01
[Info] USB Device version : 0x3008
[Info] USB GadgetFS Mode
[Info] Wait for connection : 0
[Info] Loop on disconnect : 0

[ 68.616000] DEBUG_LOCKS_WARN_ON(val > preempt_count())
[ 68.616000] ------------[ cut here ]------------
[ 68.616000] WARNING: at kernel/sched/core.c:2985
[ 68.616000] Modules linked in: gadgetfs dhd cfg80211
[ 68.616000]
[ 68.616000] CPU: 0 PID: 1197 Comm: umtprd Not tainted 4.4.71-00005-g2fc62ed-dirty #208
[ 68.616000] task: ffffffc023bd8c00 ti: ffffffc020c98000 task.ti: ffffffc020c98000
[ 68.616000] PC is at preempt_count_sub+0x60/0xd0
[ 68.616000] LR is at preempt_count_sub+0x60/0xd0
[ 68.616000] pc : [] lr : [] pstate: 80000145
[ 68.616000] sp : ffffffc020c9bd20
[ 68.616000] x29: ffffffc020c9bd20 x28: ffffffc020c98000
[ 68.616000] x27: ffffffc00082e000 x26: 0000000000000040
[ 68.616000] x25: 000000000000011d x24: 0000000000000015
[ 68.616000] x23: 0000000000000000 x22: 0000000000000004
[ 68.616000] x21: ffffffc020ce6e00 x20: ffffffc020ce6e00
[ 68.616000] x19: 0000000000000001 x18: 0000000000096640
[ 68.616000] x17: 0000007fb6f73930 x16: ffffffc0001df4b4
[ 68.616000] x15: 000000000000000a x14: ffffffc080d9029f
[ 68.616000] x13: 0000000000000005 x12: 0000000000000030
[ 68.616000] x11: ffffffc000d902ad x10: 00000000fffffffe
[ 68.616000] x9 : 0000000005f5e0ff x8 : 706d65657270203e
[ 68.616000] x7 : 206c6176284e4f5f x6 : ffffffc000d902d9
[ 68.616000] x5 : ffffffc00086df20 x4 : 0000000000000000
[ 68.616000] x3 : ffffffc00044956c x2 : 0000000000000000
[ 68.616000] x1 : 0000000000000000 x0 : 000000000000002a
[ 68.616000]
[ 68.616000] ---[ end trace 4d5f9b115a8c362a ]---
[ 68.616000] Call trace:
[ 68.616000] [] preempt_count_sub+0x60/0xd0
[ 68.616000] [] _raw_spin_unlock_irq+0x30/0x58
[ 68.616000] [] dev_config+0x1a0/0x3a8 [gadgetfs]
[ 68.616000] [] __vfs_write+0x48/0xe8
[ 68.616000] [] vfs_write+0xbc/0x158
[ 68.616000] [] SyS_write+0x54/0x98
[ 68.616000] [] el0_svc_naked+0x24/0x28

Any idea what's wrong? I guess it's more a kernel bug.

error when writing to cfg/usb_gadget/g1/UDC (error : Device or resource busy)

Hello

I am trying to use uMTP-responder on a nanoPi Neo Core with a mini-shield (https://wiki.friendlyarm.com/wiki/index.php/Mini_Shield_for_NanoPi_NEO_Core/Core2) and linux armbian FriendlyArm distribution.

I have build umtprd with the Makefile with no error.
Then I copied the file umtprd into /usr/bin
I copied also the file umtprd.conf (from the subfolder conf) into /etc/umtprd/umtprd.conf
Then I have launched the script umtprd-ffs.sh with the sudo command
But the last line of the script:
ls /sys/class/udc/ > cfg/usb_gadget/g1/UDC
gives an error message : ls: write error: Device or resource busy

Interactively, the shell command ls /sys/class/udc works and returns musb-hdrc.4.auto

But, if I type the command echo musb-hdrc.4.auto >cfg/usb_gadget/g1/UDC, we have the same error:
bash: echo: write error: Device or resource busy

Then the problem occurs when we try to write the standard output into the file cfg/usb_gadget/g1/UDC

Do you have an idea to resolve this issue on the nanopi platform ?

Support removable device

I'm facing a problem and I'm not sure how to fix it.

I want uMTP-R to expose a micro-SD card, if it's plugged to my system. The mountpoint is a directory inside /media whose name is the label of the filesystem, so not a fixed one (but I may be able to change that if needed).

What I do right now, is have /media as a MTP volume. /media is a 64-kB tmpfs, since it only ever contains mountpoints and no actual data. It works fine on Linux, but Windows will refuse to copy since it detects that the drive is 64-kB.

Do you have an idea how I could make this setup work?

Thumbnails

It should be possible to support thumbnails by implementing the "Representative Sample" object properties.

The thumbnailing process itself should be deferred to an external program, pointed to in the config.

good project

Hi, I am a android developer, I want to import images from my DSLR to my android device, Can I use this project on android? thanks very much

Is there any reason for not support dwc3?

We menaged add dwc3 (superspeed) support, it seems fairly easy. (just add some extra config inside init_usb_mtp_gadget())
So, Is there some limitation behind the screen? (We encountered some stable issue during test, not sure if it is related)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.