Giter Site home page Giter Site logo

rpi4-preemptrt's Introduction

Raspberry Pi 4 Preempt-RT Patch

These steps will help you through the installation of preempt-rt on the Raspberry Pi 4. The kernel that is used is the 4.19.86 linux kernel.

  • It contains additional support as an option to use W5500 Ethernet network driver for users who need extra ethernet port on raspberry pi.
  • You can find out much more simplified method using pre-built kernel on the link

Requirements:

  • Raspberry Pi 4
  • 16gb Micro-SD card + reader
  • Computer with Ubuntu
  • (Option) WIZnet W5500 Ethernet chip with SPI interface

Create a new raspbian image on the micro-SDcard with the Pi imager. Use the file on the link below.
2020-02-13-raspbian-buster.zip


A. Directory initialization

  1. Create directories on the host computer
host@ubuntu:~$ mkdir rpi-kernel
host@ubuntu:~$ cd rpi-kernel
host@ubuntu:~/rpi-kernel$ mkdir rt-kernel
  1. Start by pulling the linux repository
host@ubuntu:~/rpi-kernel$ git clone -b rpi-4.19.y-rt https://github.com/raspberrypi/linux.git
host@ubuntu:~/rpi-kernel$ git clone https://github.com/raspberrypi/tools.git

B. Building linux

  1. Environment variable setting
host@ubuntu:~/rpi-kernel$ export ARCH=arm
host@ubuntu:~/rpi-kernel$ export CROSS_COMPILE=~/rpi-kernel/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-
host@ubuntu:~/rpi-kernel$ export INSTALL_MOD_PATH=~/rpi-kernel/rt-kernel
host@ubuntu:~/rpi-kernel$ export INSTALL_DTBS_PATH=~/rpi-kernel/rt-kernel
  1. Setting for Raspberry pi 4
host@ubuntu:~/rpi-kernel$ export KERNEL=kernel7l
host@ubuntu:~/rpi-kernel$ cd linux/
host@ubuntu:~/rpi-kernel/linux$ make bcm2711_defconfig
  1. Configurate Kernel Compile options
host@ubuntu:~/rpi-kernel/linux$ sudo apt-get install libncurses-dev libssl-dev flex bison
host@ubuntu:~/rpi-kernel/linux$ make menuconfig
  1. Edit the following variables:
[Kernel hacking] → [Debug preemptible kernel] Off
(Option) [Device Drivers] → [Network device support] → [Ethernet driver support] → [WIZnet W5100 Ethernet support], [WIZnetW5100/W5200/W5500 Ethernet support for SPI mode] On
  1. Build the linux kernel (This can take some time, so get coffee or tea...)
host@ubuntu:~/rpi-kernel/linux$ make -j4 zImage modules dtbs
host@ubuntu:~/rpi-kernel/linux$ make –j4 modules_install dtbs_install

C. Installing the linux kernel on the Micro-SD card

  1. Create .img Kernel file
host@ubuntu:~/rpi-kernel/linux$ mkdir $INSTALL_MOD_PATH/boot
host@ubuntu:~/rpi-kernel/linux$ ./scripts/mkknlimg ./arch/arm/boot/zImage $INSTALL_MOD_PATH/boot/$KERNEL.img
  1. Replace the Kernel to Raspberry Pi
host@ubuntu:~/rpi-kernel/linux$ cd $INSTALL_MOD_PATH
host@ubuntu:~/rpi-kernel/rt-kernel$ tar czf ../rt-kernel.tgz *
host@ubuntu:~/rpi-kernel/rt-kernel$ cd ..
host@ubuntu:~/rpi-kernel$ scp rt-kernel.tgz pi@<raspberry pi IP address>:/tmp

D. Installing the preempt-rt on the Raspberry pi

  1. Inside the raspberry pi, unpack the .tgz and copy it
pi@raspberrypi:~$ cd /tmp
pi@raspberrypi:/tmp$ tar xzf rt-kernel.tgz
pi@raspberrypi:/tmp$ cd boot
pi@raspberrypi:/tmp/boot$ sudo cp -rd * /boot/
pi@raspberrypi:/tmp/boot$ cd ../lib
pi@raspberrypi:/tmp/lib$ sudo cp -rd * /lib/
pi@raspberrypi:/tmp/lib$ cd ../overlays
pi@raspberrypi:/tmp/overlays$ sudo cp -d * /boot/overlays
pi@raspberrypi:/tmp/overlays$ cd ..
pi@raspberrypi:/tmp$ sudo cp -d bcm* /boot/
  1. Edit the boot configutarion
pi@raspberrypi:/tmp$ sudo nano /boot/config.txt

Add in the beginning:

kernel=kernel7l.img

(Option) Type in the last line:

dtoverlay=w5500
  1. Reboot and check the patched kernel
pi@raspberrypi:/tmp$ sudo reboot
pi@raspberrypi:~$ uname -r

BENCHMARK:

rpi4-preemptrt's People

Contributors

shkwon98 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

rpi4-preemptrt's Issues

Issue after Build the linux kernel

After doing

make -j4 zImage 
make -j4 modules 
make -j4 dtbs 

I get error at this step do you have idea what could be the issue
make -j4 modules_install

I have attached the error snapshot
dtbs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.