Notifications
Clear all

Configuring Arduino IDE for ESP32 in Debian

17 Posts
4 Users
5 Likes
2,924 Views
b89john
(@b89john)
Member
Joined: 3 years ago
Posts: 7
Topic starter  

I have been trying to upload the famous Blink routine to my ESP32. The procedure has been successfully compiled but every time I try to upload the compiled code I receive the error "Serial port not selected"

The port option in Tools is greyed out. My user account belongs to dialout, tty, plugdev all groups for which it is suggested membership is essential to access serial ports.

I noticed that using dmesg showed that the ESP32 did in fact connect to the USB port but then immediately disconnected:

johnb@mac-mini:~$ dmesg | tail -f
[18902.614086] usb 1-1: New USB device found, idVendor=10c4, idProduct=ea60, bcdDevice= 1.00
[18902.614092] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[18902.614095] usb 1-1: Product: CP2102 USB to UART Bridge Controller
[18902.614098] usb 1-1: Manufacturer: Silicon Labs
[18902.614101] usb 1-1: SerialNumber: 0001
[18902.629088] cp210x 1-1:1.0: cp210x converter detected
[18902.631171] usb 1-1: cp210x converter now attached to ttyUSB0
[18905.015392] usb 1-1: usbfs: interface 0 claimed by cp210x while 'brltty' sets config #1
[18905.016347] cp210x ttyUSB0: cp210x converter now disconnected from ttyUSB0
[18905.016394] cp210x 1-1:1.0: device disconnected

t makes no difference whether I connect to the pc usb port directly or via a powered usb hub, the report is the same just the port ID changes.

Any ideas??

John B


   
Quote
(@yurkshirelad)
Member
Joined: 3 years ago
Posts: 493
 

This may be wide of the mark, but I found a post elsewhere that suggested a possible clash with VirtualBox. Are you running VirtualBox or anything similar?


   
ReplyQuote
b89john
(@b89john)
Member
Joined: 3 years ago
Posts: 7
Topic starter  

@yurkshirelad

Aaaaah! Now that is interesting! I set up VirtualBox just a few days ago on the Mac-Mini. I use Linux Mint (LMDE40) instead of MacOS and I had been unable to get software to run two scanners in Linux and so I setup VirtualBox to run Windows so that I could use the scanners. And yes there is a problem with connecting to the USB ports although not so difficult to overcome .

After I posted I tried connecting the ESP32 to a Raspberry Pi and the connection was stable. So I was beginning to think the Mini might have some esoteric hardware configuration.

Yours is much less of a stretch for the imagination. A quick purge of VirtualBox......

Thanks for the suggestion Yurkshirelad. I will let you know how it goes.

John B


   
YurkshireLad reacted
ReplyQuote
(@jfabernathy)
Member
Joined: 3 years ago
Posts: 141
 

I found that Virtualbox and ESP32 IDF or VSCode were not compatible.  If you have the ESP32 setup right on Linux Mint 20 or Ubuntu 20.04, you have to install python-is-python3.  If you try to install Virtualbox it forces you to uninstall python-is-python3.  the esptool.py use pyserial.py and they have to run with python3.

At least this is what was explained to me. And I got it working by doing this.  I wanted to use Virtualbox to put my Arduino in one VM and VSCode in another VM.  I also had to install the Espressif IDE so I could build CircuitPython with some special menuconfig options.  All of that screwed up Arduino.

So I ended up using 2 different computers instead of VMs. I have a Raspberry Pi 4 so I can run Arduino setup of everything except ESP32.  I also have it setup with another SSD to run VSCode with Pico SDK which is not compatible with PlatformIO, at least I've not been successful having both on the same system.

What I do is setup a Raspberry Pi 4 with just what I need to do a task and then save that image with free space removed.  That image can be restored using Raspberry Pi Imager.  

If your code won't compile, have another glass of bourbon. Eventual the problem will be solved.


   
Centari reacted
ReplyQuote
(@yurkshirelad)
Member
Joined: 3 years ago
Posts: 493
 

Another option for running VMs under Linux is https://www.linux-kvm.org/page/Main_Page, but I'm not sure if it would solve the original USB problem.


   
ReplyQuote
b89john
(@b89john)
Member
Joined: 3 years ago
Posts: 7
Topic starter  

Progress so far: removed/purged VirtualBox from system (LMDE 4 on Mac-Mini) . Arduino IDE still does not see USB connection and dmesg still showing esp32 connecting and then disconnecting.

I think you may be right. I have shifted the VirtualBox setup to another computer. Although I am using Linux Mint it is the Debian based version as opposed to the Ubuntu/Debian Mint. I have found it to be sometimes a bit picky about what you can assume is present in your installation and it is often necessary to load additional resources before apps work BUT so far I have always found a solution. I may go radical and follow Bill's idea of using the Ubuntu route and recreate his workshop setup which how I got into this issue in the first place but I am always suspicious of Apple hardware being peculiar to Apple. For the moment I will continue to continue beating my head off the wall.
 
Thanks both for your ideas and suggestions. I will keep you posted
 
John B

   
ReplyQuote
(@jfabernathy)
Member
Joined: 3 years ago
Posts: 141
 

@b89john I went and looked for how I got things working last time and I found a recipe that I saved so I cold repeat it if necessary. This was a file saved with my Arduino stuff.

Stuff to add to a new system to get Arduino running for Ubuntu 20.04 based systems.

