Rock64 : Les premiers pas …

Pour faire suite à mon post : https://www.cyber-neurones.org/2019/03/rock64-2-capteurs-de-debits-deau-debitmetre/ . A noter qu’il faut consommer plus de 0.075 L/s ou 4,5 L/min pour avoir une mesure fiable. Mon but est de mesure un outil qui fait dans les 50 L/min ….


Etapes n°1 : Choisir une version d’OS : http://wiki.pine64.org/index.php/ROCK64_Software_Release

Mon choix : stretch-minimal-rock64-0.7.8-1061-arm64.img.xz

  • Login avec
    • username: rock64
    • password: rock64

Etape n°2 : Décompresser :

unxz stretch-minimal-rock64-0.7.8-1061-arm64.img.xz

du -h stretch-minimal-rock64-0.7.8-1061-arm64.img 
1,8G	stretch-minimal-rock64-0.7.8-1061-arm64.img

Etape n°3 : Mettre sur la SDCard avec ApplePi.

Etape n°4 : Boot et ssh :

Etape n°5 : Mise à jours :

rock64@rock64:~$ sudo apt-get update

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for rock64: 
...

rock64@rock64:~$ sudo apt-get dist-upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages will be REMOVED:
  linux-rock64-package u-boot-rockchip-rock64
The following NEW packages will be installed:
  board-package-rock64-0.7-30 linux-headers-4.4.132-1075-rockchip-ayufan-ga83beded8524
  linux-image-4.4.132-1075-rockchip-ayufan-ga83beded8524 u-boot-rockchip-rock64-2017.09-rockchip-ayufan-1025-g482cd6ec8b
The following packages will be upgraded:
  apt apt-transport-https apt-utils base-files curl dirmngr firmware-brcm80211 firmware-realtek git git-man gnupg gnupg-agent gpgv
  libapt-inst2.0 libapt-pkg5.0 libc-bin libc-dev-bin libc-l10n libc6 libc6-dev libcurl3 libcurl3-gnutls libgnutls30 libnm0
  libpam-systemd libperl5.24 libpolkit-agent-1-0 libpolkit-backend-1-0 libpolkit-gobject-1-0 libpython3.5-minimal
  libpython3.5-stdlib libseccomp2 libssl1.0.2 libssl1.1 libsystemd0 libudev1 libxapian30 linux-libc-dev linux-rock64 locales
  multiarch-support network-manager openssh-client openssh-server openssh-sftp-server openssl perl perl-base perl-modules-5.24
  policykit-1 python3.5 python3.5-minimal ssh systemd systemd-sysv tzdata udev wpasupplicant
58 upgraded, 4 newly installed, 2 to remove and 0 not upgraded.
Need to get 76.5 MB of archives.
After this operation, 141 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

Etape n°6 : Installation pour Python

rock64@rock64:~$ sudo apt-get install python-dev python3-dev
Reading package lists... Done
Building dependency tree       
...
rock64@rock64:~$ sudo apt-get install mercurial
Reading package lists... Done
Building dependency tree       
...

Aie, perl n’est pas contant :

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LANG = "fr_FR.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Selecting previously unselected package libjs-excanvas.
(Reading database ... 66469 files and directories currently installed.)
Preparing to unpack .../libjs-excanvas_0.r3-4_all.deb ...
Unpacking libjs-excanvas (0.r3-4) ...
Selecting previously unselected package mercurial-common.
Preparing to unpack .../mercurial-common_4.0-1+deb9u1_all.deb ...
Unpacking mercurial-common (4.0-1+deb9u1) ...
Selecting previously unselected package mercurial.
Preparing to unpack .../mercurial_4.0-1+deb9u1_arm64.deb ...
Unpacking mercurial (4.0-1+deb9u1) ...
Setting up libjs-excanvas (0.r3-4) ...
Setting up mercurial-common (4.0-1+deb9u1) ...
Setting up mercurial (4.0-1+deb9u1) ...
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/mercurial/hgrc.d/hgext.rc with new version

