Amazon FreeRTOS and ESP32 with Eclipse on Windows

AlexESP32 wrote on October 03, 2019:

Really nobody here who can handle this?

Is this my fault or an Error of bad documentation / bad code from Amazon?
Someone here wo worked with Amazon FreeRTOS ESP-IDF, would be nice to know I’m not alone in this problem :smiley:

Hello everyone!
Hope somebody can help me…
I just want to get a simple “Hello World” on my ESP32 but I even don’t know how to start…

OS: Windows 10
Prefered IDE: Eclipse
Download: https://github.com/aws/amazon-freertos
Tutorial: https://docs.aws.amazon.com/en_pv/freertos/latest/userguide/getting_started_espressif.html

Start at heading: “Build, Flash, and Run the Amazon FreeRTOS Demo Project”, is this correct?

My first question is:
My source code directory / build binaries directory is correct, now i have to click “configure”, now wich generator in CMake-GUI do I need:
MSYS Makefiles,? MinGW Makefile,?, Ninja?, Eclipse CDT4 - MinGW Makefiles?

After that correct Configure and Generate, i have got a build directory…
Now the big question is: how can i get this build files in Eclipse and then on my ESP32?

Thank you very much for taking your time.

Greetings.

I tried to build with CMake, the generator was “Eclipse CDT4 - MinGw Makefiles” and i got this error:

C:\Users\ALEXALEX\Desktop\amazon-freertos-master\amazon-freertos-master>cmake --bu
ild build
1% Built target afr_kernel
3% Built target afr_freertos_plus_tcp
13% Built target afr_3rdparty_mbedtls
14% Built target afr_crypto
17% Built target afr_pkcs11_implementation
17% Built target afr_pkcs11
19% Built target afr_tls
20% Built target afr_secure_sockets
20% Built target afr_platform
21% Built target afr_common
21% Built target afr_https
22% Built target afr_dev_mode_key_provisioning
22% Built target afr_3rdparty_tinycbor
22% Building C object CMakeFiles/afr_serializer.dir/libraries/c_sdk/standard/se
rializer/src/json/iot_serializer_json_encoder.c.obj
C:\Users\ALEXALEX\Desktop\amazon-freertos-master\amazon-freertos-master\libraries
c_sdk\standard\serializer\src\json\iot_serializer_json_encoder.c: In function ‘_ap
pendData’:
C:\Users\ALEXALEX\Desktop\amazon-freertos-master\amazon-freertos-master\libraries
c_sdk\standard\serializer\src\json\iot_serializer_json_encoder.c:465:13: error: ‘s
trncpy’ output truncated before terminating nul copying 4 bytes from a string of t
he same length -Werror=stringop-truncation
strncpy( ( char * ) _jsonContainerPointer( pContainer ), _JSON_NULL_V
ALUE, _JSON_NULL_VALUE_LENGTH );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

C:\Users\ALEXALEX\Desktop\amazon-freertos-master\amazon-freertos-master\libraries\
c_sdk\standard\serializer\src\json\iot_serializer_json_encoder.c: In function '_ap
pendBoolean':
C:\Users\ALEXALEX\Desktop\amazon-freertos-master\amazon-freertos-master\libraries\
c_sdk\standard\serializer\src\json\iot_serializer_json_encoder.c:417:9: error: 'st
rncpy' output truncated before terminating nul copying 4 bytes from a string of th
e same length -Werror=stringop-truncation
         strncpy( ( char * ) _jsonContainerPointer( pContainer ), _JSON_BOOL_TRUE,
 _JSON_BOOL_TRUE_LENGTH );
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\ALEXALEX\Desktop\amazon-freertos-master\amazon-freertos-master\libraries\
c_sdk\standard\serializer\src\json\iot_serializer_json_encoder.c:422:9: error: 'st
rncpy' output truncated before terminating nul copying 5 bytes from a string of th
e same length -Werror=stringop-truncation
         strncpy( ( char * ) _jsonContainerPointer( pContainer ), _JSON_BOOL_FALSE
, _JSON_BOOL_FALSE_LENGTH );
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1.exe: some warnings being treated as errors
CMakeFiles\afr_serializer.dir\build.make:100: recipe for target 'CMakeFiles/afr_se
rializer.dir/libraries/c_sdk/standard/serializer/src/json/iot_serializer_json_enco
der.c.obj' failed
mingw32-make.exe2: *** CMakeFiles/afr_serializer.dir/libraries/c_sdk/standard/s
erializer/src/json/iot_serializer_json_encoder.c.obj Error 1
CMakeFiles\Makefile2:334: recipe for target 'CMakeFiles/afr_serializer.dir/all' fa
iled
mingw32-make.exe1: *** CMakeFiles/afr_serializer.dir/all Error 2
Makefile:82: recipe for target 'all' failed
mingw32-make.exe: *** all Error 2

