Trying to compile for a second time, the esp_spiffs.c can’t find esp_spiffs.h. I’m guessing since I hardcoded the location of esp_spiffs.h in my main.c that esp_spiffs.c can’t use that.
../amazon-freertos/vendors/espressif/esp-idf/components/spiffs/esp_spiffs.c
../amazon-freertos/vendors/espressif/esp-idf/components/spiffs/esp_spiffs.c:15:10: fatal error: esp_spiffs.h: No such file or directory
#include "esp_spiffs.h"
What do I try next?
I have read I should update my compiler with the location of the espressif components, but I haven’t found how to do that?
If I do update this location in my compiler, will this resolve this issue for when I move forward to add more of espressif’s components?
Some details if needed…
spiffs demo is located at
/amazon-freertos/vendors/espressif/esp-idf/examples/storage/spiffs/main/spiffs_example_main.c
my CMAKEList.txt
cmake_minimum_required(VERSION 3.13)
project(freertos_spiffs)
# Tell IDF build to link against this target.
set(IDF_EXECUTABLE_SRCS
"/src/main.c"
"/amazon-freertos/vendors/espressif/esp-idf/components/spiffs/esp_spiffs.c"
)
set(IDF_PROJECT_EXECUTABLE hello_world_app)
# Add FreeRTOS as a subdirectory. AFR_BOARD tells which board to target.
set(AFR_BOARD espressif.esp32_devkitc CACHE INTERNAL "")
add_subdirectory(amazon-freertos)
# Link against the mqtt library so that we can use it. Dependencies
# are transitively linked.
target_link_libraries(
hello_world_app
PRIVATE
AFR::core_mqtt
)
What I observe from your CMakeLists.txt is that you’re mostly setting variables related to AFR and ESP-IDF, and it looks like you’re relying on the cmake configuration in amazon-freertos to build the project from those variables. For your current configuration, I suspect there may be an IDF variable related to the include path that you have to set to add more directories to it.
When I’ve used cmake before for my own sources, I’ve generally set the sources for the target with add_executable, the include path with target_include_directories, and any libraries with target_link_libraries. Perhaps if you are still having difficulty with your current cmake configuration, then you can consider a similar approach and gather your source files and include directories in one cmake file, while linking AFR as a library.
For those looking to do the same. I had to change two files. first the esp32/CMakeLists.txt file at around line 125. I added the spiffs include files for the kernal to find. Second the idf::spiffs in my CMakeLists.txt shown above.
@shubhamkulkarni97 When I want to add other components in the future, what do I put in the spiffs part of idf::spiffs? Is this based off what folder name it’s in or something else?
Ideally the change that you mentioned in esp32/CMakeLists.txt should not be required.
Regarding your question of adding other components, you should add idf::component_name in target_link_libraries. It is same as the folder name of the component.