nrf54l15tag overlay for BTN1

I want to program BTN1. For this I used the definition sw0 of nrf54l15 but that doesn't work (SW crash).
What overlay structure should be used?

AI suggested the overlay which I include below (AI_Overlay.txt).
Since the zephyr DTS already contains button definitions for nrf54l15 (not Tag) the second overlay suggestion should be used.
In any case I tried both, also changing the alias sw0 by another name (btn1).

I added these changes to the exiting board overlay nrf54l15dk_nrf54l15_cpuapp.overlay.

nRF54L15 Tag – BTN1 Overlay
The issue is that sw0 on the nRF54L15 DK maps to P1.13 (Button 0 on the DK), but on the nRF54L15 Tag, BTN1 is connected to P0.00. [Tag Buttons]
So if you're using the DK board target with the Tag hardware, the sw0 alias points to the wrong pin, causing a crash. You need to override it with a devicetree overlay that redefines sw0 to point to P0.00.
Here is the overlay structure you should use:

/ {
    aliases {
        sw0 = &btn1_tag;
    };

    buttons {
        compatible = "gpio-keys";
        btn1_tag: button_0 {
            gpios = <&gpio0 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
            label = "BTN1";
        };
    };
};

Key points:

    gpio0 0 maps to P0.00, which is where BTN1 is physically connected on the nRF54L15 Tag. [Tag Buttons]
    GPIO_PULL_UP | GPIO_ACTIVE_LOW is the standard configuration for active-low buttons without external pull-up resistors (consistent with nRF54L15 button hardware). [DK Buttons & LEDs]
    If the existing board DTS already defines a buttons node or sw0 alias, you may need to delete the conflicting nodes first:

/ {
    aliases {
        /delete-property/ sw0;
    };
};

/delete-node/ &{/buttons/};

/ {
    aliases {
        sw0 = &btn1_tag;
    };

    buttons {
        compatible = "gpio-keys";
        btn1_tag: button_0 {
            gpios = <&gpio0 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
            label = "BTN1";
        };
    };
};

  • Hi Leon,

    I take it that both solutions build, but you're wondering what is best? Or do neither of them build, and lead to a crash like before? 

    I would generally say that there is often no clear cut answer to this, you have to find a way to work with the dts that works for your application. These methods might both work, but the first option there is maybe a bit messy, and second one deleting the buttons node might lead to other issues.

    Could you show me the error log you got?

    For further tips and docs on how to work with dts, I would recommend the DevAcademy btw.

    Regards,

    Elfving

  • Hi Elfving,

    Perhaps some explanation first. I'm testing CS using two nrf54l15 tags. I want to modify the sample ras_initiator project (..\nrf\samples\bluetooth\channel_sounding). The nrf54l15 tag has button BTN1 on pin P0.00, which clashes with the normal nrf54l15 config.
    In nrf54l15df_nrf54l15_cpuapp.overlay, I first added the first suggestion of AI. The project did build. On initiating the button, device_is_ready(button.port) did not give an error. However the following did give an error:

    gpio_pin_interrupt_configure_dt(&button, GPIO_INT_TRIG_BOTH);

    button is defined in the usual way:

    #define BTN_DIO_DTS sw0          // BTN1
    #define BUTTON DT_ALIAS(BTN_DIO_DTS)
    static const struct gpio_dt_spec button = GPIO_DT_SPEC_GET(BUTTON, gpios);

    Then I tried the next suggestion of AI, which is included below. I got the following build error:

    -- Found BOARD.dts: C:/ncs/zephyr/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l15_cpuapp.dts
    -- Found devicetree overlay: C:/Developer/channel_sounding/ras_initiator/boards/nrf54l15dk_nrf54l15_cpuapp.overlay
    devicetree error: /aliases: undefined node label 'button1'
    CMake Error at C:/ncs/zephyr/cmake/modules/dts.cmake:314 (execute_process):
      execute_process failed command indexes:

    /*
     * Copyright (c) 2025 Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
     */

    / {
        cs_antenna_switch: cs-antenna-config {
            status = "okay";
            compatible = "nordic,bt-cs-antenna-switch";
            ant-gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>,
                    <&gpio1 12 GPIO_ACTIVE_HIGH>,
                    <&gpio1 13 GPIO_ACTIVE_HIGH>,
                    <&gpio1 14 GPIO_ACTIVE_HIGH>;
            multiplexing-mode = <0>;
        };
    };

    / {
        aliases {
            /delete-property/ sw0;
        };
    };

    /delete-node/ &{/buttons/};

    / {
        aliases {
            sw0 = &btn1_tag;
        };

        buttons {
            compatible = "gpio-keys";
            btn1_tag: button_0 {
                gpios = <&gpio0 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
                label = "BTN1";
            };
        };
    };
  • If you are referring to this, are you using the right build target? Using overlay files like what you are doing should be completely fine, but I believe there also is a "nrf54l15tag/nrf54l15/cpuapp"? If it doesnt show up in VSC, you might need to check the box for all boards being visible.

    Regards,

    Elfving

Related