Use custom Kconfig options in defconfig of custom board

Greetings,

I have defined some custom Kconfig options for our custom FW ( custom device and board) which I use in my prj.config file successfully (Located in C:/ncs/project_dir/project_dir/src and also some subdirectories of this) and was wondering which is the easiest way to use these Kconfig options in my custom_board.defconfig file which is in a different directory.

I tried adding the following lines in the Kconfig file inside the board directory as shown below:

<project_dir>/boards/arm/<custom_board_name>/Kconfig : 

source "C:/nsc/<project_dir>/<project_dir>/src/Kconfig"
source "C:/nsc/<project_dir>/<project_dir>/src/modules/Kconfig"
source "C:/nsc/<project_dir>/<project_dir>/src/protocols/Kconfig"
source "C:/nsc/<project_dir>/<project_dir>/src/sensors/Kconfig"

Ideally, I want to include the custom Kconfig files I have in my source code directory using a preprocessor token such as:

source "${PROJECT_SOURCE_DIR}/src/Kconfig"

source "${PROJECT_SOURCE_DIR}/src/modules/Kconfig"

source "${PROJECT_SOURCE_DIR}/src/protocols/Kconfig"

source "${PROJECT_SOURCE_DIR}/src/sensors/Kconfig"

Am I going about this the wrong way? How can I use these Kconfig custom options I created inside my custom_board.defconfig file?

Thank you very much and I look forward to hearing from you!

Best regards,

Stavros

  • Hi Amanda,

    Thank you very much for the quick response.

    I may have not been able to explain myself correctly.

    What I actually meant is that I have already created custom configuration options(Kconfig files for different modules inside my source code directory) but I want to use those same custom configuration options in my custom_board Kconfig file and .defconfg file.

    Here is my project's file structure just to give you a more clear picture:

    +- <Project_directory>
    +- boards
    | +- arm
    | +- <custom_board>
    | +- Kconfig
    | +- Kconfig.board
    | +- Kconfig.defconfig
    | +- <custom_board>.dts
    | +- <custom_board>.defconfig
    +- src
    +- Kconfig
    +- Kconfig.app_info
    +- Kconfig.fw_version
    +- Kconfig.hw_version
    +- modules
    | +- Kconfig
    | +- Kconfig.something
    | +- Kconfig.something_else
    +- protocols
    | +- Kconfig
    | +- Kconfig.something
    | +- Kconfig.something_else
    +- sensors
    | +- Kconfig
    | +- Kconfig.something
    | +- Kconfig.something_else

    Every Kconfig file in the "src" directory has been created and has all the custom configuration options needed for our application. Also we have successfully included them in the prj.conf file and the application code. The application has been built successfully and works great using these new custom configuration options we created.

    Now I want to use these custom configuration options(that already exist in the src directory and subdirectories) in the <custom_board>.defconfig file so I tried using a command like:

    source "$(PROJECT_DIR)/feel_v2_fw/src/Kconfig"
    in the <Project_directory>/boards/arm/<custom_board>/Kconfig.defconfig and the <Project_directory>/boards/arm/<custom_board>/Kconfig file inside the board directory but with no success.
    How do I include a file in my Kconfig that is in a different directory (not a sub directory).
    I want include the Kconfig custom options I have already created:
    <Project_directory>/src/Kconfig , <Project_directory>/src/modules/Kconfig , <Project_directory>/src/protocols/Kconfig , <Project_directory>/src/sensors/Kconfig
    in the <Project_directory>/boards/arm/<custom_board>/Kconfig
    I want to include the options residing in the src folder and subfolders without having to rewrite a multitude of files again in the Kconfig.defconfig file
    what Kconfig command or preprocessor directive do I need to use to successfully include them in my <Project_directory>/boards/arm/<custom_board>/Kconfig file which is in a different directory?
    Thank you very much and I look forward to hearing from you!
    Best regards,
    Stavros
  • Hi, 

    If you mean to have them in the app, you need to source them from their src/Kconfig file. 

    https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/Kconfig shows how to source other Kconfigs but the board should not be sourcing the application's Kconfig files, the board should source its own files only, the application should source its own files only. 

    -Amanda H.

  • Hi, 

    You can use rsource "src/Kconfig" instead.

    An rsource statement is available for including files specified with a relative path

Related