examples/device/mtp/README.md
A USB Media Transfer Protocol device backed by a small in-RAM filesystem that the host can browse, read from and write to.
readme.txt and tinyusb.png.| Interface | Class driver |
|---|---|
| 0 | MTP |
Notable tusb_config.h settings:
#define CFG_TUD_MTP 1
#define CFG_TUD_MTP_EP_BUFSIZE 512
#define CFG_TUD_MTP_EP_CONTROL_BUFSIZE 16 // should be enough to hold data in MTP control request
// MTP device info
#define CFG_TUD_MTP_DEVICEINFO_EXTENSIONS "microsoft.com: 1.0; "
#define CFG_TUD_MTP_DEVICEINFO_SUPPORTED_OPERATIONS \
MTP_OP_GET_DEVICE_INFO, \
MTP_OP_OPEN_SESSION, \
MTP_OP_CLOSE_SESSION, \
MTP_OP_GET_STORAGE_IDS, \
MTP_OP_GET_STORAGE_INFO, \
MTP_OP_GET_OBJECT_HANDLES, \
MTP_OP_GET_OBJECT_INFO, \
MTP_OP_GET_OBJECT, \
MTP_OP_GET_PARTIAL_OBJECT, \
MTP_OP_DELETE_OBJECT, \
MTP_OP_SEND_OBJECT_INFO, \
MTP_OP_SEND_OBJECT, \
MTP_OP_RESET_DEVICE, \
MTP_OP_GET_DEVICE_PROP_DESC, \
MTP_OP_GET_DEVICE_PROP_VALUE, \
MTP_OP_SET_DEVICE_PROP_VALUE
#define CFG_TUD_MTP_DEVICEINFO_SUPPORTED_EVENTS \
MTP_EVENT_OBJECT_ADDED
#define CFG_TUD_MTP_DEVICEINFO_SUPPORTED_DEVICE_PROPERTIES \
MTP_DEV_PROP_DEVICE_FRIENDLY_NAME
#define CFG_TUD_MTP_DEVICEINFO_CAPTURE_FORMATS \
MTP_OBJ_FORMAT_UNDEFINED, \
MTP_OBJ_FORMAT_ASSOCIATION, \
MTP_OBJ_FORMAT_TEXT, \
MTP_OBJ_FORMAT_PNG
#define CFG_TUD_MTP_DEVICEINFO_PLAYBACK_FORMATS \
MTP_OBJ_FORMAT_UNDEFINED, \
MTP_OBJ_FORMAT_ASSOCIATION, \
MTP_OBJ_FORMAT_TEXT, \
MTP_OBJ_FORMAT_PNG
CMake:
mkdir build && cd build
cmake -DBOARD=raspberry_pi_pico ..
cmake --build .
Make:
make BOARD=raspberry_pi_pico all
The device enumerates as an MTP device and shows up in a file browser (e.g. the Files/Explorer app, or mtp-detect / mtp-files from libmtp). You should see readme.txt and tinyusb.png; you can copy a small file onto the device and delete files.