Skip to content

Commit b6b6ba4

Browse files
committed
fix(idf): fix p4 config
Signed-off-by: sakumisu <[email protected]>
1 parent 51ad371 commit b6b6ba4

File tree

1 file changed

+74
-13
lines changed

1 file changed

+74
-13
lines changed

osal/idf/usb_config.h

Lines changed: 74 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,16 @@
2525
#define CONFIG_USB_ALIGN_SIZE 4
2626
#endif
2727

28+
// #define CONFIG_USB_DCACHE_ENABLE
29+
2830
/* attribute data into no cache ram */
2931
#define USB_NOCACHE_RAM_SECTION
3032

33+
/* use usb_memcpy default for high performance but cost more flash memory.
34+
* And, arm libc has a bug that memcpy() may cause data misalignment when the size is not a multiple of 4.
35+
*/
36+
// #define CONFIG_USB_MEMCPY_DISABLE
37+
3138
/* ================= USB Device Stack Configuration ================ */
3239

3340
/* Ep0 in and out transfer buffer */
@@ -49,6 +56,9 @@
4956
/* Enable test mode */
5057
// #define CONFIG_USBDEV_TEST_MODE
5158

59+
/* enable advance desc register api */
60+
#define CONFIG_USBDEV_ADVANCE_DESC
61+
5262
/* move ep0 setup handler from isr to thread */
5363
// #define CONFIG_USBDEV_EP0_THREAD
5464

@@ -84,7 +94,7 @@
8494
// #define CONFIG_USBDEV_MSC_POLLING
8595

8696
/* move msc read & write from isr to thread */
87-
// #define CONFIG_USBDEV_MSC_THREAD
97+
#define CONFIG_USBDEV_MSC_THREAD
8898

8999
#ifndef CONFIG_USBDEV_MSC_PRIO
90100
#define CONFIG_USBDEV_MSC_PRIO 4
@@ -94,6 +104,28 @@
94104
#define CONFIG_USBDEV_MSC_STACKSIZE 2048
95105
#endif
96106

107+
#ifndef CONFIG_USBDEV_MTP_MAX_BUFSIZE
108+
#define CONFIG_USBDEV_MTP_MAX_BUFSIZE 2048
109+
#endif
110+
111+
#ifndef CONFIG_USBDEV_MTP_MAX_OBJECTS
112+
#define CONFIG_USBDEV_MTP_MAX_OBJECTS 256
113+
#endif
114+
115+
#ifndef CONFIG_USBDEV_MTP_MAX_PATHNAME
116+
#define CONFIG_USBDEV_MTP_MAX_PATHNAME 256
117+
#endif
118+
119+
#define CONFIG_USBDEV_MTP_THREAD
120+
121+
#ifndef CONFIG_USBDEV_MTP_PRIO
122+
#define CONFIG_USBDEV_MTP_PRIO 4
123+
#endif
124+
125+
#ifndef CONFIG_USBDEV_MTP_STACKSIZE
126+
#define CONFIG_USBDEV_MTP_STACKSIZE 4096
127+
#endif
128+
97129
#ifndef CONFIG_USBDEV_RNDIS_RESP_BUFFER_SIZE
98130
#define CONFIG_USBDEV_RNDIS_RESP_BUFFER_SIZE 156
99131
#endif
@@ -112,6 +144,7 @@
112144
#endif
113145

114146
#define CONFIG_USBDEV_RNDIS_USING_LWIP
147+
#define CONFIG_USBDEV_CDC_ECM_USING_LWIP
115148

116149
/* ================ USB HOST Stack Configuration ================== */
117150

@@ -137,7 +170,7 @@
137170
#define CONFIG_USBHOST_PSC_STACKSIZE 2048
138171
#endif
139172

140-
// #define CONFIG_USBHOST_GET_STRING_DESC
173+
//#define CONFIG_USBHOST_GET_STRING_DESC
141174

142175
// #define CONFIG_USBHOST_MSOS_ENABLE
143176
#ifndef CONFIG_USBHOST_MSOS_VENDOR_CODE
@@ -236,11 +269,27 @@
236269

