Real time Kernels for FD810?

versatile 64-bit multi-user Linux distribution

Moderators: kirk, jamesbond, p310don, JakeSFR, step, Forum moderators

Post Reply
paulski
Posts: 7
Joined: Fri Aug 28, 2020 7:46 am
Location: Germany

Real time Kernels for FD810?

Post by paulski »

I've been enjoying playing around with many of the good music packages and DAWs on the repository in FD810 Final.
(A big thankyou for whoever is doing the hard work getting working recipes for those things off the ground and compiling them!)

Of course Fatdog is not meant to be a music specialist distro - There is some good work to be found on the old forum for that (e.g. music2go or studio13.37).

But for my general messing around (Fatdog is my main workhorse distro) I wouldn't mind using a real time kernel.

Looking through the repository I notice there might have been one for previous FD 810 Betas or similar - 4.19.24

Nothing for 4.19.92 or newer.

Does anyone know how to compile one? Any hints or links? Or anyone game enough to compile one?
user1111

Re: Real time Kernels for FD810?

Post by user1111 »

Nothing for 4.19.92 or newer
Doesn't seem so under the standard Fatdog repo. Looking through http://distro.ibiblio.org/fatdog/kernels/810/ and yes the only RT choice is

kernel-modules.sfs-4.19.24-rt14
vmlinuz-4.19.24-rt14

Which you can install using the guidance provided in FatDog help, specifically ...

cd /usr/share/doc/fd-help
mdview kernel.md

Kernel compilation can take quite a while. Never had a reason to compile my own RT kernel. However looking at this http://murga-linux.com/puppy/viewtopic. ... 71#1045571 and stemsee indicates that usage of a kernel built by rockedge (and still a active link in rockedge's posts a few posts above that) ... and it seems that 4.19.82-rt30 SMP PREEMPT RT kernel build worked well for Fatdog. But still short of your desire for 4.19.92 or later.
User avatar
rockedge
Site Admin
Posts: 5904
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2130 times
Been thanked: 2234 times
Contact:

Re: Real time Kernels for FD810?

Post by rockedge »

You can check out the various real time kernels I've complied that are tested and work.
https://rockedge.org/kernels/

I am working on a 5.6.X real time kernel but so far I am reaching kernel panic during the boot process, so so refinement needed.
Clarity
Posts: 3397
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1396 times
Been thanked: 449 times

Re: Real time Kernels for FD810?

Post by Clarity »

A stupid question from a stupid user (me).
  • What is missing in a RT kernel that the normal kernel have?
  • Is a RT kernel recommended for any general purpose system where multiple or many multiple things are being done?
The ONLY way I know to reduce latency is to dedicate the OS+Application such that no other system elements get service. Is that still true?
jamesbond
Posts: 605
Joined: Tue Aug 11, 2020 3:02 pm
Location: The Pale Blue Dot
Has thanked: 99 times
Been thanked: 325 times

Re: Real time Kernels for FD810?

Post by jamesbond »

@paulski
You can thank me for that :lol:

Now, to the kernel: I don't build RT kernels any more because they're often hit and miss. However, many of the benefits of RT kernel (as far as audio work is concerned) can also be found in low-latency kernel. The 5.4.60 kernel in ibiblio is configured as such, with 1000Hz timer tick, exactly for that purpose. If you add "threadirqs" to the boot options. you can use rtirq script to control the priority of your sound card interrupts just like the RT kernel. See details here: https://wiki.linuxaudio.org/wiki/system_configuration.

If you still want to try newer RT kernel, then give @rockedge kernels a try. I haven't tried them myself so I can't say whether they are suitable for Fatdog, but there is nothing wrong with trying, especially, because with Fatdog you can temporarily boot and use another kernel without modifying anything other than your bootloader configuration.

Code: Select all