C:\Users\ALEXALEX\Desktop\amazon-freertos-master\amazon-freertos-master>

Maybee somenone can help me ;)

Edited by: AlexESP32 on Oct 3, 2019 2:22 AM

Edited by: AlexESP32 on Oct 3, 2019 7:07 AM

Edited by: AlexESP32 on Oct 3, 2019 7:08 AM

gordon-AWS wrote on October 03, 2019:

Hello,

As you are using Windows, you should choose Ninja (preferred) or MinGW Makefiles as your generator. See this page for more information.
https://docs.aws.amazon.com/en_pv/freertos/latest/userguide/building-cmake.html

Regarding the compiler error: I am not completely sure what the cause is, but it may be your ESP toolchain version. You must use a toolchain compatible with ESP-IDF 3.1.5. See “Set Up Your Development Environment” on this page:
https://docs.aws.amazon.com/en_pv/freertos/latest/userguide/getting_started_espressif.html

gordon-AWS wrote on October 04, 2019:

Hello,

Amazon FreeRTOS does not officially support Eclipse on ESP32. Therefore, you will need to manually add the Amazon FreeRTOS sources to Eclipse, though this is a lot of work. You could also just add the demo binary, aws_demos, to Eclipse; this will allow you to flash, run, and debug, but you will not have the sources in Eclipse.

AlexESP32 wrote on October 04, 2019:

Thank you very much for your answer, it helped me a lot.

I chose Ninja & the Toolchain of Amazon and it worked. My fault was at first I did not took Ninja and I took the toolchain of the esspressif website with the compiler version 8.2.0…

After that, my last question: How can I get a hello-World project to Eclipse?

On the espressif webiste, there is a get-started example project online and I only worked through the manual and this worked, but at the amazon download this example project is missing?
https://docs.espressif.com/projects/esp-idf/en/latest/get-started-legacy/eclipse-setup.html

If this question is answered, i am lucky and can go on on myself.

Thank you.

AlexESP32 wrote on October 05, 2019:

Thank you again for your help.
Now i can flash a program (i even dont know wich) on my ESP32 :slight_smile:

My question still is this one: How can I get a program on my ESP32 with eclipse?

  1. Wich folder can I configure: Is it this one --> amazon-freertos-master\projects\espressif\esp32\make\aws_demos
    Or is it this one: amazon-freertos-master\build\vendors\espressif\boards\esp32\CMakeFiles\aws_demos.dir\aws_demos

    There are so many aws_demos, I really dont know wich one I have to choose…

  2. And after that: Wich Library (directory) I have to add to Eclipse? Do i need to include the files of the build-directory, i.e. afr_mqtt.a?

  3. Do i have to select this settings in eclipse? --> https://docs.espressif.com/projects/esp-idf/en/latest/get-started-legacy/eclipse-setup.html
    or is it only this website: https://docs.aws.amazon.com/en_pv/freertos/latest/portingguide/porting-create-project.html
    Am i right?

  4. If I compare the Amazon ESP-IDF with the espressif ESP-IDF, there are some components missing, i.e. the CAN Driver, i would need this, how can i get this to my project?
    This should be the directory where at espressif ESP-IDF the can is available: amazon-freertos-master\vendors\espressif\esp-idf\components\driver\include\driver

