{"id":26399928,"url":"https://github.com/albrechtl/rpi-managed-switch-4-port","last_synced_at":"2026-01-03T08:06:43.752Z","repository":{"id":280458139,"uuid":"942005572","full_name":"AlbrechtL/rpi-managed-switch-4-port","owner":"AlbrechtL","description":"An open source 4 port Gigabit managed switch based on a Raspberry Pi","archived":false,"fork":false,"pushed_at":"2025-03-03T14:11:01.000Z","size":1637,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-03T15:24:43.081Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlbrechtL.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-03T12:21:03.000Z","updated_at":"2025-03-03T14:11:05.000Z","dependencies_parsed_at":"2025-03-03T15:35:12.911Z","dependency_job_id":null,"html_url":"https://github.com/AlbrechtL/rpi-managed-switch-4-port","commit_stats":null,"previous_names":["albrechtl/rpi-managed-switch-4-port"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlbrechtL%2Frpi-managed-switch-4-port","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlbrechtL%2Frpi-managed-switch-4-port/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlbrechtL%2Frpi-managed-switch-4-port/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlbrechtL%2Frpi-managed-switch-4-port/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlbrechtL","download_url":"https://codeload.github.com/AlbrechtL/rpi-managed-switch-4-port/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244041840,"owners_count":20388312,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-17T13:32:42.966Z","updated_at":"2026-01-03T08:06:43.746Z","avatar_url":"https://github.com/AlbrechtL.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# 4-Port Managed Switch\n\nAn open-source 4-port gigabit managed switch HAT based on a Raspberry Pi with OpenWrt support.\n\n**Disclaimer:** This is an ongoing project where some features are not working, and some hardware bugs may exist.\n\n![4 Port Managed Switch Front](pictures/switch-front.jpg)\n\n## Features\n* 4 Gigabit Ethernet RJ45 ports  \n* Supports Raspberry Pi 1–5 (including Raspberry Pi Zero 1–2)  \n  - Tested with a Raspberry Pi Zero 1  \n  - Raspberry Pi 5 is not working with OpenWrt due to this [issue](https://github.com/openwrt/openwrt/issues/18034)  \n* Works with a [custom OpenWrt](https://github.com/AlbrechtL/rpi-managed-switch-openwrt/tree/rpi_managed_switch)  \n* Two overlays:  \n  1. For Linux [Distributed Switch Architecture (DSA)](https://www.kernel.org/doc/Documentation/networking/dsa/dsa.txt)  \n  2. For OpenWrt [swconfig](https://openwrt.org/docs/techref/swconfig)  \n* VLAN support\n* Switching hardware offloading support \n* Hardware design in KiCad\n* Ready for JLCPCB production\n  - Using a much as possible basic parts to lower the assembling costs\n\n## Software Status\n\nThe hardware works with a modified OpenWrt: https://github.com/AlbrechtL/openwrt/tree/rpi_managed_switch\n\nI added the following to OpenWrt:  \n* Two device tree overlays (for swconfig and DSA)  \n* Enabled the ENC28J60 driver  \n* Added a small patch to enable the ENC28J60 for DSA  \n* Added detection of swconfig or DSA in the first boot scripts so that OpenWrt uses the switch  \n\nSee the differences:  \nhttps://github.com/openwrt/openwrt/compare/main...AlbrechtL:openwrt:rpi_managed_switch  \n\nTo communicate with the RTL8367S switch chip, two different Linux drivers are available:  \n\n**1. Distributed Switch Architecture (DSA)**\n\nDriver: `drivers/net/dsa/realtek/rtl8365mb.c`\n* Pros:  \n  - Integrated into the Linux kernel  \n  - Mainline RTL8367S support  \n  - Works on Raspberry Pi OS with a custom Linux kernel\n* Cons:\n  - Hardware offloading and VLAN support only via patch (see https://github.com/AlbrechtL/openwrt/commit/a1c16e23b97d4cd1c184bd464960a6b93470e16a)\n  - There was a discussion on the Linux kernel mailing list about the missing hardware offloading and VLAN support (https://lkml.iu.edu/hypermail/linux/kernel/2407.0/01589.html)\n  - OpenWrt driver discussion (https://forum.openwrt.org/t/reduce-number-of-drivers-for-rtl8367s/237681)\n\nWorking DSA Example:\n```\nroot@OpenWrt:~# ip addr\n1: lo: \u003cLOOPBACK,UP,LOWER_UP\u003e mtu 65536 qdisc noqueue state UNKNOWN qlen 1000\n    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00\n    inet 127.0.0.1/8 scope host lo\n       valid_lft forever preferred_lft forever\n    inet6 ::1/128 scope host \n       valid_lft forever preferred_lft forever\n2: eth0: \u003cBROADCAST,MULTICAST,UP,LOWER_UP\u003e mtu 1508 qdisc fq_codel state UP qlen 1000\n    link/ether b8:27:eb:8f:43:df brd ff:ff:ff:ff:ff:ff\n    inet6 fe80::ba27:ebff:fe8f:43df/64 scope link \n       valid_lft forever preferred_lft forever\n3: lan1@eth0: \u003cBROADCAST,MULTICAST,UP,LOWER_UP\u003e mtu 1500 qdisc noqueue master switch state UP qlen 1000\n    link/ether b8:27:eb:8f:43:df brd ff:ff:ff:ff:ff:ff\n4: lan2@eth0: \u003cNO-CARRIER,BROADCAST,MULTICAST,UP\u003e mtu 1500 qdisc noqueue master switch state DOWN qlen 1000\n    link/ether b8:27:eb:8f:43:e0 brd ff:ff:ff:ff:ff:ff\n5: lan3@eth0: \u003cNO-CARRIER,BROADCAST,MULTICAST,UP\u003e mtu 1500 qdisc noqueue master switch state DOWN qlen 1000\n    link/ether b8:27:eb:8f:43:e1 brd ff:ff:ff:ff:ff:ff\n6: lan4@eth0: \u003cBROADCAST,MULTICAST,UP,LOWER_UP\u003e mtu 1500 qdisc noqueue master switch state UP qlen 1000\n    link/ether b8:27:eb:8f:43:e2 brd ff:ff:ff:ff:ff:ff\n7: switch: \u003cBROADCAST,MULTICAST,UP,LOWER_UP\u003e mtu 1500 qdisc noqueue state UP qlen 1000\n    link/ether b8:27:eb:8f:43:df brd ff:ff:ff:ff:ff:ff\n    inet6 fe80::ba27:ebff:fe8f:43df/64 scope link \n       valid_lft forever preferred_lft forever\n8: switch.1@switch: \u003cBROADCAST,MULTICAST,UP,LOWER_UP\u003e mtu 1500 qdisc noqueue state UP qlen 1000\n    link/ether b8:27:eb:8f:43:df brd ff:ff:ff:ff:ff:ff\n    inet 192.168.1.1/24 brd 192.168.1.255 scope global switch.1\n       valid_lft forever preferred_lft forever\n    inet6 fd8d:3fdb:486f::1/60 scope global noprefixroute \n       valid_lft forever preferred_lft forever\n    inet6 fe80::ba27:ebff:fe8f:43df/64 scope link \n       valid_lft forever preferred_lft forever\n```\n\nOpenWrt DSA screenshot  \n![OpenWrt dsa](pictures/openwrt-switch-screenshot-dsa.png)  \n\n**1. OpenWrt swconfig**\n\nDriver: `drivers/net/phy/rtl8367b.c`\n* Pros:  \n  - Full hardware offloading support  \n  - VLAN support  \n* Cons:  \n  - OpenWrt-specific  \n  - OpenWrt is transitioning from swconfig to DSA  \n\nOpenWrt swconfig screenshot  \n![OpenWrt swconfig](pictures/openwrt-switch-screenshot.png)  \n\n## Hardware Status\n\nI have two assembled PCBs that have basic functionality. See [issues](https://github.com/AlbrechtL/rpi-managed-switch-4-port/issues) for a list of hardware problems.\n\n**Raspberry Pi Zero**\n![4 Port Managed Switch Top](pictures/switch-top.jpg)\n\n**Raspberry Pi 5**\n![4 Port Managed Switch Top](pictures/switch-top-rpi5.jpg)\n\n## Performance\n\nI don't have detailed performance measurements yet, but here are some bandwidth indications:  \n* **RJ45–RJ45 with DSA (rtl8365mb) and offloading patch:** ~1 Gbit/s (wire speed, full-duplex)   \n* **RJ45–RJ45 with DSA (rtl8365mb):** ~2 Mbit/s  \n  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.  \n* **RJ45–RJ45 with OpenWrt swconfig (rtl8367b):** ~1 Gbit/s (wire speed, full-duplex)  \n* **Raspberry Pi to RJ45 (CPU port):** ~5 Mbit/s (half-duplex)  \n  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.  \n\n\n## Acknowledgements\n\nI would like to thank the following open-source projects. Without these great works, this open-source switch would not be possible:  \n* [OpenWrt](https://openwrt.org/)  \n* RTL8367S Managed Switch  \n  - Blog post: https://blog.brixit.nl/making-a-linux-managed-network-switch/  \n  - KiCad: https://github.com/FOSDEM/video/tree/master/hardware/pcbs/switch_board  \n* ENC28J60 on a Raspberry Pi Zero  \n  - Hackster: https://www.hackster.io/lightside-instruments/the-ethernet4pizero-ethernet-for-raspberry-pi-zero-shield-dd4316  \n  - KiCad: https://github.com/lightside-instruments/ethernet4pizero.git  \n* [RPI5-CFE-Hat](https://github.com/will127534/RPI5-CFE-Hat)  \n* [PCIe3_Hub](https://github.com/will127534/PCIe3_Hub)  \n* [RouterPi](https://github.com/ZakKemble/RouterPi)  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falbrechtl%2Frpi-managed-switch-4-port","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falbrechtl%2Frpi-managed-switch-4-port","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falbrechtl%2Frpi-managed-switch-4-port/lists"}