237270
#define CONFIG_USB_DWC2_DMA_ENABLE
238271

239-
#elif CONFIG_IDF_TARGET_ESP32C5 || CONFIG_IDF_TARGET_ESP32P4
272+
#elif CONFIG_IDF_TARGET_ESP32P4
273+
#define ESP_USBD_BASE 0x50000000UL
274+
275+
#define CONFIG_USBDEV_MAX_BUS 1
276+
#define CONFIG_USBDEV_EP_NUM 7 // 16
277+
278+
/* ---------------- DWC2 Configuration ---------------- */
279+
//esp32s2/s3 can support up to 5 IN endpoints(include ep0) at the same time
280+
#define CONFIG_USB_DWC2_RXALL_FIFO_SIZE (1024 / 4)
281+
#define CONFIG_USB_DWC2_TX0_FIFO_SIZE (64 / 4)
282+
#define CONFIG_USB_DWC2_TX1_FIFO_SIZE (512 / 4)
283+
#define CONFIG_USB_DWC2_TX2_FIFO_SIZE (512 / 4)
284+
#define CONFIG_USB_DWC2_TX3_FIFO_SIZE (512 / 4)
285+
#define CONFIG_USB_DWC2_TX4_FIFO_SIZE (512 / 4)
286+
#define CONFIG_USB_DWC2_TX5_FIFO_SIZE (64 / 4)
287+
#define CONFIG_USB_DWC2_TX6_FIFO_SIZE (64 / 4)
288+
#define CONFIG_USB_DWC2_TX7_FIFO_SIZE (0 / 4)
289+
#define CONFIG_USB_DWC2_TX8_FIFO_SIZE (0 / 4)
290+
291+
#define CONFIG_USB_DWC2_DMA_ENABLE
240292
#define CONFIG_USB_HS
241-
#define ESP_USBD_BASE 0x60080000
242-
// todo: check c5, p4 in later
243-
#define CONFIG_USBDEV_EP_NUM 7
244293
#else
245294
#error "Unsupported SoC"
246295
#endif
@@ -265,12 +314,24 @@
265314
*/
266315
#define CONFIG_USB_DWC2_RX_FIFO_SIZE ((200 - CONFIG_USB_DWC2_NPTX_FIFO_SIZE - CONFIG_USB_DWC2_PTX_FIFO_SIZE))
267316

268-
#elif CONFIG_IDF_TARGET_ESP32C5 || CONFIG_IDF_TARGET_ESP32P4
269-
// todo: check c5, p4 in later
270-
#define ESP_USBH_BASE 0x60080000
271-
#define CONFIG_USBHOST_PIPE_NUM 8
317+
#elif CONFIG_IDF_TARGET_ESP32P4
318+
#define ESP_USBH_BASE 0x50000000UL
319+
320+
#define CONFIG_USBHOST_MAX_BUS 1
321+
#define CONFIG_USBHOST_PIPE_NUM 16
322+
323+
/* ---------------- DWC2 Configuration ---------------- */
324+
/* largest non-periodic USB packet used / 4 */
325+
#define CONFIG_USB_DWC2_NPTX_FIFO_SIZE (512 / 4)
326+
/* largest periodic USB packet used / 4 */
327+
#define CONFIG_USB_DWC2_PTX_FIFO_SIZE (512 / 4)
328+
/*
329+
* (largest USB packet used / 4) + 1 for status information + 1 transfer complete +
330+
* 1 location each for Bulk/Control endpoint for handling NAK/NYET scenario
331+
*/
332+
#define CONFIG_USB_DWC2_RX_FIFO_SIZE ((896 - CONFIG_USB_DWC2_NPTX_FIFO_SIZE - CONFIG_USB_DWC2_PTX_FIFO_SIZE))
333+
334+
#define CONFIG_USB_HS
272335
#else
273336
#error "Unsupported SoC"
274-
#endif
275-
276-
#define CONFIG_USBDEV_ADVANCE_DESC
337+
#endif

0 commit comments

Comments
 (0)