### Example for grub2, modify as needed
menuentry "Fatdog64 5.4.60" {
	linux /vmlinuz-5.4.60 rootfstype=ramfs extrasfs=ram:device:sda5:/kernel-modules.sfs-5.4.60
	initrd /initrd
}
@Clarity
RT kernel meets the hard real-time requirements, e.g. certain actions must be done precisely at certain time (or event). It is usually used to control machineries (CNC comes to mind), and audio work with sub-millisecond latencies (read: professional audio recording, like that Rainer does for a living).

Is RT kernel recommended for general purpose system? No, absolutely not. RT kernels have their downsides, and are usually slower when doing general purpose workloads, not to mention that if you don't use them correctly, they can easily lock up your computer.
___

EDIT: remove references to private server as ibiblio's access is now up and we have updated the kernel modules with the correct drivers.
User avatar
rockedge
Site Admin
Posts: 5904
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2130 times
Been thanked: 2234 times
Contact:

Re: Real time Kernels for FD810?

Post by rockedge »

File servers and web servers actually run best not using RT kernels. I use 4.19.82-rt30 in several Bionic64-CE's with success but I could use a newer low latency kernel just as well. I do get really good performance on one particular machine with this combo, with very low CPU usage especially at idle and low temperatures even under stress.
jamesbond
Posts: 605
Joined: Tue Aug 11, 2020 3:02 pm
Location: The Pale Blue Dot
Has thanked: 99 times
Been thanked: 325 times

Re: Real time Kernels for FD810?

Post by jamesbond »

rockedge wrote: Fri Sep 04, 2020 2:21 am File servers and web servers actually run best not using RT kernels.
Indeed. It's about using the right tools for the job.
I use 4.19.82-rt30 in several Bionic64-CE's with success but I could use a newer low latency kernel just as well
You're welcome to try the 5.4.60 kernel. The source is here: http://distro.ibiblio.org/fatdog/sfs/800/ (this is what I mean by the "usual places").
User avatar
rockedge
Site Admin
Posts: 5904
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2130 times
Been thanked: 2234 times
Contact:

Re: Real time Kernels for FD810?

Post by rockedge »

Thanks @jamesbond

I have a 5.4.5-rt3 that works really well that I am using. I'll give the 5.4.60 a drive around the block, might come in handy later on.
User avatar
Duprate
Posts: 304
Joined: Sat Aug 22, 2020 8:14 pm
Location: Southern Brazil
Has thanked: 151 times
Been thanked: 104 times

Re: Real time Kernels for FD810?

Post by Duprate »

Hello! When I hear the word "kernel", my ears stand up! I don't understand enough about it, but the explanations were very useful. What I can say is that I am using the 5.4.60 kernel at http://distro.ibiblio.org/fatdog/kernels/810, on FatDog64 810 and also on Debian 10.5. Without any noticeable change in what already worked perfectly for me in FatDog64. All browsers, Wine, PortableApps Platform, many 32-bit Windows games. Today, this is my main and irreplaceable system! Thanks to the FatDog64 developers!
paulski
Posts: 7
Joined: Fri Aug 28, 2020 7:46 am
Location: Germany

Re: Real time Kernels for FD810?

Post by paulski »

Thanks everyone for all the help so far. This is still such a good forum!

I think I'll give the 5.4.60 a try and see if the latency is good enough for my audio needs.

I really notice the time delay in 4.19.92 kernel when trying to record Audio via a USB Audio Device.
(I might just do the upgrade to FD 8.11 which will do the same and get me a 5.4.60 Kernel).
Failing that I 'll try Rockedge's kernels.
...and failing that I might take a few days off and try actually compiling the 5.4.61 Kernel as kernel.org doesn't have a RT patch for 5.4.60 but they do for 5.4.61 if I'm navigating the site right.... (need a bit more courage before I go that far and actually compile a kernel).

I'll report back for whatever works - hopefully it helps others too.
User avatar
rockedge
Site Admin
Posts: 5904
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2130 times
Been thanked: 2234 times
Contact:

Re: Real time Kernels for FD810?

Post by rockedge »

