ArduinoIDE - how to install ESP32 driver for USB to serial communication?

OS: Manjaro XFCE 22.0.0
Kernel 5.15.89-1
Arduino IDE 1.8.19

Hello,

it is claimed that to run the Arduino IDE, it is necessary to install driver for USB to serial communication according to the board chip, namely CP2102 with link to driver:

Very well.
After downloading the driver tar file, I created a folder “driver” in some directory, untar the files into it
And start to read the release note file, which states:

This driver was tested on Linux 5.4.0 kernel (Ubuntu 18.04.5 LTS) only
but it should work with other versions of Linux kernel as well.
Linux kernel also has a default cp210x driver which is maintained at www.kernel.org.
It is recommended to use the driver there that matches your specific kernel version.

The bundle contains:

  • cp210x.c
  • Makefile
  • cp210x_gpio_example.c
  • cp210x_gpio_example_gpiolib.c
  • build.sh
  • CP210x_VCP_Linux_4.x_Release_Notes.txt

Build instrutions:

Ubuntu:

  1. make ( your cp210x driver )
  2. cp cp210x.ko to /lib/modules//kernel/drivers/usb/serial
  3. insmod /lib/modules/<kernel-version/kernel/drivers/usb/serial/usbserial.ko
  4. insmod cp210x.ko

OK.
I don’t understand why with ESP8266 board which is also having cp210x chip I can compile, but not with ESP32.
Anyway, I opened a terminal window and typed: make cp210x, here’s the console’s output

$ make cp210x
cc cp210x.c -o cp210x
cp210x.c:14:10: erreur fatale: linux/slab.h : Aucun fichier ou dossier de ce type
14 | #include <linux/slab.h>
| ^~~~~~~~~~~~~~
compilation terminée.
make: *** [: cp210x] Error 1
[xf@xf22 driver]$

Not familiar, with such kind of issue, I’m stuck for help.
Is the problem really the driver, especially if there is one in the kernel and it works with ESP8266?
Aka, WHAT’S THE ROOT CAUSE OF THE PROBLEM, really the driver??

The initial issue being:
In ArduinoIDE 1.8.19
File>Preferences>Additionnal Boards Manager URL
https://arduino.esp8266.com/stable/package_esp8266com_index.json, https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

Installed ESP32

Tools Board:

Tried first: ESP32 DEV MODULE
2nd try: DOIT ESP32 DEV KIT v1

Both lead to same error:

