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

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 :laughing:

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)

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

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.

@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.

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

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.

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.

Thanks,

Carl

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

Thanks

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.

Thanks for you response.

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

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

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.

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.:roll_eyes:

Please help, if you have any clue.

Thanks

Follow all the instructions as mentioned here (it is mandatory) Getting started with the Espressif ESP32-DevKitC and the ESP-WROVER-KIT - FreeRTOS

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

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

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