1 1
Rolf Bakker

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

Recommended Posts

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"

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
1 1