I just attempted to compile a real time 5.4.61-rt37 kernel. The real time and aufs5 patches were successful but compilation failed. Looking into that later today. Using the kernel-kit, the build is about 60% before an error halts the build. All the real time kernel preemption options for full RT are present in the configuration options.

Build machine is running Fossapup64-9.0.5
user1111

Re: Real time Kernels for FD810?

Post by user1111 »

Each/every 5 series kernel I've tried compiling fails to boot. Looks like UEFI keys are failing despite this laptop being set to legacy boot mode (booting using grub4dos). Tried all sorts of commenting out the likes of CONFIG_SYSTEM_TRUSTED_KEYRING/whatever, but to no avail, make -j2 opts to reactivate that setting, the kernel compiles, but when I boot it - it just locks up.

No idea how to work around that.
User avatar
puddlemoon
Posts: 189
Joined: Sun Sep 06, 2020 9:26 pm
Location: In between
Has thanked: 89 times
Been thanked: 64 times

Re: Real time Kernels for FD810?

Post by puddlemoon »

paulski wrote: Sun Sep 20, 2020 1:50 pm (need a bit more courage before I go that far and actually compile a kernel).

I'll report back for whatever works - hopefully it helps others too.
I hear that. i have managed to build one with arch/aur but it seems like cheating as it's so automated.

meanwhile, would the kernels in this thread be compatible with other puppies/dogs?
user1111

Re: Real time Kernels for FD810?

Post by user1111 »

puddlemoon wrote: Tue Sep 22, 2020 3:54 pm
paulski wrote: Sun Sep 20, 2020 1:50 pm (need a bit more courage before I go that far and actually compile a kernel).

I'll report back for whatever works - hopefully it helps others too.
I hear that. i have managed to build one with arch/aur but it seems like cheating as it's so automated.
Going to https://www.kernel.org/releases.html ... 5.4 version has a end of life projection of Dec 2025. Following the higher level folders in the following script for both busybox (all of the useful unix commands) and kernel, I edit the file to point to those. With a pre-prepared initrd.gz that I migrate from one build to the next ... I've just started that script running

Code: Select all

# Load fatdog devx
# MAKE SURE THE INITRD.GZ IS IN THE SAME FOLDER AS BUILD.SH
# AS THIS SCRIPT COPIES THAT INTO THE VMLINUZ (BZIMAGE)

# Modified version of as outlined in this thread/post
#http://www.murga-linux.com/puppy/viewtopic.php?p=949389

# We build a standard Linux kernel and initial basic initrd
# but replace that initrd with a cutdown fatdog version that
# includes wifi net connect and ssh/scp .. also includes our
# ssh keys (update - not now, removed that) that are ccrypt
# encrypted so if we lose the usb then keys are encrypted. 
# ccrypt was specifically compiled for busybox using musl and
# is upx'd 

# Modify the following two wget's as desired
wget http://kernel.org/pub/linux/kernel/v5.x/linux-5.4.66.tar.gz
wget http://busybox.net/downloads/busybox-1.32.0.tar.bz2
mkdir bootfiles
tar -xvf linux-5.4.66.tar.gz
tar -xvf busybox-1.32.0.tar.bz2
cd busybox-1.32.0
make distclean defconfig
sed -i "s/.*CONFIG_STATIC.*/CONFIG_STATIC=y/" .config
make busybox install
cd _install
rm -f linuxrc
mkdir dev proc sys
echo '#!/bin/sh' > init
echo 'dmesg -n 1' >> init
echo 'mount -t devtmpfs none /dev' >> init
echo 'mount -t proc none /proc' >> init
echo 'mount -t sysfs none /sys' >> init
echo 'setsid cttyhack /bin/sh' >> init
chmod +x init
find . | cpio -R root:root -H newc -o | gzip > ../../bootfiles/initrd-basic.gz
cd ../../linux-5.4.66
# Replace default initramfs_data.cpio with our initrd.gz
# i.e build the initrd.gz into the kernel
cp ../initrd.gz usr/.
cd usr
rm initramfs_data.cpio
gzip -d initrd.gz
mv initrd initramfs_data.cpio
cd ..
N=`nproc`
N=`expr $N + 1`
#make -j$N mrproper defconfig bzImage
make localyesconfig
#sed -i "s/CONFIG_OVERLAY_FS.*/CONFIG_OVERLAY_FS=y/" .config
make -j$N
cp arch/x86/boot/bzImage ../bootfiles/vmlinuz
Hopefully, in 1 hour 30 to 2 hours time I'll have a vmlinuz that can be booted alone.

