Skip to content

Instantly share code, notes, and snippets.

@abobija
Last active September 9, 2023 02:20
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abobija/2721427f18d78e439fa9875cac960ffa to your computer and use it in GitHub Desktop.
Save abobija/2721427f18d78e439fa9875cac960ffa to your computer and use it in GitHub Desktop.
ESP-IDF on Ubuntu 20.04.1

ESP-IDF on Ubuntu 20.04.1

This is commands used in youtube video

How to setup ESP-IDF on Ubuntu 20.04.1

Commands:

sudo apt update && sudo apt upgrade -y
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1
sudo apt install -y python3-pip
sudo update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
sudo apt install -y git wget flex bison gperf python-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util
cd ~
mkdir esp
cd esp
git clone --recursive https://github.com/espressif/esp-idf.git
cd esp-idf
. ./install.sh
pip install --upgrade pip
. ./export.sh
nano ~/.profile

Append next line to ~/.profile script:

. $HOME/esp/esp-idf/export.sh

To save press CTRL+X, Y, ENTER

sudo usermod -a -G dialout,tty $USER

Restart machine. If you are on virtual machine then shutdown completely and start it again.

ls /dev/ttyUSB*
cd ~/Desktop
cp -r $IDF_PATH/examples/get-started/hello_world .
cd hello_world
idf.py set-target esp32
idf.py menuconfig
idf.py build

Put ESP32 into programming mode.

idf.py -p /dev/ttyUSB0 flash
idf.py monitor

To exit monitor press CTRL+]

@Olljoh95
Copy link

I'm using the Adafruit esp32 feather huzzah and had to include baud rate that's different from the default in order to flash.

https://cdn-learn.adafruit.com/downloads/pdf/adafruit-huzzah32-esp32-feather.pdf
According to the datasheet, they recommend 921600

The command would then be:
idf.py -p /dev/ttyS8 -b 921600 flash monitor

@0rion12
Copy link

0rion12 commented Jan 22, 2022

Hello, first thanks for the tutorial ! I tried different tutorials to do that during more than a week and none of them worked for me, but yours worker so thanks a lot !

But now, I'd like to flash an existing project namely the AT-command firmware : https://github.com/espressif/esp-at but I have absolutly no idea on how to do that, I tried the method explained there : https://docs.espressif.com/projects/esp-at/en/release-v2.2.0.0_esp32c3/Compile_and_Develop/How_to_clone_project_and_compile_it.html but I got errors.

Do you have any idea on how to do that ?

@vandana2510
Copy link

Hi thanks for step by step explanation but I am not able to come out of monitor. please help

@kampi0
Copy link

kampi0 commented Oct 23, 2022

Hi,
Amazing video - thanks a lot.

I want to share what was not working in my case:
. ./install.sh causing terminal crash, works with
chmod +x install.sh
and
flashing return error related, the solution was pressing BOOT button and executing idf.py -p /dev/ttyUSB0 flash
and
idf.py monitor return error, works with
idf.py monitor -p /dev/ttyUSB0

issues are probably related to my setup (Ubuntu VM on Parallels + ES-WROOM-32)

@abobija
Copy link
Author

abobija commented Oct 23, 2022

Thank you @kampi0

@henocsoares
Copy link

When doing "ls /dev/ttyUSB*" I get: "ls: cannot access '/dev/ttyUSB': No such file or directory".

If doing "ls /dev/tty*": there none close even to ttyUSB. It seems the OS lacks the drivers to work on. So I downloaded the following: Linux 3.x.x/4.x.x/5.x.x VCP Driver

Well, when I do 'make' for installing, it, I get errors and, so far, no good (have tried a lot online):

