gpio on orangepi one

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

gpio on orangepi one

Stephen Graf
I continue to bang away at my orangepi one.

 

Now my problem is how to set up the gpio. First off, the boot shows multiple
gpio devices:

 

ampintc0 at simplebus0 nirq 160, ncpu 4

sxirtc0 at simplebus0

gpio0 at sxipio0: 32 pins

gpio1 at sxipio0: 32 pins

gpio2 at sxipio0: 32 pins

gpio3 at sxipio0: 32 pins

gpio4 at sxipio0: 32 pins

gpio5 at sxipio0: 32 pins

gpio6 at sxipio0: 32 pins

gpio7 at sxipio1: 32 pins

agtimer0 at mainbus0: tick rate 24000 KHz

 

One would be sufficient!

 

Next I have not been able to determine how to set up the pin definitions.
The documentation that I read says it has to be done at run level 0, but how
that happens is still a mystery to me.

 

Currently all the devices show no pins available:

 

# gpioctl gpio0

/dev/gpio0: 0 pins

# gpioctl gpio1

/dev/gpio1: 0 pins

# gpioctl gpio2

/dev/gpio2: 0 pins

# gpioctl gpio3

/dev/gpio3: 0 pins

# gpioctl gpio4

/dev/gpio4: 0 pins

# gpioctl gpio5

/dev/gpio5: 4 pins

# gpioctl gpio6

/dev/gpio6: 0 pins

# gpioctl gpio7

 

Any and all guidance is most appreciated.

Reply | Threaded
Open this post in threaded view
|

Re: gpio on orangepi one

Mark Kettenis
> From: "Stephen Graf" <[hidden email]>
> Date: Sat, 19 Aug 2017 18:29:59 -0700
>
> I continue to bang away at my orangepi one.
>
> Now my problem is how to set up the gpio. First off, the boot shows multiple
> gpio devices:
>
> ampintc0 at simplebus0 nirq 160, ncpu 4
> sxirtc0 at simplebus0
> gpio0 at sxipio0: 32 pins
> gpio1 at sxipio0: 32 pins
> gpio2 at sxipio0: 32 pins
> gpio3 at sxipio0: 32 pins
> gpio4 at sxipio0: 32 pins
> gpio5 at sxipio0: 32 pins
> gpio6 at sxipio0: 32 pins
> gpio7 at sxipio1: 32 pins
> agtimer0 at mainbus0: tick rate 24000 KHz
>
> One would be sufficient!

You'll need to have some understanding of ow the hardware works to use
the gpio pins.  The pins are subdivided in groups of up to 32 pins.
These groups correspond to letters in the hardware documentation.  So
for example, hardware pin PA0 corresponds to pin 0 on gpio0 and
hardware pin PF6 corresponds to pin 6 on gpio5.  Not all pins in each
group actually exist.  Many pins are multiplexed.  Only pins that are
configured as gpio_in or gpio_out are available through the gpio(4)
interface.  Pins used by device drivers (for example the pin used to
detect whether an SD card is inserted) are not made available either.

> Next I have not been able to determine how to set up the pin definitions.
> The documentation that I read says it has to be done at run level 0, but how
> that happens is still a mystery to me.

Put something like:

  /usr/sbin/gpioctl gpio7 24 set out green_led

in /etc/rc.securelevel.  On my Banana Pi this makes pin PH24 available
and configures it as an output to control the green LED that is on the
board.

Be very careful what you put in there.  Configuring the wrong pin
might damage your hardware.

Reply | Threaded
Open this post in threaded view
|

Re: gpio on orangepi one

Stephen Graf
In reply to this post by Stephen Graf
Thank you for your informative response.
The comment about being careful was initially not followed enough.  I tested
with PC7 as it was on the header and not defined in the dtb.
The mmc got corrupted and I had to reload the system.  I then checked the
schematic and found that PC7 was used on the eMMC.

However, I didn't have much success with gpio so far.

I set up rc.securelevel for a couple of pins without success.
I checked the dtb by de-compiling into a dts and comparing with the orangepi
one schematic.

