Kconfig selection error in lwm2m client project

I am working on adding a new LWM2M object (3302 Presence) to the lwm2m client project from SDK version 1.9.1. After creating and including the file "Kconfig.ipso_presence_sensor" which is located in the ipso folder, I now receive the below build errors:

warning: the default selection LWM2M_IPSO_PRESENCE_VERSION_1_0 (defined at C:\code\TWPS\src\ipso\Kconfig.ipso_presence_sensor:24, c:\code\TWPS\build\subsys\net\lib\lwm2m\Kconfig.ipso:310) of <choice> (defined at C:\code\TWPS\src\ipso\Kconfig.ipso_presence_sensor:20) is not contained in the choice

warning: the choice symbol LWM2M_IPSO_PRESENCE_VERSION_1_0 (defined at C:\code\TWPS\src\ipso\Kconfig.ipso_presence_sensor:24, c:\code\TWPS\build\subsys\net\lib\lwm2m\Kconfig.ipso:310) is defined with a prompt outside the choice

warning: the choice symbol LWM2M_IPSO_PRESENCE_VERSION_1_1 (defined at C:\code\TWPS\src\ipso\Kconfig.ipso_presence_sensor:27, c:\code\TWPS\build\subsys\net\lib\lwm2m\Kconfig.ipso:313) is defined with a prompt outside the choice

warning: the choice symbol LWM2M_IPSO_PRESENCE_VERSION_1_0 (defined at C:\code\TWPS\src\ipso\Kconfig.ipso_presence_sensor:24, c:\code\TWPS\build\subsys\net\lib\lwm2m\Kconfig.ipso:310) is defined with a prompt outside the choice

warning: the choice symbol LWM2M_IPSO_Parsing C:/code/TWPS/Kconfig
Loaded configuration 'C:/code/TWPS/build/zephyr/.config'
PRESENCE_VERSION_1_1 (defined at C:\code\TWPS\src\ipso\Kconfig.ipso_presence_sensor:27, c:\code\TWPS\build\subsys\net\lib\lwm2m\Kconfig.ipso:313) is defined with a prompt outside the choice

error: Aborting due to Kconfig warnings

Here is the file code:

#
# Copyright (c) 2021 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

config LWM2M_APP_PRESENCE
    bool
    help
      This IPSO object should be used to report detected presence


if LWM2M_APP_PRESENCE
config LWM2M_IPSO_PRESENCE_INSTANCE_COUNT
    int
    default 3
    help
      Total count of IPSO Presence instances available to the LWM2M client.

choice
    prompt "Select IPSO Presence object version"
    default LWM2M_IPSO_PRESENCE_VERSION_1_0

config LWM2M_IPSO_PRESENCE_VERSION_1_0
    bool "Version 1.0"

config LWM2M_IPSO_PRESENCE_VERSION_1_1
    bool "Version 1.1"
endchoice # IPSO Presence object version
endif # LWM2M_APP_PRESENCE
I am not sure why I am receiving this error since the file contents are formatted exactly like the file Kconfig.ipso_colour_sensor which is located in the same folder.
  • I found the solution to this issue. Below is an extract from another Zephyr forum but I have changed the file references to match my situation:

    --------------------------------------------------------------------------------------------------------------------------------------

    "What I notice, is this:

    warning: the choice symbol LWM2M_IPSO_PRESENCE_VERSION_1_0 (defined at C:\code\TWPS\src\ipso\Kconfig.ipso_presence_sensor:24, c:\code\TWPS\build\subsys\net\lib\lwm2m\Kconfig.ipso:310) is defined with a prompt outside the choice

    Those two:

    Defined at
     C:\code\TWPS\src\ipso\Kconfig.ipso_presence_sensor:24
     c:\code\TWPS\build\subsys\net\lib\lwm2m\Kconfig.ipso:310
    

    indicates that the SAME Kconfig file is sourced twice from different locations.
    Note, that when you have:

    - name: nrf
      repo-path: sdk-nrf
      path: nrf
      revision: v1.3.0
      remote: ncs   
    

    in your manifest, then the nrf/Kconfig.nrf is automatically included by the build system, so if you ALSO do something similar to:
    source "<path>/nrf/Kconfig.nrf" inside your own project, then you could end up with the same Kconfig files sourced twice, and leading to undefined behaviour."

    --------------------------------------------------------------------------------------------------------------------------------------

    I had the following code in the main project Kconfig file:

    if APP_PRESENCE
        rsource "src/ipso/Kconfig.ipso_presence_sensor"
    endif # APP_PRESENCE
    Once I removed these lines from the main project Kconfig file, the compile warnings went away and the symbols defined correctly.
Related