Outils pour utilisateurs

Outils du site


core:picore_rpi3

piCore64-13.0 (64-bit) sur Raspberry Pi 3

  • Installer un lecteur de musique Squeezelite (client pour LMS) et Shairport Sync (AirPlay) sur Raspberry Pi 3
  • piCore est un Raspberry Pi port de Tiny Core Linux.
  • Il y a plus d'informations sur l'usage de piCore dans la page de mon installation précédente piCore-9.0.3, qui est une installation différente pour un player UPnP.

Installer piCore64-13.0

  1. Sur mon PC de bureau sous Linux, download le fichier http://www.tinycorelinux.net/13.x/aarch64/releases/RPi/piCore64-13.0.zip et le mettre sur une carte micro SD (/dev/sdb dans mon cas) :
    wget http://www.tinycorelinux.net/13.x/aarch64/releases/RPi/piCore64-13.0.zip
    unzip piCore64-13.0.zip
    sudo dd bs=4M if=piCore64-13.0.img of=/dev/sdb
    sudo sync
  2. Lire IMPORTANT et README.
  3. Booter la RPi avec une connexion Ethernet et se connecter via ssh avec login/passwd tc/piCore.
  4. Sauvegarder les clés SSH générées avec la commande
    tc@box:~$ filetool.sh -b
  5. Étendre la deuxième partition et créer une troisième grosse partition swap (voir la section “SD card partitioning” de README). Voici un exemple avec une carte micro SD de 8G (si la commande sudo mkswap /dev/mmcblk0p3 donne un message d'erreur mkswap: write error: Text file busy, faire d'abord la commande sudo swapoff /dev/mmcblk0p3).
    • La partition swap sera reconnue et utilisée automatiquement par piCore au prochain boot. Elle est nécessaire pour la compilation de programmes.
      tc@box:~$ free -m
                    total        used        free      shared  buff/cache   available
      Mem:            912          38         856          11          17         860
      Swap:          1649           0        1649

WiFi

  • Si on a besoin d'utiliser le WiFi intégré au lieu de Ethernet.
    tc@box:~$ tce-load -wi wifi.tcz firmware-rpi-wifi.tcz
    tc@box:~$ sudo reboot
    tc@box:~$ sudo wifi.sh    [configurer le wifi]
    tc@box:~$ vi /opt/bootlocal.sh    [ajouter une ligne: wifi.sh -a -w 2>&1 > /tmp/wifi.log]
    tc@box:~$ filetool.sh -b
    • :!: wifi.sh enregistre l'info dans le fichier /home/tc/wifi.db qui est utilisé au pour la connexion wifi au boot. Il ne faut pas le supprimer !
    • Maintenant, plus besoin de Ethernet.

