One of the challenges I had recently was setting up the latest version of Amazon FreeRTOS on my PC. The main issue I had was the fact that the Getting started documentation was outdated(201910.00) and won’t work for anyone trying to install the current version(202012.00) at the time this post was published. Different versions of FreeRTOS require different compilers so It’s important that the compiler is compatible and following the Getting started documentation, you’ll end up downloading the most recent version of FreeRTOS(202012.00) which comes with ESP-IDF v3.3 but install an older version of the compiler which will lead to build errors. This blog post is only for windows users but you might get an idea or two if you’re a mac or linux user and having issues with the installation.
Download FreeRTOS
The very first thing you’ll need to do is download FreeRTOS from Github. The current version of FreeRTOS is 202012.00. Make sure git is installed on your PC. You can install it in any folder you want. I installed mine in my C: drive. Open the command prompt, navigate to where you want to install it by using the cd command and then run the following command –
git clone https://github.com/aws/amazon-freertos.git --recurse-submodules
Setup your development environment
The next step is to download and install ESP-IDF tools. Go here to download the latest version of the ESP-IDF tools at the time this blog was published. It is important that ESP-IDF tools come with a compiler that is compatible with the esp-idf version you installed in the first step. Start the installation of the the tools.
During the installation setup, you need to make sure you install python 3. If It’s already installed on you PC, you can select that instead. Then click next. Since you already have git installed, you can select the installed version and click next. This next step is important. Select, use and existing ESP-IDF directory and navigate to the ESP-IDF directory of the amazon-freertos you installed in step 1. The directory should look like this – C:\amazon-freertos\vendors\espressif\esp-idf. Then click next and install the ESP-IDF tools. An ESP-IDF command prompt should be installed on your PC. Open it and move on to the next step.
Configure the FreeRTOS Demo Applications
Go to the configure the FreeRTOS Demo applications section of the Getting started guide. You don’t need to go through steps 1-4. Start from step 5- installing boto3- and then follow the remaining steps until you get to the end of the section.
Build FreeRTOS on windows
Once you are done with configuring the FreeRTOS Demo Applications, Open you ESP-IDF command prompt if its closed and navigate to the freertos download directory. Enter the following command.
cmake -DVENDOR=espressif -DBOARD=esp32_wrover_kit -DCOMPILER=xtensa-esp32 -GNinja -S . -B
build-directory
Where build-directory represents the directory you want your project to be built. It can be anywhere on your PC. Once that is done, navigate to the build-directory in the command prompt and enter the following command –
or remain in the FreeRTOS download directory and enter ninja
cmake --build build-directory
in your command prompt wherebuild-directory represents the build directory.
Flash and Run FreeRTOS
Once the previous step has been completed, plug in the esp32 dev board, go to the FreeRTOS download directory and enter the following command
idf.py -B -build build-directory -p COMPORT flash
Where the COMPORT is the serial port of the esp32 development board. Open the AWS IOT console.
To monitor, enter
idf.py -B -build build-directory -p COMPORT monitor
Monitoring MQTT messages on the cloud
Sign in to the AWS iot console. In the navigation pane, choose Test to open the MQTT client. In Subscription topic, enter , and then choose Subscribe to topic. In Subscription topic, enter thing-name/example/topic
, and then choose Subscribe to topic. thing-name represents the thing name you entered in your configure.json file. You should then see multiple “hello world” being received.