Remove unused leds and buttons from nrf9160dk board

Hello,

We are using our custom board which has the nRF9160 SOC. We have taken as a starting development point Asset Tracker 2 (AT2) which has 4 leds and 4 buttons defined. I need to remap and remove some of the leds, also I want to do the same with the buttons definition.

First, it comes to my mind the first doubt. 

By the moment I created an overlay file inside of boards folder, which reconfigures the HW definition, but I continue compiling for nrf9160dk board. Does it have sense to create a custom board for our project based on nrf9160dk?

If I use  "/delete-node/ leds;" instruction, it suppose to delete all leds node previously defined. If I only define leds0 node, the compiler complains about led1, led2 and led3 aliases. Is there any way to remove those aliases?

I have the same issue with buttons node, also, I try to remap the button ports, It is not working, the following picture explain how I did it:

Maybe here the problem is the usage of nrf9160dk as my board, instead of creating a new one... I do not know. What do you recommend?

Regards

  • Hi,

    You need to delete the aliases to the LED nodes you have removed. For example, using the existing nrf9160dk_nrf9160_ns.overlay file from the application:

    /	{
    	/delete-node/ leds;
    
    	leds0 {
    		compatible = "gpio-leds";
    		status = "okay";
    		label = "LED0";
    		led0: led_0 {
    			status = "okay";
    			gpios = <&gpio0 2 0>;
    			label = "Green LED 1";
    		};
    	};
    
    	aliases {
    		/delete-property/ led1;
    		/delete-property/ led2;
    		/delete-property/ led3;
    	};
    
    };
    

    Please be aware that you are removing LEDs used by the application, which might lead to unexpected behavior. I recommend changing the code so the LEDs you remove are not used in the code,

    Best regards,
    Marte

  • Hello,

    I am aware of that, we are changing the application too. Thanks for the advice.

    I did it like this:

    /	{
    	/delete-node/ leds;
    	leds0 {
    		compatible = "gpio-leds";
    		status = "okay";
    		label = "LED0";
    		led0: led_0 {
    			status = "okay";
    			gpios = <&gpio0 28 0>;
    			label = "Green LED 1";
    		};
    	};
    
    	leds1 {
    		compatible = "gpio-leds";
    		status = "okay";
    		label = "LED1";
    		led1: led_1 {
    			gpios = <&gpio0 31 0>;
    			label = "Green LED 2";
    		};
    	};
    	aliases {
    		/delete-property/ led0;
    		/delete-property/ led1;
    		/delete-property/ led2;
    		/delete-property/ led3;
    	};
    };

    However, I still have the definitions here:

    Moreover, the new ones appear here:

    Therefore, I am not sure if it is been applied well or not.

    does it correct?

    Regards

  • Hi,

    The devicetree view in the nRF Connect for VS Code extension gets information from the board files in the SDK, not the generated board file. You can see this by clicking on one of the properties, for example pin 4, and it will open nrf9160dk_nrf9160_common.dts located in zephyr/boards/arm/nrf9160dk_nrf9160.
    However, if you look at the generated devicetree, build/zephyr/zephyr.dts, you will see that there is no LED2 property, nor is pin4 used for anything.

    So your overlay is correct.

    Best regards,
    Marte

Related