ALSA

  • tc@box:~$ tce-load -wi alsa.tcz alsa-utils.tcz
  • La carte son interne est activée par défaut :
    tc@box:~$ cat /proc/asound/cards
     0 [Headphones     ]: bcm2835_headphonbcm2835 Headphones - bcm2835 Headphones
                          bcm2835 Headphones
     1 [U20X1          ]: USB-Audio - USB Audio 2.0(X1)
                          Singxer USB Audio 2.0(X1) at usb-3f980000.usb-1.3, high speed

    Pour la désactiver,

    tc@box:~$ mount /mnt/mmcblk0p1
    tc@box:~$ vi /mnt/mmcblk0p1/config.txt
    [Il suffit de commenter la ligne "dtparam=audio=on" en ajoutant un # devant : #dtparam=audio=on]                                                                                                                         
    tc@box:~$ sudo reboot
    
    tc@box:~$ cat /proc/asound/cards
     0 [U20X1          ]: USB-Audio - USB Audio 2.0(X1)
                          Singxer USB Audio 2.0(X1) at usb-3f980000.usb-1.3, high speed
  • Vérifier/Confogurer ALSA pour volume au maximum 100 :
    tc@box:~$ sudo alsamixer
    Error opening terminal: xterm-256color.    [si cette erreur, exécuter la ligne suivante]
    tc@box:~$ export TERM=xterm                
    tc@box:~$ sudo alsamixer
    [vérifier les réglages de la carte son, il n'y a rien à changer pour mon interface USB Singxer-X1]
    ###### A faire seulement si des modifications ont été faites avec la commande "sudo alsamixer"
    ### Sinon, pas besoin de cette partie sur "alsactl" :
    tc@box:~$ sudo mkdir -p /var/lib/alsa
    tc@box:~$ sudo alsactl store
    tc@box:~$ echo "var/lib/alsa" >> /opt/.filetool.lst
    tc@box:~$ vi /opt/bootlocal.sh    [ajouter une ligne: alsactl restore]
    tc@box:~$ filetool.sh -b
    ############################################################################

Sqeezelite

  • Pas de TCZ (http://tinycorelinux.net/13.x/aarch64/tcz/). Le plus simple est d'utiliser le binaire squeezelite :
    tc@box:~$ wget https://sourceforge.net/projects/lmsclients/files/squeezelite/linux/squeezelite-1.9.9.1390-aarch64.tar.gz
    [ ... predre la dernière version sur https://sourceforge.net/projects/lmsclients/files/squeezelite/linux/ ] 
    tc@box:~$ tar zxvf squeezelite-1.9.9.1390-aarch64.tar.gz
    tc@box:~$ mv squeezelite /mnt/mmcblk0p2/tce/
    tc@box:~$ vi /opt/bootlocal.sh
    ##### ajouter une ligne après la ligne wifi #####
    /mnt/mmcblk0p2/tce/squeezelite -n SqueezeliteRPi3 -o hw:0,0 -z -C 10
    ################################################################# 
    tc@box:~$ filetool.sh -b
    tc@box:~$ sudo reboot

Shairport Sync (AirPlay)

  • Note : Utiliser tinysvcmdns au lieu de avahi pour réduire les dépendances.
  • tce-load -wi compiletc.tcz squashfs-tools.tcz
    tce-load -wi libasound-dev.tcz
    tce-load -wi openssl-dev.tcz popt-dev.tcz autoconf.tcz automake.tcz libdaemon-dev.tcz
    
    # Il faut d'abord libconfig.
    sudo mkdir /mnt/mmcblk0p2/compile
    sudo chown tc:staff /mnt/mmcblk0p2/compile
    mkdir /mnt/mmcblk0p2/compile/libconfig
    cd /mnt/mmcblk0p2/compile/libconfig
    wget http://download.tuxfamily.org/bz31notes/picore/tcz_src/libconfig/libconfig-1.7.3.tar.gz
    wget http://download.tuxfamily.org/bz31notes/picore/tcz_src/libconfig/libconfig.build
    sh libconfig.build
    mv /tmp/libconfig/libconfig.tcz* /mnt/mmcblk0p2/tce/optional/
    mv /tmp/libconfig-dev/libconfig-dev.tcz* /mnt/mmcblk0p2/tce/optional/
    tce-load -i libconfig.tcz libconfig-dev.tcz
     
    # Maintenant shairport-sync
    mkdir /mnt/mmcblk0p2/compile/shairport-sync
    cd /mnt/mmcblk0p2/compile/shairport-sync
    wget http://download.tuxfamily.org/bz31notes/picore/tcz_src/shairport-sync/shairport-sync-3.3.8.tar.gz
    wget http://download.tuxfamily.org/bz31notes/picore/tcz_src/shairport-sync/shairport-sync.build
    wget http://download.tuxfamily.org/bz31notes/picore/tcz_src/shairport-sync/shairport-sync.tcz.dep
    sh shairport-sync.build
    mv /tmp/shairport-sync/shairport-sync.tcz* /mnt/mmcblk0p2/tce/optional/
    cp shairport-sync.tcz.dep /mnt/mmcblk0p2/tce/optional/
    tce-load -i shairport-sync.tcz
    
    #### tester ####
    shairport-sync
    ################
    
    vi /mnt/mmcblk0p2/tce/onboot.lst    [ajouter shairport-sync.tcz]
    vi /home/tc/shairport-sync.conf 
    ### créer ce fichier shairport-sync.conf avec le contenu :  ###
    sessioncontrol = 
    {
      allow_session_interruption = "yes";
    };
    
    alsa =
    {
      output_device = "plughw:0,0";
    };
    #########################################
    vi /opt/bootlocal.sh    [ajouter une ligne : shairport-sync -c /home/tc/shairport-sync.conf &] 
    filetool.sh -b
    sudo reboot

Nettoyage final

  • Lorsque tout marche bien, on optimise l'utilisation de RAM. Pour ne charger que le nécessaire au boot, supprimer tous les fichiers non nécessaires dans /home/ et /opt/. Enlever les packages non nécessaires dans /mnt/mmcblk0p2/tce/onboot.lst. Et reboot !
    • Le fichier /mnt/mmcblk0p2/tce/onboot.lst (wifi activé)
      openssh.tcz
      wifi.tcz
      firmware-rpi-wifi.tcz
      alsa.tcz
      alsa-utils.tcz

      et le fichier /opt/bootlocal.sh

      #!/bin/sh
      
      # To start serial terminal /w console
      # Add the following to the cmdline.txt console=serial0,115200
      # Reference https://www.raspberrypi.org/documentation/configuration/uart.md for UART configuration
      # Uncomment the next line
      # /usr/sbin/startserialtty &
      
      # Set CPU frequency governor to ondemand (default is performance)
      echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
      
      # Load modules - i2c-dev needs manually loaded even if enabled in config.txt
      #/sbin/modprobe i2c-dev
      
      # Start openssh daemon
      /usr/local/etc/init.d/openssh start
      
      # ------ Put other system startup commands below this line
      
      wifi.sh -a -w 2>&1 > /tmp/wifi.log
      /mnt/mmcblk0p2/tce/squeezelite -n SqueezeliteRPi3 -o hw:0,0 -z -C 10
      shairport-sync -c /home/tc/shairport-sync.conf &

Divers

  • Changer le hostname : changer le hostname box en rpi3
    tc@box:~$ vi /opt/bootsync.sh
    tc@box:~$ filetool.sh -b
    tc@box:~$ sudo reboot
    
    tc@rpi3:~$ uname -a
    Linux rpi3 5.4.51-piCore-v8 #1 SMP PREEMPT Tue Jul 28 16:02:58 EDT 2020 aarch64 GNU/Linux
    tc@rpi3:~$ date
    Thu Dec 31 11:13:32 UTC 2020
  • Visualiser les processus avec htop :
    tc@rpi3:~$ tce-load -wi htop.tcz
    tc@rpi3:~$ htop
    Error opening terminal: xterm-256color.
    tc@rpi3:~$ export TERM=xterm
    tc@rpi3:~$ htop
    • Note : htop est installé avec ses dépendances htop.tcz*, aterm.tcz*, libXetx.tcz*, libxcb.tcz*, libICE.tcz*, libSM.tcz*, libXdmcp.tcz*, libXau.tcz*, libX11.tcz*.
  • Désactiver/Supprimer un package : Pour ne pas le charger au boot, il suffit de l'enlever dans /mnt/mmcblk0p2/tce/onboot.lst et reboot. Ensuite si on veut le supprimer complètement, il suffit de supprimer le package et ses dépendances installées dans /mnt/mmcblk0p2/tce/optional.
  • Manipuler les packages *.tcz :
    tce-load -wi squashfs-tools.tcz
    # Lister les fichier :
    unsquashfs -l /mnt/mmcblk0p2/tce/optional/nom_package.tcz
    # Extraire un package :
    unsquashfs -f -d /chemin_vers_dossier-destination nom_package.tcz
  • Backup : Sur une machine linux et avec la carte sd reconnue comme /dev/sdb
    sudo dd bs=4M if=/dev/sdb of=piCore-12.0_backupMySDCard.img
core/picore_rpi3.txt · Dernière modification : 2021/10/26 20:01 de bz31