Skip to content

cpu/efm32: add ethernet driver#22306

Open
basilfx wants to merge 6 commits into
RIOT-OS:masterfrom
basilfx:feature/efm32_eth
Open

cpu/efm32: add ethernet driver#22306
basilfx wants to merge 6 commits into
RIOT-OS:masterfrom
basilfx:feature/efm32_eth

Conversation

@basilfx

@basilfx basilfx commented May 19, 2026

Copy link
Copy Markdown
Member

Contribution description

Note

Development of this PR happens in parallel to the LPC1768 ethernet driver in #22305. Any feedback on this one is likely applicable to the other one as well. I will try to keep both PRs in sync where it matters.

This PR adds an ethernet driver for the EFM32. While working on the LPC1768 version, I decided to also add support for the EFM32.

What is provided:

  • Low-level driver with netdev driver on top of it.
  • Separate modules (efm32_eth_link_up, efm32_eth_auto) like the STM32.
  • lwIP/GNRC auto-initialization.
  • Kconfig tunables for buffers/timeouts/etc.

Testing procedure

The only EFM32 board with ethernet in RIOT's code base, is the SLSTK3701a.

Like the LPC1768 ethernet driver, I would rather receive feedback on the general structure and adoption. I will then do my best to collect as much evidence as possible.

