SPI to Ethernet Communication on Forlinx OK-MX9352-C Board: W5500 Driver Setup & Debug Guide

This article takes Forlinx Embedded’s OK-MX9352-C development board as an example to elaborate on how to adapt the network port module through the SPI interface to achieve Ethernet communication. The W5500 module, a high-performance SPI to 100Mbps Ethe…


This content originally appeared on DEV Community and was authored by ronnie R

This article takes Forlinx Embedded’s OK-MX9352-C development board as an example to elaborate on how to adapt the network port module through the SPI interface to achieve Ethernet communication. The W5500 module, a high-performance SPI to 100Mbps Ethernet chip with up to 80Mbps data rate, suits embedded network needs.

Modules used:

SPI to Ethernet Communication on Forlinx OK-MX9352-C Board: W5500 Driver Setup & Debug Guide

Hardware Connection
Wiring between W5500 and OK-MX9352-C is in the table below.

Develop board pins

W5500 pins

LPSPI3_PCS0 SCS
LPSPI3_SIN MISO
LPSPI3_SOUT MOSI
LPSPI3_SCK SCLK
GPIO_IO04 INT
GPIO_IO05 RST
Among them, SCS is the chip-select signal, MISO is the master-in slave-out data line, MOSI is the master-out slave-in data line, SCLK is the clock signal, INT is the interrupt signal, and RST is the reset signal.

Software Configuration and Driver Debugging

  1. Compilation Drive First, add the relevant options to the kernel configuration

Device Drivers
> Network device support
> Ethernet driver support
......
[*] WIZnet devicesWIZnet W5100 Ethernet support < > WIZnet W5300 Ethernet support
WIZnet interface mode (Select interface mode in runtime) --->WIZnet W5100/W5200/W5500 Ethernet support for SPI mode
......

  1. Devie Tree Modification‌ Add the relevant configuration of W5500 under SPI3 node.

&lpspi3 {
fsl,spi-num-chipselects =;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&pinctrl_lpspi3>;
pinctrl-1 = <&pinctrl_lpspi3>;
cs-gpios = <&gpio2 8 GPIO_ACTIVE_LOW>;
status = "okay";

ethernet: w5500@0 {
    compatible = "wiznet,w5500";
    reg =;
    status = "okay";
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_w5500>;
    interrupt-parent = <&gpio2>;
    interrupts =;
    spi-max-frequency =;
};

};
Multiplexed SPI

pinctrl_lpspi3: lpspi3grp {
fsl,pins = < MX93_PAD_GPIO_IO08_GPIO2_IO08 0x3fe MX93_PAD_GPIO_IO09LPSPI3_SIN 0x3fe MX93_PAD_GPIO_IO10LPSPI3_SOUT 0x3fe MX93_PAD_GPIO_IO11LPSPI3_SCK 0x3fe >;
};
pinctrl_w5500: w5500grp {
fsl,pins = < MX93_PAD_GPIO_IO04
GPIO2_IO04 0x31e //int MX93_PAD_GPIO_IO05_GPIO2_IO05 0x31e //rst >;
};
Since the W5500 driver uses software reset by default, it’s only necessary to ensure that the reset pin is in a pull-up state.

  1. Compilation&Porting Compile the device tree and drivers, including w5100.ko and w5100-SPI. Ko for W5500.

$ root@DESKTOP-GJ47EH8:/home/OKMX93-linux-sdk# ./build.sh kernel
After compiling, replace the device tree on the development board and place the driver in the directory where the system can find it.

$ root@ok-mx93:~# cp /run/media/boot-mmcblk1p1/OK-MX93-C.dtb /run/media/Boot-mmcblk0p1/
$ root@ok-mx93:~# cp /run/media/boot-mmcblk1p1/w5100.ko ./
$ root@ok-mx93:~# cp /run/media/boot-mmcblk1p1/w5100-spi.ko ./

  1. Driver Loading‌ Execute the load driver command on the development board

root@ok-mx93:~# insmod w5100.ko
root@ok-mx93:~# insmod w5100-spi.ko
The new eth2 network card can be seen through the ifconfig -a command, and the network card can be up normally.

