This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

converting zephyr driver led_ws2812 to run on nrf9160

In the nrfConnect SDK 1.4 there is a sample for chainable RGB LEDs ../ncs/zephyr/samples/drivers/led_ws2812

I want to use this with nrf9160 so I created nrf9160dk_nrf9160ns.overlay by copying and editing the nrf52 one:

```

/*
* Copyright (c) 2019, Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

#include "../nrf52-bindings.h"

&spi2 {
  led_strip: ws2812@0 {
    mosi-pin = <31>;
    compatible = "worldsemi,ws2812-spi";
    label = "WS2812";

    /* SPI */
    reg = <0>; /* ignored, but necessary for SPI bindings */
    spi-max-frequency = <SPI_FREQ>;

    /* WS2812 */
    chain-length = <10>; /* arbitrary; change at will */
    spi-one-frame = <ONE_FRAME>;
    spi-zero-frame = <ZERO_FRAME>;
  };
};

/ {
  aliases {
    led-strip = &led_strip;
  };
};

```

When I try to build that west gives:

```

Error: nrf9160dk_nrf9160ns.dts.pre.tmp:587.25-26 syntax error

FATAL ERROR: Unable to parse input tree

CMake Error at /Users/paul_tanner/Nordic/nrfsrc/ncs/zephyr/cmake/dts.cmake:213 (message):

  command failed with return code: 1

Call Stack (most recent call first):

  /Users/paul_tanner/Nordic/nrfsrc/ncs/zephyr/cmake/app/boilerplate.cmake:590 (include)

  /Users/paul_tanner/Nordic/nrfsrc/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)

  /Users/paul_tanner/Nordic/nrfsrc/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:35 (include_boilerplate)

  CMakeLists.txt:5 (find_package)

-- Configuring incomplete, errors occurred!

FATAL ERROR: command exited with status 1: /usr/local/bin/cmake -DWEST_PYTHON=/usr/local/opt/python/bin/python3.7 -B/Users/paul_tanner/Nordic/nrfsrc/ncs/zephyr/samples/drivers/led_ws2812/build -S/Users/paul_tanner/Nordic/nrfsrc/ncs/zephyr/samples/drivers/led_ws2812 -GNinja -DBOARD=nrf9160dk_nrf9160ns

```

Note: the file named nrf52-bindings.h does not look as though it needs to be changed so I did not rename i

Perhaps I need to do more to convert this for nrf9160?

There's a note in the README.rst: create a ``led-strip`` :ref:`devicetree alias <dt-alias-chosen>` ... I'm not sure what's needed.

Regards.

  • Hi,

    I also have a problem with compiling code after adding nrf9160dk_nrf9160ns.overlay.
    Bulding output is next:

    Maybe, you can share your example with config?

    Thanks 

  • These are my config files

    ```

    CONFIG_SPI=y
    CONFIG_LOG=y
    CONFIG_LED_STRIP=y
    CONFIG_LED_STRIP_LOG_LEVEL_DBG=y
    CONFIG_WS2812_STRIP=y

    ```

    and overlay...

    ...

    &spi3 {
    status = "okay";
    compatible = "nordic,nrf-spim";
    mosi-pin = <31>;
    miso-pin = <29>;
    sck-pin = <28>;
    led_strip: ws2812@0 {
    compatible = "worldsemi,ws2812-spi";
    label = "WS2812";

    /* SPI */
    reg = <0>; /* ignored, but necessary for SPI bindings */
    spi-max-frequency = <4000000>;

    /* WS2812 */
    chain-length = <1>; /* arbitrary; change at will */
    spi-one-frame = <0x70>;
    spi-zero-frame = <0x40>;
    };
    };

    / {
    aliases {
    led-strip = &led_strip;
    };
    };

    ```

    I am building with west

    Hope this helps.

    /P

  • Hi,

    The overlay filename is incorrect and should be nrf9160dk_nrf9160_ns.overlay.

    Afterwards, you'll likely encounter another compile error:

    -- Found devicetree overlay: /Users/lance/Developer/led_ws2812/boards/nrf9160dk_nrf9160_ns.overlay
    /Users/lance/Developer/led_ws2812/build/nrf9160dk_nrf9160_ns.dts.pre.tmp:367.32-371.5: Warning (simple_bus_reg): /soc/cryptocell-sw: missing or empty reg/ranges property
    devicetree error: 'color-mapping' is marked as required in 'properties:' in /Users/lance/ncs/zephyr/dts/bindings/led_strip/worldsemi,ws2812-spi.yaml, but does not appear in <Node /soc/peripheral@40000000/spi@b000/ws2812@0 in 'nrf9160dk_nrf9160_ns.dts.pre.tmp'>
    CMake Error at /Users/lance/ncs/zephyr/cmake/dts.cmake:251 (message):
    gen_defines.py failed with return code: 1
    Call Stack (most recent call first):
    /Users/lance/ncs/zephyr/cmake/app/boilerplate.cmake:545 (include)
    /Users/lance/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
    /Users/lance/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:35 (include_boilerplate)
    /Users/lance/Developer/led_ws2812/build/CMakeLists.txt:7 (find_package)


    -- Configuring incomplete, errors occurred!
    FATAL ERROR: command exited with status 1: /opt/nordic/ncs/v1.8.0/toolchain/bin/cmake -DWEST_PYTHON=/opt/nordic/ncs/v1.8.0/toolchain/opt/[email protected]/bin/python3.9 -B/Users/lance/Developer/led_ws2812/build -S/Users/lance/Developer/led_ws2812 -GNinja -DBOARD=nrf9160dk_nrf9160_ns -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=On -DNCS_TOOLCHAIN_VERSION:STRING=NONE '-DBOARD_ROOT:STRING=/Users/lance/Developer/renewables-evse-controller;/Users/lance/Developer/led_ws2812' -DCMAKE_BUILD_TYPE:STRING=Debug -DCONFIG_DEBUG_OPTIMIZATIONS:STRING=y -DCONFIG_DEBUG_THREAD_INFO:STRING=y -DCONF_FILE:STRING=/Users/lance/Developer/led_ws2812/prj.conf
    The terminal process terminated with exit code: 1.

    The fix as the error states is to add the color-mapping property:

    color-mapping = < LED_COLOR_ID_GREEN
    LED_COLOR_ID_RED
    LED_COLOR_ID_BLUE >;

Related