I would like to use USB host on ESP32-S2 in ESP-IDF
I would like to use USB host on ESP32-S2 in ESP-IDF
The current support is a USB composite device with a CDC driver. That's not what I'm interested in using. Are there any references of how to write your own code to interface with tinyUSB, such as sending out BULK IN, responding to control transfer etc.? My first place to look will be the CDC driver in IDF though but I just wonder if there are anything else. My goal is to port my usb device-class code to esp32-s2 or s3. Also, any plan to enable usb host mode on s2 and s3? Thanks.
Last edited by zliudr on Fri Mar 19, 2021 3:08 am, edited 1 time in total.
Re: I would like to use tinyUSB on ESP32-S2 in ESP-IDF
I think the best source is this repository with examples:
https://github.com/hathach/tinyusb
but you can also check those examples:
https://github.com/chegewara/esp-idf/tr ... herals/usb
I dont have any info about host driver, but i think its still few months before we will get it ready to start with.
https://github.com/hathach/tinyusb
but you can also check those examples:
https://github.com/chegewara/esp-idf/tr ... herals/usb
I dont have any info about host driver, but i think its still few months before we will get it ready to start with.
Re: I would like to use tinyUSB on ESP32-S2 in ESP-IDF
Thanks for your response and sorry it took so long to get back. I'm still interested in tinyUSB host stuff.
When you said the host code won't be ready, do you mean there's currently no way to interact with the ESP32-s2 USB controller in the host mode using tinyUSB calls?
Are the basic functions supported under ESP-IDF, tinyUSB, both, such as control transfer, BULK IN and OUT? I could just do straight polling instead of using the "periodic TX FIFO" which sounds like it's for INT EP purposes. If I could do the bare minimum, with control transfer, bulk in and out, then I'm good. I can transplant my own host stack on top of these functions.
I don't see any inclusion of usb host code:
https://github.com/espressif/esp-idf/bl ... eLists.txt
When you said the host code won't be ready, do you mean there's currently no way to interact with the ESP32-s2 USB controller in the host mode using tinyUSB calls?
Are the basic functions supported under ESP-IDF, tinyUSB, both, such as control transfer, BULK IN and OUT? I could just do straight polling instead of using the "periodic TX FIFO" which sounds like it's for INT EP purposes. If I could do the bare minimum, with control transfer, bulk in and out, then I'm good. I can transplant my own host stack on top of these functions.
I don't see any inclusion of usb host code:
https://github.com/espressif/esp-idf/bl ... eLists.txt
-
- Posts: 9772
- Joined: Thu Nov 26, 2015 4:08 am
Re: I would like to use tinyUSB on ESP32-S2 in ESP-IDF
There is no functional host mode in ESP-IDF/tinyUSB as of yet. We're working on developing something.
Re: I would like to use tinyUSB on ESP32-S2 in ESP-IDF
Thank you! Would you be posting in the announcement if you have something like basic host setup function and control_transfer, bulk in/out? I am happy to test your code. I just started reading the hardware reference manual on S2's USB peripheral and could provide some assistance in testing your code. I'm familiar with the UHS library made for arduino and MAX3421E USB host IC. I'm going to read tinyUSB's host stack for some understanding.
-
- Posts: 9772
- Joined: Thu Nov 26, 2015 4:08 am
Re: I would like to use tinyUSB on ESP32-S2 in ESP-IDF
Sure, will see if we can give you a headsup once the code hits the public git repos. Note that we likely won't be using the TinyUSB host stack, we have something more libusb-like in the works.
Re: I would like to use tinyUSB on ESP32-S2 in ESP-IDF
Great! I've started reading libusb documentation. It's good to know how it does its work. TinyUSB doesn't have a good usb host stack so it's good to not use it for host. I will definitely test out libusb once you release a version of ESP-IDF with the support.
Re: I would like to use USB host on ESP32-S2 in ESP-IDF
Any release date for the usb host stack? Thanks.
Re: I would like to use USB host on ESP32-S2 in ESP-IDF
A part of the HCD is now pushed to master (see link) if you need some sort of support immediately. However the HCD currently only supports Bulk and Control transfers.
However, do note that this is a private_include and the API will likely change. See the maintainers_notes.md for more information regarding the API.
However, do note that this is a private_include and the API will likely change. See the maintainers_notes.md for more information regarding the API.
Re: I would like to use USB host on ESP32-S2 in ESP-IDF
I would like to thank you for update and posting API to github.ESP_Dazz wrote: ↑Fri Mar 19, 2021 7:59 amA part of the HCD is now pushed to master (see link) if you need some sort of support immediately. However the HCD currently only supports Bulk and Control transfers.
However, do note that this is a private_include and the API will likely change. See the maintainers_notes.md for more information regarding the API.
I am trying to start to work with it, by copy/paste code from test cases, but i can get any port events even if basic code should be fine. Here is output log from init of USB host:
Code: Select all
I (632) : USB host setup properly
I (732) : hcd_port_state_t: 0 // HCD_PORT_STATE_NOT_POWERED
I (732) : Port powered ON
I (732) : hcd_port_state_t: 1 // HCD_PORT_STATE_DISCONNECTED
Code: Select all
hcd_port_state_t state = hcd_port_get_state(port_hdl);
ESP_LOGI("", "hcd_port_state_t: %d", state);
//Power ON the port
if(ESP_OK == hcd_port_command(port_hdl, HCD_PORT_CMD_POWER_ON)) ESP_LOGI("", "Port powered ON");
state = hcd_port_get_state(port_hdl);
ESP_LOGI("", "hcd_port_state_t: %d", state);
//Wait for connection event
printf("Waiting for conenction\n");
phy_force_conn_state(true, pdMS_TO_TICKS(100)); //Allow for connected state on PHY
hcd_port_event_t event;
while (!isConnected) // await on port queue event
{
if(HCD_PORT_EVENT_CONNECTION == (event = hcd_port_handle_event(port_hdl))) { // additionally polling for debugging purpose
ESP_LOGI("", "HCD_PORT_EVENT_CONNECTION");
isConnected = true;
} else if(event != HCD_PORT_EVENT_NONE) {
ESP_LOGE("", "port event: %d", event);
}
vTaskDelay(1);
}
https://pl.rs-online.com/web/p/zlacza-usb/1225096/
Ive been trying to swap pins 19 and 20, but no success.
EDIT connected USB device is just CP2102N (esp32 S2 - saola)
Am i missing something?
Thanks
Who is online
Users browsing this forum: No registered users and 89 guests