Raspberry Pi rt-kernel
Ce wiki a été archivé en 2018.
Le nouveau wiki se trouve à: ressources.labomedia.org Les fonctionnalités sont désactivées: vous pouvez faire une recherche sur Google site:https://wiki.labomedia.org et découvrir La Labomedia. |
Compiler/tester un noyau temps-réel audio sur raspberry pi2
Sommaire
Test de latence du noyau
- Setup : raspi2 + qjackctl 0.3.9 + sooperlooper 1.6.18 + carte son xenyx 302USB behringer
Outils de test
Connaitre les réglages actuel du noyau
zcat /proc/config.gz > ~/config
si il n'y à pas de fichier de configuration
sudo modprobe configs
RealTimeConfigQuickScan
scripts qui permettent de connaitre la configuration du kernel
git clone git://github.com/raboof/realtimeconfigquickscan.git cd realtimeconfigquickscan perl ./realTimeConfigQuickScan.pl
Cyclictest
Tester les performances temps réel
git clone git://git.kernel.org/pub/scm/linux/kernel/git/clrkwllms/rt-tests.git cd rt-tests make all sudo cp ./cyclictest /usr/bin/ cd ~ sudo cyclictest -l1000000 -m -n -a0 -t1 -p99 -i400 -h400 -q
ou tester chaque coeurs
sudo cyclictest -a -t -n -p99
Les résultats sont en microsecondes
- source
https://www.osadl.org/Realtime-Preempt-Kernel.kernel-rt.0.html#externaltestingtool
https://github.com/raboof/realtimeconfigquickscan
http://www.linuxtopia.org/online_books/linux_kernel/kernel_configuration/ch08.html
https://rt.wiki.kernel.org/index.php/Cyclictest
http://people.redhat.com/williams/latency-howto/rt-latency-howto.txt
CCRMA Satellite pi2
https://ccrma.stanford.edu/~eberdahl/Satellite/
Installation/Configuration
CCRMA Satellite (une distribution créer pour faire de l'audio)
- copier l'image su la carte sd
sudo dd if=/home/blablabla/SatelliteCCRMA_Rpi2_v1.03.dd of=/dev/mmcblk0 bs=4096
- login et mot de passe
login : ccrma mp : temppwd
- arrêter les scripts par défaults
exit-stand-alone sudo rm /etc/default/randomsound sudo rm /etc/init.d/randomsound sudo /home/ccrma/bin/disable-flash-writes
- relancer le système
sudo reboot
- lancer x
startx
Alors quoi?
- Pour le moment pd-extended crash régulièrement donc préférer la version vanilla...
- qjackctl ne fonctionne qu'en root donc sooplerlooper aussi
- pas trop de documentation : https://groups.google.com/forum/#!topic/satelliteccrma/gAvRQd8XbHY
- test avec la carte son scarlett 2i2 : il faut modifier le fichier /boot/cmdline.txt et ajouter
dwc_otg.fiq_fsm_enable=0
- test avec behringer xenyx302USB
pas de soucis de latence avec jack jusqu'à 48KHz, 128 échantillons : 5.33ms
Test de copie du kernel
Le coté audio de cette distribution étant plutôt satisfaisant, mais la surcouche concernant la protection en écriture et les scripts inutiles donnent envie de récupérer le kernel sur une distribution plus basique.
Copie de /boot/kernel7.img Copie de /boot/bcm2709-rpi-2-b.dtb Copie de cmdline.txt Copie de config.txt
sudo apt-get install cpufrequtils
modifier rc.local
cpufreq-set -g performance swapoff -a
sources:
https://www.bentasker.co.uk/documentation/linux/304-copying-a-linux-kernel-from-one-system-to-another
http://ubuntuforums.org/showthread.php?t=829472
https://forums.gentoo.org/viewtopic-t-813106-start-0.html
http://superuser.com/questions/439511/how-to-save-or-export-a-custom-linux-kernel-configuration
http://superuser.com/questions/287371/obtain-kernel-config-from-currently-running-linux-system
proc/version
ccrma@satellite ~/Desktop/realtime $ cat /proc/version Linux version 3.18.11-v7+ (dc4@dc4-XPS13-9333) (gcc version 4.8.3 20140303 (prerelease) (crosstool-NG linaro-1.13.1+bzr2650 - Linaro GCC 2014.03) ) #781 SMP PREEMPT Tue Apr 21 18:07:59 BST 2015
CyclicTest
Test avec SooperLooper 3 pistes, jack : 128 échantillons, 44100 Hz, 3 périodes/tampon
ccrma@satellite ~ $ sudo cyclictest -a -t -n -p99 # /dev/cpu_dma_latency set to 0us policy: fifo: loadavg: 0.78 0.45 0.24 4/220 4238 T: 0 ( 4079) P:99 I:1000 C: 348228 Min: 10 Act: 26 Avg: 22 Max: 749 T: 1 ( 4080) P:99 I:1500 C: 232139 Min: 9 Act: 26 Avg: 19 Max: 205 T: 2 ( 4081) P:99 I:2000 C: 174114 Min: 9 Act: 38 Avg: 18 Max: 153 T: 3 ( 4082) P:99 I:2500 C: 139291 Min: 9 Act: 39 Avg: 20 Max: 717
QuickScan
ccrma@satellite ~/Desktop/realtime $ perl ./realTimeConfigQuickScan.pl == GUI-enabled checks == Checking if you are root... no - good Checking filesystem 'noatime' parameter... 3.18.11 kernel - good (relatime is default since 2.6.30) Checking CPU Governors... CPU 0: 'performance' CPU 1: 'performance' CPU 2: 'performance' CPU 3: 'performance' - good Checking swappiness... 1 - good Checking for resource-intensive background processes... none found - good Checking checking sysctl inotify max_user_watches... < 524288 - not good increase max_user_watches by adding 'fs.inotify.max_user_watches = 524288' to /etc/sysctl.conf and rebooting For more information, see http://wiki.linuxaudio.org/wiki/system_configuration#sysctlconf Checking access to the high precision event timer... not found - not good /dev/hpet not found. Checking access to the real-time clock... not found - not good /dev/rtc not found (perhaps create a symlink?). Checking whether you're in the 'audio' group... yes - good Checking for multiple 'audio' groups... no - good Checking the ability to prioritize processes with chrt... yes - good Checking kernel support for high resolution timers... found - good Kernel with Real-Time Preemption... not found - not good Kernel without real-time capabilities found For more information, see http://wiki.linuxaudio.org/wiki/system_configuration#installing_a_real-time_kernel Checking if kernel system timer is set to 1000 hz... not found - not good Try setting CONFIG_HZ to 1000 Checking kernel support for tickless timer... found - good == Other checks == Checking filesystem types... ok. ok. ** Set $SOUND_CARD_IRQ to the IRQ of your soundcard to enable more checks. Find your sound card's IRQ by looking at '/proc/interrupts' and lspci.
Raspbian wheezy pi2
Version d'origine sans overclock
pi@raspberrypi cat /proc/version Linux version 3.18.11-v7+ (dc4@dc4-XPS13-9333) (gcc version 4.8.3 20140303 (prerelease) (crosstool-NG linaro-1.13.1+bzr2650 - Linaro GCC 2014.03) ) #781 SMP PREEMPT Tue Apr 21 18:07:59 BST 2015
CyclicTest
Test avec SooperLooper 3 pistes, jack : 128 échantillons, 44100 Hz, 3 périodes/tampon
SooperLooper : got Xrun après environ une minute de test
pi@raspberrypi ~ $ sudo cyclictest -a -t -n -p99 # /dev/cpu_dma_latency set to 0us policy: fifo: loadavg: 1.61 0.77 0.38 2/218 3923 T: 0 ( 3910) P:99 I:1000 C: 94273 Min: 15 Act: 24 Avg: 45 Max: 867 T: 1 ( 3911) P:99 I:1500 C: 62852 Min: 17 Act: 26 Avg: 36 Max: 364 T: 2 ( 3912) P:99 I:2000 C: 47139 Min: 15 Act: 18 Avg: 31 Max: 421 T: 3 ( 3913) P:99 I:2500 C: 37711 Min: 15 Act: 29 Avg: 35 Max: 362
pi@raspberrypi ~ $ sudo cyclictest -l1000000 -m -n -a0 -t1 -p99 -i400 -h400 -q # /dev/cpu_dma_latency set to 0us # Histogram # Total: 000249828 # Min Latencies: 00014 # Avg Latencies: 00036 # Max Latencies: 00730 # Histogram Overflows: 00088 # Histogram Overflow at cycle number: # Thread 0: 09404 44073 44392 44551 44630 44869 44908 44988 44989 45025 225464 225760 226073 226682 227131 227653 228740 229146 229241 229244 229416 229797 229801 229893 229954 230007 230010 230071 230186 230275 230368 230467 230487 230545 230563 230680 230757 230916 231005 231099 231103 231195 231236 231332 231579 231713 232099 232959 233891 233892 234087 234464 234614 234621 236152 237379 237733 237818 237987 238038 238040 238078 238142 238236 238330 238474 238691 239425 239515 239608 239723 239726 240186 240189 240353 240467 241170 241259 241349 241539 241596 241630 241633 241724 241873 241907 241971 242005
QuickScan
pi@raspberrypi ~/realtimeconfigquickscan $ perl ./realTimeConfigQuickScan.pl == GUI-enabled checks == Checking if you are root... no - good Checking filesystem 'noatime' parameter... 3.18.11 kernel - good (relatime is default since 2.6.30) Checking CPU Governors... CPU 0: 'powersave' CPU 1: 'powersave' CPU 2: 'powersave' CPU 3: 'powersave' - not good Set CPU Governors to 'performance' with 'cpufreq-set -c <cpunr> -g performance' See also: http://linuxmusicians.com/viewtopic.php?f=27&t=844 Checking swappiness... 1 - good Checking for resource-intensive background processes... none found - good Checking checking sysctl inotify max_user_watches... < 524288 - not good increase max_user_watches by adding 'fs.inotify.max_user_watches = 524288' to /etc/sysctl.conf and rebooting For more information, see http://wiki.linuxaudio.org/wiki/system_configuration#sysctlconf Checking access to the high precision event timer... not found - not good /dev/hpet not found. Checking access to the real-time clock... not found - not good /dev/rtc not found (perhaps create a symlink?). Checking whether you're in the 'audio' group... yes - good Checking for multiple 'audio' groups... no - good Checking the ability to prioritize processes with chrt... yes - good Checking kernel support for high resolution timers... found - good Kernel with Real-Time Preemption... not found - not good Kernel without real-time capabilities found For more information, see http://wiki.linuxaudio.org/wiki/system_configuration#installing_a_real-time_kernel Checking if kernel system timer is set to 1000 hz... not found - not good Try setting CONFIG_HZ to 1000 Checking kernel support for tickless timer... found - good == Other checks == Checking filesystem types... ok. not found. ** Warning: no tmpfs partition mounted on /tmp For more information, see: - http://wiki.linuxaudio.org/wiki/system_configuration#tmpfs - http://lowlatency.linuxaudio.org ** Set $SOUND_CARD_IRQ to the IRQ of your soundcard to enable more checks. Find your sound card's IRQ by looking at '/proc/interrupts' and lspci.
RaspbianWheezy + modifs ccrma pi2
Comparaison wheezy/ccrma
Le /boot de la CCRMA-Satellite est identique à la Raspbian-Wheezy de base à part quelques modifications des fichiers cmdline.txt et config.txt et l'ajout de os_config.json.
- /boot/cmdline.txt : En gras ce qui est ajouté sur la version CCRMA
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p6 rootfstype=ext4 elevator=deadline rootwait fastboot noswap cgroup_enable=memory
Pour comprendre les options de boot c'est par là
- /etc/rc.local :il à aussi d'autres réglages dans le rc.local
sudo apt-get install cpufrequtils
modifier rc.local
cpufreq-set -g performance swapoff -a
QuickScan
pi@raspberrypi ~/realtimeconfigquickscan $ perl ./realTimeConfigQuickScan.pl == GUI-enabled checks == Checking if you are root... no - good Checking filesystem 'noatime' parameter... 3.18.11 kernel - good (relatime is default since 2.6.30) Checking CPU Governors... CPU 0: 'performance' CPU 1: 'performance' CPU 2: 'performance' CPU 3: 'performance' - good Checking swappiness... 1 - good Checking for resource-intensive background processes... none found - good Checking checking sysctl inotify max_user_watches... < 524288 - not good increase max_user_watches by adding 'fs.inotify.max_user_watches = 524288' to /etc/sysctl.conf and rebooting For more information, see http://wiki.linuxaudio.org/wiki/system_configuration#sysctlconf Checking access to the high precision event timer... not found - not good /dev/hpet not found. Checking access to the real-time clock... not found - not good /dev/rtc not found (perhaps create a symlink?). Checking whether you're in the 'audio' group... yes - good Checking for multiple 'audio' groups... no - good Checking the ability to prioritize processes with chrt... yes - good Checking kernel support for high resolution timers... found - good Kernel with Real-Time Preemption... not found - not good Kernel without real-time capabilities found For more information, see http://wiki.linuxaudio.org/wiki/system_configuration#installing_a_real-time_kernel Checking if kernel system timer is set to 1000 hz... not found - not good Try setting CONFIG_HZ to 1000 Checking kernel support for tickless timer... found - good == Other checks == Checking filesystem types... ok. not found. ** Warning: no tmpfs partition mounted on /tmp For more information, see: - http://wiki.linuxaudio.org/wiki/system_configuration#tmpfs - http://lowlatency.linuxaudio.org ** Set $SOUND_CARD_IRQ to the IRQ of your soundcard to enable more checks. Find your sound card's IRQ by looking at '/proc/interrupts' and lspci.
CyclicTest
pi@raspberrypi $ sudo cyclictest -a -t -n -p99 # /dev/cpu_dma_latency set to 0us policy: fifo: loadavg: 0.62 0.71 0.64 2/223 2689 T: 0 ( 2686) P:99 I:1000 C: 30154 Min: 11 Act: 20 Avg: 33 Max: 396 T: 1 ( 2687) P:99 I:1500 C: 20103 Min: 11 Act: 26 Avg: 26 Max: 136 T: 2 ( 2688) P:99 I:2000 C: 15077 Min: 11 Act: 17 Avg: 28 Max: 136 T: 3 ( 2689) P:99 I:2500 C: 12061 Min: 12 Act: 19 Avg: 24 Max: 98
pi@raspberrypi $ sudo cyclictest -l1000000 -m -n -a0 -t1 -p99 -i400 -h400 -q # /dev/cpu_dma_latency set to 0us # Histogram # Total: 001000000 # Min Latencies: 00009 # Avg Latencies: 00022 # Max Latencies: 00311 # Histogram Overflows: 00000 # Histogram Overflow at cycle number: # Thread 0:
Emlid-raspberryPi2-raspbian-rt
http://docs.emlid.com/navio/Downloads/Real-time-Linux-RPi2/
Pas moyen de lancer jack pour le moment, affaire à suivre...
Compilation du noyau depuis la pi
DOCUMENTATION EN COURS
Installation/Configuration
Test à partir d'une image minibian 2015-11-12-jessie-minibian
- voir par ici pour les configurations de bases
Installer les dépendances
sudo apt-get install git bc libncurses5-dev gcc make screen ncurses-dev
Obtenir les sources
git clone --depth=1 https://github.com/raspberrypi/linux
Configuration du noyau
- A partir du noyau actuel
zcat /proc/config.gz > ./.config
- A partir de la configuration par défaut du raspberry
pour pi2
KERNEL=kernel7 make bcm2709_defconfig
pour les autres pi
KERNEL=kernel make bcmrpi_defconfig
Configurer les options du noyau
avec une interface pas très simple à naviguer
make menuconfig
ou une interface plus feng shui
make nconfig
puis sauvegarder les modifications comme .config
- Sources :
https://www.raspberrypi.org/documentation/linux/kernel/building.md
https://github.com/raspberrypi/linux/tree/rpi-4.1.y
Compiler le nouveau noyau
- Compilation (compter ~1h30 pour une pi2)
make -j4
(-j4) pour utiliser 4 processus en même temps ou bien pour créer un paquet (pas encore tester)
make -j4 deb-pkg
- Créer l'image du noyau et compiler les modules
make -j4 zImage modules dtbs sudo make modules_install
Copier le nouveau noyau
sudo cp arch/arm/boot/dts/*.dtb /boot/ sudo cp arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/ sudo cp arch/arm/boot/dts/overlays/README /boot/overlays/ sudo scripts/mkknlimg arch/arm/boot/zImage /boot/kernel-rt.img
Configurer le bootloader et tester le nouveau noyau
- Éditer config.txt
sudo nano /boot/config.txt
et ajouter
disable_splash=1 force_turbo=1 kernel=kernel-rt.img
- Éditer cmdline.txt et ajouter en début de ligne
sudo nano /etc/cmdline.txt sdhci_bcm2708.enable_llm=0 dwc_otg.speed=1
- Redémarrer et test de version
sudo reboot pi@minibian:~$ cat /proc/version Linux version 4.1.17-v7+ (pi@minibian) (gcc version 4.9.2 (Raspbian 4.9.2-10) ) #1 SMP Tue Feb 16 23:22:53 GMT 2016
En cas d'erreurs
- Initialise la compilation mais garde le .config
make clean
- Initialise la compilation et supprime le .config
make mrproper
Patchage du noyau
Télécharger le patch temps réel
- Il faut tout d'abord connaitre la version actuellement installer sur la pi
head Makefile -n 3
uname -r
- Chercher par ici
- puis télécharger le patch correspondant
wget https://www.kernel.org/pub/linux/kernel/projects/rt/4.1/older/patch-4.1.7-rt8.patch.gz gunzip patch*
Appliquer le patch
cat patch-4.1.7-rt8.patch | patch -p1
sources
https://rt.wiki.kernel.org/index.php/RT_PREEMPT_HOWTO
http://framboisepi.fr/compilation-croise-du-kernel-linux-pour-raspberry-pi-2/
http://connect.ed-diamond.com/GNU-Linux-Magazine/GLMFHS-075/Raspberry-Pi-et-temps-reel
http://2014.capitoledulibre.org/symposion_media/media/coverage/linux-temps-reel-sur-raspberry-pi/Linux_RPi_TR_Capitole2014.pdf
sources
http://wiki.linuxaudio.org/wiki/system_configuration#build_your_own_real-time_kernel
https://www.raspberrypi.org/documentation/linux/kernel/building.md
http://www.talkunafraid.co.uk/2014/04/real-time-kernels-and-audio-on-the-raspberry-pi/
http://wiki.linuxaudio.org/wiki/system_configuration#quickscan
http://elinux.org/Raspberry_Pi_Kernel_Compilation
http://www.blaess.fr/christophe/2014/03/06/compilation-native-de-modules-kernel-sur-raspberry-pi/