# How to compile an AWS FreeRTOS ESP32 project using VS Code?

**URL:** <https://forums.freertos.org/t/how-to-compile-an-aws-freertos-esp32-project-using-vs-code/11785>\
**Category:** Espressif\
**Tags:** debug, tutorial\
**Created:** [February 17, 2021, 5:12pm UTC](https://forums.freertos.org/t/how-to-compile-an-aws-freertos-esp32-project-using-vs-code/11785 "2021-02-17T17:12:21Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yoimer](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/yoimer/32/1308_2.png) [@Yoimer](https://forums.freertos.org/u/Yoimer)\
**Post date:** [February 17, 2021, 5:12pm UTC](https://forums.freertos.org/t/how-to-compile-an-aws-freertos-esp32-project-using-vs-code/11785/1 "2021-02-17T17:12:22Z")

</div>

Hello to all the FreeRTOS and AWS community. Congratulations for this great work.

Kindly, I am asking for support about how to compile AWS FreeRTOS ESP32 projects in VS Code.

I will explain first, all the details about how I’ve compiled, and successfully tested some `demos` using the` ESP-IDF Command Prompt` `v4.2` of IDF, with the toolchain `esp-idf-tools-setup-2.3.exe`, `Python 3.8.3`, `git version 2.30.1.windows.1` on Windows 7 Ultimate.

I have been able to compile via ESP-IDF Command Prompt examples from the AWS FreeRTOS Console, and freertos-aws-reference-integrations from Github.  
In both cases, the version is `Version 202012.00` with `crosstool-ng-1.22.0-80-g6c4433a` used in `5.2.0`

The freertos-aws-reference-integrations for Espressif (and other vendors) on Github

The unzipped folder I place it on `C:\esp-idf-v4.2` just for consistency, I keep it as my root folder :`C:\esp-idf-v4.2\FreeRTOS`

I modified one line of code on `C:/users/username/.espressif/_idf_cmd_init.bat` which makes possible to move back and forth to use the native idf v4.2 examples and demos from FreeRTOS just commenting that line.

For `path` configuration, I used the default one which is made from the esp-idf-tools-setup-2.3.exe installation.

And for FreeRTOS, I used the `install.bat` and `export.bat` present on `C:\esp-idf-v4.2\FreeRTOS\vendors\espressif\esp-idf\install.bat` and `C:\esp-idf-v4.2\FreeRTOS\vendors\espressif\esp-idf\export`

In order to execute the `coreMQTT` and `ota` examples, I double clicked the `ESP-IDF Command Prompt cmd.exe` (generated from toolchain installation), changed directories to FreeRTOS `cd FreeRTOS` and issued the next commands:

1. coreMQTT demo

`cmake -DVENDOR=espressif -DBOARD=esp32_devkitc -DCOMPILER=xtensa-esp32 -GNinja -S . -B demos/coreMQTT/build`

`python C:/esp-idf-v4.2/FreeRTOS/vendors/espressif/esp-idf/tools/idf.py build -B demos/coreMQTT/build`

`python C:/esp-idf-v4.2/FreeRTOS/vendors/espressif/esp-idf/tools/idf.py erase_flash flash monitor -p COM4 demos/coreMQTT/build`

1. ota demo  
`cmake -DVENDOR=espressif -DBOARD=esp32_devkitc -DCOMPILER=xtensa-esp32 -GNinja -S . -B demos/ota/build`

`python C:/esp-idf-v4.2/FreeRTOS/vendors/espressif/esp-idf/tools/idf.py build -B demos/ota/build`

`python C:/esp-idf-v4.2/FreeRTOS/vendors/espressif/esp-idf/tools/idf.py erase_flash flash monitor -p COM4 -B demos/ota/build`

All working quite good so far 😆

I want to achieve all that I did for AWS FreeRTOS on cli using VS code. I tested and flashed the `simple_sniffer` from IDF 4.2 example using VS code and worked flawlessly.

My issue is trying to do the same with any of the examples on demos folder on FreeRTOS. Probably I am missing some cross-compiling configurations? Some path issues?

My working configurations for VS code are here (the one I used for the simple\_sniffer example)

> **[.vs\_code\_simple\_sniffer.zip](https://www.dropbox.com/s/wxm91eil6rpb059/.vs_code_simple_sniffer.zip)**
>
> Shared with Dropbox

The failing configurations for AWS FreeRTOS ESP32 for VS code are here.

> **[esp-32-vs-code.zip](https://www.dropbox.com/s/ih0lxy3tfqxonrk/esp-32-vs-code.zip)**
>
> Shared with Dropbox

I even checked the link using-visual-studio-code-for-freertos-development.html, but still I can’t make it work.

I would really appreciate your support on this. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![leegeth](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@leegeth](https://forums.freertos.org/u/leegeth)\
**Post date:** [February 17, 2021, 11:17pm UTC](https://forums.freertos.org/t/how-to-compile-an-aws-freertos-esp32-project-using-vs-code/11785/2 "2021-02-17T23:17:56Z")

</div>

@Yoimer

Thanks for your interest in FreeRTOS and bringing this question to our attention. We are looking into your question and will get back to you once we have an update.

---

<div class="post-metadata">

**Author:** ![Yoimer](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/yoimer/32/1308_2.png) [@Yoimer](https://forums.freertos.org/u/Yoimer)\
**Post date:** [February 17, 2021, 11:35pm UTC](https://forums.freertos.org/t/how-to-compile-an-aws-freertos-esp32-project-using-vs-code/11785/3 "2021-02-17T23:35:53Z")

</div>

Hello @leegeth. Thanks a replying. Looking forward to seeing your updates. 😄

---

<div class="post-metadata">

**Author:** ![Yoimer](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/yoimer/32/1308_2.png) [@Yoimer](https://forums.freertos.org/u/Yoimer)\
**Post date:** [February 18, 2021, 5:18pm UTC](https://forums.freertos.org/t/how-to-compile-an-aws-freertos-esp32-project-using-vs-code/11785/4 "2021-02-18T17:18:22Z")

</div>

Good morning dear @leegeth. Hope you and yours are doing great. A quick question, do you happen to have any update regarding this?. Thanks a lot.

---

<div class="post-metadata">

**Author:** ![lundinc](https://avatars.discourse-cdn.com/v4/letter/l/0ea827/32.png) [@lundinc](https://forums.freertos.org/u/lundinc)\
**Post date:** [February 25, 2021, 5:04pm UTC](https://forums.freertos.org/t/how-to-compile-an-aws-freertos-esp32-project-using-vs-code/11785/5 "2021-02-25T17:04:08Z")

</div>

Hello Yoimer,

I have posted a reply at [How to build, compile and flash AWS FreeRTOS ESP32 on VS Code · Issue #3002 · aws/amazon-freertos · GitHub](https://github.com/aws/amazon-freertos/issues/3002).

Thanks,

Carl

---

<div class="post-metadata">

**Author:** ![abhibhatia98](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/abhibhatia98/32/1717_2.png) [@abhibhatia98](https://forums.freertos.org/u/abhibhatia98)\
**Post date:** [June 15, 2021, 6:40am UTC](https://forums.freertos.org/t/how-to-compile-an-aws-freertos-esp32-project-using-vs-code/11785/6 "2021-06-15T06:40:08Z")

</div>

> [@Yoimer](#):
>
> I modified one line of code on `C:/users/username/.espressif/_idf_cmd_init.bat` which makes possible to move back and forth to use the native idf v4.2 examples and demos from FreeRTOS just commenting that line.

Hi @Yoimer would you please mention here whats the exact line you have commented in this?

Thanks

---

<div class="post-metadata">

**Author:** ![Yoimer](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/yoimer/32/1308_2.png) [@Yoimer](https://forums.freertos.org/u/Yoimer)\
**Post date:** [June 15, 2021, 1:02pm UTC](https://forums.freertos.org/t/how-to-compile-an-aws-freertos-esp32-project-using-vs-code/11785/7 "2021-06-15T13:02:39Z")

</div>

Hi @abhibhatia98 . On C:\Users\Yoimer.espressif (my path) I edited the idf\_cmd\_init.bat file. I changed IDF\_PATH=%CD% to IDF\_PATH=“C:\esp-idf-v4.2\FreeRTOS\vendors\espressif\esp-idf”

I just downloaded FreeRTOS zip file from the AWS Console, and unzipped on C:\esp-idf-v4.2.

That way you could build and compile that FreeRTOS using ESP-IDF 4.2. The installer will download all the libraries needed.

If you want to use the ESP-IDF-4.2 back (not FreeRTOS) then change again the idf\_cmd\_init.bat file as it was in the first time.

---

<div class="post-metadata">

**Author:** ![abhibhatia98](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/abhibhatia98/32/1717_2.png) [@abhibhatia98](https://forums.freertos.org/u/abhibhatia98)\
**Post date:** [June 15, 2021, 1:19pm UTC](https://forums.freertos.org/t/how-to-compile-an-aws-freertos-esp32-project-using-vs-code/11785/8 "2021-06-15T13:19:11Z")

</div>

Thanks for you response.

when I ran this command `vendors\espressif\esp-idf\export.bat` that basically ran idf.py I see following error

```auto
Adding ESP-IDF tools to PATH...
ERROR: tool xtensa-esp32-elf has no installed versions. Please run 'C:\FreeRTOS1\vendors\espressif\esp-idf\install.bat' to install it.
ERROR: tool esp32ulp-elf has no installed versions. Please run 'C:\FreeRTOS1\vendors\espressif\esp-idf\install.bat' to install it.

```

If you can help me to get out from this I will be thankful.  
I already tried all the steps correctly three times.

Although I have posted out the same issue on git with below subject(can’t add link as I am new user here)

> ERROR: tool xtensa-esp32-elf has no installed versions. Please run ‘C:\FreeRTOS1\vendors\espressif\esp-idf\install.bat’ to install it.

Thanks  
Abhishek

---

<div class="post-metadata">

**Author:** ![Yoimer](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/yoimer/32/1308_2.png) [@Yoimer](https://forums.freertos.org/u/Yoimer)\
**Post date:** [June 15, 2021, 1:35pm UTC](https://forums.freertos.org/t/how-to-compile-an-aws-freertos-esp32-project-using-vs-code/11785/9 "2021-06-15T13:35:11Z")

</div>

First make sure you installed ESP-IDF-4.2 correctly in your path. Then, build any of the examples, compile and flash them to the ESP32.

If all of the above went OK, proceed as explained on my previous response for AWS FreeRTOS.

---

<div class="post-metadata">

**Author:** ![abhibhatia98](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/abhibhatia98/32/1717_2.png) [@abhibhatia98](https://forums.freertos.org/u/abhibhatia98)\
**Post date:** [June 15, 2021, 2:38pm UTC](https://forums.freertos.org/t/how-to-compile-an-aws-freertos-esp32-project-using-vs-code/11785/10 "2021-06-15T14:38:40Z")

</div>

I have tried the same you mentioned.

1. Set up ESP-IDF
2. Try to build hello world example by esp idf that works well.
3. Then I downloaded the aws FreeRTOS project from aws console.
4. Add the data in configure.json
5. python SetupAWS.py setup
6. And then after “vendors\espressif\esp-idf\export.bat” this command give me  
error as specified above.  
and there I got stuck.🙄

Please help, if you have any clue.

Thanks

---

<div class="post-metadata">

**Author:** ![Yoimer](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/yoimer/32/1308_2.png) [@Yoimer](https://forums.freertos.org/u/Yoimer)\
**Post date:** [June 15, 2021, 2:59pm UTC](https://forums.freertos.org/t/how-to-compile-an-aws-freertos-esp32-project-using-vs-code/11785/11 "2021-06-15T14:59:16Z")

</div>

Follow all the instructions as mentioned here (it is mandatory) [Getting started with the Espressif ESP32-DevKitC and the ESP-WROVER-KIT - FreeRTOS](https://docs.aws.amazon.com/freertos/latest/userguide/getting_started_espressif.html)

If any of this works for you, ask again in your issue here [[General] \<ERROR: tool xtensa-esp32-elf has no installed versions. Please run 'C:\FreeRTOS1\vendors\espressif\esp-idf\install.bat' to install it.\> · Issue #3235 · aws/amazon-freertos · GitHub](https://github.com/aws/amazon-freertos/issues/3235)

Another thing you can do is just follow the instructions (for AWS FreeRTOS on ESP-IDF 4.2) as cleary shown here

> **[aws/amazon-freertos](https://github.com/aws/amazon-freertos)**
>
> IoT operating system for microcontrollers. Contribute to aws/amazon-freertos development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![abhibhatia98](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/abhibhatia98/32/1717_2.png) [@abhibhatia98](https://forums.freertos.org/u/abhibhatia98)\
**Post date:** [June 16, 2021, 8:46am UTC](https://forums.freertos.org/t/how-to-compile-an-aws-freertos-esp32-project-using-vs-code/11785/12 "2021-06-16T08:46:13Z")

</div>

well I already followed the same guide 3 times, I have a confusion at a point in this.

At the aws page it is mentioned to open MINGW32.exe, so what i have done here is I have downloaded mingw installer and installed that and added C:\MinGW\bin in the environment variables.

Is is the right way or something else ?

Thanks  
Abhishek