That's building the standard linux kernel and standard busybox, so it will be interesting to see if that works for me. As it builds using make localyesconfig then it is machine specific, just compiles in all of the modules for that box into the kernel (along with initrd also being contained within the kernel).

I just leave it running and the system activity is usually a good indicator of it having paused to ask something (or have completed)

s.png
s.png (269.34 KiB) Viewed 776 times

Building via fatdog is even easier, download the kernel sources and devx, extract the kernel sources (to HDD as it all takes quite a bit of disk space), cd to the sources sub folder and run make -j2 (for if you have 2 cores, -j4 if you have four ... etc. i.e. the more cores you throw at it the quicker is will build).

If you run make menuconfig before running make -j2 then that will present a menu of all of the settings, that you can change as you see fit. There's masses of options however so it takes a lot of reading/understanding to know whether any one setting should be on or off. Most Linux kernels have it set to that you can view the .config file content it was built with, that you can view/extract by running

zcat /proc/config.gz >.config

So if you put such a .config into the sources folder before running make -j2, it will build using that configuration. Has to be from the same version however, if not, then run make oldconfig after having copied in the .config file, and that will update it accordingly.
User avatar
rockedge
Site Admin
Posts: 5904
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2130 times
Been thanked: 2234 times
Contact:

Re: Real time Kernels for FD810?

Post by rockedge »

the ones I have made should work. I tested all the ones I have available from Bionic32 and Bionic64 through to Tahr64 and Tahr32 and Xenial. I have run some with the FirstRib and WeeDog32-Void and WeeDog64-Void with success as well.
They are here for browsing and downloading -> https://rockedge.org/kernels/
User avatar
puddlemoon
Posts: 189
Joined: Sun Sep 06, 2020 9:26 pm
Location: In between
Has thanked: 89 times
Been thanked: 64 times

Re: Real time Kernels for FD810?

Post by puddlemoon »

Thanks @rockedge
That's just what i needed to know. I've seen your collection but was unsure about puppy/dog compatibility.
my demands are not specific enough to focus on building one. Really the low latency is sufficient for the most part but i will be testing yours.
cheers!
user1111

Re: Real time Kernels for FD810?

Post by user1111 »

I've given up with building a 5.x kernel, opted to instead upgrade from 4.14 to 4.19. Every 5.x I've build compiles OK but just wont boot.

So opted to compile the 4.19.146 (latest dot release, along with latest busybox).

Less than 7.5MB for full busybox complement of commands along with automatic wifi net connect at bootup and ssh (using dropbear). Fatdog as a 'toolchain' is great :thumbup2:

Code: Select all

