ESP32 (3) – Eclipse

by luca
12 comments

In the previous blog post, I explained how to install the official development framework (Espressif IoT Development Framework) and how to use it to compile your first example, Hello world.

Even if you can write your programs with a simple text editor (on Windows I always suggest to use the opensource Notepad++), it’s very easier to do it with an IDE (Integrated Development Environment), that is a graphical application which you can use to write the code (it often includes syntax highlighting and auto-completion), to compile it and to upload the binary on you development board. Among the available IDEs, one of the most famous and adopted is without doubts Eclipse.

Installation

Eclipse installation is really straightforward: connect to the official site and download Eclipse IDE for C/C++ Developers for your operating system (as in the previous post, I decided to use Windows):

eclipse-01

Eclipse is shipped as a zip archive. When the download is complete, unzip the archive in a folder of your hard drive. To make it easy, I chose the same folder (the user’s home folder) where I’ve already installed the esp-idf:

eclipse-02

Run Eclipse with a double-click on eclipse.exe. At first, you are prompted to specify the path of your workspace (= the folder where your projects will be saved in). I chose to create the workspace as a subfolder of Eclipse’s installation folder:

eclipse-03

Project configuration

To be able to develop a project based on esp-idf with Eclipse, you need to do some configuration. First, import the project in the IDE. For this tutorial, I’m going to use the 01_hello_world example; in a future post I’ll show you how to start with an empty project.

Choose File – Import, then run the Existing Code as Makefile project wizard:

eclipse-04

Give the project a name, choose the folder that contains the code and make sure that the selected toolchain isCross GCC:

eclipse-05

When the import is complete, open the project Properties:

eclipse-06

First select C/C++ Build – Environment. Add (using the Add… button) two new variables:

  • name V, value 1
  • name IDF_PATH, value the path where esp-idf is installed (note: you have to use / instead of \)

On Windows, in addition, change the PATH variable with the following value (if msys32 is installed in the default path):

C:\msys32\usr\bin;C:\msys32\mingw32\bin;C:\msys32\opt\xtensa-esp32-elf\bin

eclipse-07

If you’re under Windows, now choose C/C++ Build, unflag Use default… and type the following build command:

bash ${IDF_PATH}/tools/windows/eclipse_make.sh

eclipse-08

The final step is to choose C/C++ General – Preprocessor Include Paths and open the Providers tab.

Click on CDT Cross GCC Built-in Compiler Settings and change the text ${COMMAND} with xtensa-esp32-elf-gcc:

eclipse-09

Then click on CDT GCC Build Output Parser and add xtensa-esp32-elf- at the beginning of the command:

eclipse-10

You’re now ready to compile the project:

eclipse-11

It may happens that, after the compile process, Eclipse warns about some “unresolved inclusion”:

eclipse-12

The warnings should appear only under Windows and they are caused by a known bug that doesn’t block the compile process. You may solve it manually adding the different include folders found starting from the folder esp-idf/components in the project properties (C/C++ General – Paths and Symbols – GNU C):

eclipse-13

Flash

You can also configure Eclipse to run the make flash command, to load the compiled version of your program on the development board.

Choose, on the right panel, the Build Targets tab:

eclipse-14

Right-click on the project’s folder and choose New.

Type flash as target name, then confirm with Ok:

eclipse-15

If now you right-click on the new command, you can start the flash process choosing Build Target:

eclipse-16

The Console tab, in the lower panel of the IDE, shows flash command output and result:

eclipse-17

Related Posts

12 comments

Junhyuk Lee Saturday August 12th, 2017 - 01:09 AM

Hi, Luca!
Thanks for good tutorials!
I have learned many things about ESP32 from them.

How do you debug ESP32 in Eclipse IDE or CLI?

Reply
laudix Thursday February 8th, 2018 - 03:37 PM

