ESP32 (3) – Eclipse

luca 15/12/2016 10

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

10 Comments »

  1. Junhyuk Lee 12/08/2017 at 01:09 - Reply

    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?

  2. laudix 08/02/2018 at 15:37 - Reply

    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

  3. Sergio 19/03/2018 at 22:36 - Reply

    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

    • luca 21/03/2018 at 09:51 - Reply

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

  4. Sergio 22/03/2018 at 23:22 - Reply

    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

  5. Serkan 07/04/2018 at 20:28 - Reply

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

    • luca 08/04/2018 at 13:06 - Reply

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

  6. Stefano 16/04/2018 at 08:29 - Reply

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

    Ciao

  7. Zekah 30/04/2018 at 16:50 - Reply

    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?

    • luca 03/05/2018 at 13:29 - Reply

      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.

Leave A Response »

Click here to cancel reply.

This website uses cookies to ensure you get the best experience on our website maggiori informazioni

Questo sito utilizza i cookie per fonire la migliore esperienza di navigazione possibile. Continuando a utilizzare questo sito senza modificare le impostazioni dei cookie o clicchi su "Accetta" permetti al loro utilizzo.

Chiudi