On continue :

rock64@rock64:~$ sudo apt-get install python-pip python3-pip
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  python-pip-whl
Recommended packages:
  python-all-dev python-setuptools python-wheel python3-setuptools python3-wheel
The following NEW packages will be installed:
  python-pip python-pip-whl python3-pip
...

Maintenant la gestion GPIO :

rock64@rock64:~$ pip install R64.GPIO
Collecting R64.GPIO
  Could not find a version that satisfies the requirement R64.GPIO (from versions: )
No matching distribution found for R64.GPIO

Aie …

rock64@rock64:~$ sudo apt-get install git
...
rock64@rock64:~$ git clone https://github.com/Leapo/Rock64-R64.GPIO.git
Cloning into 'Rock64-R64.GPIO'...
remote: Enumerating objects: 254, done.
remote: Total 254 (delta 0), reused 0 (delta 0), pack-reused 254
Receiving objects: 100% (254/254), 79.38 KiB | 0 bytes/s, done.
Resolving deltas: 100% (125/125), done.
...
rock64@rock64:~$ sudo apt-get install python-setuptools           
Reading package lists... Done
Building dependency tree       
Reading state information... Done
...
rock64@rock64:~$ pip install spidev
Collecting spidev
  Downloading https://files.pythonhosted.org/packages/fb/14/4c2e1640f0cb04862c76d9d76ed7c945b0f67876e503ac02f7f675fe86a0/spidev-3.4.tar.gz
Building wheels for collected packages: spidev
  Running setup.py bdist_wheel for spidev ... error
  Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-f9zDi7/spidev/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmp2UN7bFpip-wheel- --python-tag cp27:
  usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     or: -c --help [cmd1 cmd2 ...]
     or: -c --help-commands
     or: -c cmd --help
  
  error: invalid command 'bdist_wheel'
  
  ----------------------------------------
  Failed building wheel for spidev
  Running setup.py clean for spidev
Failed to build spidev
Installing collected packages: spidev
  Running setup.py install for spidev ... done
Successfully installed spidev-3.4
...
rock64@rock64:~$ ln -s Rock64-R64.GPIO/R64/ .
...

Les GPIO que je vais utiliser : n°12 et n°16

La photo :

smacap_Bright

Le premier programme de test en Python :

rock64@rock64:~/Rock64-R64.GPIO$ cat R64-GPIO-test.py 
#!/usr/bin/env python

# Allison Creely, 2018, LGPLv3 License
# Rock 64 GPIO Library for Python

import R64.GPIO as GPIO
from time import sleep

print("Testing R64.GPIO Module...")

# Test Variables
print("")
print("Module Variables:")
print("Name           Value")
print("----           -----")
print("GPIO.ROCK      " + str(GPIO.ROCK))
print("GPIO.BOARD     " + str(GPIO.BOARD))
print("GPIO.BCM       " + str(GPIO.BCM))
print("GPIO.OUT       " + str(GPIO.OUT))
print("GPIO.IN        " + str(GPIO.IN))
print("GPIO.HIGH      " + str(GPIO.HIGH))
print("GPIO.LOW       " + str(GPIO.LOW))
print("GPIO.PUD_UP    " + str(GPIO.PUD_UP))
print("GPIO.PUD_DOWN  " + str(GPIO.PUD_DOWN))
print("GPIO.VERSION   " + str(GPIO.VERSION))
print("GPIO.RPI_INFO  " + str(GPIO.RPI_INFO))
# Set Variables
var_gpio_in = 12
var_gpio_in2 = 16
# GPIO Setup
GPIO.setwarnings(True)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(var_gpio_in, GPIO.IN, pull_up_down=GPIO.PUD_UP)  # Set up GPIO as an input, pullup enabled
GPIO.setup(var_gpio_in2, GPIO.IN, pull_up_down=GPIO.PUD_UP)  # Set up GPIO as an input, pullup enabled
print("Testing GPIO Input:")
# Test Input
var_gpio_state = GPIO.input(var_gpio_in)                    # Return state of GPIO
print("Input State  : " + str(var_gpio_state))              # Print results
sleep(20)
# Test interrupt
print("")
print("Waiting 3 seconds for interrupt...")
var_interrupt = GPIO.wait_for_edge(var_gpio_in, GPIO.FALLING, timeout=3000)
if var_interrupt is None:
    print("Timeout!")
