Skip to content

Commit 3f525d3

Browse files
committed
Fix: Build_all tests
- Fix assert msg - Add missing include
1 parent eabbc8a commit 3f525d3

File tree

5 files changed

+43
-14
lines changed

5 files changed

+43
-14
lines changed

samples/subsys/usb/mtp/README.rst

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,19 @@ Zephyr project tree.
1717
Requirements
1818
************
1919

20-
- USB device driver support
21-
- Storage media with Littlefs/FAT filesystem support
20+
- USB device driver support.
21+
- Storage media with Littlefs/FAT filesystem support.
22+
- Partitions must be mounted before connecting the board to Host.
2223

2324
Building and Running
2425
********************
2526

26-
This sample can be built for multiple boards which can support at least one storage parition.
27-
28-
Reel Board
29-
===========
30-
31-
Build and flash the project:
27+
This sample can be built for multiple boards which can support at least one storage parition,
28+
in this example we will build it for the stm32f769i_disco board:
3229

3330
.. zephyr-app-commands::
3431
:zephyr-app: samples/subsys/usb/mtp
35-
:board: reel_board
32+
:board: stm32f769i_disco
3633
:goals: flash
3734
:compact:
3835

@@ -56,13 +53,17 @@ You can then:
5653
- Browse the device storage
5754
- Transfer files to/from the device
5855
- Create/delete directories
59-
- Manage files on the device
6056

6157
The storage contents will persist across device reboots as long as the
6258
filesystem is properly unmounted before disconnecting or resetting the device.
6359

60+
.. note::
61+
62+
Not All MTP Features are implemented, for example you can't move/copy
63+
files from within the device, it must be done via Host.
64+
6465
Troubleshooting
65-
==============
66+
===============
6667

6768
If the device is not recognized properly:
6869

subsys/usb/device_next/class/usbd_mtp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ struct net_buf *mtp_buf_alloc(const uint8_t ep)
109109
}
110110

111111
bi = udc_get_buf_info(buf);
112-
memset(bi, 0, sizeof(struct udc_buf_info));
113112
bi->ep = ep;
114113

115114
#if BUF_TRACE_DEBUG

subsys/usb/device_next/class/usbd_mtp_class.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <wctype.h>
88
#include <stddef.h>
9+
#include <stdio.h>
910

1011
#include <zephyr/net_buf.h>
1112
#include <zephyr/devicetree.h>
@@ -432,7 +433,18 @@ const char *mtp_code_to_string(uint16_t code)
432433

433434
return str;
434435
}
436+
#else
437+
#define RESET
438+
#define GREEN
439+
#define BLUE
440+
#define MAGENTA
441+
#define CYAN
442+
const char *mtp_code_to_string(uint16_t code)
443+
{
444+
return (char*)NULL;
445+
}
435446
#endif
447+
436448
int mtp_get_pending_packet(struct mtp_context* ctx, struct net_buf *buf)
437449
{
438450
if (ctx->pending_fn) {
@@ -452,7 +464,7 @@ static void net_buf_add_utf16le(struct net_buf *buf, const char *str)
452464
uint16_t len = strlen(str) + 1; /* we need the null terminator */
453465

454466
for (int i = 0; i < len; i++) {
455-
__ASSERT(ascii7_str[i] > 0x1F && ascii7_str[i] < 0x7F,
467+
__ASSERT(str[i] > 0x1F && str[i] < 0x7F,
456468
"Only printable ascii-7 characters are allowed in USB "
457469
"string descriptors");
458470
net_buf_add_le16(buf, str[i]);
@@ -516,7 +528,7 @@ static int dir_traverse(uint8_t storage_id, const char *root_path, uint32_t pare
516528
/* If it's a file, store the path in the array */
517529
if (sstorage->files_count < MAX_FILES) {
518530
strncpy(sstorage->filelist[sstorage->files_count].name, entry.name,
519-
MAX_PATH_LEN - 1);
531+
MAX_FILE_NAME - 1);
520532
sstorage->filelist[sstorage->files_count].size = entry.size;
521533
sstorage->filelist[sstorage->files_count].type =
522534
entry.type; /* FS_DIR_ENTRY_FILE=0 or FS_DIR_ENTRY_DIR=1 */

tests/subsys/usb/device_next/build_all.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ CONFIG_UART_LINE_CTRL=y
2222
CONFIG_USBD_CDC_ACM_CLASS=y
2323

2424
CONFIG_USBD_MSC_CLASS=y
25+
26+
CONFIG_FILE_SYSTEM=y
2527
CONFIG_USBD_MTP_CLASS=y
2628

2729
CONFIG_USBD_AUDIO2_CLASS=y

tests/subsys/usb/device_next/build_all.overlay

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,21 @@
6767
};
6868
};
6969

70+
fstab {
71+
compatible = "zephyr,fstab";
72+
lfs1: lfs1 {
73+
compatible = "zephyr,fstab,littlefs";
74+
read-size = <32>;
75+
prog-size = <32>;
76+
cache-size = <256>;
77+
lookahead-size = <64>;
78+
block-cycles = <512>;
79+
partition = <&storage_partition>;
80+
mount-point = "/lfs1";
81+
automount;
82+
mtp-enabled;
83+
};
84+
};
7085
};
7186

7287
&zephyr_udc0 {

0 commit comments

Comments
 (0)