make -C /lib/modules/uname -r/build M=/home/brasoares/Desktop/ESP-IDF/drivers/Linux_3.x.x_4.x.x_VCP_Driver_Source modules make[1]: Entering directory '/usr/src/linux-headers-6.4.6-76060406-generic' warning: the compiler differs from the one used to build the kernel The kernel was built by: x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0 You are using: gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0 CC [M] /home/brasoares/Desktop/ESP-IDF/drivers/Linux_3.x.x_4.x.x_VCP_Driver_Source/cp210x.o /home/brasoares/Desktop/ESP-IDF/drivers/Linux_3.x.x_4.x.x_VCP_Driver_Source/cp210x.c:281:35: error: initialization of ‘void (*)(struct tty_struct *, struct usb_serial_port *, const struct ktermios *)’ from incompatible pointer type ‘void (*)(struct tty_struct *, struct usb_serial_port *, struct ktermios *)’ [-Werror=incompatible-pointer-types] 281 | .set_termios = cp210x_set_termios, | ^~~~~~~~~~~~~~~~~~ /home/brasoares/Desktop/ESP-IDF/drivers/Linux_3.x.x_4.x.x_VCP_Driver_Source/cp210x.c:281:35: note: (near initialization for ‘cp210x_device.set_termios’) /home/brasoares/Desktop/ESP-IDF/drivers/Linux_3.x.x_4.x.x_VCP_Driver_Source/cp210x.c:291:35: error: initialization of ‘void (*)(struct usb_serial_port *)’ from incompatible pointer type ‘int (*)(struct usb_serial_port *)’ [-Werror=incompatible-pointer-types] 291 | .port_remove = cp210x_port_remove, | ^~~~~~~~~~~~~~~~~~ /home/brasoares/Desktop/ESP-IDF/drivers/Linux_3.x.x_4.x.x_VCP_Driver_Source/cp210x.c:291:35: note: (near initialization for ‘cp210x_device.port_remove’) cc1: some warnings being treated as errors make[2]: *** [scripts/Makefile.build:252: /home/brasoares/Desktop/ESP-IDF/drivers/Linux_3.x.x_4.x.x_VCP_Driver_Source/cp210x.o] Error 1 make[1]: *** [Makefile:2038: /home/brasoares/Desktop/ESP-IDF/drivers/Linux_3.x.x_4.x.x_VCP_Driver_Source] Error 2 make[1]: Leaving directory '/usr/src/linux-headers-6.4.6-76060406-generic' make: *** [Makefile:7: all] Error 2
Are you able to please help? I am on:
NAME="Pop!_OS" VERSION="22.04 LTS"
Snip (from terminal):
image

@henocsoares
Copy link

henocsoares commented Sep 9, 2023

When doing "ls /dev/ttyUSB*" I get: "ls: cannot access '/dev/ttyUSB': No such file or directory".

If doing "ls /dev/tty*": there none close even to ttyUSB. It seems the OS lacks the drivers to work on. So I downloaded the following: Linux 3.x.x/4.x.x/5.x.x VCP Driver

Well, when I do 'make' for installing, it, I get errors and, so far, no good (have tried a lot online):

make -C /lib/modules/uname -r/build M=/home/brasoares/Desktop/ESP-IDF/drivers/Linux_3.x.x_4.x.x_VCP_Driver_Source modules make[1]: Entering directory '/usr/src/linux-headers-6.4.6-76060406-generic' warning: the compiler differs from the one used to build the kernel The kernel was built by: x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0 You are using: gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0 CC [M] /home/brasoares/Desktop/ESP-IDF/drivers/Linux_3.x.x_4.x.x_VCP_Driver_Source/cp210x.o /home/brasoares/Desktop/ESP-IDF/drivers/Linux_3.x.x_4.x.x_VCP_Driver_Source/cp210x.c:281:35: error: initialization of ‘void (*)(struct tty_struct *, struct usb_serial_port *, const struct ktermios *)’ from incompatible pointer type ‘void (*)(struct tty_struct *, struct usb_serial_port *, struct ktermios *)’ [-Werror=incompatible-pointer-types] 281 | .set_termios = cp210x_set_termios, | ^~~~~~~~~~~~~~~~~~ /home/brasoares/Desktop/ESP-IDF/drivers/Linux_3.x.x_4.x.x_VCP_Driver_Source/cp210x.c:281:35: note: (near initialization for ‘cp210x_device.set_termios’) /home/brasoares/Desktop/ESP-IDF/drivers/Linux_3.x.x_4.x.x_VCP_Driver_Source/cp210x.c:291:35: error: initialization of ‘void (*)(struct usb_serial_port *)’ from incompatible pointer type ‘int (*)(struct usb_serial_port *)’ [-Werror=incompatible-pointer-types] 291 | .port_remove = cp210x_port_remove, | ^~~~~~~~~~~~~~~~~~ /home/brasoares/Desktop/ESP-IDF/drivers/Linux_3.x.x_4.x.x_VCP_Driver_Source/cp210x.c:291:35: note: (near initialization for ‘cp210x_device.port_remove’) cc1: some warnings being treated as errors make[2]: *** [scripts/Makefile.build:252: /home/brasoares/Desktop/ESP-IDF/drivers/Linux_3.x.x_4.x.x_VCP_Driver_Source/cp210x.o] Error 1 make[1]: *** [Makefile:2038: /home/brasoares/Desktop/ESP-IDF/drivers/Linux_3.x.x_4.x.x_VCP_Driver_Source] Error 2 make[1]: Leaving directory '/usr/src/linux-headers-6.4.6-76060406-generic' make: *** [Makefile:7: all] Error 2 Are you able to please help? I am on: NAME="Pop!_OS" VERSION="22.04 LTS" Snip (from terminal): image

It started to work actually within the hour after this post. If you were wishing to help: Tks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment