Skip to content

Commit e2ec91a

Browse files
committed
USB: Device_next: Add USB MTP class support
Implement a basic version of USB MTP (Media transfer protocol) class which support the necessary MTP commands to handle Dir/file transfer between a device and host. Signed-off-by: Mohamed ElShahawi <[email protected]>
1 parent e41909a commit e2ec91a

File tree

10 files changed

+1992
-0
lines changed

10 files changed

+1992
-0
lines changed

dts/bindings/fs/zephyr,fstab-common.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,8 @@ properties:
4343
4444
This causes the FS_MOUNT_FLAG_USE_DISK_ACCESS option to be set in
4545
the mount descriptor generated for the file system.
46+
47+
mtp-enabled:
48+
type: boolean
49+
description: |
50+
Provide File system access over USB MTP Protocol

include/zephyr/usb/usb_ch9.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ struct usb_association_descriptor {
264264
#define USB_BCC_AUDIO 0x01
265265
#define USB_BCC_CDC_CONTROL 0x02
266266
#define USB_BCC_HID 0x03
267+
#define USB_BCC_IMAGE 0x06
267268
#define USB_BCC_MASS_STORAGE 0x08
268269
#define USB_BCC_CDC_DATA 0x0A
269270
#define USB_BCC_VIDEO 0x0E

subsys/usb/device_next/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,10 @@ zephyr_linker_sources_ifdef(
9999
SECTIONS class/usbd_dfu.ld
100100
)
101101

102+
zephyr_library_sources_ifdef(
103+
CONFIG_USBD_MTP_CLASS
104+
class/usbd_mtp.c
105+
class/usbd_mtp_class.c
106+
)
107+
102108
zephyr_linker_sources(DATA_SECTIONS usbd_data.ld)

subsys/usb/device_next/class/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ rsource "Kconfig.uac2"
1212
rsource "Kconfig.hid"
1313
rsource "Kconfig.midi2"
1414
rsource "Kconfig.dfu"
15+
rsource "Kconfig.mtp"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright (c) 2025 Mohamed ElShahawi ([email protected])
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
config USBD_MTP_CLASS
6+
bool "USB MTP Class"
7+
help
8+
USB Media Transfer Protocol Device Class support.
9+
Allow file transfer independent of storage file system.
10+
11+
if USBD_MTP_CLASS
12+
13+
config USBD_MTP_MAX_HANDLES
14+
int "Max number of Object handles"
15+
default 10
16+
help
17+
Maximum number of objects to be handled by MTP, including
18+
stored, removed and added objects.
19+
20+
module = USBD_MTP
21+
module-str = usbd mtp
22+
default-count = 1
23+
source "subsys/logging/Kconfig.template.log_config"
24+
25+
rsource "Kconfig.template.instances_count"
26+
endif

0 commit comments

Comments
 (0)