Build Matter Light Bulb using ZAP auto generated files dynamically

  

        Sorry for the inconvenience!

        I have downloaded V2.8.0 nRF SDK, and I use this command to build light bulb project:

        west build -p always --build-dir nrf/samples/matter/light_bulb/build -b nrf52840dk_nrf52840 nrf/samples/matter/light_bulb

        It can build pass! But I noticed that bulb project used zap generated files, I want to auto generate zap files in the build flow(that means generating code files by light_bulb.zap dynamically), could you tell me how can I do?

        Furthermore, I have noticed the macro("BYPASS_IDL") in cmake file is TRUE, so it skip auto generate flow, how can I set it to FALSE?

        chip_configure_data_model(app
               INCLUDE_SERVER
               BYPASS_IDL
               GEN_DIR ${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/zap-generated
               ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/light_bulb.zap
        )

BR

Chuan

        

  • Hi Chuan,

    But I noticed that bulb project used zap generated files, I want to auto generate zap files in the build flow(that means generating code files by light_bulb.zap dynamically), could you tell me how can I do?

    The zap files are generated with the "west zap generate" command. You cannot combine this and the west build command into one, but you can create a script that runs both commands.

    Furthermore, I have noticed the macro("BYPASS_IDL") in cmake file is TRUE, so it skip auto generate flow, how can I set it to FALSE?

    You can omit BYPASS_IDL from chip_configure_data_model, and it should not bypass it.

    Best regards,
    Marte

  •  

            Thanks for your support!

            I have omit BYPASS_IDL as blow:

    chip_configure_data_model(app
                   INCLUDE_SERVER
                   GEN_DIR ${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/zap-generated
                   ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/light_bulb.zap
            )

            But meet build error:

    ninja: error: '../../src/default_zap/light_bulb.matter', needed by 'gen/app-codegen/cpp-app/app/PluginApplicationCallbacks.h', missing and no known rule to make it
    [11/23] Generating new Factory Data...
    [INFO] Generating SPAKE2+ Verifier...
    [WARNING] KEY password has not been provided. It means that DAC key is not encrypted.
    [INFO] Validating JSON with schema...
    [INFO] Validate OK
    FAILED: _sysbuild/sysbuild/images/light_bulb-prefix/src/light_bulb-stamp/light_bulb-build

            Can you have a try? If the same case, could you please tell me the reason and how to fix this error?

    BR

    Chuan

  • Hi Chuan,

    When you remove BYPASS_IDL, the chip_configure_data_model() function tries to generate source files from a .matter IDL file, but it cannot find the .matter file. You must provide it using the IDL option, for example:

    chip_configure_data_model(app
        INCLUDE_SERVER
        GEN_DIR ${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/zap-generated
        ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/light_bulb.zap
        IDL ${CMAKE_CURRENT_SOURCE_DIR}/src/light_bulb.matter
    )

    Please note that you need to have zap-cli installed, and the installed version must match the version used in the SDK you are using. If not, you will get an error when it tries to generate the zap files.
    You can install it by running the following in modules/lib/matter:

    python3 scripts/setup/nrfconnect/get_zap.py -l <location_path> -o

    Best regards,
    Marte

Related