Thank you very much for your help :slight_smile:

Edited by: AlexESP32 on Oct 5, 2019 4:12 AM

Edited by: AlexESP32 on Oct 5, 2019 5:29 AM

Edited by: AlexESP32 on Oct 5, 2019 6:08 AM

AlexESP32 wrote on October 06, 2019:

Maybee someone can help me.

Thank you.

gordon-AWS wrote on October 08, 2019:

Hello,

  1. You should flash the aws_demos.bin file. It will be located in your build directory.
  2. You do not need to include the files in the build directory. Actually, you shouldn’t have to add any files to Eclipse to flash. Eclipse will be able to open any needed files automatically, since the paths are part of the debug information in the binary.
  3. You should follow the first link and set the environment variables in your Eclipse project file. The instructions in the second link are optional, but useful if you would like to browse the source tree from Eclipse.
  4. You will need to download any additional ESP-IDF files and add them to the project manually. Make sure that you download the correct version of the drivers compatible with ESP-IDF.

AlexESP32 wrote on October 12, 2019:

Thank you.

I even dont know how to build a correct project in eclipse with Amazon FreeRTOS.
At Espressif there is an example project where i have to import in the IDE, do some settings and it works. At Amazon i couldnt find this…
My question still is:
How can i get an example project in eclipse. In my opinion the starting guide at AWS requires advanced skills to get a build / flash project.
I tried this guide: https://docs.aws.amazon.com/freertos/latest/portingguide/porting-set-up-directory.html
but i think there are some steps missing?

A few more questions:

  1. Wich directory i have to choose at Amazon Freertos to make a new project, the best case copy / paste another project? --> maybee this one: amazon-freertos\vendors\espressif\boards\esp32\aws_demos
  2. How could look like the CMakeLists.txt? The Makefile could look like that? -->
    PROJECT_NAME := blink