from the openbsd dtb (dts)

                      led_pins@0 {
                                pins = "PA15";
                                function = "gpio_out";
                                linux,phandle = <0x2b>;
                                phandle = <0x2b>;


In rc.securelevel:

echo "In rc.securelevel, setting gpio."
#
# PA15 is status led defined in dtb
echo "PA15"
/usr/sbin/gpioctl gpio0 15 unset
/usr/sbin/gpioctl gpio0 15 set out status_led
#
# PD10 is on pin 12 of the header, not defined in dtb
echo "PD10"
/usr/sbin/gpioctl gpio3 10 set out hdr_pin_12

From the console log:

clearing /tmp
In rc.securelevel, setting gpio.
PA15
gpioctl: GPIOPINUNSET: Invalid argument
gpioctl: GPIOPINSET: Operation not supported by device
PD10
gpioctl: GPIOPINSET: Operation not supported by device
kern.securelevel: 0 -> 1

I tried without the PA15 unset but got the same result.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Mark
Kettenis
Sent: Sunday, August 20, 2017 5:14 AM
To: [hidden email]
Cc: [hidden email]
Subject: Re: gpio on orangepi one

> From: "Stephen Graf" <[hidden email]>
> Date: Sat, 19 Aug 2017 18:29:59 -0700
>
> I continue to bang away at my orangepi one.
>
> Now my problem is how to set up the gpio. First off, the boot shows
> multiple gpio devices:
>
> ampintc0 at simplebus0 nirq 160, ncpu 4
> sxirtc0 at simplebus0
> gpio0 at sxipio0: 32 pins
> gpio1 at sxipio0: 32 pins
> gpio2 at sxipio0: 32 pins
> gpio3 at sxipio0: 32 pins
> gpio4 at sxipio0: 32 pins
> gpio5 at sxipio0: 32 pins
> gpio6 at sxipio0: 32 pins
> gpio7 at sxipio1: 32 pins
> agtimer0 at mainbus0: tick rate 24000 KHz
>
> One would be sufficient!

You'll need to have some understanding of ow the hardware works to use the
gpio pins.  The pins are subdivided in groups of up to 32 pins.
These groups correspond to letters in the hardware documentation.  So for
example, hardware pin PA0 corresponds to pin 0 on gpio0 and hardware pin PF6
corresponds to pin 6 on gpio5.  Not all pins in each group actually exist.
Many pins are multiplexed.  Only pins that are configured as gpio_in or
gpio_out are available through the gpio(4) interface.  Pins used by device
drivers (for example the pin used to detect whether an SD card is inserted)
are not made available either.

> Next I have not been able to determine how to set up the pin definitions.
> The documentation that I read says it has to be done at run level 0,
> but how that happens is still a mystery to me.

Put something like:

  /usr/sbin/gpioctl gpio7 24 set out green_led

in /etc/rc.securelevel.  On my Banana Pi this makes pin PH24 available and
configures it as an output to control the green LED that is on the board.

Be very careful what you put in there.  Configuring the wrong pin might
damage your hardware.


Reply | Threaded
Open this post in threaded view
|

Re: gpio on orangepi one

Stephen Graf
In reply to this post by Stephen Graf
Sorry but my paste of the rc.securelevel messed up in last message.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of
Stephen Graf
Sent: Sunday, August 20, 2017 3:15 PM
To: 'Mark Kettenis' <[hidden email]>
Cc: [hidden email]
Subject: Re: gpio on orangepi one

Thank you for your informative response.
The comment about being careful was initially not followed enough.  I tested
with PC7 as it was on the header and not defined in the dtb.
The mmc got corrupted and I had to reload the system.  I then checked the
schematic and found that PC7 was used on the eMMC.

However, I didn't have much success with gpio so far.

I set up rc.securelevel for a couple of pins without success.
I checked the dtb by de-compiling into a dts and comparing with the orangepi
one schematic.

from the openbsd dtb (dts)

                      led_pins@0 {
                                pins = "PA15";
                                function = "gpio_out";
                                linux,phandle = <0x2b>;
                                phandle = <0x2b>;


In rc.securelevel:

echo "In rc.securelevel, setting gpio."
#
# PA15 is status led defined in dtb
echo "PA15"
/usr/sbin/gpioctl gpio0 15 unset
/usr/sbin/gpioctl gpio0 15 set out status_led
 # PD10 is on pin 12 of the header, not defined in dtb
echo "PD10"
/usr/sbin/gpioctl gpio3 10 set out hdr_pin_12

From the console log:

clearing /tmp
In rc.securelevel, setting gpio.
PA15
gpioctl: GPIOPINUNSET: Invalid argument
gpioctl: GPIOPINSET: Operation not supported by device
PD10
gpioctl: GPIOPINSET: Operation not supported by device
kern.securelevel: 0 -> 1

I tried without the PA15 unset but got the same result.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Mark
Kettenis
Sent: Sunday, August 20, 2017 5:14 AM
To: [hidden email]
Cc: [hidden email]
Subject: Re: gpio on orangepi one

> From: "Stephen Graf" <[hidden email]>
> Date: Sat, 19 Aug 2017 18:29:59 -0700
>
> I continue to bang away at my orangepi one.
>
> Now my problem is how to set up the gpio. First off, the boot shows
> multiple gpio devices:
>
> ampintc0 at simplebus0 nirq 160, ncpu 4
> sxirtc0 at simplebus0
> gpio0 at sxipio0: 32 pins
> gpio1 at sxipio0: 32 pins
> gpio2 at sxipio0: 32 pins
> gpio3 at sxipio0: 32 pins
> gpio4 at sxipio0: 32 pins
> gpio5 at sxipio0: 32 pins
> gpio6 at sxipio0: 32 pins
> gpio7 at sxipio1: 32 pins
> agtimer0 at mainbus0: tick rate 24000 KHz
>
> One would be sufficient!

You'll need to have some understanding of ow the hardware works to use the
gpio pins.  The pins are subdivided in groups of up to 32 pins.
These groups correspond to letters in the hardware documentation.  So for
example, hardware pin PA0 corresponds to pin 0 on gpio0 and hardware pin PF6
corresponds to pin 6 on gpio5.  Not all pins in each group actually exist.
Many pins are multiplexed.  Only pins that are configured as gpio_in or
gpio_out are available through the gpio(4) interface.  Pins used by device
drivers (for example the pin used to detect whether an SD card is inserted)
are not made available either.

> Next I have not been able to determine how to set up the pin definitions.
> The documentation that I read says it has to be done at run level 0,
> but how that happens is still a mystery to me.

Put something like:

  /usr/sbin/gpioctl gpio7 24 set out green_led

in /etc/rc.securelevel.  On my Banana Pi this makes pin PH24 available and
configures it as an output to control the green LED that is on the board.

Be very careful what you put in there.  Configuring the wrong pin might
damage your hardware.