ADIN1110 Linux kernel configuration
In the following tutorial I explain the procedure to generate ADIN1110 kernel module and load it at boot.
What is the use of a linux kernel module?
A Linux Kernel Module (LKM) is a piece of code that can be dynamically loaded and unloaded into the Linux kernel at runtime. These modules extend the functionality of the Linux kernel without requiring a reboot. Here are some common uses and benefits of Linux Kernel Modules:
Device Drivers: One of the primary uses of kernel modules is to provide device drivers. Hardware devices like network cards, graphics cards, and USB peripherals often require specific drivers to interact with the kernel. Kernel modules allow these drivers to be loaded when needed and unloaded when they are no longer required.
Linux Kernel Modules provide a flexible way to extend and customize the Linux kernel’s functionality, making it easier to manage hardware, add features, and experiment with new capabilities without the need for a full kernel rebuild or system reboot.
SW Environment preparation
The following commands are for a kernel compilation on Rpi. For Raspberry Pi 4 and 400, and Raspberry Pi Compute Module 4 the default kernel is a 32-bit build configuration. More details on cross compilation like 64bit Raspy Os, or different architecture can be found on official link.
First of all we need to install the tools chain and download the kernel source files.
sudo apt install git bc bison flex libssl-dev make
git clone --depth=1 https://github.com/raspberrypi/linux
When the download was completed
cd linux
make bcm2711_defconfig
make menuconfig
The menuconfig shows a terminal graphic with blue and gray colors. Use the key “/” and search CRC8, then enable the module.
Use the key “/” and search Switch , then enable the module Switch (and switch-ish) device support.
Use the key “/” and search ADIN, then enable the modules Analog Devices Industrial Ethernet TlL PHYs, Analog Devices ADIN1110 MAC-PHY and Analog Devices Industrial Ethernet PHYs.
Enable the modules with option M.
Before exit from menuconfig, save the custom configuration in .config file.
Compile and install kernel modules
make -j4 zImage modules dtbs
sudo make modules_install
sudo cp arch/arm/boot/dts/*.dtb /boot/
sudo cp arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/
sudo cp arch/arm/boot/dts/overlays/README /boot/overlays/
KERNEL=kernel7l
sudo cp arch/arm/boot/zImage /boot/$KERNEL.img
Generate overlay file
To generate overlay file, copy the following code in adin1110-overlay.dts
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2708";
fragment@0 {
target = <&spi0>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
eth1: adin1110@0{
compatible = "adi,adin1110";
reg = <0>; /* CE0 */
pinctrl-names = "default";
pinctrl-0 = <ð1_pins>;
interrupt-parent = <&gpio>;
interrupts = <22 0x2>;
spi-max-frequency = <23000000>;
mac-address = [ CA 2F B7 10 23 63 ];
status = "okay";
phy@1 {
compatible = "ethernet-phy-id0283.bc91";
reg = <0>;
};
};
};
};
fragment@1 {
target = <&spidev0>;
__overlay__ {
status = "disabled";
};
};
fragment@2 {
target = <&gpio>;
__overlay__ {
eth1_pins: eth1_pins {
brcm,pins = <22>;
brcm,function = <0>; /* in */
brcm,pull = <0>; /* none */
};
};
};
};
Generate the dtbo file
sudo dtc -@ -I dts -O dtb -o adin1110.dtbo adin1110-overlay.dts
Copy the adin1110.dtbo in /boot/overlays/
Add adint1110 in /boot/config.txt
dtoverlay=adin1110
It is possible to force Raspberry to load kernel at 32bit adding this line kernel=kernel7l.img in config.txt
Before reboot the board check the jumpers configuration, SPI_CGF0 and SPI_CGF1 must be enable to put ADIN1110 in generic SPI protocol without CRC.
Reboot the board with sudo reboot.
If all the procedure is ok we can see al the modules loaded, use the command lsmod | grep adin
We can check if the overlay file was loaded without error with dmesg | grep adin1
With ifconfig we can check if eth1 is configured
It is important to note that the eth1 MAC address is defined in overlay file.
Leave a Reply