Using GPIO pins
#1
I am sure this is a basic question, but where can I get the python libraries for the Rockpro64.

I have tried the Rock64 from Laepo's github but I do not think they are right for the pro64 board.

When I did try them in Ubuntu 18.04 Bionic lxde OS build I am getting the following errors when I try to access the pins:

>>>Unable to export GPIO
>>>Unable to set GPIO Direction

Programming is fairly new to me, but I try to google everything before asking questions

Thanks

Dave
  Reply
#2
Are you running under root ?
Try it from bash under root user.
Code:
# cd /sys/class/gpio
# ### chose pin to use - pinheader pin 11 == GPIO1_C6 == should be CPU pin 54 (1*32+2*8+6)
# echo 54 > export
# ls gpio54
active_low  device  direction  edge  power  subsystem  uevent  value
# echo out > gpio54/direction
# echo 0 > gpio54/value
# echo 1 > gpio54/value
# echo 0 > gpio54/value
# echo 1 > gpio54/value
# echo in > gpio54/direction
# cat gpio54/value
# echo 54 > unexport
I left this community in Aug 2019 due to PINE64 refusal to produce/deliver ROCK64-1G version 3 after more than one year of changing statuses to "planning", "evaluating", "releasing", "availability", "estimated availability" and finally "no schedule" Angry. ROCK64 is dead platform without any advantage. Buy Raspberry PI 4 !
Away
  Reply
#3
This is what I get when I run the script

rock64@rockpro64:~/gpio$ sudo ./test.sh
active_low  device  direction  edge  power  subsystem  uevent  value
./test.sh: 5: ./test.sh: active_low: not found
0
rock64@rockpro64:~/gpio$
  Reply
#4
Oh, no. Not this way. "#" indicate interactive root prompt (but comment in scripts). Your way:
Code:
rock64@rockpro64:~/gpio$ sudo bash
root@rockpro64:~# cd /sys/class/gpio
root@rockpro64:/sys/class/gpio# echo 54 > export
root@rockpro64:/sys/class/gpio# ls gpio54
active_low  device  direction  edge  power  subsystem  uevent  value
root@rockpro64:/sys/class/gpio# echo out > gpio54/direction
root@rockpro64:/sys/class/gpio# echo 0 > gpio54/value
root@rockpro64:/sys/class/gpio# echo 1 > gpio54/value
...
This was write "interactively" so you can check pin with voltmeter or simple low power LED diode (something like this but diode on pin 11 on pinheader (marked as BCM_cpu_pin_17 in demo link, demo link uses BCM_cpu_pin_18 (pin 12 on pinheader))) ... some learning path before you.
I left this community in Aug 2019 due to PINE64 refusal to produce/deliver ROCK64-1G version 3 after more than one year of changing statuses to "planning", "evaluating", "releasing", "availability", "estimated availability" and finally "no schedule" Angry. ROCK64 is dead platform without any advantage. Buy Raspberry PI 4 !
Away
  Reply
#5
Thanks, I will try this later on today with a multimeter. I did try the above commands to make sure they work in the OS, and they do work in my rockpro64.

Thanks

ps I have done the light blinking and some other coding on the RP3 and arduinos, but getting the GPIO pins working on the Rockpro seems to be a little more involved
  Reply
#6
So I have this all figured out now. I have spoken with Allison (leapo), given her the new array values and she will be updating her python scripts to include the Rockpro64 board. Thanks for everyone's help, especially Mcerveny

Until the new python scripts get updated you can use these values in the _GPIO.py file


ROCK_valid_channels = [52,53,152,54,50,33,48,39,41,43,155,156,125,122,121,148,147,120,36,149,153,42,45,44,124,126,123,127]

BOARD_to_ROCK = [0,0,0,52,0,53,0,152,148,0,147,54,120,50,0,33,36,0,149,48,0,39,153,41,42,0,45,43,44,155,0,156,124,125,0,122,126,121,123,0,127]

BCM_to_ROCK = [43,44,52,53,152,155,156,45,42,39,48,41,124,125,148,147,124,54,120,122,123,127,33,36,149,153,121,50]
  Reply
#7
Thanks smartdave for your work.

What I do not understand? How do I get the numbers out? http://files.pine64.org/doc/rockpro64/Ro...ver0.2.png

My script


Code:
#!/usr/bin/env python

# Frank Mankel, 2018, LGPLv3 License
# Rock 64 GPIO Library for Python
# Thanks Allison! Thanks smartdave!

import R64.GPIO as GPIO
from time import sleep

print("Output Test R64.GPIO Module...")

# Set Variables
var_gpio_out = 52
#var_gpio_in = 18


# GPIO Setup
GPIO.setwarnings(True)
GPIO.setmode(GPIO.ROCK)
GPIO.setup(var_gpio_out, GPIO.OUT, initial=GPIO.HIGH)       # Set up GPIO as an output, with an initial state of HIGH
#GPIO.setup(var_gpio_in, GPIO.IN, pull_up_down=GPIO.PUD_UP)  # Set up GPIO as an input, pullup enabled

# Test Output
print("")
print("Testing GPIO Input/Output:")

while True:
       var_gpio_state = GPIO.input(var_gpio_out)       # Return State of GPIO
       if var_gpio_state == str(0):
               GPIO.output(var_gpio_out,1)                         # Set GPIO to LOW
               print("Output State IF : " + str(var_gpio_state))              # Print results
       else:
               GPIO.output(var_gpio_out,0)                         # Set GPIO to LOW
               print("Output State ELSE: " + str(var_gpio_state))
       sleep(0.5)
exit()


More infos here -> https://forum.frank-mankel.org/topic/292...-rp64-gpio (sry, only german)
Sorry for any mistakes. English is not my native language

1. Quartz64 Model B, 4GB RAM

2. Quartz64 Model A, 4GB RAM

3. RockPro64 v2.1

https://linux-nerds.org/
  Reply
#8
What do you mean get the numbers out?

I did all the conversions and came up with the following for CPU pin numbers.

[Image: rockpro64.jpg]
  Reply
#9
That's what I meant. Thank You!
Sorry for any mistakes. English is not my native language

1. Quartz64 Model B, 4GB RAM

2. Quartz64 Model A, 4GB RAM

3. RockPro64 v2.1

https://linux-nerds.org/
  Reply
#10
Quick test. All pins works except pin # 19 & 26 Undecided
Sorry for any mistakes. English is not my native language

1. Quartz64 Model B, 4GB RAM

2. Quartz64 Model A, 4GB RAM

3. RockPro64 v2.1

https://linux-nerds.org/
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  setting permissions on gpio baraqiyal 0 1,338 08-16-2022, 11:37 AM
Last Post: baraqiyal
  No Hardware Interrupts for GPIO pantera 2 5,313 05-08-2021, 10:16 AM
Last Post: Badger
  RockPro64 Fan Pins TheUnknownMuncher 7 11,421 11-14-2019, 04:06 AM
Last Post: vecnar
  SPI support in GPIO mr_rabbit 2 4,798 07-21-2019, 11:42 PM
Last Post: Wom the Bat
  DSI connector is 30 pins NOT 32 ( be aware) AmroIb 3 5,444 05-25-2019, 06:15 AM
Last Post: dukla2000
  UART pins and settings for ROCKPRO64 frewind 2 5,627 07-27-2018, 03:25 PM
Last Post: frewind

Forum Jump:


Users browsing this thread: 1 Guest(s)