ESP32 NodeMCU D1 R32 CH340G cant make it work in Ubuntu

Hi Folks I am on ubuntu 22,04
I cant make the upload I installed the ESP32 module
I am using in preferences
https://dl.espressif.com/dl/package_esp32_index.json

afterwards installed ESP32.

Also selected the card Board manager >ESP32>ESP32 Dev Module,
I also have tested ESP32>ESP32 Wrover module,

I get followingg error:

Build options changed, rebuilding all
Sketch uses 197736 bytes (15%) of program storage space. Maximum is 1310720 bytes.
Global variables use 13084 bytes (3%) of dynamic memory, leaving 314596 bytes for local variables. Maximum is 327680 bytes.
esptool.py v3.0-dev
Serial port /dev/ttyS0
Connecting........_____....._____....._____....._____....._____....._____.....____An error occurred while uploading the sketch
_

A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header```
Please help me out


I also downloaded the driver from 
https://learn.sparkfun.com/tutorials/how-to-install-ch340-drivers/all

but when I compile I get followingg error:

make -C /lib/modules/5.15.0-56-generic/build M=/home/xsisec/Downloads/CH341SER_LINUX
make[1]: Entering directory '/usr/src/linux-headers-5.15.0-56-generic'
CC [M] /home/xsisec/Downloads/CH341SER_LINUX/ch34x.o
/home/xsisec/Downloads/CH341SER_LINUX/ch34x.c: In function ‘ch34x_close’:
/home/xsisec/Downloads/CH341SER_LINUX/ch34x.c:591:9: error: unknown type name ‘wait_queue_t’; did you mean ‘wait_event’?
591 | wait_queue_t wait;
| ^~~~~~~~~~~~
| wait_event
/home/xsisec/Downloads/CH341SER_LINUX/ch34x.c:591:22: warning: unused variable ‘wait’ [-Wunused-variable]
591 | wait_queue_t wait;
| ^~~~
/home/xsisec/Downloads/CH341SER_LINUX/ch34x.c:590:14: warning: unused variable ‘timeout’ [-Wunused-variable]
590 | long timeout;
| ^~~~~~~
/home/xsisec/Downloads/CH341SER_LINUX/ch34x.c:589:13: warning: unused variable ‘bps’ [-Wunused-variable]
589 | int bps;
| ^~~
/home/xsisec/Downloads/CH341SER_LINUX/ch34x.c: At top level:
/home/xsisec/Downloads/CH341SER_LINUX/ch34x.c:1297:27: error: initialization of ‘unsigned int (*)(struct tty_struct )’ from incompatible pointer type ‘int ()(struct tty_struct )’ [-Werror=incompatible-pointer-types]
1297 | .write_room = ch34x_write_room,
| ^~~~~~~~~~~~~~~~
/home/xsisec/Downloads/CH341SER_LINUX/ch34x.c:1297:27: note: (near initialization for ‘ch34x_device.write_room’)
/home/xsisec/Downloads/CH341SER_LINUX/ch34x.c:1298:28: error: initialization of ‘unsigned int (
)(struct tty_struct )’ from incompatible pointer type ‘int ()(struct tty_struct *)’ [-Werror=incompatible-pointer-types]
1298 | .chars_in_buffer = ch34x_chars_in_buffer,
| ^~~~~~~~~~~~~~~~~~~~~
/home/xsisec/Downloads/CH341SER_LINUX/ch34x.c:1298:28: note: (near initialization for ‘ch34x_device.chars_in_buffer’)
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:297: /home/xsisec/Downloads/CH341SER_LINUX/ch34x.o] Error 1
make[1]: *** [Makefile:1903: /home/xsisec/Downloads/CH341SER_LINUX] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.15.0-56-generic'
make: *** [Makefile:5: default] Error 2


I Also tested following piece in the preferences:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

WARNING: Category '' in library ESP RainMaker is not valid. Setting to 'Uncategorized'
WARNING: Category '' in library WiFiProv is not valid. Setting to 'Uncategorized'
Archiving built core (caching) in: /tmp/arduino_cache_297087/core/core_esp32_esp32_esp32s2_CDCOnBoot_default,MSCOnBoot_default,DFUOnBoot_default,UploadMode_default,PSRAM_disabled,PartitionScheme_default,CPUFreq_240,FlashMode_qio,FlashFreq_80,FlashSize_4M,UploadSpeed_921600,DebugLevel_none,EraseFlash_none_52bf19a6e2a33ef9e88e633d13bcdebe.a
Sketch uses 174874 bytes (13%) of program storage space. Maximum is 1310720 bytes.
Global variables use 9876 bytes (3%) of dynamic memory, leaving 317804 bytes for local variables. Maximum is 327680 bytes.
esptool.py v4.2.1
Serial port /dev/ttyS0
Connecting.....................................An error occurred while uploading the sketch
.

A fatal error occurred: Failed to connect to ESP32-S2: No serial data received.
For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html

Many thanks in advance

Hi and welcome to the forum!

Shoudn't that be /dev/ttyUSB0 or /dev/ttyACM0 ?
Those are the usual default ports for the Arduino/ESP devices on Linux.
Did you select the correct serial port in the IDE?

BTW, I checked my Boards Manager URLs list in preferences and I have the following URL for the ESP32:

https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

This is the second link you posted although, TBH, I am not sure which one is the "official" one to use.

I thought that but unfortuntely not.

Does the lsusb command show the device?

I just checked mine - its a ESP32-WROOM-32 dev board and it come up on /dev/ttyACM0. In lsusb it is shown as a 'QinHeng Electronics USB' device. I don't believe that they generally have a CH340 UART chip onboard. Older boards may have a CP2102, while newer boards might have a CH9102. Both should be supported 'out-of-the-box' so to speak on a modern Linux.

Incidentally, the CH340 should also be supported natively in Linux. There should have been be no need to install a driver.

I solved it actually.

:+1:

Don't bother telling us how you solved this.

No one cares, no one will ever have a similar problem and find this thread and wonder, "gee, how did @xsisec ever get over this little bump? If only s/he had left even a minimal clue. Oh well."

a7

1 Like

And here I am today with exactly the same error in my console wondering what the solution might be.

cjlyth, are you using IDE2.0.x? Does your board show up as a serial port in Linux?

I only had to choose the correct board from the manager then it was working.

I forgot to select the correct board from the manager.

I did a rocky mistake forgot to pick correct board from the manager then its working.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.