In Part 2 of Getting Started with ESP32 ESP-IDF, we prepared the ESP32 toolchain and set up our Development Environment for ESP32 within Ubuntu 14.04.
In this article, we download and configure the ESP32 ESP-IDF from Espressif GitHub page. We then compile a sample blinking LED project and generate the appropriate BIN files for ESP32.
Download ESP32 ESP-IDF from GitHub
We will directly clone the Espressif ESP32 ESP-IDF from Espressif GitHub to our ESP32 development environment.
In this article, we will simply create a folder called iotbits_esp32 on the desktop, where we will clone the contents of ESP-IDF. You could place this wherever you find convenient. However, stick with our steps if you are not very familiar with Linux.
Here are the steps that are to be followed, in a new command window:
- Create a folder called iotbits_esp32 on the Desktop manually or by using command terminal:
- Change to iotbits_esp32 as the current directory:
- Clone the ESP-IDF GitHub repository to this directory. This step is VERY IMPORTANT and must be done with this command only:
git clone --recursive https://github.com/espressif/esp-idf.git
- Next, define IDF_PATH environment variable based on the location of esp_idf folder cloned from GitHub. Note that this step must be performed in EVERY terminal session. If you want this to be permanent, please make sure the IDF_PATH is set in bashrc as we did for the toolchain.
Add IDF path for current session as follows:
- Your copy of ESP32 ESP-IDF is now configured for working properly!
Compile blinking LED example
In this section, we will follow the steps necessary to compile the blinking LED example provided in the ESP-IDF.
To compile the blinking LED example project, proceed as follows:
- Make sure that the parameter IDF_PATH is defined (as instructed in the section above). You may check if IDF_PATH is defined correctly by using command:
- Switch to the example project directory in iotbits_esp32 folder (02_blink in this case):
- Now run the following command to bring up the configuration menu, which lets you set parameters such as flash related parameters and other important values that define your ESP32 hardware:
You should see a configuration window like this:
You may leave out all the parameters at their respective defaults. However, if you do change anything, make sure that in option Serial flasher config, spi mode is DIO and spi flash speed is 40MHz. This is necessary for the current ESP-IDF version to work stably across most configurations!
- In menu Example Configuration, the GPIO to blink LED on is set as GPIO5 (default).
- Hit to save the configuration in the default location as follows:
- Now that the configuration is done, it is time to actually generate the BIN files from the source code!
To build the sources of ESP32 LED blinking program, use command:
- You should see an output like this, with no errors, which indicates that the solution was successfully built and the BIN files were generated in the output folder.
Congratulations! You just generated the BIN files which need to be downloaded to ESP32 flash memory for the blinking LED code to work!
Download program to ESP32!
The BIN files needed to make your program run were created above. To run the program on the ESP32 development board, here is how you can proceed: