Kerminy HackSpace

Outils du site


ressources:odroid_n2

ODROID N2

C'est un vrai petit PC, il intègre 'Petitboot' sorte de BIOS comme sur un PC. Elle va nous servir comme serveur agri-culturel dans une des serres, à la fois pour la création sonore utilisant les capteurs présents et à l'aide, la surveillance des cultures.

On commence à travers la liaison série

  • nmtui pour définir la connexion WiFi que j'utilise
  • apt update; apt upgrade (quand le unattended-upgrade à fini)… ça c'est fait… je me rassure il ne change pas de noyau 4.9 …
apt update; apt upgrade -y
dpkg-reconfigure tzdata
dpkg-reconfigure locales
apt install odroid-wiringpi odroid-wiringpi-python vim git
journalctl --vacuum-size=1M
echo "SystemMaxUse=5M" >> /etc/systemd/journald.conf

Ajout bouton on/off

Connexion du bouton sur 9/11

ajouter dans /media/boot/boot.ini dans la section Boot Args juste apres la ligne bootargs en surcharge

### in case of GPIOX.3 (Pin 11) of 2x20 pins connector
setenv gpiopower "479"
setenv bootargs ${bootargs} gpiopower=${gpiopower}

En profiter pour regarder si il y a overlays=“spi0 i2c0 i2c1 uart0”

Ajout interface graphique

autologin

apt remove lightdm # si besoin?
apt install nodm

modifier /etc/default nodm pour loger l'utilisateur odroid et pas root

# nodm configuration
# Set NODM_ENABLED to something different than 'false' to enable nodm
NODM_ENABLED=true
# User to autologin for
NODM_USER=odroid
# First vt to try when looking for free VTs
NODM_FIRST_VT='7'
# X session
NODM_XSESSION=/usr/bin/startfluxbox
# Options for nodm itself
NODM_OPTIONS=
# Options for the X server.
# Format: [/usr/bin/<Xserver>] [:<disp>] <Xserver-options>
# The Xserver executable and the display name can be omitted, but should
# be placed in front, if nodm's defaults shall be overridden.
NODM_X_OPTIONS='-nolisten tcp'
# If an X session will run for less than this time in seconds, nodm will wait an
# increasing bit of time before restarting the session.
NODM_MIN_SESSION_TIME=60
# Timeout (in seconds) to wait for X to be ready to accept connections. If X is
# not ready before this timeout, it is killed and restarted.
NODM_X_TIMEOUT=300

..j'ai cherché longtemps le truc de remplacer Xsession par startfluxbox … pour avoir une compatibilité maximale et surtout le lancement automatique par le fichier .fluxbox/startup !

bureau fluxbox

Un bureau fluxbox minimaliste consommant moins de 300Mo (mieux que les 800 de mate ou 600 de xfce),
sous root pour minimiser les temps de latence (attention aux connexion…)

apt install xserver-xorg-core xserver-xorg-input-libinput xinit dbus-x11 xfonts-base x11-xserver-utils x11-utils libgl1-mesa-dri mesa-utils mesa-utils-extra
apt install vim fluxbox xterm  xfonts-base x11-xserver-utils
apt install pcmanfm xpad avahi-daemon rox-filer # options
 
mkdir -p /root/.fluxbox
echo "startfluxbox" > /root/.xsession
**startfluxbox**
echo "
# fluxbox startup-script:
#  ~/.fluxbox/startup
# Lines starting with a '#' are ignored.
# doit finir par exec fluxbox
#fbsetbg -l
fbsetroot -solid black

xterm -T 'Top' -e /usr/bin/top &
##lancement installation sonore 
/root/.fluxbox/rapidestart.sh &
#
wmnd  &
wmmisc &
#

/root/.fluxbox/x11vnc.sh 2>&1 > /tmp/x11vnc.log &
exec fluxbox -log ~/.fluxbox/fluxbox.log
" > /root/.fluxbox/startup
chmod 755 /root/.fluxbox/startup

menu fluxbox ./fluxbox/menu

[begin] (Fluxbox)
  [exec] (Bash) { /usr/bin/xterm -T "Bash" -e /bin/bash --login} <>
  [exec] (alsamixergui) {alsamixergui -c1} <>
  [exec] (start.sh) {~/start.sh} <>
  [exec] (stop.sh) {~/stop.sh} <>
  [exec] (enregistre volumes) {alsactl store 1 -f ~/volumes_param.txt} <>
  [exec] (restore volumes) {alsactl restore 1 -f ~/volumes_param.txt} <>

  [exec] (ROX) {rox-filer} <>
  [exec] (Xkill) {xkill} <>
  [exec] (Xrefresh) {xrefresh} <>
  [submenu] (Monitoring) {}
       [exec] (Pstree) { xterm -T "Pstree" -e /usr/bin/pstree.x11} </usr/share/p
ixmaps/pstree16.xpm>
       [exec] (Top) { xterm -T "Top" -e /usr/bin/top} <>
       [exec] (Top) { xterm -T "HTOP" -e /usr/bin/htop} <>
       [exec] (Xconsole) {xconsole -file /dev/xconsole} <>
       [exec] (Xload) {xload} <>
  [end]

   [submenu] (Styles) {}
      [stylesdir] (/usr/share/fluxbox/styles)
      [stylesdir] (~/.fluxbox/styles)
   [end]

   [config] (Configuration)
   [workspaces] (Workspaces)
   [reconfig] (Reconfigure)
   [restart] (Restart)
   [exec] (Power Off) {sudo /sbin/shutdown -h now}
   [exec] (Reboot) {sudo /sbin/shutdown -r now}
   [exit] (Exit)

[end]

VNC

 
apt install x11vnc avahi-daemon 
x11vnc -storepasswd votre_mot_de_passe ~/.vnc_passwd
echo "
sleep 3
/usr/bin/x11vnc -rfbauth /root/.vnc_passwd -geometry 1024x780 \
	-reopen -bg -avahi -forever -display :0 
exit 0
" >/root/.fluxbox/x11vnc.sh

Premier capteur weather board

de https://wiki.odroid.com/odroid-n2/application_note/software/weather_board avec pour nous une sortie OSC
Connexion sur 1-3V 2→SDA 3→SDC 9→GND

– Sensors : BME280, Si1132

