RPi

From GIMX
Jump to: navigation, search

This page is a translated version of the page RPi and the translation is 30% complete.


Outdated translations are marked like this.
Other languages:
Deutsch • ‎English • ‎français

Attention : le support de la RPi doit être considéré comme expérimental. Soyez prêt à affronter des problèmes si vous exécutez GIMX sur la RPi.

GIMX peut s'exécuter sur beaucoup de cibles GNU/Linux, et le Raspberry Pi est l'une d'entre elles !

Considérations matérielles

Utiliser un HUB USB seulement si tous les ports USB sont occupés sur la RPi.
Il est fortement recommandé d'utiliser un HUB avec alimentation externe.

Mise à jour du firmware

Comme les premiers firmware avaient de gros soucis de gestion de l'USB, il est recommandé de mettre à jour le firmware avant d'utiliser GIMX.
Ceci est aussi utile pour utiliser un volant Logitech avec retour de force (le module uhid était absent dans les firmwares plus anciens).
Taper la commande suivante :

sudo rpi-update && sudo reboot

Firmware testé :

pi@raspberrypi ~ $ uname -a
Linux raspberrypi 4.1.9+ #819 PREEMPT Thu Oct 1 20:31:26 BST 2015 armv6l
GNU/Linux

If you plan to use a Logitech force feedback wheel, you will have to build the uhid.ko module for your kernel.
Install the right version of gcc, as explained here: link.
Update your kernel:

sudo rpi-update

In case the kernel was updated, reboot:

sudo reboot

Install the rpi-source tool:

sudo wget https://raw.githubusercontent.com/notro/rpi-source/master/rpi-source -O /usr/bin/rpi-source && sudo chmod +x /usr/bin/rpi-source && /usr/bin/rpi-source -q --tag-update

Run rpi-source:

rpi-source

This step may take a while to complete.
Install ncurses:

sudo apt-get install libncurses5-dev

Enable the UHID module compilation:

cd linux
make menuconfig

Select Device Drivers>HID support>User-space I/O driver support for HID subsystem. The line should start with '<M>'.
To speed up the compilation, you can disable all other modules in the HID support section and subsections.
Save the config to the default location and exit.
Build the module:

make prepare
make scripts
make M=drivers/hid

Install it:

sudo cp drivers/hid/uhid.ko /lib/modules/`uname -r`/kernel/drivers/hid/
sudo depmod -a

-->

Utiliser l'interface UART avec l'adaptateur USB

Matériel requis

L'interface série fonctionne aux niveaux 0V/3.3V, alors que la carte AVR USB doit être alimentée à 5V pour fonctionner à 16MHz (à 3.3V elle ne peut fonctionner qu'à 8MHz).
Connecter directement la RPi et la carte AVR USB peut endommager le matériel !
Une solution peu couteuse est d'utiliser un diviseur de tension :

  • Connecter les broches GND.
  • Il est sans danger de connecter la broche TXD du RPi à la broche RX de la carte AVR USB (le firmware GIMX configure la broche RX comme une entrée).
  • Pour connecter la broche TX de la carte AVR USB à la broche RXD du RPi, il faut convertir les niveaux de tension de 0..5V à 0..3.3V.

Ceci peut se faire simplement à l'aide d'un diviseur de tension :

Vin est la broche TX de la carte AVR USB, Vout est la broche RXD du RPi, R1=2.2kΩ , R2=3.3kΩ

  • Ne connecter aucune autre broche !

Ajustements logiciels

Par défaut, le RPi utilise le port série pour un terminal. Pour l'utiliser avec GIMX, exécuter :

sudo raspi-config 

Puis sélectionner :

"Advanced Options", "Serial", "No", "Finish"

Ouvrir le fichier /boot/config.txt avec l'éditeur nano :

sudo nano /boot/config.txt

Et ajouter la ligne suivante en fin de fichier :

init_uart_clock=8000000 

Créer un lien symbolique pour que gimx-launcher trouve le port série :

sudo ln -s /dev/ttyAMA0 /dev/ttyUSB0

Installation de GIMX

sudo apt-get install gdebi
wget http://gimx.fr/download/gimx-raspbian -O gimx.deb
sudo gdebi gimx.deb

En cas de dépendance insatisfaite, mettre à jour Raspbian :

sudo apt-get update && sudo apt-get upgrade

Arrêt/désactivation du service triggerhappy

Triggerhappy est un service qui ouvre tous les périphériques en lecture et qui consomme quelques pourcent du temps CPU.

Il est conseillé de l'arrêter lorsqu'on exécute GIMX.

Pour l'arrêter :

sudo service triggerhappy stop

Pour le désactiver :

sudo update-rc.d triggerhappy disable

Démarrage de GIMX

Lire la page démarrage rapide pour apprendre comment démarrer GIMX via une interface graphique.
C'est une bonne idée d'exécuter GIMX directement depuis un terminal, sans démarrer une session graphique.
Ceci peut se faire via le réseau, en utilisant un client ssh.
Idéalement, GIMX devrait être démarré dans utiliser le port Ethernet (car il est connecté sur le bus USB).
Plus de détails sur la page ligne de commande.

Autostart GIMX at boot without GUI

Simply create a file /etc/systemd/system/gimx.service (as root) with the following content:

[Unit]
Description=GIMX  
After=syslog.target network.target

[Service]
User=pi  
Type=simple  
ExecStart=/usr/bin/gimx -p /dev/ttyUSB0 -c LogitechDrivingForceGT_G29.xml --nograb  
Restart=always  
RestartSec=5

[Install]
WantedBy=multi-user.target

Replace ttyUSB0 with your device and LogitechDrivingForceGT_G29.xml with your mapping file (which should be available in the pi home directory as /home/pi/.gimx/config/LogitechDrivingForceGT_G29.xml)

Run

sudo systemctl daemon-reload

to notify systemd about the new file and

sudo systemctl enable gimx && sudo systemctl start gimx

to enable the gimx service start at boot and start it in the same line.

Notify when GIMX is running using a led

In order to have a proper confirmation about if the gimx service is up and running, you can add a simple python script that turns a led on if the gimx service is running.

The file will be located at /home/pi/blink.py:

#!/usr/bin/python
import os  
import time  
import RPi.GPIO as GPIO

led = 23  
button = 18  
GPIO.setmode(GPIO.BCM)  
GPIO.setup(led, GPIO.OUT)  
GPIO.setup(button, GPIO.IN, pull_up_down = GPIO.PUD_UP)

def Shutdown(channel):  
  GPIO.output(led, True)
  time.sleep(0.2)
  GPIO.output(led, False)
  time.sleep(0.2)
  GPIO.output(led, True)
  time.sleep(0.2)
  GPIO.output(led, False)
  os.system("sudo shutdown -h now")

GPIO.add_event_detect(18, GPIO.FALLING, callback = Shutdown, bouncetime = 2000)

while True:  
  found = False
  time.sleep(5)
  pids = [pid for pid in os.listdir('/proc') if pid.isdigit()]
  for pid in pids:
    try:
      cmd = open(os.path.join('/proc', pid, 'cmdline'), 'rb').read()
      if "gimx" in cmd:
        found = True
    except IOError: # proc has already terminated
      continue
  if found == True:
    GPIO.output(led, True)
  else:
    GPIO.output(led, False)

As a bonus, you can add a button so when it is pressed, there is a little blink effect, and the pi is shutted down.

PiButtonLed.png

To start at boot, simply add it to the pi user crontab (crontab -e) as

@reboot python /home/pi/blink.py &