16010 views|13 replies

1366

Posts

6

Resources
The OP
 

ESP32-S2 Development Pitfalls (4) -- USB Pitfalls [Copy link]

 

Get tinyusb according to the following readme instructions

https://github.com/hathach/tinyusb

esp32s2 porting

TinyUSB already supports ESP32S2 , mainly hid.msc and cdc on the device side . The host side does not support it yet.

To understand an open source library, most libraries will have debug log prints. We need to align the debug prints to understand the operation of tinyusb .

In actual debugging, it is recommended to cooperate with the source code. As a small USB protocol stack, tinyusb is still worth learning.

You can see that in tusb_common.h , there are macro definitions for log printing. Here, 0 means no printing is required, 1 means printing when an error occurs, and 2 means printing the debug log.

The print output function can be customized or directly use the Printf of the C library , but the premise is that you need to redirect. Here, esp32s2 redirects printf to serial port 0, so we don't need to customize it here. The official default is 1 , which means it will only print when an error occurs. We change it to 2 here , and print all logs. Then compile and burn

In this way, relevant initialization and enumeration processes will appear when printing. In order to have a deeper understanding of the tinyusb library, it is necessary to enable this debug for tracking.

This post is from DIY/Open Source Hardware

Latest reply

gtq
I have benefited a lot from the talk of experience. The host is awesome. I have benefited a lot from the talk of experience. The host is awesome.   Details Published on 2024-7-12 11:02
Personal signature

1084534438 欢迎交流  [加油,一切皆有可能]

 

1366

Posts

6

Resources
2
 

At present, tingusb has basically transplanted the three devices cdc, msc, and hid to esp32s2 . The example used here is the cdc_msc_freertos example. The macros have enabled cdc and msc as follows .

In the main function, you first need to adapt and initialize the board. Here, tinyusb initializes Espressif's esp32s2_saola board. However, the board's related peripherals are different from Espressif's. For example, the LEDs used are different.

You need to create a new port on the bsp to adapt and call related interfaces. Mainly board_init , board_led_write , and board_button_read . The USB is also initialized in board_init . Espressif does not have any relevant documentation on USB peripherals, so I will not go into details here. Tinyusb also guesses esp32s2 based on the USB peripherals of stm32 . For specific instructions, please refer to the pull of tinyusb .

https://github.com/hathach/tinyusb/pull/319

This post is from DIY/Open Source Hardware
Personal signature

1084534438 欢迎交流  [加油,一切皆有可能]

 
 

1366

Posts

6

Resources
3
 

The examples are available in Linux and Windows , but there are some points to note :

When judging whether the serial port is connected or disconnected, the state of DTR is used as the judgment. Therefore, whether you use someone else's serial port assistant or your own host computer, you need to turn on DTR when opening the serial port . Tinyusb can use this to judge whether it is connected. You can turn off DTR when closing the serial port .

Cdc can adapt to the baud rate related properties. If you need to fix the baud rate yourself, you can change it as follows.

On MSC , you can also change the disk name and write related files on the disk file. However, since the internal flash is mapped and the external flash has not been mapped, it is not clear about msc , and the author needs to search further.

Here the OP verified the cdc and found no problem with the 100ms timing after sending and receiving for more than an hour . At present, esp32 has only two serial ports, and one of them is used as debug . It is a good thing to have a cdc to supplement such a tight serial port resource .

This post is from DIY/Open Source Hardware
Personal signature

1084534438 欢迎交流  [加油,一切皆有可能]

 
 
 

1366

Posts

6

Resources
4
 

CDC sending and receiving effect:

This post is from DIY/Open Source Hardware
Personal signature

1084534438 欢迎交流  [加油,一切皆有可能]

 
 
 

6040

Posts

204

Resources
5
 

Very good, thanks for sharing!

This post is from DIY/Open Source Hardware
 
 
 

7

Posts

0

Resources
6
 

If this is made into uvc, it will be very useful.

This post is from DIY/Open Source Hardware
 
 
 

3

Posts

0

Resources
7
 
RCSN posted on 2020-5-17 22:26 The examples are available in Linux and Windows, but the following points should be noted: When judging whether it is...

OP, do you have any idea about MSC mapping external flash?

This post is from DIY/Open Source Hardware
 
 
 

1

Posts

0

Resources
8
 

I have been working on it for a week or two but I can't figure it out. Can I get a copy of the source code to study? 1412134399@qq.com, thank you very much

This post is from DIY/Open Source Hardware
 
 
 

1462

Posts

0

Resources
9
 

Thanks to the OP, it is very good sharing. I don’t know how to do it, so I will learn it in my spare time.

This post is from DIY/Open Source Hardware
 
 
 

2

Posts

0

Resources
10
 

Thanks for sharing, it’s very good sharing. I am planning to learn it. I will take a look and learn in my spare time!

This post is from DIY/Open Source Hardware
 
 
 

185

Posts

0

Resources
11
 

If this is made into uvc, it will be very useful.

This post is from DIY/Open Source Hardware
 
 
 

1462

Posts

0

Resources
12
 
Learn a little while passing by. Learn a little while passing by. Learn a little while passing by.
This post is from DIY/Open Source Hardware
 
 
 

2

Posts

0

Resources
13
 

What version of IDF do you use? Is it only 4.4 that can use tinyusb?


This post is from DIY/Open Source Hardware
 
 
 

15

Posts

0

Resources
14
 

I have benefited a lot from the talk of experience. The host is awesome. I have benefited a lot from the talk of experience. The host is awesome.

This post is from DIY/Open Source Hardware
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list