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

Board.dts file modification (nRF Connect SDK v1.6.0-rc2)

Hello.
I need to add an output gpio to the dts file, I modified the board.dts file, inserting these lines in the leds section
res: res_ {
gpios = <& gpio0 17 GPIO_ACTIVE_LOW>;
label = "reset epaper";
};
but when I try to compile the application I get the report that the file has been modified externally and after reloading the project, I have an error.
Is there an editor to correctly edit the dts file?
what is the correct procedure to add a gpio in output or in input?
Thank you
Parents Reply Children
  • Put the overlay file in the same place as the Kconfig and CMakeLists.txt file and name it the same name as the board name you are building for and it will be included in the build (<board_name>.overlay). 

  • Hello,

    I created the file nrf52dk_nrf52832.overlay inside I put the following code:

    / {

    ereset: reset_ {

     gpios = <& gpio0 17 GPIO_ACTIVE_LOW>;

      label = "reset epaper";

    };

    };

    the file is in the same directory as the Kconfig and CMakeList.txt files

    Now how do I access the pin defined ereset, without using the alias as I did before.

    with the following code:

    #define ERESET_NODE DT_ALIAS (ereset)

    #if DT_NODE_HAS_STATUS (ERESET_NODE, okay)

    #define ERESET DT_GPIO_LABEL (ERESET_NODE, gpios)

    #define ERESET_PIN DT_GPIO_PIN (ERESET_NODE, gpios)

    #define ERESET_FLAGS DT_GPIO_FLAGS (ERESET_NODE, gpios)

    #else / * A build error here means your board isn't set up to blink an LED. * /

    #error "Unsupported board: ereset devicetree alias is not defined"

    #endif

    const struct device *deReset;

    void Init_gpio () {

    deReset = device_get_binding (ERESET);

    ret = gpio_pin_configure (deReset, ERESET_PIN, GPIO_OUTPUT_ACTIVE | ERESET_FLAGS);

    }

    Thanks in avance

    Fausto

  • Hi, was there a question in there? 

    Is the code not working? If so, what error are you getting?

  • Hi

    when compile i get the error

    #error "Unsupported board: ereset devicetree alias is not defined"

    Best regards

    Fausto

  • Hi, after looking more closely into this, every node in tree that represents a device is required to have the "compatible" property. 

    Here is an example defining the node with the "gpio-leds" binding.

    / {
    	eres_node {
    		compatible = "gpio-leds";
    		ereset: reset_ {
    			gpios = <&gpio0 17 GPIO_ACTIVE_LOW>;
    			label = "reset epaper"; 
    			status = "okay";
    		};
    	};
    	aliases {
    		ereset = &ereset;
    	};
    };

    You can obviously change this property, just make sure that you include all the required properties when you do. See the Bindings index for a full list of available devicetree bindings in Zephyr. 

    Best regards,

    Heidi

Related