ESP32-S2 USB-CDC Flashing (Arduino)

ozgbostan
Posts: 16
Joined: Sat Oct 31, 2020 7:19 am

Re: ESP32-S2 USB-CDC Flashing (Arduino)

Postby ozgbostan » Mon Feb 22, 2021 10:24 pm

chegewara wrote:
Sun Feb 21, 2021 8:08 pm
ozgbostan wrote:
Fri Feb 12, 2021 11:29 pm
Thanks for the discussion. You have anything in your mind to recommend as a solution?
I investigated it a bit today and there is something changed in tinyusb library which is in idf-release/v4.2, since branch esp32s2 works good, and by works good i mean if you have flashed USBSerial example from branch esp32s2, then you can flash anything over native USB from any branch. Currentlu USBSerial example cant be installed, due some issue in tinyusb and misconfiguration.
So you mean, I should use esp32s2 branch until the issue gets resolved, right?

Which commit by the way? The last commit is stable enough, or is there any commit number you are going to share?

ozgbostan
Posts: 16
Joined: Sat Oct 31, 2020 7:19 am

Re: ESP32-S2 USB-CDC Flashing (Arduino)

Postby ozgbostan » Tue Feb 23, 2021 7:55 am

ozgbostan wrote:
Mon Feb 22, 2021 10:24 pm
chegewara wrote:
Sun Feb 21, 2021 8:08 pm
ozgbostan wrote:
Fri Feb 12, 2021 11:29 pm
Thanks for the discussion. You have anything in your mind to recommend as a solution?
I investigated it a bit today and there is something changed in tinyusb library which is in idf-release/v4.2, since branch esp32s2 works good, and by works good i mean if you have flashed USBSerial example from branch esp32s2, then you can flash anything over native USB from any branch. Currentlu USBSerial example cant be installed, due some issue in tinyusb and misconfiguration.
So you mean, I should use esp32s2 branch until the issue gets resolved, right?

Which commit by the way? The last commit is stable enough, or is there any commit number you are going to share?
By the way, you have just released a library a couple of days ago, does not that library solve the problem that you mentioned about?

chegewara
Posts: 1392
Joined: Wed Jun 14, 2017 9:00 pm

Re: ESP32-S2 USB-CDC Flashing (Arduino)

Postby chegewara » Tue Feb 23, 2021 8:05 am

ozgbostan wrote: By the way, you have just released a library a couple of days ago, does not that library solve the problem that you mentioned about?
Yes and no. I am aware that we have issue with tinyusb_init, so i am ignoring return from that function until it wont get fixed in arduino. I also implemented USB persistent code, so it allows to upload over USB in arduino IDE, more or less, then by accident i deleted library and whole day work gone. I will try to recreate code and add this functionality this week.

chegewara
Posts: 1392
Joined: Wed Jun 14, 2017 9:00 pm

Re: ESP32-S2 USB-CDC Flashing (Arduino)

Postby chegewara » Wed Feb 24, 2021 5:54 am

I just added persist reboot to my library, which allows to flash without using buttons to enable download mode. My version has small issue, but i think it is better to have it working this way than not having it at all.

ozgbostan
Posts: 16
Joined: Sat Oct 31, 2020 7:19 am

Re: ESP32-S2 USB-CDC Flashing (Arduino)

Postby ozgbostan » Wed Feb 24, 2021 6:07 am

chegewara wrote:
Wed Feb 24, 2021 5:54 am
I just added persist reboot to my library, which allows to flash without using buttons to enable download mode. My version has small issue, but i think it is better to have it working this way than not having it at all.
Thanks for your support and contribution. Now, after uploading the example sketch just one time, the CDC flashing will be always available for the upcoming upload procedures, right?

chegewara
Posts: 1392
Joined: Wed Jun 14, 2017 9:00 pm

Re: ESP32-S2 USB-CDC Flashing (Arduino)

Postby chegewara » Wed Feb 24, 2021 6:36 am

ozgbostan wrote: Thanks for your support and contribution. Now, after uploading the example sketch just one time, the CDC flashing will be always available for the upcoming upload procedures, right?
CDC flashing will available as long as CDC is running on device, so you have to add it to your code each time.

ozgbostan
Posts: 16
Joined: Sat Oct 31, 2020 7:19 am

