RealtimePi – out of the box real-time RaspberryPi Raspbian October 9, 2017
Posted by GuySoft in linux, open source, programming.Tags: CustomPiOS, open source, Raspberry Pi, raspbian
trackback
RealtimePi logo
Hey all,
So it started as a curiosity, and it looks like its working. I made a Raspbian-based distro that ships with a realtime kernel called RealtimePi. You can download the latest here. It’s open source, sources are here.
A realtime system means its deterministic, it means you should know how long things take to run. They way to do is is to apply a patch to the linux kernel that makes it non-preemptible. To explain – Preemption is the act of temporarily interrupting a task being carried out by a computer system, without requiring its cooperation, and with the intention of resuming the task later.
This is useful for building hardware and robotics, low latency audio and other gpio because there are no surprises when it comes to timing. It seems like something good to try out with the RaspberryPi, because of the GPIO and IOT capabilities.
Bundled with CustomPiOS you can build your customized realtime-kernel device.
Features
- Both armv6 and arm v7 are supported! Aka all versions of RaspberryPi to date!
- 4.9.52-rt37-v7 with PREEMPT kernel
- Easy way to set up the network using realtimepi_wpa_supplicant.txt in the boot partition
Steps to install
- Download the image here
- Unzip and flash it to an SD card (small enough to fit a 2GB card)
- Open newly flashed image and edit two files, one for the wifi, and one for the bot token:
- Put in realtimepi-wpa-supplicant.txt your wifi address (skip if using Ethernet cable). Here is how it should look:

