Compiling and replacing the Linux kernel (with yours) on an existing, working Raspberry Pi system is fairly easy and straightforward. However, if you’re using Navio2 which relies on an RCIO kernel module to communicate with Navio2 for handling PWM, ADC, SBUS and PPM, you will most likely bump into a version inconsistency issue between the Linux kernel and the RCIO kernel module (and Navio2 no longer works). Even if you are compiling the kernel obtained from the Raspbian repository maintained by Emlid, it won’t work as the source code for the RCIO kernel module is not included.
To solve the aforementioned issue, the RCIO kernel module has to be compiled against your kernel and be specifically installed on your system.
In this article, instructions for compiling installing the RCIO kernel module directly on your Raspberry Pi system are introduced.
Since you are highly likely in the development of your own custom kernel, it is recommended to patch your kernel to include RCIO source code to avoid further hassles. Skip here and go to this post for details.
- Your Raspberry Pi + Navio2 can work properly before altering the kernel
[Step 0] Set Up Development Environment on Raspberry Pi (3/4)
If you have not already installed all the necessary tools, run the following command to get everything you need [ref]:
sudo apt install git bc bison flex libssl-dev make
[Step 1] Get Linux Kernel Source Code
cd /lib/modules/4.19.83-emlid-v7l+/ sudo rm build sudo git clone --depth=1 https://github.com/cchen140/linux-rt-rpi.git build cd build sudo git checkout rpi-4.19.83-navio
Optionally, configure the kernel based on your needs.
sudo vim arch/arm/configs/bcm2711_navio2_defconfig sudo make bcm2711_navio2_defconfig
[Step 2] Get RCIO Source Code
cd ~ git clone https://github.com/cchen140/rcio-dkms.git cd rcio-dkms
For those who are interested in how compiling a kernel module works, check the
Makefile in the folder.
[Step 3] Compile and Install
To compile and install the RCIO kernel module, run:
sudo make -j 5 sudo dkms remove rcio/1.0.0 --all sudo dkms install .
Note that the RCIO source code provided in the above link has a version of 1.0.0, so these instructions will install/load
rcio/1.0.0 into the kernel.
[Step 4] Verify RCIO Status (Optional)
To verify if the RCIO kernel module has been correctly loaded, you can use
dmesg. An example is given as follows:
lsmod | grep rcio
You should see a similar output like shown below if RCIO is running correctly.
rcio_spi 16384 0 rcio_core 36864 1 rcio_spi
Try the following to load the RCIO kernel module if you don’t see them loaded already (i.e., the output above is empty):
sudo modprobe rcio_spi sudo modprobe rcio_core
Check out a Emlid’s RT Linux branch, and then we can extract the changes for Navio2 into a patch file:
git format-patch -10 HEAD --stdout > navio2-4.14.19.patch
To apply the patch, go to the root folder of the target Linux source code and move the patch file to here, then run:
git apply --stat navio2-4.14.19.patch git apply --check navio2-4.14.19.patch git am < navio2-4.14.19.patch