Re: ESP32-S2 USB-CDC Flashing (Arduino)

Postby ozgbostan » Wed Feb 24, 2021 10:09 am

chegewara wrote:
Wed Feb 24, 2021 6:36 am
CDC flashing will available as long as CDC is running on device, so you have to add it to your code each time.
OK, I have understood. So, what about "Serial connected to:" option of Arduino IDE? Is it another feature of ESP32 Arduino Core? As far as I understood, the released library of yours and that option are different alternatives, right?

chegewara
Posts: 1392
Joined: Wed Jun 14, 2017 9:00 pm

Re: ESP32-S2 USB-CDC Flashing (Arduino)

Postby chegewara » Wed Feb 24, 2021 12:21 pm

ozgbostan wrote:
Wed Feb 24, 2021 10:09 am
OK, I have understood. So, what about "Serial connected to:" option of Arduino IDE? Is it another feature of ESP32 Arduino Core? As far as I understood, the released library of yours and that option are different alternatives, right?
Thats right. My library is alternative for espressif library in arduino IDE which is having only CDC class at the moment, as far as i know, and only 1 example.
The option "Serial connected to" is another thing. It is like ESP_CONSOLE_USB_CDC option in IDF menuconfig, will log all from Serial to USB instead of UART. For the same reason i described earlier (bug in tinyusb) this option is also broken in current version of arduino.
My library is more like a separate library to build CDC and other classes device and is not compatible with espressif library, so cant be used with "Serial connected to". It is because i started my library before usb hal has been created.

My library the same as espressif library can be used to control esp32. Recently i finished some device which is connected to RPi in some closed facility. To control esp32 i am using CDC and simple terminal app i wrote. Of course it can works with standard UART connection, but "my device" is a custom PCB without UART, and if it would have UART i could use screen to see logs at the same time when i control device over CDC.

Here is issue you can track
https://github.com/espressif/arduino-esp32/issues/4847

ozgbostan
Posts: 16
Joined: Sat Oct 31, 2020 7:19 am

Re: ESP32-S2 USB-CDC Flashing (Arduino)

Postby ozgbostan » Wed Feb 24, 2021 12:58 pm

chegewara wrote:
Wed Feb 24, 2021 12:21 pm
Thats right. My library is alternative for espressif library in arduino IDE which is having only CDC class at the moment, as far as i know, and only 1 example.
The option "Serial connected to" is another thing. It is like ESP_CONSOLE_USB_CDC option in IDF menuconfig, will log all from Serial to USB instead of UART. For the same reason i described earlier (bug in tinyusb) this option is also broken in current version of arduino.
My library is more like a separate library to build CDC and other classes device and is not compatible with espressif library, so cant be used with "Serial connected to". It is because i started my library before usb hal has been created.

My library the same as espressif library can be used to control esp32. Recently i finished some device which is connected to RPi in some closed facility. To control esp32 i am using CDC and simple terminal app i wrote. Of course it can works with standard UART connection, but "my device" is a custom PCB without UART, and if it would have UART i could use screen to see logs at the same time when i control device over CDC.

Here is issue you can track
https://github.com/espressif/arduino-esp32/issues/4847
OK. Thanks all the support you provide by so far.
With ESP_CONSOLE_USB_CDC option in ESP-IDF, I was able to both flash and read logs via native USB. As far as I know, this "Serial connected to:" option is capable enough for flashing in Arduino as well. However, as you noted there is problem and it's not working at all. Now, I am gonna try your library and let you know the result.

Thanks again.

chegewara
Posts: 1392
Joined: Wed Jun 14, 2017 9:00 pm

Re: ESP32-S2 USB-CDC Flashing (Arduino)

Postby chegewara » Thu Feb 25, 2021 11:34 pm

I fixed one more thing in my library and now you can also use it as a standard Serial library

Code: Select all

#define NO_GLOBAL_SERIAL   // this will prevent  to create instance of HardwareSerial Serial
#include "cdcusb.h"

CDCusb Serial;

void setup()
{
    Serial.begin();
    while(!Serial); // wait until USB cable is connected and stack is ready
    Serial.println("Serial is ready");
}

void loop()
{
  delay(1000);
  Serial.println(millis());
}

Who is online

Users browsing this forum: ozgbostan and 20 guests