You can test the realtime kernel is enabled, by running in the commandline
uname -a
You should see something like this, note PREEMPT RT which indicates its realtime:
Linux realtimepi 4.9.52-rt37 #1 PREEMPT RT Fri Oct 6 22:29:28 UTC 2017 armv6l GNU/Linux
The line should look a little different for armv7
I am not an expert with actually building realtime systems, so input on how it preforms, and examples would be appreciated!
I went to try it out. For me, Gadget USB-Ethernet seems to crash under mild network traffic on the pi zero.
Hey, it might be that you got this known issue:
https://www.osadl.org/Single-View.111+M5c03315dc57.0.html
I haven’t managed to reproduce it, so I didn’t apply the patch given there.
They give a workaround, adding this in the cmdline.txt:
dwc_otg.fiq_enable=0
dwc_otg.fiq_fsm_enable=0
If you can try that and report its success or failure, I’ll know what to fix for the next release.
The patch is now part of the release.
Thanks, I’m going to try this with my Pedal-Pi
I recently got a Pedal-Pi too, and was thinking of trying this! How did it go for you?
https://polldaddy.com/js/rating/rating.js
Iv’e been reading and it looks like the Pedal-Pi is just a rewrite of the arduino version. If you already have a Pi you should really try guitarix or rackarack, you can have a full real-time padal system like that. I’m looking in to building a distro for this.
Thank you, I’ll take a swing at those. I look forward to the distro!
Searching for a solution to use effects on raspberry pi.
you should have a look at : https://github.com/BlokasLabs/modep-gen
It uses mod-app (a midi pedalboard for guitar and bass under debian or archlinux) and a midi and analog audio Pi-Hat.
Is there a project page? That is just a fork of the pi-gen buildroot. I really suggest moving to CustomPiOS, its impossible at a glance to understand what that disrro does.
There’s a commercial website to sell the Raspberry Pi Hat named Pisound which is an audio interface + midi interface.
I think it’s a Raspbian lite RT with an application (mod-app) taransforming the Rpi in a midi multieffect with web interface accessible via Wifi adhoc.
Please take a look :
https://blokas.io/
Thanks GuySoft 🙂
PiSound didn’t invent that, they are using moddevices mod-ui. Which you can also get from the Zynthian project that I am part of 🙂
http://zynthian.org/
Also- they are using pi-gen’s source to build it. Which means contributing to it would be a major pain. That is why I built CustomPiOS.
I would have tested the PiSound, but with a price tag of 99 eur its too much for me to experiment with, so i’ve been testing audioinjectors. If you can report audio quality results it would be great, because audioinjector at the moment seems to be lacking it.
I know that PiSound did not invent mod-ui and mod-host etc …
My goal :
– use Rpi 3B or Pi zero W
– my regular usb soundcard + midi (presonus audiobox usb)
– using LV2 plugin with Jack2 etc …
– playing guitar or bass guitar plugged into the usb soudndcard
– possibility to have access with a remote PC or Phone to the parametres of the effects.
my first attemp is here :
In french 🙂
Cool! So is that setup with RealtimePi or just plain raspbian?
I can ship a desktop-install script if you need that.
On this video it’s a raspbian desktop, jack launched by Cadence (from Kxstudio), Guitarix.
I have downloaded the last nightly of realtimepi and i have to test it headless (ssh).
Can I have a graphical window throught ssh ?
You can either install a desktop. Or ssh using -X flag on a computer with X . Or use this script: https://github.com/guysoft/OctoPi/blob/devel/src/modules/octopi/filesystem/home/pi/scripts/install-desktop
Thanks Guysoft !
Ok, my Pi zero W don’t boot.
My Pi 3B is booting very weel. I will test that later.
I can’t for now connect with ssh from Windows 10 and Putty.
I will tell you when it’s ok
Ok GuySoft ! Great ! My Pi3 is booting on RT kernel and desktop is installed and configured. my audio interface is recognised and confirgured as well.
I have to start Jack now. Any advice ? could you help ?
Thanks a lot.
Yoy can try settings of jack with qjackctl, which is a gui tool. Your usb card should work with it. However the USB host driver otg_dwc for raspberrypi is not mainline kernel (meaning its on different fork) and might not work correctly.
https://discourse.zynthian.org/t/realtime-kernel-for-raspi/1063/11?u=guysoft
Hello GuySoft, Not a very good attemp for me.
No possibility to use Under à good latency and more and more xruns. Better with the raspbian lite + lightdm without RT Kernel.
The realtime kernel gives you low latency ,which you do not have with your normal kernel. It doesn’t not increase performance but lowers it.
I get no xruns using a raspberrypi audioinjector card that connects using the i2c interface.
xruns means that you are probably setting wrong settings for your usb card. Or that your card does not work well with a realtime kernel due to it using a usb host module that is not part of the mainline kernel.
See: https://github.com/raspberrypi/linux/issues/2244#issuecomment-342822204
Hello GuySoft, Which audioinjector card should I buy ?
do you have an url of the shop ?
You need either the stereo card: http://www.audioinjector.net/
Or if you are patient they have a new one launching:
https://www.kickstarter.com/projects/1250664710/audio-injector-ultra-sound-card-for-the-raspberry/
I added the above lines. For me, the pi zero was still hanging. I could not get past a ‘sudo apt-get update’. It also crashed for me sometimes while ssh-ing into the device. I tried an external power supply thinking the crashes were due to insufficient power on the OTG port, but that did not seem to solve it. To test if it was the hardware, I went back to a stock raspian sd card and it seemed to be OK.
Sounds like this issue:
https://github.com/guysoft/RealtimePi/issues/3
Hey, there is an RC of version 0.2 with a patch that might solve your problem now:
https://github.com/guysoft/RealtimePi/issues/4
I Just tested the 0.3 version of the nightly builds on the Pi Zero. Everything appears to working much better.
Cyclictests (@idle) are showing latency of :
min: 16us
avg: 34 us
max: 96us
which is better than i thought it would be. Additionally, the USB g_ether was working flawlessly.
Nice Work!
Cool, would appreciate if you report that to the git issue tracker so its saved there, and other users can reply, and not here, where this stuff would be lost.
I have installed it and now I must enter my login data. But I don’t know the default login and password. Can anybody help me?
Same as any raspbian image pi/raspberry
I am having trouble setting up wifi and having it automatically come up on boot.
I have separately tried editing realtimepi-wpa-supplicant.txt and realtimepi-network.txt to have my wifi ssid and key. I have also changed both. From reading the comments in realtimepi-network.txt it seems that only thins file needs to be edited for a single ssid setup.
I cannot however get the wlan going – neither automaticall at boot or manually via iwconfig or ifconfig or iw
What i have for the realtimepi-wpa-supplicant.txt, I put identical info to what I used with a standard raspbian install:
code:
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
Network={
ssid=”myssid”
psk=”mypassword”
key_mgmt=WPA-PSK
}
for realtimepi-network.txt I used:
code:
auto wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
wpa-ssid myssid
wpa-psk mypassword
Some help would be greatly appreciated.
Thank you
G
Please open an issue in the github, this a comment section, not a issue tracker.
https://github.com/guysoft/RealtimePi/issues
Just paste it so we can go though troubleshooting there.
I have created an issue in github. I also corrected my code there.
Hi, have you thinking about a FullpageOS rt-preeemted distro?
You can build that already, but why would you want to build that?
Just install your realTimePi distro but the kernel seems not to be real time :
$ uname -a
Linux NoiseStation 4.14.62-v7+ #1134 SMP Tue Aug 14 17:10:10 BST 2018 armv7l GNU/Linux
should I install the patch myself ?
I don’t know what you had installed, but your hostname is of a different system, it says NoiseStation. Can you please open an issue in the github issue tracker, and describe what exactly you did. https://github.com/guysoft/RealtimePi/issues
I changed my hostname before checking if the kernel was rt. I just put your kernel manually and now i got :
$ uname -a
Linux NoiseStation 4.14.34-rt27-v7 #2 SMP PREEMPT RT Tue Jun 12 19:20:24 UTC 2018 armv7l GNU/Linux
Don’t know what went wrong at flashing time. Do you want me to retry a fresh install to check if it’s doing it again ?
I am not sure why you are asking me what to do – either use the kernel you evidently got working, or post an issue in the issue tracker with a detailed explanation of what is not working for you.
I download the tar file
http://unofficialpi.org/Distros/RealtimePi/2018-06-12_realtimepi-kernel-4.14.34.tar.gz
What directory should I extract this file to so I can compile other application require the header?
Thanks,
Tac.
Use the ready made image. not the tar kernel.
Please post an issue in github, so we can figure what headers are needed, and publish that in separate tar.gz files.
Why not buying this instead
https://www.ebay.com/itm/MH1210B-220V-LCD-Digital-Temp-Controller-Thermocouple-with-Alarming-Sound-R2J2/312218247268?hash=item48b1a86064:g:-0kAAOSwbpVbdqky
https://polldaddy.com/js/rating/rating.js
https://polldaddy.com/js/rating/rating.js
https://polldaddy.com/js/rating/rating.js
Hello Guysoft. I really appreciate that you have rolled a precompiled RT kernel for the RPi, but I have a favour to ask. Could you please build an imahe that is saved in SquashFS?
This would allow me to multiboot it with BerryBoot on my RPi.
Hey Brad,
First suggest you open this as an issue on the GitHub page at: https://github.com/guysoft/RealtimePi/issues
I am not going to do something like this if there is no call, there seems to be a simpe guide how to do this on BerryBoot wiki:
https://www.berryterminal.com/doku.php/berryboot/adding_custom_distributions
You are welcome to help maintain this, I barley get enough time to release. I am behind schedule already supporting 3 A+.