Express if provides the necessary tools for the development of esp32 series hardware. ESP-IDF is the IOT Development Framework from Express if for ESP32 chip. The software development framework by Espressif is intended for rapidly developing Internet-of-Things (IoT) applications, with Wi-Fi, Bluetooth, power management and several other system features.
ESP32 integrates Wi-Fi (2.4 GHz band) and Bluetooth 4.2 solutions on a single chip, along with dual high-performance cores, Ultra-Low Power co-processor and several peripherals. Powered by 40 nm technology, ESP32 provides a robust, highly integrated platform to meet the continuous demands for efficient power usage, compact design, security, high performance, and reliability.
To develop applications for ESP32 you need:
Preparation of development environment consists of three steps:
The quickest way to start development with ESP32 is by installing a prebuilt toolchain. Windows don’t have a built-in “make” environment, so as well as installing the toolchain you will need a GNU-compatible environment. We use the MSYS2 environment.
The quick setup is to download the Windows all-in-one toolchain & MSYS zip file from:
https://dl.espressif.com/dl/esp32_win32_msys2_environment_and_toolchain-20170111.zip
Unzip the zip file to C: and it will create a “msys32” directory with a pre-prepared environment.
Note: Usage of toolchain
Use cd to change to the project directory (not the ESP-IDF directory.) Type make menuconfig to configure your project, then make to build it, make clean to remove built files, and make flash to flash (use the menuconfig to set the serial port for flashing.)
Besides the toolchain (that contains programs to compile and build the application), you also need ESP32 specific API / libraries. They are provided by Espressif in ESP-IDF repository. To get it, open an MSYS2 terminal window with administrative permissions by running C:\msys32\msys2_shell.cmd. The environment in this window is a bash shell., navigate to the directory you want to put ESP-IDF, and clone it using git clone command:
cd *$IDF_PATH *(This path can be user specific) git clone --recursive https://github.com/espressif/esp-idf.git
ESP-IDF will be downloaded into $IDF_PATH/esp-idf
NOTE:
cd $IDF_PATH/esp-idf git submodule update --init
The user profile scripts are contained in C:/msys32/etc/profile.d/directory. They are executed every time you open an MSYS2 window.
export IDF_PATH*=*"C:/msys32/home/user-name/esp/esp-idf"
Remember to replace back-slashes with forward-slashes in the original Windows path.
IDF_PATH
is set, by typing:printenv IDF_PATH
The path previously entered in the script file should be printed out.
Now you are ready to prepare your application for ESP32. To start off quickly, we will use get-started/hello_world project from examples directory in the downloaded esp-idf file.
cd* $IDF_PATH*/examples/get-started/hello_world .
You can also find a range of example projects under the examples directory in ESP-IDF.
Being in the terminal window, go to the directory of hello_world application by typing cd $IDF_PATH/examples/get-started/hello_world. Then start project configuration utility menuconfig:
cd *$IDF_PATH*/examples/get-started/hello_world make menuconfig
If previous steps have been done correctly, the following menu will be displayed:
In the menu, navigate to Serial flasher config > Default serial port to configure the serial port, where the project will be loaded to. Confirm the selection by pressing enter, save the configuration by selecting < Save >and then exit the application by selecting < Exit >.
Note: On Windows, serial ports have names like COM1. On MacOS, they start with /dev/cu.. On Linux, they start with /dev/tty.
Now you can build and flash the application. Run:
make flash
This will compile the application and all the ESP-IDF components, generate bootloader, partition table, and application binaries, and flash these binaries to your ESP32 board. If there are no issues, at the end of the build process, you should see messages describing the progress of the loading process. Finally, the end module will be reset and “hello_world” application will start.
To see if “hello_world” application is indeed running, type make monitor
. This command is launching IDF Monitor application:
$ make monitor MONITOR --- idf_monitor on COM12 115200 --- --- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H --- ets Dec 18 2017 03:22:57 rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) ets Dec 18 2017 03:22:57
Several lines below, after start-up and diagnostic log, you should see “Hello world!” printed out by the application.
... Hello world! Restarting in 10 seconds... I (211) cpu_start: Starting scheduler on APP CPU. Restarting in 9 seconds... Restarting in 8 seconds... Restarting in 7 seconds...
To exit the monitor use shortcut Ctrl+].
Note: If instead of the messages above, you see a random garbage similar to:
e���)(Xn@�y.!��(�PW+)��Hn9a/9�!�t5��P�~�k��e�ea�5�jA ~zY��Y(1�,1�� e���)(Xn@�y.!Dr�zY(�jpi�|�+z5Ymvp
or monitor fails shortly after upload, your board is likely using 26MHz crystal, while the ESP-IDF assumes a default of 40MHz. Exit the monitor, go back to the menuconfig, change ESP32_XTAL_FREQ_SEL to 26MHz, then build and flash the application again.
To execute make flash and make monitor in one go, type make flash monitor.
Configuring Eclipse on Windows requires some different steps. The full configuration steps for Windows are shown below.
(For OS X and Linux instructions, see the Eclipse IDE page.)
Once your new Eclipse installation launches, follow these steps:
Note: you may see warnings in the UI that Cygwin GCC Toolchain could not be found. This is OK, we’re going to reconfigure Eclipse to find our toolchain.
Before your project is first built, Eclipse may show a lot of errors and warnings about undefined values. This is because some source files are automatically generated as part of the esp-idf build process. These errors and warnings will go away after you build the project.
If you try to build without running a configuration step first, esp-idf will prompt for configuration on the command line – but Eclipse is not able to deal with this, so the build will hang or fail.
TIP: If your project had already been built outside Eclipse, you may need to do a Project -> Clean before choosing Project -> Build. This is so Eclipse can see the compiler arguments for all source files. It uses these to determine the header include paths.
You can integrate the “make flash” target into your Eclipse project to flash using esptool.py from the Eclipse UI:
Note that you will need to use “make menuconfig” to set the serial port and other config options for flashing. “make menuconfig” still requires a command line terminal (see the instructions for your platform.)
.