include $(IDF_PATH)/make/project.mk

  1. if i get a projcet (maybee the get-started hello_world from espressif?: --> eclipse import: “import existing code as makefile project”?
  2. configure Amazon Project: settings (IDF_PATH, BATCH_BUILD, …) from espressif site?
  3. import directories like here: https://docs.aws.amazon.com/freertos/latest/portingguide/porting-create-project.html Is the folder structure really correct? At example first step the structure is: aws_tests in the /projects/vendors//boards// --> in my case it would look like that: projects\espressif\esp32\make\aws_demos

Maybee someone can explain the metho exact. Now i can build / flash demo projects with cmake / ninja at cmd. The next step is to build / flash at eclipse. But i dont know how to get the result.

Thank you.

Edited by: AlexESP32 on Oct 12, 2019 3:08 PM

SarenaAtAws wrote on October 14, 2019:

Hello AlexESP32,

We use the Makefile build to create an Eclipse IDE project. This Makefile is located under vendors\espressif\boards\esp32\aws_demos\Makefile.

We do not use CMake for the Eclipse IDE project.
We do not currently have the resource to assist in plugging in CMake for an Eclipse project. Integration of CMake in Eclipse for all platforms is in the backlog and we appreciate your valuable feedback.

Here are instructions for getting started with the Makefile Eclipse build. Please note this is NOT official support. This is a convenience we have checked-in for some developers:

  1. To use the Makefile build with Eclipse you will need to make sure you have a minGW 32-bit environment installed and the Espressif ESP32 toolchain.

You can get both at once in this page:

https://docs.espressif.com/projects/esp-idf/en/feature-esp32s2beta/get-started/windows-setup.html

I install this under C:/msys as directed on the page.

  1. We have an eclipse project under:projects\espressif\esp32\make\aws_demos.project

In your installation of Eclipse for C/C++ developers you import this project.

  1. You will need to update the PATH for the location of your minGW binaries and the Espressif toolchain. If you followed step 1. as I have done, then you will need to go to the project’s properties pages, then to “Environment”. Edit “PATH” to include at the end:

C:\msys32\mingw32\bin;C:\msys32\opt\xtensa-esp32-elf\bin;C:\msys32\usr\bin

  1. You MUST run “make menuconfig” in your minGW 32-bit environment before building in eclipse IDE. Open C:\msys32\mingw32.exe.

Change directory to the root of your amazon-freertos repo.
Run

 make menuconfig 
  1. Go back to Eclipse and right click on your project to clean or build.

The eclipse project that I have given you instructions for above followed these instructions to be created: https://docs.espressif.com/projects/esp-idf/en/latest/get-started-legacy/eclipse-setup.html

You will notice in the “Project Explorer” there are files. These files shown are FOR REFERENCE ONLY and may be out of date with what is currently in the repo. Just because a file is shown or now shown here does not make it included in the build.
This Eclipse project does a non-native Makefile project build. Which means it invokes this Makefile to build: vendors\espressif\boards\esp32\aws_demos\Makefile. The Amazon FreeRTOS files that are included in this build can be found at: vendors\espressif\boards\esp32\aws_demos\application_code\espressif_code\amazon-freertos-common\component.mk

AlexESP32 wrote on October 15, 2019:

Thank you very much this was the answer I searched :slight_smile:

Now I can compile the software and flash it on my ESP32.

But there are also a few more “errors” / questions, maybee you can explain me this one and then I can go on my own way hopefully.

  1. The directory “ports” is the only one wich highlights a few functions --> ESP_LOG --> Symbol could not be resolved. Maybee you can explain me that?
  2. Can I change the name of application_code-> If I do this, I get an error:
    ERROR: IDF_PATH is defined in your environement, it will not point to vendors/espressif/esp-idf. To remove the variable run the command “unset IDF_PATH”. Stop.
  3. Can I delete the directory “ports”?
  4. The application_code directory is the directory, where I should put my source code (i. E. more third-party-code, …)
  5. Properties --> Build directory --> my path: amazon-freertos\vendors\espressif\boards\esp32\aws_demos
    Is this right? This is the directory with the makefile… Otherwise i get an error:make: *** No rule to make target ‘all’. Stop.

Thank you very much! This helps me a lot and i can start with my project :wink:

Feedback of my configuration: Now i dont have the “IDF_PATH”-variable on my environment at eclipse, the “PATH”-variable is set as in the project properties from espressif explained and the “build location” at “C/C++ Build” is folowing location: …\vendors\espressif\boards\esp32\aws_demos
At the first time of building I got 0 errors, 118 warnings, at the second time I got 0 errors and 0 warnings. The highlighting “Symbol ‘ESP_LOG_ERROR’ could not be resolved” is still there.

Now the Hightlights are away, Solution: I checked the Box: C/C++ General --> Indexer --> Allow heuristic resolution of includes

Edited by: AlexESP32 on Oct 15, 2019 11:43 AM

Edited by: AlexESP32 on Oct 15, 2019 12:48 PM

Edited by: AlexESP32 on Oct 15, 2019 12:58 PM

update to my situation, problems are still there unfortunately…

  1. At file demos/shadow/aws_iot_demo_shadow.c and in many others there are for example at function _shadowDeltaCallback “errorr”: The Type int32_t could not been resolved -> Can I ignore this error or should I change it to uint32_t, OR are my settings false?
  2. In directory esp-idf/components/bt/bluedroid/api there are all Header Files with error: “unresolved inclusion” of header-Files --> Where can I include this Header / How can I solve this problem?

Maybee you can help me with this, Thank you very much :wink:

Edited by: AlexESP32 on Oct 16, 2019 10:11 AM

AlexESP32 wrote on October 16, 2019:

Hello, Thank you.

  1. I tried it again with the newest github version, the “question mark” “Type ‘int32_t’ could not be resolved” is still there. Always “int32_t” - datatype are red highligthed. If I want to open it with F3, i can open it without problems but i have to “select one element from the list”, ist this an error?
    File for example: libraries/abstractions/platform/freertos/iot_metrics.c

  2. For example at freertos_plus/standard/freertos_plus_tcp/include/FreeRTOS_IP_Private.h I get for example at “ProtocolPacket_t”-union the TCPPacket_t datatype red higlighted with “Could not find symbol ‘TCPPaket_t’ in index” or at esp-idf/components/driver/include/driver/adc2_wifi_internal.h at #include “esp_err.h” --> could not find include file ‘esp_err.h’ on include paths, how can i solve that?

  3. Maybee then one of the last question: (you already explained it but i really didnt understand this)
    If i want to add can.c /can.h in esp-idf/components directory, how can i get them to include (the error: “Could not find include file “esp_err.h” on include paths”.

I think I’m getting close to get the rigth result :wink:

Again: Thank you very much for your good help!

Update to Point 3.
I “only” added it and it worked. Yeah :wink:

Edited by: AlexESP32 on Oct 16, 2019 3:15 PM

Edited by: AlexESP32 on Oct 18, 2019 1:55 PM

And one last question:
Why didnt Amazon put together there “normal” ESP-IDF from Espressif and the Amazon FreerRTOS ESP-IDF extension? In the current situation, we / I have to decide wich ESP-IDF i want to choose to start the project. Hmm…

SarenaAtAws wrote on October 16, 2019:

  1. This error does not exist in the repo as downloaded from https://github.com/aws/amazon-freertos.

  2. Related to 1. please make sure that you DO NOT have ESP-IDF set in your system’s Environment Variables. Amazon FreeRTOS code needs to use the esp-idf that we have in our repo. It has a few small compatibility changes although mostly the same.

  3. Are you speaking of this directory? vendors\espressif\boards\esp32\ports These are needed for support of the TCP layer, Network layer (wifi, ble), and security (pkcs11). I would NOT recommend removing this.

  4. You can put your code anywhere as long as you update vendors\espressif\boards\esp32\aws_demos\application_code\espressif_code\amazon-freertos-common\component.mk to reference that directory. The Espressif Makefile system takes all the code in whole directories, it does not target individual files.

  5. The build directory is the the location of the Makefile. This is the correct directory. The Makefile in vendors\espressif\boards\esp32\aws_demos is the target.

6./7. These errors do not exist in the repo as downloaded from https://github.com/aws/amazon-freertos. Please make a comparison of the configurations you have made apart from the bare minimum instructions, I have given you, off the original repo.

SarenaAtAws wrote on October 21, 2019:

So are these “issues” you are relaying to me are related to data types being highlighted in the Eclipse IDE when you open the code from the “Project Explorer” under “aws_demos”?
If the code builds successfully then you can ignore those data type highlights. These are not errors that will effect the build. We only set up the Eclipse project to build the code listed in the Makefile and NOT to perform syntax highlighting or other C language code sensing.

As I have mentioned in a previous post, the source files shown in the Eclipse “Project Explorer” are FOR REFERENCE ONLY. They are NOT an indication of the files being used for building and may be OUT OF DATE with what is actually in the repo. NONE of the highlighting you see in the project explorer is relevant to the build.

If you are confused about how Makefiles work please see: https://www.gnu.org/software/make/manual/html_node/Introduction.html

can.c/can.h is not part of the Amazon FreeRTOS version of the ESP-IDF. You will need to drop them in, in the mirror location as here: https://github.com/espressif/esp-idf/tree/master/components/driver. There may be code differences and you will need to work out the errors as they arise while building. This is the most we can guide here.

We are continually working with Espressif to integrate the changes in our version of the ESP-IDF with the their hosted version. We understand your concern and have taken the steps to ensure customers use our version with notes in the getting started guide: https://docs.aws.amazon.com/freertos/latest/userguide/getting_started_espressif.html#setup-env-esspressif