Standard Linux kernel 4.19.146, busybox 1.32.0 made with localyesconfig
(so laptop/machine specific, all modules/firware built into the kernel. 
initrd also incorporated into the kernel, so only needs bzImage (vmlinuz)
to boot. Other that busybox (and a number of scripts) just has static versions
of dropbear and wpa_supplicant binaries added in. Fundamentally a thin
client, that wifi net connects automatically at bootup (ssid/password 
passed as boot parameters), that can then ssh into other boxes. KASLR
enabled (to kernel randomised), also prompts whether to use a random mac
or not at startup.

Less than 7.5MB total bzImage filesize

# free -m
              total        used        free      shared  buff/cache   available
Mem:           3401          21        3373           5           6        3161
Swap:             0           0           0


# uname -a
Linux bulldog64 4.19.146 #3 SMP Wed Sep 23 14:54:44 BST 2020 x86_64 GNU/Linux


# cd / 
# du -sh *

2.6M    bin
4.0K    dev
28.0K   docs
148.0K  etc
4.0K	home
0       init
8.0K    init.txt
36.0K   kernel
4.0K    lib
0       lib64
0       linuxrc
0       mnt
0       opt
0       proc
12.0K   root
0       run
28.0K   sbin
0       sys
0       tmp
2.7M    usr
0       var

# df -h
Filesystem                Size      Used Available Use% Mounted on
devtmpfs                  1.7G      4.0K      1.7G   0% /dev


# ls -l bzImage
-rw-r--r--    1 root     root       7835696 Sep 23 13:56 bzImage


Booted using BIOS style boot and grub4dos
title Pugdog 4.19.146 LTS to Dec 2025 busybox 1.32
root (hd0,3)
kernel /CODE/MINI/FRESH-BUILD/bzImage net=wpa2:VMxxxxxx-xx:xxxxxxxxx:wlan0:dhcp
jamesbond
Posts: 605
Joined: Tue Aug 11, 2020 3:02 pm
Location: The Pale Blue Dot
Has thanked: 99 times
Been thanked: 325 times

Re: Real time Kernels for FD810?

Post by jamesbond »

rufwoof wrote:Less than 7.5MB for full busybox complement of commands along with automatic wifi net connect at bootup and ssh (using dropbear).
That illustrates the point exactly that if you are prepare to spend the effort to customise and optimise the kernel down to one specific system only, you can make it very, very small. :thumbup2:
And that's exactly what Fatdog is - a tinkerer's dog (perhaps we should rename it to TinkerDog) :lol:
jamesbond
Posts: 605
Joined: Tue Aug 11, 2020 3:02 pm
Location: The Pale Blue Dot
Has thanked: 99 times
Been thanked: 325 times

Re: Real time Kernels for FD810?

Post by jamesbond »

I've just built real-time kernel 5.4.66-rt38. It uses the same config as 811's 5.4.60 (except that this one is PREEMPT_RT). The usual 3rd party drivers are included, and kernel source is also available.

EDIT: I have moved the real-time Linux kernel 5.4.66-rt38 to its proper locations as I've run with it for a while now and it feels stable. You can now find it here: http://distro.ibiblio.org/fatdog/kernels/800. The kernel source can be found here: http://distro.ibiblio.org/fatdog/sfs/800/.
user1111

Re: Real time Kernels for FD810?

Post by user1111 »

jamesbond wrote: Wed Sep 23, 2020 3:27 pm That illustrates the point exactly that if you are prepare to spend the effort to customise and optimise the kernel down to one specific system only, you can make it very, very small. :thumbup2:
And that's exactly what Fatdog is - a tinkerer's dog (perhaps we should rename it to TinkerDog) :lol:
This is the init (system-init)

Code: Select all

#!/bin/ash

# Format of our boot (grub4dos menu.lst entry) ...
# kernel /bzImage net=wpa2:<ssid>:<password>:wlan0:dhcp
# Change <ssid> and <password> to actual ssid and password

### bail out unless we're PID 1
[ $$ -eq 1 ] || exit 1

### configuration parameters
DEFAULT_DEVICE_DELAY=0	# seconds - default delay time for devices (so that they are recognised by kernel)
WIFI_ENABLE_TIMEOUT=${WIFI_ENABLE_TIMEOUT:-100}	# unit of 1/10 seconds, max time to wait for wifi connection
KERNEL_POLL_MSECS=${KERNEL_POLL_MSECS:-5000}	# default kernel polling value if unset

### utilities - decz
# decz - decrements counter, and return true when it is zero
# $1 - name of variable to be decremented
decz() {
	local curval
	eval "curval=\$$1"
	curval=$((curval-1))
	[ $curval -le 0 ] && return 0
	eval "$1=$curval"
	return 1
}

### cmdline processing - net
process_net() {
	[ -z "$net" ] && return;
	OIFS="$IFS"; IFS=":"; set -- $net; IFS="$OIFS"
	
	echo -n "Configure network "
	echo "on $2 ($1) using dhcp"
	echo " "
	
	# Ask if want to use a random mac
	/usr/sbin/random-mac-ask $4
	
	busybox ifconfig $4 up
	wpa_supplicant -B -C/var/run/wpa_supplicant -Dwext -i$4
	wpa_cli ap_scan 1 > /dev/null
	wpa_cli add_net 0 > /dev/null
	wpa_cli set_net 0 ssid \"$2\" > /dev/null
	wpa_cli set_net 0 psk \"$3\" > /dev/null
	wpa_cli select_net 0 > /dev/null
	while [ "$(wpa_cli status | sed -ne '/wpa_state/ {s/wpa_state=//;p}')" != "COMPLETED" ];
	do
		sleep 0.1; decz WIFI_ENABLE_TIMEOUT && return
	done;
	iwconfig $4 power off # disable power management
	shift 2
	# connection type
	udhcpc -i $2 > /dev/null
	ifconfig lo up	# in any case bring loopback up also
}

######################   main   ##########################

# mount core filesystems
/bin/mount -t proc proc /proc # mount /proc first so /proc/self/exe works from now
mount -t sysfs sysfs /sys
if ! mount -t devtmpfs devtmpfs /dev 2> /null; then		# /dev/null may not exist yet
	# if no devtmpfs, use tmpfs and use mdev instead
	mount -t tmpfs tmpfs /dev -o mode=755 # mode 755 is what devtmpfs uses
	mdev -s
fi

[ -f /null ] && rm /null	# Clear up the null file created above
[ ! -e /dev/shm ] && mkdir -p /dev/shm
[ ! -e /dev/pts ] && mkdir -p /dev/pts
[ "$TZ" ] && hwclock -t # set kernel timezone

# debugging and error logging
# comment out next two lines for greater info during bootup
! grep -q showerr /proc/cmdline && exec 2> /dev/initrd.err
grep -q debuginitrd /proc/cmdline && set -x

# enable polling
if ! grep -q block.events_dfl_poll_msecs /proc/cmdline; then # if not explicitly set
	echo $KERNEL_POLL_MSECS > /sys/module/block/parameters/events_dfl_poll_msecs
fi

# keymap hard coded to use uk (GB)
loadkmap < /lib/boot/keymaps/uk

echo "Connecting to the net in readiness for ssh key checking"
process_net

export HOME=/root

#echo if want just pure console mode no job control no tty no ssh etc
#while :; do
#  /bin/ash
#done

# pseudo terminal so we can run screen ssh etc
mount -t devpts none /dev/pts -o ptmxmode=0666,newinstance # pseudo terminal for screen

# attach to a tty so we can ssh, use screen ...etc.
while :; do
	setsid cttyhack /bin/ash
done
... and I've just noticed iwconfig, which I deleted the bin for, so will have to reinsert that in again (but seems to work ok without adjusting the power management)
paulski
Posts: 7
Joined: Fri Aug 28, 2020 7:46 am
Location: Germany

Re: Real time Kernels for FD810?

Post by paulski »

I said I'd report back - Man you're all moving fast - this is turning into a gold thread I'll be referencing when it comes to compiling a kernel. Courage building stuff! Thanks everyone.

I found for my general messing around the standard low latency kernel with 8.11 is really good.. a bit of midi, or guitar and effects work... but I will get ambitious soon and find where it falls down. (I'll run all the audio gear i've got at once!). And there's some interesting CNC stuff out there - love to have a laptop running fatdog telling a CNC router what to do.

Thanks Jamesbond for making a 5.4.66-rt38 kernel. Saw it on the repo before Iooked here.
I plan to make a separate boot and try it out to compare.
Post Reply

Return to “FatDog64”