else:
    print("Detected!")
print("Testing GPIO Input:")
# Test Input
var_gpio_state2 = GPIO.input(var_gpio_in2)                    # Return state of GPIO
print("Input State  : " + str(var_gpio_state2))              # Print results
sleep(20)
# Test interrupt
print("")
print("Waiting 3 seconds for interrupt...")
var_interrupt2 = GPIO.wait_for_edge(var_gpio_in2, GPIO.FALLING, timeout=3000)
if var_interrupt2 is None:
    print("Timeout!")
else:
    print("Detected!")
GPIO.cleanup([var_gpio_in, var_gpio_in2])                   # Perform cleanup on specified GPIOs
print("")
print("Test Complete")

résultat :

rock64@rock64:~/Rock64-R64.GPIO$ python R64-GPIO-test.py 
Testing R64.GPIO Module...

Module Variables:
Name           Value
----           -----
GPIO.ROCK      ROCK
GPIO.BOARD     BOARD
GPIO.BCM       BCM
GPIO.OUT       out
GPIO.IN        in
GPIO.HIGH      1
GPIO.LOW       0
GPIO.PUD_UP    0
GPIO.PUD_DOWN  1
GPIO.VERSION   0.6.3
GPIO.RPI_INFO  {'P1_REVISION': 3, 'RAM': '1024M', 'REVISION': 'a22082', 'TYPE': 'Pi 3 Model B', 'PROCESSOR': 'BCM2837', 'MANUFACTURER': 'Embest'}
Error: Unable to export GPIO
Error: Unable to set GPIO direction
Error: Unable to export GPIO
Error: Unable to set GPIO direction
Testing GPIO Input:
You must setup() the GPIO channel (BOARD 12) first
Input State  : None

Waiting 3 seconds for interrupt...
You must setup() the GPIO channel (BOARD 12) as an input first
Timeout!
Testing GPIO Input:
You must setup() the GPIO channel (BOARD 16) first
Input State  : None

Waiting 3 seconds for interrupt...
You must setup() the GPIO channel (BOARD 16) as an input first
Timeout!

Test Complete

Oups il faut le faire en root, et je suis passer à 10 sec. pour l’interruption :

rock64@rock64:~/Rock64-R64.GPIO$ sudo python R64-GPIO-test.py 
Testing R64.GPIO Module...

Module Variables:
Name           Value
----           -----
GPIO.ROCK      ROCK
GPIO.BOARD     BOARD
GPIO.BCM       BCM
GPIO.OUT       out
GPIO.IN        in
GPIO.HIGH      1
GPIO.LOW       0
GPIO.PUD_UP    0
GPIO.PUD_DOWN  1
GPIO.VERSION   0.6.3
GPIO.RPI_INFO  {'P1_REVISION': 3, 'RAM': '1024M', 'REVISION': 'a22082', 'TYPE': 'Pi 3 Model B', 'PROCESSOR': 'BCM2837', 'MANUFACTURER': 'Embest'}
Testing GPIO Input:
Input State  : 0

Waiting 10 seconds for interrupt...
Detected!
Testing GPIO Input:
Input State  : 1

Waiting 10 seconds for interrupt...
Detected!

Test Complete

Donc quand je souffle, je détecte l’interruption.

La première étape est donc faite.

A noter cette documentation : https://github.com/Leapo/Rock64-R64.GPIO/wiki/GPIO-Modes , ils ne sont pas tous fonctionnel :

Et a noter aussi que la fonction suivante n’est pas disponible : Error: GPIO.add_event_detect() Not implemented.

Ce qui complique le programme ….

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Time limit is exhausted. Please reload CAPTCHA.