Closed chegewara closed 4 years ago
Ok, i think i found problem.
Looks like git init
is not enough and i need to create repository on git and make at least 1 commit.
@chegewara Yes, git init
is not enough, I've seen this before, you need at least an initial commit.
Well, almost have it build. I copy/paste main.c from afr aws_demo folder i am getting different header files missing, depend on what AFR modules i add as target_link_libraries:
FAILED: CMakeFiles/my_app.dir/main/main.c.obj
../main/main.c:63:41: fatal error: iot_network_manager_private.h: No such file or directory
../amazon-freertos/libraries/freertos_plus/aws/ota/src/http/aws_iot_ota_http.c:43:40: fatal error: aws_iot_ota_agent_internal.h: No such file or directory
../amazon-freertos/libraries/freertos_plus/aws/ota/src/http/aws_iot_ota_http.c:42:31: fatal error: aws_iot_ota_agent.h: No such file or directory
compilation terminated.
[23/25] Building C object CMakeFiles/my_app.dir/amazon-freertos/demos/wifi_provisioning/aws_wifi_connect_task.c.obj
and probably more
I started with target_link_libraries from getting started, which is simple and adds only AFR::mqtt, then i added all libraries i will need eventually:
target_link_libraries(my_app PRIVATE AFR::demo_mqtt AFR::shadow AFR::ota AFR::wifi AFR::ble AFR::ble_wifi_provisioning AFR::demo_ble_numeric_comparison AFR::demo_wifi_provisioning)
but none of it can compile.
@chegewara I can confirm this issue with the newest release. My example repo does not have this problem though. I'll get back to you once I figure what's going on.
Thanks @tgsong for help and support. Yes, with your example repo i didnt have this problem, it works great.
@chegewara I found a bug introduced from a previous PR, I've raised a PR to fix it.
Thanks for trying it out and report the issue. I'll also coordinate with our CI team to add a check in our PR so that we can catch this kind of problem earlier in the future.
Thank you so much for taking care of it and fixing it so quick.
I can confirm that this fix works, thanks.
@tgsong One more thing, could you confirm that extra components in components subfolder works with this setup in CMakeLists.txt, because my app is complaining about missing header files:
# Add some extra components. IDF_EXTRA_COMPONENT_DIRS is an variable used by ESP-IDF
# to collect extra components.
get_filename_component(
EXTRA_COMPONENT_DIRS
"components/foo" ABSOLUTE
)
list(APPEND IDF_EXTRA_COMPONENT_DIRS ${EXTRA_COMPONENT_DIRS})
@chegewara Yes it does work for me. Do you also have the CMakeLists.txt file under components/foo
folder?
Yes, i have all configured, but i made mistake. Ive been trying to use get_filename_component
to load few components at the same time, but i need to use it to load 1 component at the time.
I think this is last issue i have, and it seems to be AFR issue, or i have to add component required to component CMakeLists.txt:
In file included from ../amazon-freertos/vendors/espressif/boards/esp32/aws_demos/config_files/iot_config.h:76:0,
from ../amazon-freertos/demos/include/iot_demo_logging.h:35,
from ../components/stockd_ble/example/demo_client_callbacks.c:13:
../amazon-freertos/demos/include/iot_config_common.h:35:50: fatal error: platform/iot_platform_types_freertos.h: No such file or directory
Here is my current CMakeLists.txt from component:
set(COMPONENT_ADD_INCLUDEDIRS
include
example
)
# set(COMPONENT_REQUIRES )
# set(COMPONENT_PRIV_REQUIRES )
set(COMPONENT_SRCDIRS source example)
register_component()
Anyway, i think i will use ESP_LOGX in my components instead.
Thanks for all help and support @tgsong
I have one more question, it is related to my last post and issue with compiling.
Now, when AFR is used as component, and i have my own components in folder components
, how i can add for example AFR::wifi
to my component dependency or linking?
Let say i have CMakeLists.txt like this:
set(COMPONENT_ADD_INCLUDEDIRS
include
example
)
# set(COMPONENT_REQUIRES )
# set(COMPONENT_PRIV_REQUIRES )
set(COMPONENT_SRCDIRS source example)
register_component()
I cant use add_library
and target_link_libraries
in my component because i get error.
I have second project with AFR as component, without my own components this time and this is error i have (which i didnt have with you demo repo):
../amazon-freertos/libraries/freertos_plus/aws/ota/src/mqtt/aws_iot_ota_mqtt.c:39:40: fatal error: aws_iot_ota_agent_internal.h: No such file or directory
...
../amazon-freertos/libraries/freertos_plus/aws/ota/src/http/aws_iot_ota_http.c:43:40: fatal error: aws_iot_ota_agent_internal.h: No such file or directory
with:
target_link_libraries(project_name PRIVATE AFR::demo_mqtt AFR::shadow AFR::ota AFR::wifi AFR::ble AFR::ble_wifi_provisioning AFR::demo_ble_numeric_comparison AFR::demo_wifi_provisioning)
@chegewara How are you using target_link_libraries
function? I did try this myself and it was working, here's my CMakeLists.txt for the component,
# include paths of this components.
set(COMPONENT_ADD_INCLUDEDIRS include)
# source files of this components.
set(COMPONENT_SRCDIRS src)
# Alternatively, use COMPONENT_SRCS to specify source files explicitly
# set(COMPONENT_SRCS src/foo.c)
# add this components, this will define a CMake library target.
register_component()
# standard CMake function can be used to specify dependencies. ${COMPONENT_TARGET} is defined
# from esp-idf when you call register_component, by default this should be the folder name.
target_link_libraries(${COMPONENT_TARGET} PRIVATE AFR::mqtt)
and within foo.c I'm able to include the header.
Looks like i had to copy/paste too many config files from aws to custom configs folder. At least with project that is not using additional components.
With project that is using additional components i have bigger problem, because i have to modify AFR::ble. My modifications are rather big, because i implemented BLE client API, which is missing in AFR. It is including update existing API with ble scan and adding gattc API.
I have solution, but it is only partially solution. I could use esp32 BLE library or even esp-idf client API, but i have to use AFR::wifi in my own component and here is a problem. Sorry for being so lame, but i didnt have to work with cmake before and using cmake with AFR seems to be for pro.
EDIT this is not related to AFR as component, but with old folders setup i can build esp32 project with make, but i cant with cmake:
In file included from .../vendors/espressif/boards/esp32/aws_demos/application_code/components/stockd_m5stack/source/display_system_menu.c:15:0:
.../libraries/abstractions/wifi/include/aws_wifi.h:41:37: fatal error: types/iot_network_types.h: No such file or directory
compilation terminated.
line 15:
#include "aws_wifi.h"
which is one of the most important header file (iot_wifi.h in master branch).
and eventually this one:
.../vendors/espressif/boards/esp32/aws_demos/application_code/components/stockd_ble/source/ble_advertising_data_parse.c:15:30: fatal error: iot_demo_logging.h: No such file or directory
including:
#include "iot_demo_logging.h"
but here may be my issue, because i am trying to use demo logging.
Looks like you mentioned few things, I'm trying to summarize it here, let me know if I missed anything
AFR::wifi
in your own component but ran into build error.
A: Looks like you're using the 201906.00
version because aws_wifi.h
only exist in that version, and we renamed it in following release. I did try to link to AFR::wifi
in the foo
component in my example repo, it's building fine and I was able to do #include <iot_wifi.h>
. I couldn't tell exactly what you're trying to do from your error message, would you mind uploading your code to a repo? It would be easier to explain from there.Hi @tgsong
This is my current CMakeLists.txt for component that needs to use AFR::wifi:
set(COMPONENT_ADD_INCLUDEDIRS
include example // <--- my own component files
)
set(COMPONENT_PRIV_REQUIRES bt ) // <--- use esp-idf ble
set(COMPONENT_SRCDIRS source example) // <--- my own component files
register_component()
No you don't need to modify it, just do the normal target_link_libraries(${COMPONENT_TARGET} PRIVATE AFR::wifi)
in your component CMake file and you should be able to use it. One thing I noticed is that the error is from vendors/espressif/boards/esp32/aws_demos/application_code/components/stockd_m5stack/source/display_system_menu.c
, this is something we don't have in our codebase. Did you add this component yourself? I was referring to the components sitting outside of our codebase, so this might be something different though.
Yes, it is my own component with pre release-1.5. I have issue with adding components in cmake, but my code is compiling with GNU make. Now i am trying to move my components from vendors/espressif/boards/esp32/aws_demos/application_code/components/
to AFR as component and master branch and im having exactly the same issues compiling with cmake.
I can create private repository, can i invite you to check what i am doing wrong?
This is error when i moved to AFR as component with master:
../amazon-freertos/vendors/espressif/boards/esp32/aws_demos/config_files/iot_config.h:76:31: fatal error: iot_config_common.h: No such file or directory
../components/stockd_m5stack/source/display_system_menu.c:15:22: fatal error: iot_wifi.h: No such file or directory
Sure, I can check it for you. Can you share the link?
Ok, i am missing this line in component CMakeLists.txt: https://github.com/tgsong/amazon-freertos-examples/blob/master/components/foo/CMakeLists.txt#L14
It is not shown in this docs: https://docs.aws.amazon.com/freertos/latest/userguide/getting_started_espressif.html#getting_started_espressif_cmake_project
Thanks for help, again.
Now i have another issue, but it will be fixed in AFR. I am using some functions from AFR in my component, which are in this demo folder: https://github.com/aws/amazon-freertos/tree/master/demos/network_manager
No CMakeLists.txt in it, so i cant add it to my component CMakeLists.txt with target_link_libraries
.
@chegewara Network manger is in AFR::demo_base
, see here. However, network manager is not supposed to be here, we will probably move it in the future, but for now you can link to this as a work around.
I'll work with our doc team to add the use of target_link_libraries
for components.
Thanks, i hope this will help others with AFR as component.
With your help I fixed almost all issues i have. What can you tell about that one:
[7/107] Building C object amazon-freertos/esp-idf/stockd_m5stack/CMakeFiles/idf_comp..._/__/amazon-freertos/libraries/freertos_plus/aws/ota/src/http/aws_iot_ota_http.c.ob
FAILED: amazon-freertos/esp-idf/stockd_m5stack/CMakeFiles/idf_component_stockd_m5stack.dir/__/__/amazon-freertos/libraries/freertos_plus/aws/ota/src/http/aws_iot_ota_http.c.obj
/home/chegewara/esp/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc -DESP_PLATFORM -DGCC_NOT_5_2_0=0 -DHAVE_CONFIG_H -DIDF_VER=\"v3.3-163-g601a03e\" -DMBEDTLS_CONFIG_FILE=\"/home/chegewara/demos/afr-submodule/hello_world/amazon-freertos/vendors/espressif/boards/esp32/components/mbedtls/port/include/mbedtls/esp_config.h\" -I../aws-configs -I../components/stockd_m5stack/include -I../components/stockd_m5stack/example -Iconfig -I../amazon-freertos/vendors/espressif/esp-idf/components/nvs_flash/include -I../amazon-freertos/vendors/espressif/esp-idf/components/spi_flash/include -I../amazon-freertos/vendors/espressif/boards/esp32/components/mbedtls/port/include -I../amazon-freertos/libraries/3rdparty/mbedtls/include -I../amazon-freertos/libraries/3rdparty/mbedtls/include/mbedtls -I../amazon-freertos/libraries/abstractions/pkcs11/mbedtls -I../amazon-freertos/vendors/espressif/esp-idf/components/fatfs/src -I../amazon-freertos/vendors/espressif/esp-idf/components/wear_levelling/include -I../amazon-freertos/vendors/espressif/esp-idf/components/sdmmc/include -I../amazon-freertos/vendors/espressif/esp-idf/components/driver/include -I../amazon-freertos/vendors/espressif/esp-idf/components/esp_ringbuf/include -I../components/tft -I../components/spidriver -I../amazon-freertos/vendors/espressif/esp-idf/components/bt/include -I../amazon-freertos/vendors/espressif/esp-idf/components/bt/bluedroid/api/include/api -I../components/ws2812 -I../amazon-freertos/vendors/espressif/esp-idf/components/esp32/include -I../amazon-freertos/vendors/espressif/boards/esp32/components/freertos_tcpip/tcpip_adapter/include -I../amazon-freertos/libraries/freertos_plus/standard/freertos_plus_tcp/include -I../amazon-freertos/libraries/freertos_plus/standard/freertos_plus_tcp/source/portable/Compiler/GCC -I../amazon-freertos/vendors/espressif/esp-idf/components/esp_event/include -I../amazon-freertos/vendors/espressif/esp-idf/components/log/include -I../amazon-freertos/vendors/espressif/esp-idf/components/efuse/include -I../amazon-freertos/vendors/espressif/esp-idf/components/efuse/esp32/include -I../amazon-freertos/vendors/espressif/esp-idf/components/newlib/platform_include -I../amazon-freertos/vendors/espressif/esp-idf/components/newlib/include -I../amazon-freertos/vendors/espressif/esp-idf/components/vfs/include -I../amazon-freertos/vendors/espressif/boards/esp32/components/freertos/include -I../amazon-freertos/freertos_kernel/include -I../amazon-freertos/freertos_kernel/portable/ThirdParty/GCC/Xtensa_ESP32/include -I../amazon-freertos/vendors/espressif/boards/esp32/aws_demos/config_files -I../amazon-freertos/vendors/espressif/esp-idf/components/heap/include -I../amazon-freertos/vendors/espressif/esp-idf/components/soc/esp32/include -I../amazon-freertos/vendors/espressif/esp-idf/components/soc/include -I../amazon-freertos/demos/include -I../amazon-freertos/demos/network_manager -I../amazon-freertos/vendors/espressif/esp-idf/components/app_update/include -I../amazon-freertos/vendors/espressif/esp-idf/components/bootloader_support/include -I../amazon-freertos/vendors/espressif/esp-idf/components/pthread/include -I../amazon-freertos/vendors/espressif/boards/esp32/components/freertos_tcpip/ethernet/include -I../amazon-freertos/vendors/espressif/boards/esp32/components/freertos_tcpip/smartconfig_ack/include -I../amazon-freertos/libraries/c_sdk/standard/common/include -I../amazon-freertos/libraries/abstractions/platform/include -I../amazon-freertos/libraries/abstractions/platform/freertos/include -I../amazon-freertos/libraries/abstractions/secure_sockets/include -I../amazon-freertos/libraries/c_sdk/standard/common/include/private -I../amazon-freertos/demos/dev_mode_key_provisioning/include -I../amazon-freertos/libraries/freertos_plus/standard/pkcs11/include -I../amazon-freertos/libraries/abstractions/pkcs11/include -I../amazon-freertos/libraries/freertos_plus/standard/utils/include -I../amazon-freertos/libraries/freertos_plus/standard/crypto/include -I../amazon-freertos/libraries/c_sdk/standard/ble/include -I../amazon-freertos/libraries/c_sdk/standard/serializer/include -I../amazon-freertos/libraries/3rdparty/tinycbor -I../amazon-freertos/libraries/abstractions/ble_hal/include -I../amazon-freertos/libraries/abstractions/wifi/include -I../amazon-freertos/libraries/c_sdk/standard/mqtt/include -I../amazon-freertos/libraries/c_sdk/standard/https/include -I../amazon-freertos/libraries/freertos_plus/aws/ota/include -I../amazon-freertos/libraries/c_sdk/aws/shadow/include -isystem ../amazon-freertos/libraries/3rdparty/pkcs11 -mlongcalls -mlongcalls -Og -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -nostdlib -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -ggdb -std=gnu99 -Wno-old-style-declaration -Wno-maybe-uninitialized -MD -MT amazon-freertos/esp-idf/stockd_m5stack/CMakeFiles/idf_component_stockd_m5stack.dir/__/__/amazon-freertos/libraries/freertos_plus/aws/ota/src/http/aws_iot_ota_http.c.obj -MF amazon-freertos/esp-idf/stockd_m5stack/CMakeFiles/idf_component_stockd_m5stack.dir/__/__/amazon-freertos/libraries/freertos_plus/aws/ota/src/http/aws_iot_ota_http.c.obj.d -o amazon-freertos/esp-idf/stockd_m5stack/CMakeFiles/idf_component_stockd_m5stack.dir/__/__/amazon-freertos/libraries/freertos_plus/aws/ota/src/http/aws_iot_ota_http.c.obj -c ../amazon-freertos/libraries/freertos_plus/aws/ota/src/http/aws_iot_ota_http.c
../amazon-freertos/libraries/freertos_plus/aws/ota/src/http/aws_iot_ota_http.c:43:40: fatal error: aws_iot_ota_agent_internal.h: No such file or directory
compilation terminated.
[8/107] Building C object amazon-freertos/esp-idf/stockd_m5stack/CMakeFiles/idf_comp..._/__/amazon-freertos/libraries/freertos_plus/aws/ota/src/mqtt/aws_iot_ota_cbor.c.ob
ninja: build stopped: subcommand failed.
BTW i sent you invite to private repository
EDIT i think i had to apply this fix https://github.com/aws/amazon-freertos/pull/1655
@chegewara Does it work for you after applying the fix as you mentioned?
Thanks.
Hi, that fix works with new project and with my project that does not have additional components. With project that has additional components i am having such weird errors so im embarrassed to post logs. Im getting this:
../main/main.c:177:9: error: implicit declaration of function 'SYSTEM_Init' [-Werror=implicit-function-declaration]
if( SYSTEM_Init() == pdPASS )
and errors about implicit declarations BT functions from esp-idf, which i dont understand.
SYSTEM_Init
is defined here: https://github.com/aws/amazon-freertos/blob/31c4d9b5175a88c0578337cf63b3ce85a96a2e5f/libraries/freertos_plus/standard/utils/include/iot_system_init.h#L33
Does your main.c
not include iot_system_init.h
? If it does, can you get the preprocessed file to confirm that the declaration of this function does exist in the preprocessed file?
Thanks.
Thanks, i dont know why i didnt have that header and BT errors also gone when i uncomment out headers (why i did have it commented out?).
Now all is compiling to the end, but cant link my components:
/home/chegewara/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -lstockd_m5stack
/home/chegewara/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -lspidriver
/home/chegewara/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -lws2812
/home/chegewara/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -ltftspi
/home/chegewara/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -ltft
/home/chegewara/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -lble
All components are included in CMakeLists.txt:
get_filename_component(
EXTRA_COMPONENT_DIRS
"components/spidriver" ABSOLUTE
)
list(APPEND IDF_EXTRA_COMPONENT_DIRS ${EXTRA_COMPONENT_DIRS})
get_filename_component(
EXTRA_COMPONENT_DIRS
"components/stockd_m5stack" ABSOLUTE
)
list(APPEND IDF_EXTRA_COMPONENT_DIRS ${EXTRA_COMPONENT_DIRS})
get_filename_component(
EXTRA_COMPONENT_DIRS
"components/tft" ABSOLUTE
)
list(APPEND IDF_EXTRA_COMPONENT_DIRS ${EXTRA_COMPONENT_DIRS})
get_filename_component(
EXTRA_COMPONENT_DIRS
"components/ws2812" ABSOLUTE
)
list(APPEND IDF_EXTRA_COMPONENT_DIRS ${EXTRA_COMPONENT_DIRS})
Pick one of the component, say spidriver, and check if it is being built. This will help to isolate whether:
Thanks.
It seems that all components are build, at least all libNAME.a are in place in build/subfolders.
EDIT the exact path for components is:
build/amazon-freertos/esp-idf/$COMPONENT_NAME/
@chegewara Sorry for getting back to you late, I didn't see your invite to the repo in my email. Can you check again?
If you can find the static libraries containing those functions, then it's somehow not linked to your application code. Theoretically ESP-IDF does this automatically, so this shouldn't happen unless you link manually. Did you manually specify any of those components in target_link_libraries
?
EDIT if you do want to access those targets, the underlying name is in this form idf_component_<component>
, for example, idf_component_foo
, idf_component_spidriver
. But generally you don't need to do this because ESP-IDF already does this.
@chegewara Sorry for getting back to you late, I didn't see your invite to the repo in my email. Can you check again?
No worries about that.
Did you manually specify any of those components in target_link_libraries?
Indeed, i have all libraries included and this was the last one problem, now my project is building.
Thanks for all your support and sorry for being so lame.
To make full image of building AFR as component, i am trying to add sdkconfig.defaults
to my build system, but adding it in project top folder seems to not work. Any idea?
@chegewara Have you checked this? https://github.com/aws/amazon-freertos/issues/832#issuecomment-514756608 and related PR https://github.com/aws/amazon-freertos/pull/987. There were some discussions at that time about sdkconfig
. But looks like I forgot to add it into our document, I'll provide this to our doc team.
Thanks, it works perfectly. In addition i can say that partition-table.csv can be put in project top folder without changing in menuconfig. https://github.com/aws/amazon-freertos/issues/832#issuecomment-516236030
Edit: In the custom sdkconfig it's now necessary to specify the partition table, e.g.:
Yes, you can make it pointing to any location in your own sdkconfig file.
This is still an issue. Not in documentation about making sure to git init and commit getting_started_espressif_cmake_project had me pulling my hair out for a couple hours.
With easy to setup project thanks to this docs https://docs.aws.amazon.com/freertos/latest/userguide/getting_started_espressif.html#getting_started_espressif_cmake_project i am trying to start with hello-world example from esp-idf. Project is simple so preparing CMakeLists.txt should be easy:
but im getting error: