Adding config.overlay to the west build command

We have a Waveshare display and a npm1300dk and I wanted to know the proper way to add the npm1300's config.overlay file, generated by nrfConnect's PowerUp, to the west command line? 

I could just copy the contents of the config.overlay file to the nrf52840dk_nrf52840.overlay, but that doesn't seem like the right way to do it...

I assume adding it to the command line is the best way to do it or should it be added to CMakeLists?

currently we use: west build -b nrf52840dk_nrf52840 -d build52840  -- -DSHIELD=waveshare_epaper_gdey0213b74

Parents
  • Hi mej7000,

    You can add this extra argument to the west build command: -DDTC_OVERLAY_FILE=your_file.overlay

    It is also explained in these documentations:

    Building, Flashing and Debugging (nordicsemi.com)

    Devicetree HOWTOs (nordicsemi.com)

    Hieu

  • docs.nordicsemi.com/.../build-flash-debug.html
    "Notice how the -- only appears once, even though multiple CMake arguments are given. All command-line arguments to west build after a -- are passed to CMake."

    PS C:\nrf\npm1300_fuel_gauge_2> west build -b nrf52840dk_nrf52840 -d build52840 -- -DSHIELD=waveshare_epaper_gdey0213b74 -DDTC_OVERLAY_FILE=npm1300config.overlay
    -- west build: generating a build system
    Loading Zephyr default modules (Zephyr base).
    -- Application: C:/nrf/npm1300_fuel_gauge_2
    -- CMake version: 3.21.0
    -- Using NCS Toolchain 2.6.20240304.889616714482 for building. (C:/ncs/toolchains/cf2149caf2/cmake)
    -- Found Python3: C:/ncs/toolchains/cf2149caf2/opt/bin/python.exe (found suitable version "3.9.13", minimum required is "3.8") found components: Interpreter
    -- Cache files will be written to: C:/ncs/v2.6.1/zephyr/.cache
    -- Zephyr version: 3.5.99 (C:/ncs/v2.6.1/zephyr)
    -- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
    -- Board: nrf52840dk_nrf52840
    -- Shield(s): waveshare_epaper_gdey0213b74
    -- Found host-tools: zephyr 0.16.5 (C:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.16.5 (C:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk)
    -- Found Dtc: C:/ncs/toolchains/cf2149caf2/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
    -- Found BOARD.dts: C:/ncs/v2.6.1/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts
    -- Found devicetree overlay: C:/ncs/v2.6.1/zephyr/boards/shields/waveshare_epaper/waveshare_epaper_gdey0213b74.overlay
    -- Found devicetree overlay: npm1300config
    <command-line>: fatal error: npm1300config: No such file or directory
    compilation terminated.
    CMake Error at C:/ncs/v2.6.1/zephyr/cmake/modules/extensions.cmake:3901 (message):
    failed to preprocess devicetree files (error code 1):
    C:/ncs/v2.6.1/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts;C:/ncs/v2.6.1/zephyr/boards/shields/waveshare_epaper/waveshare_epaper_gdey0213b74.overlay;npm1300config
    Call Stack (most recent call first):
    C:/ncs/v2.6.1/zephyr/cmake/modules/dts.cmake:215 (zephyr_dt_preprocess)
    C:/ncs/v2.6.1/zephyr/cmake/modules/zephyr_default.cmake:129 (include)
    C:/ncs/v2.6.1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
    C:/ncs/v2.6.1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
    CMakeLists.txt:8 (find_package)


    -- Configuring incomplete, errors occurred!
    ←[91mFATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\cf2149caf2\opt\bin\cmake.EXE' -DWEST_PYTHON=C:/ncs/toolchains/cf2149caf2/opt/bin/python.exe '-BC:\nrf\npm1300_fuel_gauge_2\build52840' -GNinja -DBOARD=nrf52840dk_nrf52840 -DSHIELD=waveshare_epaper_gdey0213b74 -DDTC_OVERLAY_FILE=npm1300config .overlay '-SC:\nrf\npm1300_fuel_gauge_2'
    ←[0m
    PS C:\nrf\npm1300_fuel_gauge_2>

  • It looks like there is a difference between Linux bash and Windows shell/command line. On Windows, you also need to enclose the file name in quotes.

    In my tested just now, this command works on Windows:

    west build -b nrf52840dk_nrf52840 -- -DDTC_OVERLAY_FILE="temp.overlay"

  • Thanks! Yes, that works, but creates an additional question... I can't seem to specify more than one overlay file successfully...

    docs.zephyrproject.org/.../howtos.html

    The CMake variable DTC_OVERLAY_FILE contains a space- or semicolon-separated list of overlay files to use. If DTC_OVERLAY_FILE specifies multiple files, they are included in that order by the C preprocessor.

    west build -b nrf52840dk_nrf52840 -d build52840  -- -DSHIELD=waveshare_epaper_gdey0213b74 -DDTC_OVERLAY_FILE="app.overlay";"config.overlay" 

    I thought I might be able to add additional overlay files with this syntax, but the declaration in config.overlay is causing: "error: '__device_dts_ord_DT_N_NODELABEL_npm1300_ek_charger_ORD' undeclared here (not in a function)"

    I can add my config.overlay code to the app.overlay and it compiles fine, so I have a solution... Just trying to understand it all completely

Reply
  • Thanks! Yes, that works, but creates an additional question... I can't seem to specify more than one overlay file successfully...

    docs.zephyrproject.org/.../howtos.html

    The CMake variable DTC_OVERLAY_FILE contains a space- or semicolon-separated list of overlay files to use. If DTC_OVERLAY_FILE specifies multiple files, they are included in that order by the C preprocessor.

    west build -b nrf52840dk_nrf52840 -d build52840  -- -DSHIELD=waveshare_epaper_gdey0213b74 -DDTC_OVERLAY_FILE="app.overlay";"config.overlay" 

    I thought I might be able to add additional overlay files with this syntax, but the declaration in config.overlay is causing: "error: '__device_dts_ord_DT_N_NODELABEL_npm1300_ek_charger_ORD' undeclared here (not in a function)"

    I can add my config.overlay code to the app.overlay and it compiles fine, so I have a solution... Just trying to understand it all completely

Children
Related