MTP

From SEGGER Wiki
Jump to: navigation, search

The Media Transfer Protocol (MTP) is a USB class protocol which can be used to transfer files to and from storage devices. MTP is an official extension of the Picture Transfer Protocol (PTP) designed to allow digital cameras to exchange image files with a computer. MTP extends this by adding support for all types of files.

SEGGER has implementations of the MTP protocol for both the emUSB-Device and the emUSB-Host stacks:

https://www.segger.com/products/connectivity/emusb-device/add-ons/mtp-class/

https://www.segger.com/products/connectivity/emusb-host/add-ons/mtp-class/

Accessing MTP devices

Linux and Windows provide out-of-the-box support for the MTP protocol. macOS requires third party tools to access MTP devices.

Accessing MTP devices under Linux

Linux supports MTP out of the box, most distributions will automatically mount MTP devices.

Below you can see Ubuntu 19.04. MTP devices are automatically mounted and shown in the left panel in Nautilus:

mtp ubuntu.png

Accessing MTP devices under Windows

MTP is supported by all Windows versions since XP. Devices are automatically mounted and shown in the Windows Explorer.

Below you can see a screenshot of emUSB-Device-MTP being used with a Windows 10 host:

mtp windows.png

Accessing MTP devices under macOS

macOS requires third party tools to access MTP devices. Most people will find Android File Transfer and OpenMTP when searching online for such tools. At the time of writing (June 2019) both of these unfortunately do not work, they are designed to work with Android devices and do not detect other MTP devices.

The company Eltima Software provides the tools "SyncMate Expert" and "Commander One", both of which provide MTP support under macOS:

https://mac.eltima.com/sync-mac.html

https://mac.eltima.com/file-manager.html

Below you can see Commander One accessing a volume on a target running emUSB-Device-MTP:

mtp macos.png

Differences between MSD and MTP

The Mass Storage Device class (MSD) is the protocol used in USB flash drives and is the most commonly used protocol for transferring files via USB. MSD is focused on speed, but it has the disadvantage of operating on a sector based level. The MSD protocol does not know anything about files. This means that it is possible for files, or the whole filesystem, to become corrupted in the event of sudden disconnection or other transfer errors. It is also not possible for an application inside the target hardware to operate on any files at the same time as the host to which the target is connected to.

MTP is designed to operate with objects (files). This allows for simultaneous access to the file system from the host and the target. The USB cable can be removed at any time without risking data corruption. The file system type is not restricted to a type which the host understands (usually FAT), but can be freely chosen to suit the target requirements. New files can be added to the MTP volume while it is connected to the host and existing files can be updated.

References