1. sudo usermod -aG dialout jim
2. sudo apt install python-is-python3
3. sudo apt-mark hold python2 python2-minimal python2.7 python2.7-minimal libpython2-stdlib
4. sudo apt install python3-pip
5. pip3 install pyserial

Once this was done I could install Arduino IDE and then just add the link for ESP32 via board manager.

espressif arduino-ide

If your code won't compile, have another glass of bourbon. Eventual the problem will be solved.


   
ReplyQuote
b89john
(@b89john)
Member
Joined: 3 years ago
Posts: 7
Topic starter  

SUCCESS!!

The solution might be a little drastic but I really didn't feel like doing the homework to sort out the path and group issues that seemed to underpin the connection to the USB bus. I installed Linux Mint 20 which is based on Ubuntu rather than pure Debian.

I then paid attention to Bill's Arduino IDE install instructions in his YouTube videos "Build a Developer's Linux Workstation" and for the ESP32:  "ESP32 Getting Started". Lo and behold 'Port' in the Arduino IDE tools is no longer greyed out and /dev/ttyUSB0 can be selected. Euphoria!

Tried to compile the ubiquitous 'blink' sketch - failed because it couldn't find "Python". So I followed each of Jim's "Stuff to add to a new system..........." and bingo compilation a success and upload worked correctly. Just got to work out why the LED isn't blinking yet. But that's small beer- I hope!

Thanks to you both @jfabernathy && @YurkshireLad for your time and help. It was much appreciated

John B


   
Centari reacted
ReplyQuote
(@yurkshirelad)
Member
Joined: 3 years ago
Posts: 493
 

Happy to hear it!


   
ReplyQuote
(@jfabernathy)
Member
Joined: 3 years ago
Posts: 141
 

Something I discovered in the last few days is getting Arduino and VSCode working with my boards in KVM-QEMU and Virtual Machine Manager. I had to abandon VIrtualbox because of the conflict between VB and the python-is-python3 package required by vscode for the ESP32.

My only issue is using the ESP-Prog JTAG debugger.  Since I have to unplug it during code upload, it causes problems with the USB assignments in QEMU. If you just use the one USB for connection to the MCU board it's not an issue since you can assign that port to the VM at start.  I can use the ESP-Prog in QEMU, but the process will drive you to drink, but that's not an issue for me. 😀 

 

If your code won't compile, have another glass of bourbon. Eventual the problem will be solved.


   
ReplyQuote
b89john
(@b89john)
Member
Joined: 3 years ago
Posts: 7
Topic starter  

@jfabernathy

Having successfully established everything works in Mint - Ubuntu version I decided to have another go with Mint - Debian version. I think the Debian version has an issue with which Python version you want to use. Its default is Python 2.7.

I tried to run sudo apt install python-is-python3 as you suggest. This fails in the Debian version ¨cannot be found¨. Similarly: python-is-python2.

This at a guess means that ´pip3 pyserial´  installs pyserial ok but it  is not seen when the arduino looks for a port using python 2,7. (As I am writing this: is there a pip2?) Your suggestion of installing python-is-python3 is the key to the solution to my original problem. I had a look at changing the default version of python in the debian setup but this is apparently fraught with its own problems: see 

https://stackoverflow.com/questions/43062608/how-to-update-alternatives-to-python-3-without-breaking-apt

where there are strong opinions for and against.

So rethink time. Again!

John B

 


   
ReplyQuote
(@jfabernathy)
Member
Joined: 3 years ago
Posts: 141
 

@b89john I run Mint 20 Cinnamon and it works fine for me.  Debian is too old and their use of Python2.7 in a time when that is dead to the world, is a problem.  In fact I had to move my Kernel in Mint 20 to 5.8 to fix some Dell XPS laptop freeze up issues.  

If your code won't compile, have another glass of bourbon. Eventual the problem will be solved.


   
SuperCharlie reacted
ReplyQuote
b89john
(@b89john)
Member
Joined: 3 years ago
Posts: 7
Topic starter  

@jfabernathy

Having tried to install the python functions pyserial etc for python2.7 in an attempt to get it consistent on LMDE4  I agree with you Mint 20 is fine and on the surface is the same OS as LMDE4. I also fail to understand why Debian is so far behind with Python. I know the OS is rock solid stable but jeeze Python 2.7 is all but 10years old. So I have installed most of the software recommended by Bill in his tutorial Workshop Workstation. Its now back to working on the ESP32 and no serial port problems. I see you have another thread running on ESP32 so I will look for your pearls of wisdom there.

John B


   
ReplyQuote
(@jfabernathy)
Member
Joined: 3 years ago
Posts: 141
 
Posted by: @b89john

@jfabernathy

... I see you have another thread running on ESP32 so I will look for your pearls of wisdom there.

John B

Be careful of those pearls; you never know when they are really painted "BS" droppings. 😆 

If your code won't compile, have another glass of bourbon. Eventual the problem will be solved.


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1122
 
Posted by: @b89john

I also fail to understand why Debian is so far behind with Python.

I'm not sure why you find this, the Debian should contain the following. - i.e always 2.7 and always the latest stable release python 3 when the distribution is released.

Supported Python Versions

  • Debian Bullseye contains 2.7, 3.9 (This information may not be final)

  • Debian Buster contains Python 2.7, 3.7

  • Debian Stretch contains Python 2.7, 3.5

  • Debian Jessie contains Python 2.7, 3.4

  • Debian Wheezy contains Python 2.7, 3.2


   
ReplyQuote
Page 1 / 2