Install Debian 11¶
Download the Raspberry Pi 32 bit OS with desktop and recommended software from here then click on Raspberry Pi OS and download the Raspberry Pi OS with desktop and recommended software.
I used 2022-09-22-raspios-bullseye-armhf-full.img.xz for this tutorial.
If your burning this on a Linux PC the easy way is to install the Gnome Disk Utility.
sudo apt install gnome-disk-utility
Then right click on the iso file and open with disk image writer
Select the destination and start restoring
Install the sd card in the Rpi and boot up.
Click Next to get started setting up the OS
Set Country and Language etc.
Enter user name and password.
Setup or Skip Wifi
Update software
If you want to do this from a Linux PC on your LAN enable SSH. On the Rpi open a From the menu go to Preferences > Raspberry Pi Configuration on the Interfaces tab enable SSH. And while your there on the Display tab disable Screen Blanking.
On the Rpi to find the IP address open a terminal (Ctrl Alt t) and do
hostname -I
On another Linux PC you can ssh into the Rpi and do all the following using the ip address of the Rpi or just do them on the Rpi, which ever is more convenient.
ssh 192.168.x.xxx
On the Rpi 4 or in a SSH terminal do the following to install packages needed to build a kernel.
Install the realtime kernel (5.15.65-rt49) As reported in github.com/kdoren/linux/releases
sudo su
cd /tmp
wget https://github.com/kdoren/linux/releases/download/rpi_5.15.65-rt49/linux-image-5.15.65-rt49-v7l+_5.15.65-1_armhf.deb
apt install ./linux-image-5.15.65-rt49-v7l+_5.15.65-1_armhf.deb
KERN=5.15.65-rt49-v7l+
mkdir -p /boot/$KERN/o/
cp -d /usr/lib/linux-image-$KERN/overlays/* /boot/$KERN/o/
cp -dr /usr/lib/linux-image-$KERN/* /boot/$KERN/
[[ -d /usr/lib/linux-image-$KERN/broadcom ]] && cp -d /usr/lib/linux-image-$KERN/broadcom/* /boot/$KERN/
touch /boot/$KERN/o/README
mv /boot/vmlinuz-$KERN /boot/$KERN/
mv /boot/initrd.img-$KERN /boot/$KERN/
mv /boot/System.map-$KERN /boot/$KERN/
cp /boot/config-$KERN /boot/$KERN/
cat >> /boot/config.txt << EOF
[all]
kernel=vmlinuz-$KERN
# initramfs initrd.img-$KERN
os_prefix=$KERN/
overlay_prefix=o/$(if [[ "$KERN" =~ 'v8' ]]; then echo -e "\narm_64bit=1"; fi)
[all]
EOF
Optimizing kernel
nano /boot/cmdline.txt
Add isolcpus=1,2,3 idle=poll to the end of the string then press Ctrl x, y, Enter
Logout and Reboot
exit
sudo reboot
Check the kernel is a real time kernel in a terminal
uname -a
Linux raspberrypi 5.15.65-rt49-v7l+ #1 SMP PREEMPT_RT Tue Sep 6 05:54:28 BST 2022 armv7l GNU/Linux