>From the advice from Mark and the further reading that I did, I think I am
doing the right things.

 

I can set the status light from u-boot, but cannot configure the pin in
OpenBSD.

 

The attached console log shows the results of my testing with annotations in
caps.

U-Boot SPL 2017.07 (Aug 15 2017 - 07:39:48)
DRAM: 512 MiB
Trying to boot from MMC1


U-Boot 2017.07 (Aug 15 2017 - 07:39:48 -0600) Allwinner Technology

CPU:   Allwinner H3 (SUN8I 1680)
Model: Xunlong Orange Pi One
DRAM:  512 MiB
MMC:   SUNXI SD/MMC: 0
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   phy interface0
eth0: ethernet@1c30000
starting USB...
USB0:   USB EHCI 1.00
USB1:   USB OHCI 1.0
scanning bus 0 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot:  0


THE FOLLOWING WORKS AND TURNS ON AND OFF THE RED STATUS LIGHT ON THE BOARD

=> gpio set PA15
gpio: pin PA15 (gpio 15) value is 1
=> gpio clear PA15
gpio: pin PA15 (gpio 15) value is 0
=> gpio set PA15
gpio: pin PA15 (gpio 15) value is 1
=> gpio status -a PA15
Bank PA:
PA15: output: 1 [ ]



=> boot
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
reading /sun8i-h3-orangepi-one.dtb
14436 bytes read in 25 ms (563.5 KiB/s)
Found EFI removable media binary efi/boot/bootarm.efi
reading efi/boot/bootarm.efi
65448 bytes read in 39 ms (1.6 MiB/s)
## Starting EFI application at 42000000 ...
Scanning disks on usb...
Scanning disks on mmc...
MMC Device 1 not found
MMC Device 2 not found
MMC Device 3 not found
Found 5 disks
>> OpenBSD/armv7 BOOTARM 0.9
boot>
booting sd0a:/bsd: 3887120+167224+496676 [281343+90+515936+242597]=0x558184

OpenBSD/armv7 booting ...
arg0 0xc0858184 arg1 0x0 arg2 0x48000000
Allocating page tables
freestart = 0x40859000, free_pages = 128935 (0x0001f7a7)
IRQ stack: p0x40887000 v0xc0887000
ABT stack: p0x40888000 v0xc0888000
UND stack: p0x40889000 v0xc0889000
SVC stack: p0x4088a000 v0xc088a000
Creating L1 page table at 0x4085c000
Mapping kernel
Constructing L2 page tables
undefined page pmap [ using 1040424 bytes of bsd ELF symbol table ]
board type: 0
Copyright (c) 1982, 1986, 1989, 1991, 1993
        The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2017 OpenBSD. All rights reserved.  https://www.OpenBSD.org

OpenBSD 6.1-current (GENERIC) #36: Wed Aug 16 00:34:41 MDT 2017
    dera...@armv7.openbsd.org:/usr/src/sys/arch/armv7/compile/GENERIC
real mem  = 536870912 (512MB)
avail mem = 517414912 (493MB)
mainbus0 at root: Xunlong Orange Pi One
cpu0 at mainbus0: ARM Cortex-A7 r0p5 (ARMv7)
cpu0: DC enabled IC enabled WB disabled EABT branch prediction enabled
cpu0: 32KB(32b/l,2way) I-cache, 32KB(64b/l,4way) wr-back D-cache
cortex0 at mainbus0
sxiccmu0 at mainbus0
psci0 at mainbus0
simplebus0 at mainbus0: "soc"
sxiccmu1 at simplebus0
sxipio0 at simplebus0: 94 pins
sxipio1 at simplebus0: 12 pins
sximmc0 at simplebus0
sdmmc0 at sximmc0: 4-bit, sd high-speed, mmc high-speed, dma
ehci0 at simplebus0
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 configuration 1 interface 0 "Generic EHCI root hub" rev 2.00/1.00 
addr 1
ehci1 at simplebus0
usb1 at ehci1: USB revision 2.0
uhub1 at usb1 configuration 1 interface 0 "Generic EHCI root hub" rev 2.00/1.00 
addr 1
sxidog0 at simplebus0
com0 at simplebus0: ns16550, no working fifo
com0: console
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
scsibus0 at sdmmc0: 2 targets, initiator 0
sd0 at scsibus0 targ 1 lun 0: <SD/MMC, SL16G, 0080> SCSI2 0/direct removable
sd0: 15193MB, 512 bytes/sector, 31116288 sectors
vscsi0 at root
scsibus1 at vscsi0: 256 targets
softraid0 at root
scsibus2 at softraid0: 256 targets
boot device: sd0
root on sd0a (da77471dbf10221d.a) swap on sd0b dump on sd0b
WARNING: preposterous clock chip time
WARNING: CHECK AND RESET THE DATE!
Automatic boot in progress: starting file system checks.
/dev/sd0a (da77471dbf10221d.a): file system is clean; not checking
/dev/sd0l (da77471dbf10221d.l): file system is clean; not checking
/dev/sd0d (da77471dbf10221d.d): file system is clean; not checking
/dev/sd0f (da77471dbf10221d.f): file system is clean; not checking
/dev/sd0g (da77471dbf10221d.g): file system is clean; not checking
/dev/sd0h (da77471dbf10221d.h): file system is clean; not checking
/dev/sd0k (da77471dbf10221d.k): file system is clean; not checking
/dev/sd0j (da77471dbf10221d.j): file system is clean; not checking
/dev/sd0e (da77471dbf10221d.e): file system is clean; not checking
setting tty flags
pf enabled
starting network
reordering libraries: done.
starting early daemons: syslogd pflogd ntpd.
starting RPC daemons:.
savecore: no core dump
checking quotas: done.
clearing /tmp

