Rust Ethernet Driver for STM32F* microcontrollers
Supported microcontrollers
- STM32F107
- STM32F4xx
- STM32F7xx
Pull requests are welcome :)
Usage
Add one of the following to the [dependencies] section in your Cargo.toml (with the correct MCU specified):
= { = "0.6.0", = ["stm32f429"] } # For stm32f4xx-like MCUs
= { = "0.6.0", = ["stm32f767"] } # For stm32f7xx-like MCUs
= { = "0.6.0", = ["stm32f107"] } # For stm32f107
stm32_eth re-exports the underlying HAL as stm32_eth::hal.
In src/main.rs add:
use ;
use RateExtU32;
use interrupt;
smoltcp support
Use feature-flag smoltcp-phy.
To make proper use of smoltcp, you will also have to activate additional smoltcp features. You can do this by adding a dependency on the same version of smoltcp as stm32-eth to your own Cargo.toml with the features you require activated.
Examples
The examples should run and compile on any MCU that has an 802.3 compatible PHY capable of generating the required 50 MHz clock signal connected to the default RMII pins.
The examples use defmt and defmt_rtt for logging, and panic_probe over defmt_rtt for printing panic backtraces.
Alternative pin configuration, HSE & PPS
If the board you're developing for has a High Speed External oscillator connected to the correct pins, the HSE configuration can be activated by setting the STM32_ETH_EXAMPLE_HSE environment variable to one of oscillator or bypass when compiling.
If the board you're developing for uses the nucleo pinout (PG11 and PG13 instead of PB11 and PB12), the pin configuration can be changed by setting the STM32_ETH_EXAMPLE_PINS environment variable to nucleo when compiling.
If you wish to use the alternative PPS output pin (PG8 instead of PB5) for the rtic-timestamp example, the pin configuration can be changed by setting the STM32_ETH_EXAMPLE_PPS_PIN environment variable to alternate when compiling.
Building examples
To build an example, run the following command:
For example, if we wish to build the ip example for an stm32f429, we should run the following command:
If we wish to build the arp example for a Nucleo-F767ZI with a HSE oscillator:
STM32_ETH_EXAMPLE_HSE=bypass STM32_ETH_EXAMPLE_PINS=nucleo \
Running examples
Install probe-run with cargo install probe-run --version '~0.3'
Find the correct value for PROBE_RUN_CHIP for your MCU from the list provided by probe-run --list-chips.
Ensure that probe-run can attach to your MCU
Then, run the following command:
DEFMT_LOG=info PROBE_RUN_CHIP=<probe-run
For example, if we wish to run the rtic-echo example on an STM32F107RCT6, we should run the following command:
DEFMT_LOG=info PROBE_RUN_CHIP=STM32F107RC \
Or, if we want to run the arp example on a Nucleo-F767ZI with a HSE oscillator:
DEFMT_LOG=info PROBE_RUN_CHIP=STM32F767ZGTx \
STM32_ETH_EXAMPLE_PINS=nucleo STM32_ETH_EXAMPLE_HSE=oscillator \
License
All source code (including code snippets) is licensed under the Apache License, Version 2.0 (LICENSE) or https://www.apache.org/licenses/LICENSE-2.0
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.