apt install i2c-tools libi2c-dev python3-smbus phyton3-liblo 
cd /usr/src
git clone https://github.com/hardkernel/WEATHER-BOARD.git
cp -a ./WEATHER-BOARD/python_weather/* /usr/local/bin/
chmod 755 /usr/local/bin/BME280.py  /usr/local/bin/SI1132.py  /usr/local/bin/weather_board.py

weather_board_osc.py.tgz

ajout d'un code python pour la transmission MQTT des données, en utilisant juste un popen

import os
cputemp = float(os.popen('cat /sys/class/thermal/thermal_zone3/temp').read()) / 
1000
broker_address = "192.168.1.13"
broker_port = 1883
topicbase = "bubulle"
client_id = "bubulle"
username = 'blabla'
password = 'blabla'
 
client = mqtt.Client(client_id)
client.username_pw_set(username, password)
client.connect(broker_address, broker_port,60)
 
topic = topicbase + "/cputemp"
client.publish(topic, (float)(bme280.read_temperature()))
time.sleep(1)
 

#!/usr/bin/python3 import os import time from paho.mqtt import client as mqtt_client

cputemp = float(os.popen('cat /sys/class/thermal/thermal_zone0/temp').read()) / 1000 broker_address = “192.168.1.13” broker_port = 1883 topicbase = “prox” client_id = “prox” username = 'blabla' password = 'blabla'

client = mqtt_client.Client(client_id) client.username_pw_set(username, password) client.connect(broker_address, broker_port,60)

topic = topicbase + “/cputemp” client.publish(topic, (float)(cputemp)) time.sleep(1)

Machine sonore

Serveur son : Jack2
GUI : Qjackctl
Outils de programmation : Puredata Script de lancement start.sh présent dans le répertoire et lancé par le startup de fluxbox

regarder du coté des applications jack …

apt install qjackctl jack-tools aj-snapshot zita-njbridge alsamixergui

installation Puredata vanilla

pour optimiser au maximum, nous laisserons les patch en no-gui donc la partie graph ne sera utile que pour la mise au point
Liste des paquets Puredata utilisables portés sur cette base Ubuntu arm64

puredata puredata-core puredata-dev puredata-doc puredata-extra \
puredata-gui puredata-gui-l10n puredata-import puredata-utils multimedia-puredata \
pd-ableton-link pd-ambix pd-arraysize pd-autopreset pd-bassemu pd-beatpipe pd-boids \
pd-bsaylor pd-chaos pd-cmos pd-comport pd-creb pd-csound pd-cxc pd-cyclone \
pd-deken pd-deken-apt pd-earplug pd-ekext pd-ext13 pd-extendedview pd-fftease \
pd-flext-dev pd-flext-doc pd-flite pd-freeverb pd-ggee pd-gil pd-hcs pd-hexloader \
pd-hid pd-iem pd-iemambi pd-iemguts pd-iemlib pd-iemmatrix pd-iemnet pd-iemutils \
pd-jmmmp pd-jsusfx pd-kollabs pd-lib-builder pd-libdir pd-list-abs pd-log \
pd-lyonpotpourri pd-mapping pd-markex pd-maxlib pd-mediasettings pd-mjlib \
pd-moonlib pd-motex pd-mrpeach pd-mrpeach-net pd-nusmuk pd-osc pd-pan \
pd-pddp pd-pdogg pd-pdp pd-pdstring pd-pduino pd-plugin pd-pmpd pd-pool \
pd-puremapping pd-purepd pd-purest-json pd-readanysf pd-rtclib pd-sigpack \
pd-slip pd-smlib pd-syslog pd-tclpd pd-testtools pd-unauthorized pd-upp \
pd-vbap pd-wiimote pd-windowing pd-xbee pd-xsample pd-zexy pdal

Installation de pdnext

pd-vanilla a un gros défaut, c'est de ne pas être multi-thread ! du coup ne cherchant un peu j'ai trouvé https://github.com/sebshader/pdnext :-)
Cela résout le problème et permet de ne pas utiliser pd-l2ork avec nw et ses besoins en ressource plus importante voir son inexistence en ARMv8 …

du coup

cd /usr/src
git clone https://github.com/sebshader/pdnext.git
cd pdnext
./autogen.sh
./configure --disable-jack-framework --enable-jack --disable-portaudio --prefix=/usr
make -j4
make install

Ensuite il faut peut etre recompiler certain paquet pd genre zexy

apt source pd-zexy
cd pd-zexy_labonne_version
./configure --prefix=/usr
make
make install

Scripts sonores

Arret

#!/bin/bash
# stop.sh , kill jack et pd
# limite les doubles cliques
if [ -f /tmp/stop.run ]; then exit 0 ; fi
# 
for i in `ps -e|grep pd|awk '{print $1}'`; do kill -9 $i; done
for i in `ps -e|grep jack|awk '{print $1}'`; do kill -9 $i; done
for i in `ps -e|grep qjackctl|awk '{print $1}'`; do kill -9 $i; done
#
date > /tmp/stop.run
#
# limite les doubles cliques
sleep 5 
rm /tmp/stop.run
exit 0

Lancement

.fluxbox/rapidestart.sh

#!/bin/bash
# rapidestart.sh lancement qjackctl puredata
#
# lancement capteur OSC
python3 /usr/local/bin/weather_board_OSC.py /dev/i2c-0 2>&1 > /dev/null &
# jackd
alsactl restore 1 -f ~/volumes_param.txt
qjackctl &
date > /tmp/start
cd /root/Pd
pd -jack /root/Pd/serre-labo.pd &

exit 0

start.sh

#!/bin/bash
# start.sh lancement qjackctl puredata
# limite les doubles cliques
if [ -f /tmp/start.run ]; then exit 0 ; fi
# 
for i in `ps -e|grep pd|awk '{print $1}'`; do kill -9 $i; done
for i in `ps -e|grep jack|awk '{print $1}'`; do kill -9 $i; done
for i in `ps -e|grep qjackctl|awk '{print $1}'`; do kill -9 $i; done
#restore volume enregistré par alsactl store 1
alsactl restore 1 -f ~/volumes_param.txt
qjackctl &
date > /tmp/start.run
sleep 4
pd -jack &
#
# limite les doubles cliques
sleep 10
rm /tmp/start.run

exit 0
ressources/odroid_n2.txt · Dernière modification : 2024/02/08 17:20 de 127.0.0.1