Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

NanoPi Neo 2 - set input pull-up via Device Tree

Featured Replies

I had a hard time to figure out how to set the input pull-up on GPIO 1 of the NanoPi neo2. In the end it appeared to be extremely simple, but in order to help other beginners I like to share how I accomplished it.

1) I created a dts file with the input pull-up definition for GPIO 1
2) I compiled the dts with the "armbian-add-overlay" tool
3) rebooted the NanoPi Neo2 

That's it.

The dts file can be placed anywhere on the Nanopi Neo2 eg. /home/pi/sun50i-h5-nanopi-neo2-pullup.dts
 

nano /home/pi/sun50i-h5-nanopi-neo2-pullup.dts


The content of sun50i-h5-nanopi-neo2-pullup.dts looks like this:

 

/dts-v1/;                                                                       
/plugin/;                                                                       
                                                                                
/ {                                                                             
        compatible = "allwinner,sun50i-h5";                                     
                                                                                
          fragment@0 {                                                          
            target = <&pio>;                                                    
            __overlay__ {                                                       
              input_0: input_0 {                                                
                pins = "PA1";                                                   
                function = "gpio_in";                                           
                bias-pull-up;                                                   
              };                                                                
            };                                                                  
          };                                                                    
                                                                                
};   


note that PIN "PA1" = GPIO 1 (BCM) 

now save the file (press ctrl-x, press y, press enter)

 

start the "armbian-add-overlay" tool
 

sudo armbian-add-overlay /home/pi/sun50i-h5-nanopi-neo2-pullup.dts

when the tool finishes, you will have to reboot to apply the changes.

That's it, I hope you save some time with this monkey proof explanation.


PS:
it is easy to convert BCM to PIN, e.g. GPIO 200 (BCM) = PIN "PG8" 
The letters A - G have the following values A=0, B=1, C=2 ... G=6
The value of the letter must be multiplied by 32, so G = 6x32 = 192
The value behind the letter is added to the value of the letter, in this case for PG8: 192 + 8 = 200
So BCM GPIO 200 is the same pin as PG8.
To derive the PIN from BCM you just do it the other way around.

e.g.
GPIO 6 (BCM) = PIN "PA6"
GPIO 201 (BCM) = PIN "PG9"

First of all thank you for this post; it helped a lot.

 

But, I've just went through a similar journey and wonder if this is a complete solution. Your 'fragment@0' does what it intends but in my experience it was only half of the solution. My gleanings through various sources indicates that to actually accomplish something a second piece of the puzzle (for arguments sake 'fragment@1') is needed and it must reference the name (or alias?) of 'fragment@0'. I guess the reference could come from some other dts file but, normally, from, at least, another overlay file, or within the same overlay file.

 

The point I'm trying to make is that 'fragment@0' on its own did little. I found that setting 'bias-pull-up' will not result in seeing '1' on a gpio pin without another device-tree node referencing that pin. As far as I can see something like https://forum.armbian.com/topic/6723-gpio-keys-mainline-linux/ with 'fragment@1' referencing 'fragment@0' (through the line 'pinctrl-0 = <&gpio_keys>;' in that instance) only then would apply the 'bias-pull-up'.

 

I'm not advocating for how this appears to me at the moment. I'd rather use a gpio on its own if possible (perhaps there's a 'compatible = XXX' that I haven't found yet).

 

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.