Hi,
I am using an ESP32-S3.
I have written the code using examples\peripherals\usb\host\msc and am able to access the USB mass storage with USB-OTG.
However, once I do this, I can no longer load or monitor via USB-OTG from the PC, the COM port is gone from the PC.
Calling usb_host_uninstall(), resetting the ESP32, unplugging and plugging the USB cable does not change this situation.
The only solution I have found is to reset and go into download mode while shorting GPIO0 to GND. However, I don't want to do this every time, and this would not allow me to do any monitoring after usb_host_uninstall().
It would be nice if our device also had a USB UART, but unfortunately it does not.
Please let me know your solution.
How to use USB-OTG as a COM device again after making it a msc host?
Re: How to use USB-OTG as a COM device again after making it a msc host?
You can manually enter bootloader mode with EN and GPIO0 pins.
Re: How to use USB-OTG as a COM device again after making it a msc host?
Thanks for the reply. But as I wrote in the beginning, I do not want to do that.
> to reset and go into download mode while shorting GPIO0 to GND. However, I don't want to do this every time, and this would not allow me to do any monitoring after usb_host_uninstall().
This method does not solve the problem of not being able to continue monitoring. Also, we don't put a button switch on the GPIO0 in our product.
> to reset and go into download mode while shorting GPIO0 to GND. However, I don't want to do this every time, and this would not allow me to do any monitoring after usb_host_uninstall().
This method does not solve the problem of not being able to continue monitoring. Also, we don't put a button switch on the GPIO0 in our product.
Re: How to use USB-OTG as a COM device again after making it a msc host?
Here is your situation:
- you can monitor device over USB or over UART, those are most basic options
- you dont have UART, so that option is not available
- you want to uninstall USB, so that option is also unavailable
more advanced options are (you can also send message to enter bootloader mode):
- monitor over mqtt, ws or tcp/ip - or other related to wifi
- monitor over BLE
Not having option to connect usb to uart module is unfortunate during development.
PS MSC host and MSC device can be used for OTA
- you can monitor device over USB or over UART, those are most basic options
- you dont have UART, so that option is not available
- you want to uninstall USB, so that option is also unavailable
more advanced options are (you can also send message to enter bootloader mode):
- monitor over mqtt, ws or tcp/ip - or other related to wifi
- monitor over BLE
Not having option to connect usb to uart module is unfortunate during development.
PS MSC host and MSC device can be used for OTA
Re: How to use USB-OTG as a COM device again after making it a msc host?
I can now monitor the log output again. But there is still a problem.
When I reset with GPIO0 Lo, it appears as COM7 to a PC connected to USB-OTG.
I run
idf.py -p COM7 flash monitor
The write to the flash is successful and the log output appears in the terminal.
The program then calls usb_host_install() and msc_host_install() once. At this point, the USB flash drive connected to USB-OTG can be accessed. And when it is done, the program calls usb_host_uninstall().
After that I call tinyusb_driver_install() and then esp_tusb_init_console(TINYUSB_CDC_ACM_0) just to be sure. This worked fine.
(I tried the same thing when I wrote the first question, but I think the reason it didn't work then was that I called tinyusb_driver_install() before usb_host_uninstall(), which was running in a separate task, had finished.)
Now, I said it worked, but there is still a problem: it was COM9, not COM7, that appeared on the PC by calling tinyusb_driver_install(). So I have to exit the command and run "idf.py -p COM9 monitor". Is it possible to leave it at COM7?
More problematic is that "idf.py -p COM9 flash" fails for the new COM9.
> A serial exception error occurred: Write timeout
In the end I have to short IO0 and GND manually with a jumper wire. Then it comes back as COM7...
When I reset with GPIO0 Lo, it appears as COM7 to a PC connected to USB-OTG.
I run
idf.py -p COM7 flash monitor
The write to the flash is successful and the log output appears in the terminal.
The program then calls usb_host_install() and msc_host_install() once. At this point, the USB flash drive connected to USB-OTG can be accessed. And when it is done, the program calls usb_host_uninstall().
After that I call tinyusb_driver_install() and then esp_tusb_init_console(TINYUSB_CDC_ACM_0) just to be sure. This worked fine.
(I tried the same thing when I wrote the first question, but I think the reason it didn't work then was that I called tinyusb_driver_install() before usb_host_uninstall(), which was running in a separate task, had finished.)
Now, I said it worked, but there is still a problem: it was COM9, not COM7, that appeared on the PC by calling tinyusb_driver_install(). So I have to exit the command and run "idf.py -p COM9 monitor". Is it possible to leave it at COM7?
More problematic is that "idf.py -p COM9 flash" fails for the new COM9.
> A serial exception error occurred: Write timeout
In the end I have to short IO0 and GND manually with a jumper wire. Then it comes back as COM7...
Re: How to use USB-OTG as a COM device again after making it a msc host?
Okay. I succeed to get COM7 back. I had to set Custom vendor ID, Custom product ID, bcdDevice, Manufacturer name, Product name and Serial string of Component config -> TinyUSB Stack -> Descriptor configuration as same as download mode. This resumes the monitor.
But still cannot flash against it. I guess I also need to start up WinUSB as a CDC service.
But still cannot flash against it. I guess I also need to start up WinUSB as a CDC service.
Re: How to use USB-OTG as a COM device again after making it a msc host?
To be able to do "idf.py flash" or "esptool.py write_flash" towards USB-OTG again, "CDC Channel count" should be set to 2, maybe. But this might still not be enough. I still get the error "A serial exception error occurred: Write timeout". Do I have to wake up (or activate) the handler in ROM? Please let me know if you know.
Re: How to use USB-OTG as a COM device again after making it a msc host?
By calling tinyusb_driver_install() and other functions, I can now get the log output flow to the PC as it did before. But that doesn't mean I could revert back to the original state. The new driver is simply working.
Before doing usb_host_install(), I need to save all information such as device descriptors and callback addresses. Then, after usb_host_uninstall() is done, I need to restore them back to their original state. Then perhaps I can get back the ability to write flash from the PC via USB-OTG.
But how? I can't find any such API.
I'm still looking for information.
Before doing usb_host_install(), I need to save all information such as device descriptors and callback addresses. Then, after usb_host_uninstall() is done, I need to restore them back to their original state. Then perhaps I can get back the ability to write flash from the PC via USB-OTG.
But how? I can't find any such API.
I'm still looking for information.
Re: How to use USB-OTG as a COM device again after making it a msc host?
Solved with short code below.
- usb_serial_jtag_driver_config_t usb_serial_jtag_config = USB_SERIAL_JTAG_DRIVER_CONFIG_DEFAULT();
- usb_serial_jtag_driver_install(&usb_serial_jtag_config);
Who is online
Users browsing this forum: Baidu [Spider] and 124 guests