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.

GPIO high at board start, want to disable

Featured Replies

Hello,

 

  I have a GPIO pin that is high when starting the board.  I am trying to force it low.  

Taking a look at gpio readall

 

 +-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |  12 |   8 |   SDA.1 | ALT5 | 0 |  3 || 4  |   |      | 5v      |     |     |
 |  11 |   9 |   SCL.1 | ALT5 | 0 |  5 || 6  |   |      | 0v      |     |     |
 |   6 |   7 | GPIO. 7 | ALT3 | 0 |  7 || 8  | 0 | ALT3 | TxD     | 15  | 13  |
 |     |     |      0v |      |   |  9 || 10 | 0 | ALT3 | RxD     | 16  | 14  |
 |   1 |   0 | GPIO. 0 | ALT3 | 0 | 11 || 12 | 0 | ALT3 | GPIO. 1 | 1   | 16  |
 |   0 |   2 | GPIO. 2 | ALT3 | 0 | 13 || 14 |   |      | 0v      |     |     |
 |   3 |   3 | GPIO. 3 | ALT3 | 0 | 15 || 16 | 0 | ALT3 | GPIO. 4 | 4   | 15  |
 |     |     |    3.3v |      |   | 17 || 18 | 0 | ALT3 | GPIO. 5 | 5   | 68  |
 |  64 |  12 |    MOSI | ALT3 | 0 | 19 || 20 |   |      | 0v      |     |     |
 |  65 |  13 |    MISO | ALT3 | 0 | 21 || 22 | 0 | ALT3 | GPIO. 6 | 6   | 2   |
 |  66 |  14 |    SCLK | ALT3 | 0 | 23 || 24 | 0 | ALT3 | CE0     | 10  | 67  |
 |     |     |      0v |      |   | 25 || 26 | 0 | ALT3 | CE1     | 11  | 71  |
 |  19 |  30 |   SDA.0 | ALT3 | 0 | 27 || 28 | 0 | ALT3 | SCL.0   | 31  | 18  |
 |   7 |  21 | GPIO.21 |  OUT | 1 | 29 || 30 |   |      | 0v      |     |     |
 |   8 |  22 | GPIO.22 | ALT3 | 0 | 31 || 32 | 0 | ALT3 | GPIO.26 | 26  | 354 |
 |   9 |  23 | GPIO.23 | ALT3 | 0 | 33 || 34 |   |      | 0v      |     |     |
 |  10 |  24 | GPIO.24 | ALT3 | 0 | 35 || 36 | 0 | ALT3 | GPIO.27 | 27  | 356 |
 |  17 |  25 | GPIO.25 | ALT3 | 0 | 37 || 38 | 0 | ALT3 | GPIO.28 | 28  | 21  |
 |     |     |      0v |      |   | 39 || 40 | 0 | ALT3 | GPIO.29 | 29  | 20  |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+


it can be seen the following line is active:

+-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+
| BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
|   7 |  21 | GPIO.21 |  OUT | 1 | 29 || 30 |   |      | 0v      |     |     |


I've tried to force it off, but doesn't seem to work:

 

/dts-v1/;
/plugin/;

/ {
        compatible = "allwinner,sun8i-h3";

        fragment@0 {

                target = <&pio>;
                __overlay__ {
                        poweroff_pins:poweroff_pins {
                        allwinner,pins = "PA7";
                        allwinner,function = "gpio_out";

                        };
                };
        };

        fragment@1 {

                target-path = "/";
                __overlay__ {
                        poweroff: poweroff {
                        compatible = "gpio-poweroff";
                        gpios = <&pio 0 7 1>;
                        };
                };
        };
};


Is this the wrong approach? 

Thanks!

18 hours ago, jgauthier said:

Is this the wrong approach?

What kind of board are you using ?

Your "gpio" tool seems to have been compiled for the wrong board, because PA7 should be named GPIO7 not GPIO21 ...

Try using gpio sysfs :

echo 7 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio7/direction 
echo 0 > /sys/class/gpio/gpio7/value 

 

  • Author

Wow, I neglected to mention it's a banana pi m2z. 

 

I can check on the build of gpio, but that doesn't change my attempt with the dts config does it? 

  • Author

@martinayotte Well,  I think it's more complicated than that.  I'm using the WiringPI from here for the BPI series here:

https://github.com/BPI-SINOVOIP/BPI-WiringPi2/tree/master/wiringPi

 

in wiringPi/wiringPi_bpi.c it looks for /var/lib/bananapi/board.sh

In there I have this entry:

BOARD=bpi-m2z

 

That said,  sysfs doesn't work.  

echo 7 > /sys/class/gpio/export
-bash: echo: write error: Device or resource busy

 

I can access the GPIO pins with the gpio utility using the physical pin:

gpio toggle 21

 

I don't believe (but I also don't know) that the DTS uses the wiringpi interface. It seems much lower level than that.  So, I would think in the DTS file I can access it by gpio 7, which is the BCM ID. PA7, specifically.

  • Author

Here's what I got:

gpiochip0: GPIOs 0-223, parent: platform/1c20800.pinctrl, 1c20800.pinctrl:
 gpio-1   (                    |sysfs               ) in  hi IRQ
 gpio-7   (                    |vcc-af-csi          ) out lo
 gpio-110 (                    |vdd-1v5-csi         ) out hi
 gpio-203 (                    |host-wakeup         ) in  lo
 gpio-204 (                    |shutdown            ) out hi
 gpio-205 (                    |device-wakeup       ) out higpiochip1: GPIOs 352-383, parent: platform/1f02c00.pinctrl, 1f02c00.pinctrl:
 gpio-353 (                    |vdd-cpux            ) out lo
 gpio-355 (                    |power               ) in  hi IRQ ACTIVE LOW
 gpio-358 (                    |usb0_id_det         ) in  hi IRQ
 gpio-359 (                    |reset               ) out hi ACTIVE LOW
 gpio-362 (                    |bananapi-m2-zero:red) out lo

 

Thanks, I hope this means more to you than it does to me ;)

34 minutes ago, jgauthier said:

gpio-7   (                    |vcc-af-csi          ) out lo

That is why you're getting "Device or resource busy" ...

 

Are you sure we are talking about an Armbian build here ? Because "vcc-af-csi" means this pin is related to a CSI camera...

  • Author

Yes, it's an armbian build,  I built it myself.  I've built a DTS package to enable the CSI camera.  Unfortunately, I do not have access to that DTS configuration to look at it right now and confirm what pin it's using.   I'll have to look it up later and post it.  Thanks!

 

  • Author

@martinayotte You're correct.

reg_vcc_af_csi: vcc-af-csi {
    compatible = "regulator-fixed";
    regulator-name = "vcc-af-csi";
    regulator-min-microvolt = <2800000>;
    regulator-max-microvolt = <2800000>;
    gpio = <&pio 0 7 GPIO_ACTIVE_HIGH>; /* PA7 */
    enable-active-high;
    regulator-boot-on;
    regulator-always-on;
};


PA7 is assigned as HIGH, to the CSI connector.

My issue is that due to forgetting about this, I've pulled PA7 out for another custom use.  That was very bad.  PA7 will have to be reassigned for my custom use.

 

While this did not go where I thought, you helped me look at stuff and figure out my problem.  I set this CSI connector up months ago and completely forgot about it.

Thank you!

 

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.