Traceback (most recent call last):
File “/home/xf/.arduino15/packages/esp32/tools/esptool_py/4.2.1/esptool.py”, line 31, in
import esptool
File “/home/xf/.arduino15/packages/esp32/tools/esptool_py/4.2.1/esptool/init.py”, line 42, in
from esptool.cmds import (
File “/home/xf/.arduino15/packages/esp32/tools/esptool_py/4.2.1/esptool/cmds.py”, line 14, in
from .bin_image import ELFFile, ImageSegment, LoadFirmwareImage
File “/home/xf/.arduino15/packages/esp32/tools/esptool_py/4.2.1/esptool/bin_image.py”, line 14, in
from .loader import ESPLoader
File “/home/xf/.arduino15/packages/esp32/tools/esptool_py/4.2.1/esptool/loader.py”, line 21, in
** import serial**
ModuleNotFoundError: No module named ‘serial’
exit status 1
Error compiling for board ESP32 Dev Module.

And ESP32 DevKitC board manual states:
In order to use ESP32 Dev Kit C V2 with Arduino IDE, follow few easy
steps. Before setting the Arduino IDE, the driver for the USB to Serial
communication has to be installed. If the driver is not installed automatically,
there is a support page that contains the drivers for Windows/Mac or Linux
and can be chosen depending on which one is used. Drivers can be
downloaded from the following link.”

Thanks

I think (and that is a guess) that you are missing udev rules
those rules are necessary to find the board/converter usb

So try to install this
https://docs.platformio.org/en/stable//core/installation/udev-rules.html

reboot after and check if the board is found
lsusb
if so check in your ide (i use code-oss) if the board is found

@bikehunter666
If you mean sthg as Arduino IDE - /dev/ttyACM0 Permission denied

I remind that it compiles with ESP8266, code at it’s simplest:

void setup() {
pinMode(2, OUTPUT);
}
void loop() {
}

If I usb-connect the ESP32 DevKitC board and do a lsusb, I do see it, but it won’t compile if I select as board target : “ESP32 Dev Module”.
Which is what the manufacturer manual claims “To select ESP32 board, go to:
Tools > Board > ESP32 Arduino > ESP32 Dev Module”.

$ lsusb
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 005: ID 04f2:b307 Chicony Electronics Co., Ltd TOSHIBA Web Camera - HD
Bus 001 Device 004: ID 03f0:064a HP, Inc HP USB Keyboard
Bus 001 Device 003: ID 0bda:0138 Realtek Semiconductor Corp. RTS5138 Card Reader Controller
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 009: ID 10c4:ea60 Silicon Labs CP210x UART Bridge
Bus 003 Device 008: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
[xf@xf22 Sensors & Micro-control - IoT]$

Well that is what i came up with.
I do use a esp32 and this needed those udev rules. compiling fails without it
lsusb does find your device but that does not necessarily mean that your ide will too and that your ide can communicate with your board.

In code-oss i do need to install platformio separately as it is not installable through extensions, see this:

I have no other solutions, sorry

Thanks @bikehunter666 , “udev rules” not in the manual…I’ll try.

In the mean time, I was looking at Code + PlatformIO
Maybe it’ll try that way.

You don’t need a driver. You need to install python-serial python-pyserial, use either pacman or pamac to install it. Don’t use pip.

There’s no need for udev, just add your user to the uucp group, then logout and back in.

sudo gpasswd -a $USER uucp

https://wiki.archlinux.org/title/Arduino

@dmt You’re supergenious, it does seem to work with basic example on ArduinoIDE.
Not tested with Code + PIO

Remarks:
The correct name is python-pyserial

Trying to compile ESP8266 to ESP32, some observation.
1/ secsEcoulées is a valid variable name with ESP8266, is invalid for ESP32
Sol: rename variable

2/ LED_BUILTIN is not defined for ESP32,
SOL: #define LED_BUILTIN 2

3/ Seems that some argument calls are different between librairies that are supposed to be the “same”.

#ifdef ESP8266
#include <ESP8266WiFi.h>
#elif defined(ESP32)
#include <WiFi.h>
#else
#error “Not using the ESP8266 nor ESP32!”
#endif

example, does not compile with ESP32
error: no matching function for call to ‘WiFiClass::softAP(String&, const char [10])’

Oops, forgot about the mismatched naming, fixed it.

@dmt To port some code from ESP8266 to ESP32, some actions;

1/ secsEcoulées is a valid variable name with ESP8266, is invalid for ESP32
Sol: rename variable

2/ LED_BUILTIN is not defined for ESP32,
SOL:
#define LED_BUILTIN 2 // in case of DevKitC
//#define LED_BUILTIN 22 // in case of Lolin Lite

3/ Seems that some argument calls are different between librairies that are supposed to be the “same”.

#ifdef ESP8266
#include <ESP8266WiFi.h>
#elif defined(ESP32)
#include <WiFi.h>
#else
#error “Not using the ESP8266 nor ESP32!”
#endif

On ESP32, WiFiClass::softAP() Arduino String is not accepted, must be const char

4/ also small change to use time from NTP

Now, an “unrelated” question with the title.
I notice ArduinoIDE binary size are very different between “ESP8266 nodeMCU 1.0” and “ESP32 Dev Module”
Namely, in my sketch case :
ESP32: 847845bytes
ESP8266: 319480bytes
(Ram claimed usage is also fattier with ESP32).

Binary difference is huge. Any wrong doings or suggestions??

For ESP32:
Sketch uses 847845 bytes (64%) of program storage space. Maximum is 1310720 bytes.
Global variables use 49116 bytes (14%) of dynamic memory, leaving 278564 bytes for local variables. Maximum is 327680 bytes.

For ESP8266
. Variables and constants in RAM (global, static), used 30788 / 80192 bytes (38%)
║ SEGMENT BYTES DESCRIPTION
╠══ DATA 1512 initialized variables
╠══ RODATA 2660 constants
╚══ BSS 26616 zeroed variables
. Instruction RAM (IRAM_ATTR, ICACHE_RAM_ATTR), used 60887 / 65536 bytes (92%)
║ SEGMENT BYTES DESCRIPTION
╠══ ICACHE 32768 reserved space for flash instruction cache
╚══ IRAM 28119 code in IRAM
. Code in flash (default, ICACHE_FLASH_ATTR), used 319480 / 1048576 bytes (30%)
║ SEGMENT BYTES DESCRIPTION
╚══ IROM 319480 code in flash

I only dabble so I’ve only used it for 1 project. I was also surprised to find my firmware very quickly taking up about 800KB+, and an empty sketch is about 200KB.

I don’t know why, but I guess the ESP32’s libs just take up more space. Perhaps there’s added complexity, it’s the first RTOS/ESP/Arduino I’ve used so I don’t really have anything to compare it to.

I think you’ll get better answers to questions about libraries at Espressif’s forum. AFAIK there aren’t many embedded programmers here.

You probably already know that you can change the partitioning scheme to allow more program space should you need it, though I suppose it depends on what else you need.

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