Ciao Luca.
Premetto che non sono molto ferrato su eclipse…
Ho risolto i problemi degli include ma quando compilo (icona a forma di martello) continua a darmi questa segnalazione:
15:31:34 **** Build of configuration Default for project hello_world ****
bash C:/Dev-Tools/msys32/home/laudicin/esp/esp-idf/tools/windows/eclipse_make.sh flash
eclipse_make.sh has been replaced with eclipse_make.py. Check the Windows Eclipse docs for the new command.
This shell script will continue to work until the next major release.
Traceback (most recent call last):
File “C:/Dev-Tools/msys32/home/laudicin/esp/esp-idf/tools/windows/eclipse_make.py”, line 36, in
main()
File “C:/Dev-Tools/msys32/home/laudicin/esp/esp-idf/tools/windows/eclipse_make.py”, line 28, in main
print(“Running make in ‘%s'” % check_path(os.getcwd()))
File “C:/Dev-Tools/msys32/home/laudicin/esp/esp-idf/tools/windows/eclipse_make.py”, line 23, in check_path
winpath = winpath.replace(“\\”, “/”) # make consistent with forward-slashes used elsewhere
TypeError: a bytes-like object is required, not ‘str’

e penso che la compilazione non sia andata a buon fine.
Puoi darmi una mano a capire?

Un saluto

Reply
Sergio Monday March 19th, 2018 - 10:36 PM

Ciao Luca
ho appena vistato il tuo sito e complimenti per l’ottimo lavoro svolto. Da poco ho iniziato a provare ESP8266 01con comandi AT. Vorrei programmarlo con eclipse è un programma che non conosco. Volevo chiederti la configurazione che fai vedere te per ESP32 posso usarla anche per ESP8266 ? ho provato a cercare in rete ma è tutto un copia incolla e riesco solo a compilare con eclipse ma non a programmare il modulo.
Grazie per la tua attenzione
Sergio

Reply
luca Wednesday March 21st, 2018 - 09:51 AM

ciao Sergio, purtroppo non ho mai provato con il chip esp8266. Hai già provato a seguire la guida ufficiale?

Reply
Sergio Thursday March 22nd, 2018 - 11:22 PM

Ciao grazie per la dritta. Alla fine ci sono riuscito anche grazie all’aiuto di un mio amico. Adesso incomincio i primi test. Certo che non è facile trovare guide solo per eclipse tutti quanti si buttano sull’ide di arduino. Grazie ancora per la tua disponibilità
Sergio

Reply
Serkan Saturday April 7th, 2018 - 08:28 PM

Hi Luca. Every time i create a new project,the settings disappear. Do i have to make those settings every new project?

Reply
luca Sunday April 8th, 2018 - 01:06 PM

hi, you can create an empty project and reuse it as a “template”

Reply
Stefano Monday April 16th, 2018 - 08:29 AM

Se il PC è in dominio il percorso dove c’è esp-idf è:
C:\Users\NomeUtente.VostroDominio\AppData\Roaming\SPB_16.6

Ciao

Reply
Zekah Monday April 30th, 2018 - 04:50 PM

Hi Luca, my doubt is, what’s the exact difference between notepad and Eclipse?..

Can I develop programs with Notepad++?,

I’ve been working with the tutorial steps for using eclipse with the esp32, but I always get heaps and heaps.. and at least a couple of red lines in the code sometimes.. e.g

“portTICK_PERIOD_MS”, (in the hello world example)…

but I just got surprised because I could flash the Hello world example, even with the red lines, this confuses to me… will I be able of developing a trusted program using eclipse even with the red lines?….

how will I know is the program is well made?

Reply
luca Thursday May 3rd, 2018 - 01:29 PM

Hi! Of course you can develop your programs with the editor you prefer (Notepad++…). With Eclipse you can run the compile process within the editor, check the syntax etc. It may happen that you get red lines (= Eclipse can’t recognize that method) but you’re still able to compile and run the program, this is because of Eclipse and the compiler are different. Your problem can be related to some symbols not addded to the Editor. If you’re under Windows, try also the official guide.

Reply
Daniele Saturday June 9th, 2018 - 12:12 PM

Salve
ho installato eclipse oxygen per C/C++ developers, assieme a MinGW, Gcc, Java jdk, quello che vorrei chiederle è se una volta effettuato il run As c/c++ application si può visualizzare l’output non solo sulla console in basso, ma anche su una console Windows tipo system32, come per esempio in Visual Studio, ed se sì, come posso fare a installare questa opzione in Eclipse..

grazie per la sua attenzione e
se non la disturbo attendo un suo cortese riscontro..
buona giornatae buon lavoro
Daniele

Reply
luca Sunday June 10th, 2018 - 05:25 PM

Salve Daniele, purtroppo non credo che Eclipse offra questa possibilità… attualmente sto utilizzando Platform.io che mi sembra ancora + intuitivo e completo… faccia una prova anche con questo IDE!

Reply

Leave a Comment

five × 5 =