An open-source 4-port gigabit managed switch HAT based on a Raspberry Pi with OpenWrt support.
Disclaimer: This is an ongoing project where some features are not working, and some hardware bugs may exist.
- 4 Gigabit Ethernet RJ45 ports
- Supports Raspberry Pi 1–5 (including Raspberry Pi Zero 1–2)
- Tested with a Raspberry Pi Zero 1
- Raspberry Pi 5 is not working with OpenWrt due to this issue
- Works with a custom OpenWrt
- Supported by Linux Distributed Switch Architecture (DSA)
- VLAN support
- Switching hardware offloading support
- Hardware design in KiCad
- Ready for JLCPCB production
- Using a much as possible basic parts to lower the assembling costs
The hardware works with a adapted OpenWrt: https://github.com/AlbrechtL/openwrt/tree/rpi_managed_switch
I added the following to OpenWrt:
- Device tree overlays for DSA
- Enabled the ENC28J60 driver
- Added a small patch to enable the ENC28J60 for DSA
- Added detection of DSA in the first boot scripts so that OpenWrt uses the switch
See the differences:
https://github.com/openwrt/openwrt/compare/main...AlbrechtL:openwrt:rpi_managed_switch
Communication with the RTL8367S switch chip uses Linux DSA. There is also an OpenWrt-specific driver (drivers/net/phy/rtl8367b.c) for OpenWrt's legacy swconfig framework, but since OpenWrt is moving to DSA, it does not make sense to use it in this project. That said, this driver does work with this switch.
Distributed Switch Architecture (DSA)
The to go Linux driver is: drivers/net/dsa/realtek/rtl8365mb.c
- Key aspects:
- Integrated into the Linux kernel
- Mainline RTL8367S support
- Works on Raspberry Pi OS with a custom Linux kernel
- Actively maintained
- Hardware offloading and VLAN support
- May be added into Linux 7.2 (https://lore.kernel.org/all/20260606-realtek_forward-v13-0-b9e409687cbe@gmail.com/)
- Available in mainline OpenWrt (openwrt/openwrt#23738)
DSA Example:
root@OpenWrt:~# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1508 qdisc fq_codel state UP qlen 1000
link/ether b8:27:eb:8f:43:df brd ff:ff:ff:ff:ff:ff
inet6 fe80::ba27:ebff:fe8f:43df/64 scope link
valid_lft forever preferred_lft forever
3: lan1@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master switch state UP qlen 1000
link/ether b8:27:eb:8f:43:df brd ff:ff:ff:ff:ff:ff
4: lan2@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master switch state DOWN qlen 1000
link/ether b8:27:eb:8f:43:e0 brd ff:ff:ff:ff:ff:ff
5: lan3@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master switch state DOWN qlen 1000
link/ether b8:27:eb:8f:43:e1 brd ff:ff:ff:ff:ff:ff
6: lan4@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master switch state UP qlen 1000
link/ether b8:27:eb:8f:43:e2 brd ff:ff:ff:ff:ff:ff
7: switch: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
link/ether b8:27:eb:8f:43:df brd ff:ff:ff:ff:ff:ff
inet6 fe80::ba27:ebff:fe8f:43df/64 scope link
valid_lft forever preferred_lft forever
8: switch.1@switch: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
link/ether b8:27:eb:8f:43:df brd ff:ff:ff:ff:ff:ff
inet 192.168.1.1/24 brd 192.168.1.255 scope global switch.1
valid_lft forever preferred_lft forever
inet6 fd8d:3fdb:486f::1/60 scope global noprefixroute
valid_lft forever preferred_lft forever
inet6 fe80::ba27:ebff:fe8f:43df/64 scope link
valid_lft forever preferred_lft forever
I have two assembled PCBs that have basic functionality. See issues for a list of hardware problems.
I don't have detailed performance measurements yet, but here are some bandwidth indications:
- RJ45–RJ45 with DSA (rtl8365mb) and offloading patches: ~1 Gbit/s (wire speed, full-duplex)
- RJ45–RJ45 with DSA (rtl8365mb): ~2 Mbit/s
Currently, the RTL8367S DSA driver doesn't support hardware offloading. As a result, all traffic is routed through the Raspberry Pi and the very slow SPI interface. For a switch, this is not acceptable. - Raspberry Pi to RJ45 (CPU port): ~5 Mbit/s (half-duplex)
To support the inexpensive Raspberry Pi Zero, an external SPI Ethernet chip (ENC28J60) is used to connect to the main switch chip (RTL8367S). Due to the slow SPI interface, only ~5 Mbit/s can be achieved. However, for a managed web interface, that's sufficient.
I would like to thank the following open-source projects. Without these great works, this open-source switch would not be possible:
- OpenWrt
- RTL8367S Managed Switch
- ENC28J60 on a Raspberry Pi Zero
- RPI5-CFE-Hat
- PCIe3_Hub
- RouterPi



