-
-
Notifications
You must be signed in to change notification settings - Fork 26
Installing Espressif IDF toolchain on Windows
Since many developers use Windows as operative system I though it will be a nice act, to make a simple guide with some screenshots, showing how to set things up in a simple way. For the sake of clarity wanted to mention I used to test this Windows 10 and I don't have an idea how is with other versions since I'm a Linux user and was never interested in buying a Windows License. So the screenshots might not match your version but it should be a similar process.
ESP-IDF is Espressif's official IoT Development Framework for the ESP32, ESP32-S, ESP32-C and ESP32-H series of SoCs. It provides a self-sufficient SDK for any generic application development on these platforms, using programming languages such as C and C++
As a resume from my side, this Framework will let you build, compile and flash Firmware to your ESP32 family of chips. ESP-IDF requires some prerequisite tools to be installed so you can build firmware for the supported chips. The prerequisite tools include Python, Git, cross-compilers, CMake and Ninja build tools.
There is a guide and links here to download the IDF framework: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/windows-setup.html
Make sure you have at least 4 GB free. The installer says about 2 GB depending on your selection but if you start downloading repositories and building stuff, you need more than that!
To start click on Windows installer download and then select one of the options:
Selected there the ESP-IDF 4.4 Offline installer, since I don't want any IDE, and usually use Microsoft VSCODE (That works in Linux also) Once it's downloaded we can just select the language of choice and start installing it. As you can see this will install:
- GNU Compiler Collection (GCC) -> This is what compiles our C / C++ code into binary so a MCU can run it
- GNU development tools ("binutils")
- GNU Debugger ("gdb")
- OpenOCD
- KConfig Frontends -> This is what opens a set of options called menuconfig (That is kind of standard and also used for example to select the options when you compile a Linux kernel)
You need to accept the agreement to install this and keep forward. Depending on your configuration, you might get:
- Checking "Long Paths Enabled" in Windows registry [WARN] -> Just let them run Powershell apply this fix for you and keep on
Then comes the select components, that you can leave all by default, I'm installing this in a computer that is not mine so I choose only what is needed:
Make sure that you select the right MCU, for example if you have ESP32 S2 or S3, select that version otherwise you won't be able to build your Firmware with that target. After doing that it might be a good moment to arm yourself with patience and grab a cup of good coffee.
Be warned that some warning pop-ups might come since this will install some stuff using Powershell, so it will ask if you trust Espressif Systems, I don't since I trust only my mother but still I said yes to avoid more pop-ups coming. Then at the end you will be prompted to add this to Powershell and command prompt, plus adding Windows Defender exclusions, which I said yes again to all since like that you won't be bothered when you want to build your firmware.
To finish this will open a command terminal and install the ESP-IDF tools to your PATH, meaning it will be accessible from any directory.
And that was easy peasy right? But let's not go so fast, cowboy!
Let's take some extra time and learn some of the commands that you need plus at the end let's flash some Hello World, or flash a LED so you can brag about it in Twitter.
To start with git is added since I guess is needed to fetch the IDF components so now you can use git clone to fetch repositories and just keep them up-to-date using git pull (Instead of downloading the ZIP compressed version) But the most important to stay in topic with our mission is what IDF installs itself. In my case I installed this in drive D: so my path looks like:
D:\Espressif\frameworks\esp-idf-v4.4.2>
Going down the tree in that directory, you can find some examples to get you started, for example:
cd examples\get-started\blink
For example that one is a simple Blink a led example, and there is a mystery still unsolved, that is to discover why nerds get excited when seeing a LED blink driven by a Microcontroller pin. But hey, it's understandable, since you can regulate the speed and make it your own special blink! Let's go for it. Now we are in that directory and we can finally set up the environment to build it. What ESP32 type we have at hand? Just get a data-USB, that is important, not a cheap USB just to charge but one that you can connect and see your phone or device data with it. In my case I have an ESP32S3. So we need to tell the toolchain that we will use that as a target:
idf.py set-target esp32s3
Be aware that the first time you run it this python command will use git to fetch all the submodules you need to run the framework so it will take a while and you will see a lot of:
-- Initialising new submodule components/xxxx
It's a big framework since it has modules for a lot of different things like WiFi, http protocol, bluetooth and a hell lot of dependencies to make all that work. Don't be surprised if you upload 200 Kb of binary to your MCU to blink a LED: That's the way it is when you use a full-fledged framework. But the good thing is that this initial submodules fetching will happen only one time per target MCU.
That's it then, now the build tool, knows that you will be using an esp32s3 as MCU and has all the right components there for you. Now we can configure it and see what options are given for the example:
idf.py menuconfig
There you can find a lot of options, you can read about many of them later, since they are specific to each field (WiFi / Bluetooth settings, MCU speed, etc) but now you can check the Example Configuration:
Blink Led type -> RMT for addressable led or GPIO driven (You can select GPIO)
And then the number of the GPIO you are going to attach the LED too always with a resistance that you have at hand since otherwise LED might bright for the last time (If you are lucky and you don't burn the GPIO) Just add anything from 300 Ohm to 1K resistance:
IO21 (Or any) ---|__300 Ohm RES__|--|> LED -> GND
Selecting GPIO driven and 21 as our driving GPIO we can have this demo example configured. Then you can click Q to quit and Y to save the configuration. This config file is saved in a text file with the name of sdkconfig which is full of config definitions that is injected as C defines and are available globally in your program. Now we are ready to build, or to build and flash, and debug via Serial.
idf.py build
That should take some seconds or minutes depending on your computer. As you can see all the files are converted to .obj binaries and then packed in a bootloader plus app.bin that is flashed in the ESP microcontroller. For that to happen after a successful build and to open serial just afterwards we use this command:
idf.py flash monitor
Now there is a mistery still unsolved, that is how to get out of Serial debugging, in their page says Ctrl+] but it does not get out (Is Ctrl+5 in Ubuntu)
I guess depends also in your Keyboard configuration. In my case with a German one it's CTRL key plus + (sign) but if you don't get it just keep CTRL pressed and go to 1->´ or 0 key plus the signs until you find it.
If that goes good then you will see the flashing happen and the resulting Serial output:
Congratulations, you have flashed your Micro-controller!!!
Revision v.1.3 | Firmware for ESP-IDF >= v. 4.3 Documentation written by Fasani Corp.
We are also launching a new company called Marespa.es that will help EU citizens find an affordable apartment in Spain. With the price of Rent going through the roof in 2024, this might be the moment to make an investment, if you plan to work from the spanish coast. With this project we are also supporting our open source projects.