Raspberry Pi 4 RT Preempt Kernel

More
17 Aug 2019 17:48 #142398 by BigJohnT
I've been trying to get the RT Preempt kernel going on my RPi4.

I followed this guide from our wiki:
sudo apt update
sudo apt install git
git clone --depth=1 https://github.com/raspberrypi/linux -b rpi-4.14.y-rt
sudo apt install bison flex libncurses5-dev libssl-dev bc mc
cd linux
KERNEL=kernel7
make bcm2709_defconfig
make menuconfig 
make -j4 zImage
make -j4 modules
make -j4 dtbs
sudo make modules_install

Install the RT PREEMPT Kernel
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 cp arch/arm/boot/zImage /boot/$KERNEL.img

sudo reboot -n

I also tried the newer kernel but didn't find the fully preemptable option.
git clone --depth=1 https://github.com/raspberrypi/linux -b rpi-4.19.y-rt

When I check the kernel after rebooting I get this:
pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.19.58-v7l+ #1245 SMP Fri Jul 12 17:31:45 BST 2019 armv7l GNU/Linux

When it's supposed to report back:
Linux raspberrypI 4.14.66-rt40-v7+ #1 SMP PREEMPT RT Sat Sep 1 16:17:01 +07 2018 armv7l GNU/Linux

In the /boot directory I see 3 kernel images:
-rwxr-xr-x 1 root root 4994704 Aug 17 07:41 kernel7.img
-rwxr-xr-x 1 root root 5600072 Aug 16 07:32 kernel7l.img
-rwxr-xr-x 1 root root 5017424 Aug 16 07:32 kernel.img

I'm kinda stuck... and need a kick start.

Thanks
JT

Please Log in or Create an account to join the conversation.

More
17 Aug 2019 17:51 - 17 Aug 2019 17:55 #142399 by Hakan
make bcm2711_defconfig
is the only difference I can see.

Ooh I see one more thing
KERNEL=kernel7l

www.raspberrypi.org/documentation/linux/kernel/building.md
Last edit: 17 Aug 2019 17:55 by Hakan.

Please Log in or Create an account to join the conversation.

More
17 Aug 2019 18:01 #142401 by BigJohnT
pi@raspberrypi:~ $ cd linux
pi@raspberrypi:~/linux $ KERNEL=kernel7l
pi@raspberrypi:~/linux $ make bcm2711_defconfig
***
*** Can't find default configuration "arch/arm/configs/bcm2711_defconfig"!
***
make[1]: *** [scripts/kconfig/Makefile:113: bcm2711_defconfig] Error 1
make: *** [Makefile:520: bcm2711_defconfig] Error 2

The only two I have are:
-rw-r--r-- 1 pi pi 33076 Aug 17 06:46 bcm2709_defconfig
-rw-r--r-- 1 pi pi  3737 Aug 17 06:46 bcm2835_defconfig

JT

Please Log in or Create an account to join the conversation.

More
17 Aug 2019 18:07 #142402 by BigJohnT
Browsing the repository for rpi-4.19.y-rt I see that fully preempt is selected and bcm2711_defconfig is in that one.

JT

Please Log in or Create an account to join the conversation.

More
17 Aug 2019 20:54 - 17 Aug 2019 21:04 #142410 by Bari
Between the bootloader (preferably u-boot) and the preempt_rt kernel config one will want to turn off all power management, speed stepping, core clock governor etc etc so that the cpu cores stay at a constant clock rate and no clocks stop or slow down for power management for the memory, cpu cores, internal bus between the memory, cpu cores and the IO used for real time, etc etc. The features to adjust the above should not even be in the kernel unless they are required to lock them into their highest rates. Not doing so will just cause latency issues and less than optimum real time performance.

The stock preempt_rt kernel for the pi's I've seen don't do this.

Also check out QEMU to build arm64 kernels on your x86 PC to save hours or days of time
wiki.ubuntu.com/ARM64/QEMU
github.com/sakaki-/gentoo-on-rpi3-64bit/...QEMU-and-binfmt_misc
Last edit: 17 Aug 2019 21:04 by Bari. Reason: add QEMU info