root@ok-mx93:~# ifconfig -a
...
eth2: flags=-28605 mtu 1500
inet 169.254.218.84 netmask 255.255.0.0 broadcast 169.254.255.255
inet6 fe80::c4c5:86ff:fe12:9f9d prefixlen 64 scopeid 0x20ether c6:c5:86:12:9f:9d txqueuelen 1000 (Ethernet)
RX packets 2115 bytes 340022 (332.0 KiB)
RX errors 0 dropped 133 overruns 0 frame 0
TX packets 56 bytes 13927 (13.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
...
root@ok-mx93:~# ifconfig eth2 up
root@ok-mx93:~# ifconfig
...
eth2: flags=-28605 mtu 1500
inet 169.254.218.84 netmask 255.255.0.0 broadcast 169.254.255.255
inet6 fe80::c4c5:86ff:fe12:9f9d prefixlen 64 scopeid 0x20ether c6:c5:86:12:9f:9d txqueuelen 1000 (Ethernet)
RX packets 2430 bytes 398823 (389.4 KiB)
RX errors 0 dropped 158 overruns 0 frame 0
TX packets 56 bytes 13927 (13.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
...

  1. Network Test After the driver is loaded, IP can be set normally and the external network can be pinged.

root@ok-mx93:~# ifconfig eth2 172.20.2.167
root@ok-mx93:~# ifconfig
...
eth2: flags=-28605 mtu 1500
inet 172.20.2.167 netmask 255.255.0.0 broadcast 172.20.255.255
inet6 fe80::c4c5:86ff:fe12:9f9d prefixlen 64 scopeid 0x20ether c6:c5:86:12:9f:9d txqueuelen 1000 (Ethernet)
RX packets 8082 bytes 1529102 (1.4 MiB)
RX errors 0 dropped 491 overruns 0 frame 0
TX packets 94 bytes 31366 (30.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
...
root@ok-mx93:~# ping -I eth2 172.20.2.166
PING 172.20.2.166 (172.20.2.166) from 172.20.2.166 eth2: 56(84) bytes of data.
64 bytes from 172.20.2.166: icmp_seq=1 ttl=64 time=0.127 ms
64 bytes from 172.20.2.166: icmp_seq=2 ttl=64 time=0.077 ms
64 bytes from 172.20.2.166: icmp_seq=3 ttl=64 time=0.077 ms
64 bytes from 172.20.2.166: icmp_seq=4 ttl=64 time=0.076 ms
^C
--- 172.20.2.166 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3076ms
rtt min/avg/max/mdev = 0.076/0.089/0.127/0.021 ms


This content originally appeared on DEV Community and was authored by ronnie R


Print Share Comment Cite Upload Translate Updates
APA

ronnie R | Sciencx (2025-03-28T00:54:22+00:00) SPI to Ethernet Communication on Forlinx OK-MX9352-C Board: W5500 Driver Setup & Debug Guide. Retrieved from https://www.scien.cx/2025/03/28/spi-to-ethernet-communication-on-forlinx-ok-mx9352-c-board-w5500-driver-setup-debug-guide/

MLA
" » SPI to Ethernet Communication on Forlinx OK-MX9352-C Board: W5500 Driver Setup & Debug Guide." ronnie R | Sciencx - Friday March 28, 2025, https://www.scien.cx/2025/03/28/spi-to-ethernet-communication-on-forlinx-ok-mx9352-c-board-w5500-driver-setup-debug-guide/
HARVARD
ronnie R | Sciencx Friday March 28, 2025 » SPI to Ethernet Communication on Forlinx OK-MX9352-C Board: W5500 Driver Setup & Debug Guide., viewed ,<https://www.scien.cx/2025/03/28/spi-to-ethernet-communication-on-forlinx-ok-mx9352-c-board-w5500-driver-setup-debug-guide/>
VANCOUVER
ronnie R | Sciencx - » SPI to Ethernet Communication on Forlinx OK-MX9352-C Board: W5500 Driver Setup & Debug Guide. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/03/28/spi-to-ethernet-communication-on-forlinx-ok-mx9352-c-board-w5500-driver-setup-debug-guide/
CHICAGO
" » SPI to Ethernet Communication on Forlinx OK-MX9352-C Board: W5500 Driver Setup & Debug Guide." ronnie R | Sciencx - Accessed . https://www.scien.cx/2025/03/28/spi-to-ethernet-communication-on-forlinx-ok-mx9352-c-board-w5500-driver-setup-debug-guide/
IEEE
" » SPI to Ethernet Communication on Forlinx OK-MX9352-C Board: W5500 Driver Setup & Debug Guide." ronnie R | Sciencx [Online]. Available: https://www.scien.cx/2025/03/28/spi-to-ethernet-communication-on-forlinx-ok-mx9352-c-board-w5500-driver-setup-debug-guide/. [Accessed: ]
rf:citation
» SPI to Ethernet Communication on Forlinx OK-MX9352-C Board: W5500 Driver Setup & Debug Guide | ronnie R | Sciencx | https://www.scien.cx/2025/03/28/spi-to-ethernet-communication-on-forlinx-ok-mx9352-c-board-w5500-driver-setup-debug-guide/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.