Olimex Support Forum

Microcontrollers => ESP32 => Topic started by: findmyname on April 02, 2021, 10:35:30 PM

Title: ESP32-S2-DevKit-Lipo-USB USB to Serial
Post by: findmyname on April 02, 2021, 10:35:30 PM
Hello,

I have hard time to discover ESP32-S2-DevKit-Lipo-USB rev.2 board on linux when connected via USB.
I tested it on Fedora 33 and Ubuntu Server.
I have noticed that the board uses CH340T USB-Serial convertor.

Therefore I tried:
- Driver ch341 which is part of linux kernel.
- Adjusted driver ch34x (https://github.com/juliagoda/CH341SER).
- Used multiple USB cables.
- Tested on two boards.

Unfortunately the board doesn't show up on linux but the led is blinking.
Doesn't show up == I expect that the board should be visible under /dev/ttyUSB*.
Is there anything special I need to do ?

Thx
BR
Title: Re: ESP32-S2-DevKit-Lipo-USB USB to Serial
Post by: findmyname on April 03, 2021, 11:06:27 PM
Hmm maybe I need USB OTG cable. I bought one so let's test it on Monday.
Title: Re: ESP32-S2-DevKit-Lipo-USB USB to Serial
Post by: LubOlimex on April 05, 2021, 09:09:20 AM
ESP32-S2-DevKit-LiPo-UBS doesn't use CH340. The USB-serial converter is part of the ESP32-S2 chip.

If you have trouble:

1. Make sure you are entering bootloader mode, this requires pressing and holding button BUT1, then resetting the board, then releasing button BUT1.

2. Try another USB port and another USB cable.
Title: Re: ESP32-S2-DevKit-Lipo-USB USB to Serial
Post by: findmyname on April 05, 2021, 04:21:17 PM
> 1. Make sure you are entering bootloader mode, this requires pressing and holding button BUT1, then resetting the board, then releasing button BUT1.

Oh that's worked. Hmm is there any document for this magic ? :D I was following Get Started tutorial for esp-s2 (https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/get-started/index.html) but there is no mention about that.

UPDATE: I found it in esp32-s2 documentation (https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/hw-reference/esp32s2/user-guide-saola-1-v1.2.html#getting-started) but there isn't mention that it should be done before connecting it to PC:
Download button. Holding down Boot and then pressing Reset initiates Firmware Download mode for downloading firmware through the serial port.

I tried to flash the first project with $ idf.py -p /dev/ttyACM0 flash but it failed.

Wrote 146832 bytes (81303 compressed) at 0x00010000 in 1.2 seconds (effective 951.6 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
ERROR: ESP32-S2 chip was placed into download mode using GPIO0.
esptool.py can not exit the download mode over USB. To run the app, reset the chip manually.
To suppress this error, set --after option to 'no_reset'.
CMake Error at run_serial_tool.cmake:50 (message):
  /home/findmyname/.espressif/python_env/idf4.4_py3.9_env/bin/python
  /home/findmyname/Documents/core/esp/esp-idf-framework/esp-idf/components/esptool_py/esptool/esptool.py
  --chip esp32s2 failed

Following is stated as note in tutorial:
In general, you should have no problems with the official esp-idf development boards. However, esptool.py is not able to reset your hardware automatically in the following cases:

    Your hardware does not have the DTR and RTS lines connected to GPIO0 and CHIP_PU

    The DTR and RTS lines are configured differently

    There are no such serial control lines at all

Depending on the kind of hardware you have, it may also be possible to manually put your ESP32-S2 board into Firmware Download mode (reset).

    For development boards produced by Espressif, this information can be found in the respective getting started guides or user guides. For example, to manually reset an esp-idf development board, hold down the Boot button (GPIO0) and press the EN button (CHIP_PU).

    For other types of hardware, try pulling GPIO0 down.
If I understand it correctly GPIO0 should be connected to boot button which is OK for Olimex board but I'm not sure what is EN button. Do they think reset button? Do you know what is correct procedure to flash it ?

As workaround I was able to flash it manually with esptool.py but I don't know how to boot it afterwards :D
I tried idf.py -p /dev/ttyACM0 monitor but there doesn't seems to run any application == no output.
I also pressed reset button but board disconnected from PC.

 Sorry for such beginner questions :D I'm don't have any experiences with ESP HW. I bought Olimex boards because I really like power efficiency & price ratio.

$ esptool.py --chip esp32s2 -p /dev/ttyACM0 -b 460800 --before=default_reset --after=no_reset write_flash --flash_mode dio --flash_freq 40m --flash_size 2MB 0x8000 build/partition_table/partition-table.bin 0x1000 build/bootloader/bootloader.bin 0x10000 build/hello-world.bin

Thanks for your time
Title: Re: ESP32-S2-DevKit-Lipo-USB USB to Serial
Post by: LubOlimex on April 05, 2021, 04:48:47 PM
The first thing is good. It means all is fine. Read carefully what it says:

"ERROR: ESP32-S2 chip was placed into download mode using GPIO0.
esptool.py can not exit the download mode over USB. To run the app, reset the chip manually."

It means "Everything went fine, but because the board is in bootloader mode we can't reset it automatically, so you have to reset it via the button to execute your software".
Title: Re: ESP32-S2-DevKit-Lipo-USB USB to Serial
Post by: findmyname on April 05, 2021, 04:52:31 PM
Yeah it seems to be fine. It just say that it cannot reset the board but when i pressed reset button the board disconnect from PC. So what is the correct procedure ?

I found also this (https://github.com/espressif/esptool/wiki/ESP32-Boot-Mode-Selection#automatic-bootloader) in esptool documentation

Note that some serial terminal programs (not esptool.py) will assert both RTS and DTR when opening the serial port, pulling them low together and holding the ESP32 in reset. If RTS is wired directly to EN then RTS/CTS "hardware flow control" needs to be disabled in the serial program to avoid this.

Development boards (including all Espressif boards) usually use additional circuitry to avoid this problem - if both RTS and DTR are both asserted together, this doesn't reset the chip. Consult Espressif development board schematics for the specific details.

If I understand schematic correctly RESET button seems to be connected to EN directly right ?
Title: Re: ESP32-S2-DevKit-Lipo-USB USB to Serial
Post by: LubOlimex on April 05, 2021, 04:54:18 PM
Refer to point 3.3 from the document lol:

https://github.com/OLIMEX/ESP32-S2-DevKit-LiPo-USB/blob/main/DOCUMENTS/Tutorial-ESP32S2.pdf
Title: Re: ESP32-S2-DevKit-Lipo-USB USB to Serial
Post by: LubOlimex on April 05, 2021, 04:55:44 PM
There are two modes - one is for programming, the other is for executing your code.

To program the board enter programming mode (via holding the button and reset), after done with programming exit with only reset.

Title: Re: ESP32-S2-DevKit-Lipo-USB USB to Serial
Post by: findmyname on April 05, 2021, 05:03:40 PM
Thanks for link, I missed that.

In tutorial 3.4 there is: Reset the board without BUT1 being pressed .... if I got it correctly i should press reset button only. This means that I cannot see app logs in idf monitor when connected via USB as it disconnects. Is that correct ? is there any way how to see application logs when connected via USB?

I'm asking because per ESP tutorial this should be possible.

Thx
Title: Re: ESP32-S2-DevKit-Lipo-USB USB to Serial
Post by: LubOlimex on April 06, 2021, 08:03:27 AM
Which ESP tutorial exactly? Post the link here. I assume it is a tutorial of a board with external USB-serial adapter.
Title: Re: ESP32-S2-DevKit-Lipo-USB USB to Serial
Post by: findmyname on April 06, 2021, 11:07:24 AM
I'm talking about this one (https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/get-started/index.html) for esp-s2 as referenced above. To be more specific please take a look on step 10 (https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/get-started/index.html#step-10-monitor).

Thx
BR
Title: Re: ESP32-S2-DevKit-Lipo-USB USB to Serial
Post by: LubOlimex on April 06, 2021, 11:34:54 AM
This guide assumes auto-reset is possible, and auto-reset is currently only possible when using external serial-USB converter. Auto-reset on "native" ESP32-S2 (e.g. without external serial-USB converter) is reported as non-working here:

https://github.com/espressif/arduino-esp32/issues/4528

At the moment, if you wish a board with auto-reset, consider ESP32-S2-DevKit-Lipo (notice that it has no "-USB" suffix in the end). ESP32-S2-DevKit-Lipo has external USB-serial convertor, it uses CH340T.

At the end of step 9 you can see troubleshooting info mentioning the reset possibilities:

https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/get-started/index.html#encountered-issues-while-flashing
Title: Re: ESP32-S2-DevKit-Lipo-USB USB to Serial
Post by: findmyname on April 07, 2021, 12:00:51 AM
Quote from: LubOlimex on April 06, 2021, 11:34:54 AMThis guide assumes auto-reset is possible, and auto-reset is currently only possible when using external serial-USB converter. Auto-reset on "native" ESP32-S2 (e.g. without external serial-USB converter) is reported as non-working here:

https://github.com/espressif/arduino-esp32/issues/4528

Well it isn't really clear whether they are discussing the very same issue but there is one comment at the end:
Is there any update related to this issue, the idf version is working properly with a simple "USB Console" configuration in menuconfig. However, on Ardunio side there is a problem even which crashes the configuration made by esp-idf.

I looked up this DOC (https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/api-guides/usb-console.html). I tried it and it works :)

Quote from: undefinedAt the end of step 9 you can see troubleshooting info mentioning the reset possibilities:

https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/get-started/index.html#encountered-issues-while-flashing
I saw it but there isn't mention that it doesn't work on esp-s2.

Thx for link
Title: Re: ESP32-S2-DevKit-Lipo-USB USB to Serial
Post by: LubOlimex on April 07, 2021, 08:12:25 AM
Nice thank you! I wasn't aware that auto-rest is working fine in ESP-IDF while the problem only affects ESP32-S2 for Arduino IDE!

Glad you got it working!
Title: Re: ESP32-S2-DevKit-Lipo-USB USB to Serial
Post by: wlami on May 13, 2021, 02:11:39 PM
Hi folks,

I've been trying hard to get serial output when not in bootloader mode so that I can "debug" my projects. The "default behavior" for me was that the board doesn't show up at all over USB when not in bootloader mode. I found out that this is related to the usage of the internal USB controller in contrast to using an additional one. To make it "visible" one has to change the output channel to USB CDC.

I've been successful with esp-idf but not with arduino. To monitor your board with esp-idf you have to do the following steps:


Now you have a serial interface when your code is running, not only in bootloader mode.


From my (very limited) understanding those config changes in idf.py menuconfig aren't easy to move to Arduino IDE. But maybe you have ideas on how to get those settings over.

Best,
Wladi
Title: Re: ESP32-S2-DevKit-Lipo-USB USB to Serial
Post by: findmyname on May 18, 2021, 11:58:40 AM
It seems that this feature isn't supported in Ardunio so far. There is also this issue (https://github.com/espressif/arduino-esp32/issues/4528) referenced about by @luboOlimex but it is still open.
Title: Re: ESP32-S2-DevKit-Lipo-USB USB to Serial
Post by: LubOlimex on May 18, 2021, 12:40:43 PM
I think the S2 branch was recently merged to main branch, and you no longer have to deal with specific S2 branch in Arduino. Double check if that is the case. Try if you see the S2 support using the default branch.
Title: Re: ESP32-S2-DevKit-Lipo-USB USB to Serial
Post by: xtrinch on May 21, 2021, 01:16:00 PM
I have serial over USB & web usb working fine with this board and the latest https://github.com/espressif/arduino-esp32#2.0.0-alpha1 release.

Does not work as well as the native serial interface and flashing only works 50% of the time without going into bootloader mode & can't monitor directly after reset, but it's fine for a start and you can still get the job done. Hoping at least the flashing issues resolve themselves over time :)