SETTING UP THE GPIO PINS
I AM PRETTY SURE MY SYNTAX IS CORRECT BUT AM PUZZLED BY THE INVALID ARGUMENT 
RESPONSE TO UNSET

In rc.securelevel, setting gpio.
PA15
gpioctl: GPIOPINUNSET: Invalid argument
gpioctl: GPIOPINSET: Operation not supported by device
PD14
gpioctl: GPIOPINSET: Operation not supported by device



kern.securelevel: 0 -> 1
creating runtime link editor directory cache.
preserving editor files.
starting network daemons: sshd smtpd sndiod.
starting local daemons: cron.
Tue Aug 22 11:30:38 PDT 2017

OpenBSD/armv7 (orangepibsd.graf.lan) (console)

login: sysadmin
Password:
Last login: Tue Aug 22 11:23:47 on console
OpenBSD 6.1-current (GENERIC) #36: Wed Aug 16 00:34:41 MDT 2017

Welcome to OpenBSD: The proactively secure Unix-like operating system.

Please use the sendbug(1) utility to report bugs in the system.
Before reporting a bug, please try to reproduce it with the latest
version of the code.  With bug reports, please try to ensure that
enough information to reproduce the problem is enclosed, and if a
known fix for it exists, include that as well.

You have new mail.
$ su
Password:
# gpioctl gpio0
/dev/gpio0: 0 pins
# gpioctl
usage: gpioctl [-q] device pin [0 | 1 | 2 | on | off | toggle]
       gpioctl [-q] device pin set [flags] [name]
       gpioctl [-q] device pin unset
       gpioctl [-q] device attach device offset mask [flag]
       gpioctl [-q] device detach device


RC.SECURELEVEL

# more /etc/rc.securelevel

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



# /usr/sbin/gpioctl /dev/gpio0 15 unset
gpioctl: GPIOPINUNSET: Operation not permitted
# /usr/sbin/gpioctl /dev/gpio0 15 set out status_led
gpioctl: GPIOPINSET: Operation not permitted
# man gpioctl
GPIOCTL(8)                  System Manager's Manual                 GPIOCTL(8)

NAME
     gpioctl - control GPIO devices

SYNOPSIS
     gpioctl [-q] device pin [0 | 1 | 2 | on | off | toggle]
     gpioctl [-q] device pin set [flags] [name]
     gpioctl [-q] device pin unset
     gpioctl [-q] device attach device offset mask [flag]
     gpioctl [-q] device detach device

DESCRIPTION
     The gpioctl program allows manipulation of GPIO (General Purpose
     Input/Output) device pins.  Such devices can be either part of the
     chipset or embedded CPU, or a separate chip.  The usual way of using GPIO
     is to connect some simple devices such as LEDs and 1-wire thermal sensors
     to its pins.

     Each GPIO device has an associated device file in the /dev directory.
     device can be specified with or without the /dev prefix.  For example,
     /dev/gpio0 or gpio0.

     GPIO pins can be either "read" or "written" with the values of logical 0
     or 1.  If only a pin number is specified on the command line, the pin
     state will be read from the GPIO controller and displayed.  To write to a
     pin, a value must be specified after the pin number.  Values can be
     either 0 or 1.  A value of 2 has a special meaning: it "toggles" the pin,
     i.e. changes its state to the opposite.  Instead of the numerical values,
     the word on, off, or toggle can be used.

     Only pins that have been configured at securelevel 0, typically during
     system startup, are accessible once the securelevel has been raised.
     Pins can be given symbolic names for easier use.  Besides using
     individual pins, device drivers that use GPIO pins can be attached to a
     gpio(4) device using the gpioctl command.

     The following configuration flags are supported by the GPIO framework.
     Note that not all the flags can be supported by the particular GPIO
     controller.

           in      input direction
           out     output direction
           inout   bi-directional
           od      open-drain output
           pp      push-pull output
           tri     tri-state (output disabled)
           pu      internal pull-up enabled
           pd      internal pull-down enabled
           iin     invert input
           iout    invert output

     When attaching an I2C device, if the flag argument is set to 0x01, the
     order of the SDA and SCL signals is reversed (see gpioiic(4)).

     When executed with only the gpio(4) device name as argument, gpioctl
     reads information about the GPIO device and displays it.  At securelevel
     0 the number of physically available pins is displayed, at higher
     securelevels the number of configured (set) pins is displayed.

     The options are as follows:

     -q      Operate quietly i.e. nothing is printed to stdout.

FILES
     /dev/gpiou  GPIO device unit u file.

EXAMPLES
     Configure pin 20 to have push-pull output:

           # gpioctl gpio0 20 set out pp

     Write logical 1 to pin 20:

           # gpioctl gpio0 20 1

     Attach a onewire(4) bus on a gpioow(4) device on pin 4:

           # gpioctl gpio0 attach gpioow 4 0x01

     Detach the gpioow0 device:

           # gpioctl gpio0 detach gpioow0

     Configure pin 5 as output and name it error_led:

           # gpioctl gpio0 5 set out error_led

     Toggle the error_led:

           # gpioctl gpio0 error_led 2

SEE ALSO
     gpio(4)

HISTORY
     The gpioctl command first appeared in OpenBSD 3.6.

AUTHORS
     The gpioctl program was written by Alexander Yurchenko
     <gra...@openbsd.org>.  Device attachment was added by Marc Balmer
     <mbal...@openbsd.org>.

OpenBSD 6.1                   September 11, 2015                   OpenBSD 6.1
#
#
#

Reply via email to