[IDFGH-2940] sdkconfig not defining values used in component

skibbidy
Posts: 8
Joined: Thu Mar 19, 2020 5:06 am

[IDFGH-2940] sdkconfig not defining values used in component

Postby skibbidy » Sun Mar 22, 2020 10:49 pm

Hi,

I'm using the idf_as_lib method and trying to add a component to my design based off the i2c_self_test example. However the sdkconfig does not seem to be defining the required variables.

For instance I expect CONFIG_I2C_SLAVE_ADDRESS to be defined in my main sdkconfig (as it is when I run i2c_self_test) and therefore available to my components/i2c_self_test/main/i2c_example.main, but it is not.

In fact my sdkconfig does not have ANY of the definitions used in the i2c_example_main.c defined. Am I missing a call to some cmake API?

I have poured through the build_system and the cmake files. I am trying to understand how kconfig detects and sets these variables, but it is a lot to learn.

Here is my toplevel CMakeLists.txt

Code: Select all

cmake_minimum_required(VERSION 3.5)
project(MYPROJECT C)
set(elf_file ${CMAKE_PROJECT_NAME}.elf)
set(SUPPORTED_TARGETS esp32)
include($ENV{IDF_PATH}/tools/cmake/idf.cmake)
idf_build_component(${CMAKE_HOME_DIRECTORY}/components/i2c_self_test)
idf_build_process(esp32
	COMPONENTS esp32 freertos esptool_py i2c_self_test
	SDKCONFIG ${CMAKE_BINARY_DIR}/sdkconfig
	BUILD_DIR ${CMAKE_BINARY_DIR})	    
add_executable(${elf_file} main.c)
target_link_libraries(${elf_file} idf::esp32 idf::freertos idf::spi_flash idf::i2c_self_test)
idf_build_executable(${elf_file})
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
the components/i2c_self_test/CMakeLists.txt is

Code: Select all

idf_component_register(SRC_DIRS main)
I build simply by

Code: Select all

cd build 
cmake .. -DCMAKE_TOOLCHAIN_FILE=$IDF_PATH/tools/cmake/toolchain-esp32.cmake -DTARGET=esp32 -G 'Unix Makefiles'
cmake --build .
My file structure is
-components/i2c_self_test/
-main/i2c_example_main.c
-CMakeLists.txti
CMakeLists.txt
main.c

ESP_Alvin
Posts: 211
Joined: Thu May 17, 2018 2:26 am

Re: [IDFGH-2940] sdkconfig not defining values used in component

Postby ESP_Alvin » Mon Mar 23, 2020 3:39 am

Moderator's note: edit the topic title for issue tracking, thanks.

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: [IDFGH-2940] sdkconfig not defining values used in component

Postby ESP_igrr » Mon Mar 23, 2020 5:57 am

Can you please check if i2c_example_main.c includes sdkconfig.h?

skibbidy
Posts: 8
Joined: Thu Mar 19, 2020 5:06 am

Re: [IDFGH-2940] sdkconfig not defining values used in component

Postby skibbidy » Mon Mar 23, 2020 4:01 pm

ESP_igrr wrote:
Mon Mar 23, 2020 5:57 am
Can you please check if i2c_example_main.c includes sdkconfig.h?
Thanks for the reply. Yes i2c_example_main.c has sdkconfig.h

Code: Select all

#include <stdio.h>
#include "esp_log.h"
#include "driver/i2c.h"
#include "sdkconfig.h"

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: [IDFGH-2940] sdkconfig not defining values used in component

Postby ESP_igrr » Mon Mar 23, 2020 8:33 pm

In that case, is CONFIG_I2C_SLAVE_ADDRESS present in sdkconfig.h? In sdkconfig (in the project root directory)? If not, then likely the Kconfig file where CONFIG_I2C_SLAVE_ADDRESS is defined is not seen by the build system.

skibbidy
Posts: 8
Joined: Thu Mar 19, 2020 5:06 am

Re: [IDFGH-2940] sdkconfig not defining values used in component

Postby skibbidy » Tue Mar 24, 2020 4:11 pm

ESP_igrr wrote:
Mon Mar 23, 2020 8:33 pm
In that case, is CONFIG_I2C_SLAVE_ADDRESS present in sdkconfig.h? In sdkconfig (in the project root directory)? If not, then likely the Kconfig file where CONFIG_I2C_SLAVE_ADDRESS is defined is not seen by the build system.
I've been digging into the kconfig stuff, but just to give an update it seems you are right. my components/i2c_self_test/main/kconfig.projbuild does not seem to be picked up during component build. Is there another way to include Kconfig.projbuild I am missing?

In my top level CMakeLists.txt I added

Code: Select all

 
idf_component_set_property(i2c_self_test KCONFIG_PROJBUILD ${CMAKE_HOME_DIRECTORY}/components/i2c_self_test/main/Kconfig.projbuild)
idf_build_component(${CMAKE_HOME_DIRECTORY}/components/i2c_self_test)
I've also tried manually defining it in my components/i2c_self_test/CMakeLists.txt

Code: Select all

set(KCONFIG_PROJBUILD main/Kconfig.projbuild)
idf_component_register(SRC_DIRS main)
I2C_SLAVE_ADDRESS is defined in the components/i2c_self_test/main/Kconfig.projbuild (which is taken from the example

I will continue my research and update if I find anything.

ESP_renz
Posts: 18
Joined: Tue May 14, 2019 2:41 am

Re: [IDFGH-2940] sdkconfig not defining values used in component

Postby ESP_renz » Wed Mar 25, 2020 7:11 am

Since you specified that '${CMAKE_HOME_DIRECTORY}/components/i2c_self_test' is a component directory, the IDF build expects, Kconfig.projbuild to be there, i.e. '.../i2c_self_test/Kconfig.projbuild'.

I guess the thing here is that in the examples, 'i2c_self_test' is not a component, it is a project - 'main' is a component under project 'i2c_self_test'. From the code you posted, it seems you want a component 'i2c_self_test'?

So either you point `idf_build_component` to '.../i2c_self_test/main' or move Kconfig.projbuild one level up.

Who is online

Users browsing this forum: No registered users and 203 guests