Please Log in or Create an account to join the conversation.

More
18 Aug 2019 06:14 - 18 Aug 2019 06:16 #142415 by Hakan
Yes, all tests I have made, and I think everyone here, is with rpi-4.19.y-rt. At least for the RPi4 that is the right one.
That needs to be updated in the wiki.
The build instructions for the RPi4 from the link I gave above is in principle OK. But with the rpi-4.19.y-rt version and to
double-check that full preempt is selected (it should). in the config.

Additionally,
- for acceptable latencies, add "isolcpus=1,2,3" to the line in /boot/cmdline.txt after you compile the kernel.
- to not have the system hibernate/suspend/whatever and bring down the ethernet interface after a while, do
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
( Ref:https://wiki.debian.org/Suspend )
That should make it possible to run 1 ms servo-thread with mesa ethernet-interfaced cards.
- to lower latency even further, bring down the wlan interface,
sudo ifdown wlan0
but that is optional, I have it working fine here with the wlan0 active.

Bari, do you know any other settings that should be in place?
Last edit: 18 Aug 2019 06:16 by Hakan.

Please Log in or Create an account to join the conversation.

More
18 Aug 2019 10:15 - 18 Aug 2019 10:33 #142425 by BigJohnT

Between the bootloader (preferably u-boot) and the preempt_rt kernel config one will want to turn off all power management, speed stepping, core clock governor etc etc so that the cpu cores stay at a constant clock rate and no clocks stop or slow down for power management for the memory, cpu cores, internal bus between the memory, cpu cores and the IO used for real time, etc etc. The features to adjust the above should not even be in the kernel unless they are required to lock them into their highest rates. Not doing so will just cause latency issues and less than optimum real time performance.

The stock preempt_rt kernel for the pi's I've seen don't do this.

I did turn off frequency scaling during the make menuconfig

Also check out QEMU to build arm64 kernels on your x86 PC to save hours or days of time
wiki.ubuntu.com/ARM64/QEMU
github.com/sakaki-/gentoo-on-rpi3-64bit/...QEMU-and-binfmt_misc


I checked out those links but they are at a level way above me and didn't make much sense.

JT
Last edit: 18 Aug 2019 10:33 by BigJohnT.

Please Log in or Create an account to join the conversation.

More
18 Aug 2019 11:40 #142431 by Hakan
It doesn't take that long to compile the kernel on the RPi4, a few hours at the most.

Please Log in or Create an account to join the conversation.

More
18 Aug 2019 12:42 #142433 by BigJohnT
Took about 1.5 hours to compile the kernel on my RPi4. But doing it over SSH you just do other stuff while it runs.

BTW, I did get the preempt rt kernel up and going and I'm installing LinuxCNC now and used OpenBox as the window manager. Total time to do all will be 3 hours.

JT
The following user(s) said Thank You: tommylight

Please Log in or Create an account to join the conversation.

More
18 Aug 2019 14:26 #142440 by BigJohnT
I got as far as building LinuxCNC with debuild -uc -us but ran into an error...
Traceback (most recent call last):
  File "../bin/halcompile", line 24, in <module>
    from yapps import runtime
ImportError: No module named yapps

So I made sure yapps2 was installed...
john@raspberrypi:~/emc $ sudo apt install yapps2
[sudo] password for john: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
yapps2 is already the newest version (2.2.1-3).

So I tested in python...
john@raspberrypi:~/emc $ python
Python 2.7.16 (default, Apr  6 2019, 01:42:57) 
[GCC 8.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from yapps import runtime
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named yapps

Then I checked to see if yapps was available.
john@raspberrypi:~/emc $ sudo apt install yapps
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package yapps

Anyone have a suggestion?
JT

Please Log in or Create an account to join the conversation.

Time to create page: 0.146 seconds
Powered by Kunena Forum