After having introduced, in the previous post, the ESP32 chip and the official development board by Espressif, today I’m going to show you how to install and use the official development environment.
The official development framework for the ESP32 chip is published by Expressif on Github, with an opensource license (Apache 2.0) and named Espressif IoT Development Framework (shortly idf).
To be able to use it under Windows, you need some GNU commands and toolchains (make, bash…). Espressif chose to offer a pre-configured version of MSYS2 that includes everything is required.
Download the ZIP archive from the Espressif website and unzip it in the root of your C drive; MSYS2 will be installed in the C:\msys32 subfolder:
Double-click on minigw32.exe to run a bash shell:
We can now clone the idf Github repository to have a local copy of it. First we must choose a folder where it will be copied; to keep it simple let’s use the user’s home folder.
Move into that folder and run the clone command:
$ cd $ git clone --recursive https://github.com/espressif/esp-idf.git
After the process is completed, the development framework is available in the esp32-idf subfolder:
To use if when compiling your projects, you have to export the path as an environment variable (IDF-PATH):
$ export IDF_PATH=~/esp-idf
Let’s connect the board!
You’re now ready to connect the development board to your computer.
If you already have the correct drivers, once connected it will appear as a new serial port:
On the contrary, the needed drivers are available on the Silicon Labs official website.
Hello World
As usual when learning a new language or framework, let’s start with a simple program that displays (using the serial-usb connection) the sentence Hello world.
The framework is distributed with some examples, among them you can find the 01_hello_world program. To compile it, move to its folder and run the make command:
$ cd $ cd esp-idf/examples/01_hello_world/ $ make
A configuration menu will be displayed: we’ll talk more about it in a next post. Now you only need to tell the flasher which is the serial port your board is connected to.
Choose Serial flasher config, then /dev/ttyUSB0 (the default port):
Type the name of your serial port (as identified above), then confirm with Ok, Save and Exit:
When the compile process is complete, you can upload the program on the board with the following command:
make flash
If you now use a terminal emulator to connect to the serial port with the correct speed (115200 baud) you should see the program output:
(the program prints the sentence “Hello world!”, counts 10 seconds and then restart the chip…)
Presumably the Espressif ZIP archive you mentioned will occasionally get updated. As I can find no quick and obvious path to this zip from either github or espressif (I’ve spent the past half-hour looking), could you provide a URL on espressif’s site that points you to their latest zip – on the grounds that such a URL might change less frequently than that to which it refers 🙂
Hi Paul, you’re right… the best way to find the link is the official documentation. I’ll update the article accordingly
Thanks. But unhappily there is more. Not that it matters to me, but I cannot find any trace of 01_hello_world in the esp-idf gittery (gittage?).
More seriously, I’m looking to make one of their wifi examples but the make – after several rumblings – just ends up saying that
… yada yada yada …
CC flash_qio_mode.o
CC bootloader_start.o
AR libmain.a
LD bootloader.elf
/bin/sh: python: command not found
And indeed the distribution shows an absence of python in /usr/bin. Thing is I already have python (both 2.7 and 3) installed under a separate cygwin environment but MSYS2 isn’t in the same universe (its / is not the same as my cygwin’s) and cannot see it. I have so many different IDEs (MPLAB, Atmel, Xilinx, not to mention GNU) living on this machine it’s hard to keep track of which one’s being used for what piece of hardware. :). I suppose I’ll have to install yet another python just for MSYS2. Gaah!
Just thought I’d mention a first-world problem!
Hi Paul! Try running the “minigw32.exe” executable instead of “msys2.exe”… it should solve your issue
mingw32.exe works – python appears to be known on that route, so thanks! But – although I get a bootloader.bin out of it, it just won’t go via (in my case) /dev/ttyS20 onto the board, Boot buttion has no effect. All I get is
serial.serialutil.SerialException: could not open port ‘/??/COM21’: WindowsError(123, ‘The filename, directory name, or volume label syntax is incorrect.’)
As it happens I have a prior prog flashed onto it (via the arduino ide) and I can see its output coming in with a ‘cat < /dev/ttyS20' so I'm pretty confident the mingw config is correct.
Paul if you are under Windows, in menuconfig enter “COM21” (without quotes) as serial port for the flasher
$ git clone –recursive https://github.com/expressif/esp-idf.git
Cloning into ‘esp-idf’…
Username for ‘https://github.com’:
Password for ‘https://abhayrjoshi@github.com’:
remote: Repository not found.
fatal: repository ‘https://github.com/expressif/esp-idf.git/’ not found
Why is it asking for a username and password?
did you configure git with your account? Are you using Github also for your projects?
thanks, works perfect
Next ESP32 (3)
MINGW32 ~/esp-idf/examples/get-started/hello_world
$ make flash
Toolchain path: /opt/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
WARNING: Toolchain version is not supported: crosstool-ng-1.22.0-61-gab8375a
Expected to see version: crosstool-ng-1.22.0-80-g6c4433a
Please check ESP-IDF setup instructions and update the toolchain, or proceed at your own risk.
Compiler version: 5.2.0
WARNING: Toolchain version is not supported: crosstool-ng-1.22.0-61-gab8375a
Expected to see version: crosstool-ng-1.22.0-80-g6c4433a
Please check ESP-IDF setup instructions and update the toolchain, or proceed at your own risk.
Please run the following command to install MSYS2’s MINGW Python cryptography package:
pacman -Sy mingw-w64-i686-python2-cryptography
make: *** [/home/ashenafi/esp-idf/make/project.mk:476: check_python_dependencies] Error 1
how can i solve this problem?
follow the instruction to update your environment –> https://docs.espressif.com/projects/esp-idf/en/latest/get-started/windows-setup.html
share it:
The following command can simply add the current path of idf to the environment variable.
$ export IDF_PATH=$PWD
Hi, the whole esp-idf was updated, I am not even sure how using “make” can be viable anymore. The project is dependent on cmake now and has a completely different approach to the build system as far as I understand.