Testing has been performed as follows:

  • Compile tests (mixes options and toolchains, see below)
  • Benchmark UDP
  • Driver test in tests/drivers/efm32_eth
  • Ping test (including fragmentation and large frames, >12 hours)
  • lwIP iPerf (depends on examples/networking/misc/lwiperf: add application #22286).
  • IPv4/IPv6.
  • Monkey testing (link up/down etc).

Based on this, I believe it is in a working state.

With efm32_eth_auto enabled, the link speed is ~7.5-10 MBit/sec (measured using lwIP iPerf).

Compile test
#!/bin/sh

set -e

BOARD=slstk3701a make -C tests/drivers/efm32_eth -j 14
BOARD=slstk3701a USEMODULE=efm32_eth_link_up make -C tests/drivers/efm32_eth -j 14
BOARD=slstk3701a USEMODULE=efm32_eth_auto make -C tests/drivers/efm32_eth -j 14

BOARD=slstk3701a make -C examples/networking/misc/benchmark_udp -j 14
BOARD=slstk3701a USEMODULE=efm32_eth_link_up make -C examples/networking/misc/benchmark_udp -j 14
BOARD=slstk3701a USEMODULE=efm32_eth_auto make -C examples/networking/misc/benchmark_udp -j 14

BOARD=slstk3701a LWIP=1 make -C examples/networking/misc/benchmark_udp -j 14
BOARD=slstk3701a USEMODULE=efm32_eth_link_up LWIP=1 make -C examples/networking/misc/benchmark_udp -j 14
BOARD=slstk3701a USEMODULE=efm32_eth_auto LWIP=1 make -C examples/networking/misc/benchmark_udp -j 14

# lwIP IPerf application is still a PR
# BOARD=slstk3701a LWIP_IPV4=1 LWIP_IPV6=1 make -C examples/networking/misc/lwiperf -j 14
# BOARD=slstk3701a USEMODULE=efm32_eth_link_up LWIP_IPV4=1 LWIP_IPV6=1 make -C examples/networking/misc/lwiperf -j 14
# BOARD=slstk3701a USEMODULE=efm32_eth_auto LWIP_IPV4=1 LWIP_IPV6=1 make -C examples/networking/misc/lwiperf -j 14

BOARD=slstk3701a LWIP_IPV4=1 LWIP_IPV6=1 make -C examples/basic/default -j 14
BOARD=slstk3701a USEMODULE=efm32_eth_link_up LWIP_IPV4=1 LWIP_IPV6=1 make -C examples/basic/default -j 14
BOARD=slstk3701a USEMODULE=efm32_eth_auto LWIP_IPV4=1 LWIP_IPV6=1 make -C examples/basic/default -j 14

TOOLCHAIN=llvm BOARD=slstk3701a make -C tests/drivers/efm32_eth -j 14
TOOLCHAIN=llvm BOARD=slstk3701a USEMODULE=efm32_eth_link_up make -C tests/drivers/efm32_eth -j 14
TOOLCHAIN=llvm BOARD=slstk3701a USEMODULE=efm32_eth_auto make -C tests/drivers/efm32_eth -j 14

TOOLCHAIN=llvm BOARD=slstk3701a make -C examples/networking/misc/benchmark_udp -j 14
TOOLCHAIN=llvm BOARD=slstk3701a USEMODULE=efm32_eth_link_up make -C examples/networking/misc/benchmark_udp -j 14
TOOLCHAIN=llvm BOARD=slstk3701a USEMODULE=efm32_eth_auto make -C examples/networking/misc/benchmark_udp -j 14

TOOLCHAIN=llvm BOARD=slstk3701a LWIP=1 make -C examples/networking/misc/benchmark_udp -j 14
TOOLCHAIN=llvm BOARD=slstk3701a USEMODULE=efm32_eth_link_up LWIP=1 make -C examples/networking/misc/benchmark_udp -j 14
TOOLCHAIN=llvm BOARD=slstk3701a USEMODULE=efm32_eth_auto LWIP=1 make -C examples/networking/misc/benchmark_udp -j 14

# lwIP IPerf application is still a PR
# TOOLCHAIN=llvm BOARD=slstk3701a LWIP_IPV4=1 LWIP_IPV6=1 make -C examples/networking/misc/lwiperf -j 14
# TOOLCHAIN=llvm BOARD=slstk3701a USEMODULE=efm32_eth_link_up LWIP_IPV4=1 LWIP_IPV6=1 make -C examples/networking/misc/lwiperf -j 14
# TOOLCHAIN=llvm BOARD=slstk3701a USEMODULE=efm32_eth_auto LWIP_IPV4=1 LWIP_IPV6=1 make -C examples/networking/misc/lwiperf -j 14

TOOLCHAIN=llvm BOARD=slstk3701a LWIP_IPV4=1 LWIP_IPV6=1 make -C examples/basic/default -j 14
TOOLCHAIN=llvm BOARD=slstk3701a USEMODULE=efm32_eth_link_up LWIP_IPV4=1 LWIP_IPV6=1 make -C examples/basic/default -j 14
TOOLCHAIN=llvm BOARD=slstk3701a USEMODULE=efm32_eth_auto LWIP_IPV4=1 LWIP_IPV6=1 make -C examples/basic/default -j 14

Issues/PRs references

None

Declaration of AI-Tools / LLMs usage:

AI-Tools / LLMs that were used are:

  • Claude Code generated the first (non-working) version of the driver in cpu/efm32. I then refined, reworked and tested it myself. I did ask Claude Code to analyze bugs I encountered during testing. The final PR review was also done with Claude Code, but changes were applied manually. The test application, auto-init adoption and several other parts are simply copy-paste of existing drivers.

@github-actions github-actions Bot added Platform: ARM Platform: This PR/issue effects ARM-based platforms Area: network Area: Networking Area: doc Area: Documentation Area: tests Area: tests and testing framework Area: build system Area: Build system Area: pkg Area: External package ports Area: drivers Area: Device drivers Area: boards Area: Board ports Area: cpu Area: CPU/MCU ports Area: sys Area: System Area: Kconfig Area: Kconfig integration labels May 19, 2026
@basilfx basilfx added the Type: new feature The issue requests / The PR implemements a new feature for RIOT label May 19, 2026
@crasbe crasbe added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label May 19, 2026
@riot-ci

riot-ci commented May 19, 2026

Copy link
Copy Markdown

Murdock results

FAILED

0f63ccf features: add efm32_eth to features

Success Failures Total Runtime
2463 0 10343 03m:59s

Artifacts

@basilfx basilfx force-pushed the feature/efm32_eth branch from 0c09c87 to 42ecd8b Compare May 20, 2026 06:39

@benpicco benpicco left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, just some nits

Comment thread cpu/efm32/periph/eth.c Outdated
Comment thread cpu/efm32/include/periph_cpu.h Outdated
Comment thread cpu/efm32/drivers/eth/eth_netdev.c
Comment thread cpu/efm32/periph/eth.c Outdated
Comment thread cpu/efm32/periph/eth.c Outdated
Comment thread cpu/efm32/periph/eth.c
Comment thread cpu/efm32/periph/eth.c Outdated
Comment thread cpu/efm32/periph/eth.c Outdated
Comment thread cpu/efm32/periph/eth.c Outdated
@basilfx

basilfx commented May 29, 2026

Copy link
Copy Markdown
Member Author

Some comments on the LPC1768 driver also apply here, so I will do some minor fixups to align both drivers next week. Thanks @benpicco.

@basilfx

basilfx commented May 29, 2026

Copy link
Copy Markdown
Member Author

Update on the preliminary test results: a ping test with 16-byte increases up to 2048 bytes has been running non-stop for the past two-ish weeks. Apart from a few switch reboots (UniFi stuff), the MCU did not crash/reboot.

@basilfx basilfx force-pushed the feature/efm32_eth branch from 69fac13 to 457145a Compare June 1, 2026 21:00
@basilfx

basilfx commented Jun 1, 2026

Copy link
Copy Markdown
Member Author

@benpicco I think I have covered all comments so far. Can I do an intermediate squash?

Mean while, I will start with final testing. Now that the lwiperf example is in, I can also do some 'load' tests.

@benpicco

benpicco commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Sure, please squash

@basilfx

basilfx commented Jun 2, 2026

Copy link
Copy Markdown
Member Author

Update on the test reults: #22305 (comment)

@basilfx basilfx force-pushed the feature/efm32_eth branch 3 times, most recently from 5fa16f0 to 1ed3398 Compare June 3, 2026 21:40
@basilfx

basilfx commented Jun 3, 2026

Copy link
Copy Markdown
Member Author

@benpicco the last three fixup commits are the changes I did since the intermediate squash. Most of them are a consequence of the changes I did to the LPC1768 driver too.

This branch is currently tested again.

@basilfx basilfx added the State: waiting for other PR State: The PR requires another PR to be merged first label Jun 3, 2026
@basilfx

basilfx commented Jun 3, 2026

Copy link
Copy Markdown
Member Author

Adding wait for PR because #22305 must be merged first, and #22344 too.

Comment thread pkg/lwip/Makefile.dep
basilfx added 6 commits June 5, 2026 00:10
This commit adds a driver for the ethernet peripheral. It is split
into a low-level peripheral driver, and a higher-level netdev driver.

Two pseudo-modules are introduced for link state monitoring and auto
negotiation.

Kconfig support has been added too.
@basilfx basilfx force-pushed the feature/efm32_eth branch from 1ed3398 to 0f63ccf Compare June 4, 2026 22:11
@github-actions github-actions Bot removed the Area: Kconfig Area: Kconfig integration label Jun 4, 2026
@basilfx basilfx removed the State: waiting for other PR State: The PR requires another PR to be merged first label Jun 4, 2026
@basilfx

basilfx commented Jun 5, 2026

Copy link
Copy Markdown
Member Author

Hmm, this seems to fail due to config.h being included via periph_cpu.c, that contains static_assert(..).

Guess that this is somewhat related to #9371 and MicroPython not using -std=c11 yet. See if we can fix that :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: boards Area: Board ports Area: build system Area: Build system Area: cpu Area: CPU/MCU ports Area: doc Area: Documentation Area: drivers Area: Device drivers Area: network Area: Networking Area: pkg Area: External package ports Area: sys Area: System Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ARM Platform: This PR/issue effects ARM-based platforms Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants