Compiling RCIO Kernel Module for Raspberry Pi + Navio2

Instructions for compiling RCIO kernel module for a Raspberry Pi (3/4) + Navio2 system.

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.

Building your own Kernel?

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.


Assumptions

  • 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 lsmod or 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
Loading the Kernel Module Manually

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

[Appendix] Create a Navio2 Patch File

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

References

  • https://community.emlid.com/t/rcio-boot-loop/13458

Was this post helpful?

5 thoughts on “Compiling RCIO Kernel Module for Raspberry Pi + Navio2”

    1. I have not tried it with an Android kernel but I think it’s doable, assuming you are running the Android kernel on a Raspberry Pi board (since the Navio2 module is built for the Raspberry Pi platform.)
      If you are not developing based on Emlid’s kernel (in this case you are not), then you should also make sure that the RCIO’s device tree overlay is correctly integrated into your kernel before the RCIO kernel module can work properly.
      Steps should be similar to what I wrote in this post but with your Android kernel source.

      1. i have tried this step with my Android kernel but he doesn’t boot when i configure it with the “bcm2709_navio2_defconfig” , do u have any idea about this issue ?

        1. Do you have your original Android kernel working on your Raspberry Pi board?
          I would first suggest trying whichever defconfig file that initially works with your Android kernel for the Raspberry Pi.

          1. I have built a custom android kernel from AOSP and it’s running success with the “bcm2709_defconfig”

Leave a Reply

Your email address will not be published.