Skip to content

Commit 34243c9

Browse files
Merge pull request #56 from datdenkikniet/docs
Docs & Examples updates
2 parents 343e2fe + cc0ac72 commit 34243c9

21 files changed

+636
-1015
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Description
2+
<!-- Give a description of what this PR adds -->
3+
4+
# TODO
5+
1. [ ] Step 1
6+
2. [ ] Update CHANGELOG.md

.github/workflows/build.yml

Lines changed: 25 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ env:
1111
CARGO_TERM_COLOR: always
1212

1313
jobs:
14-
# Run cargo fmt --check, includes macros/
1514
style:
1615
name: style
1716
runs-on: ubuntu-20.04
@@ -60,7 +59,9 @@ jobs:
6059
uses: actions-rs/cargo@v1
6160
with:
6261
command: test
63-
args: --target=${{ matrix.target }} --features ${{ matrix.features }}
62+
# We use `--no-default-features` because compiling `defmt` for non-embedded targets
63+
# doesn't work.
64+
args: --target=${{ matrix.target }} --no-default-features --features ${{ matrix.features }}
6465

6566

6667
# Compilation
@@ -78,7 +79,6 @@ jobs:
7879
- stm32f407
7980
- stm32f417
8081
- stm32f427
81-
- stm32f429
8282
- stm32f437
8383
- stm32f439
8484
- stm32f469
@@ -117,70 +117,30 @@ jobs:
117117
runs-on: ubuntu-20.04
118118
strategy:
119119
matrix:
120-
target:
121-
- thumbv7m-none-eabi
120+
example:
121+
- name: arp
122+
example: arp
123+
features: defmt
124+
- name: ip
125+
example: ip
126+
features: defmt,smoltcp-phy,smoltcp/defmt,smoltcp/socket-tcp
127+
- name: pktgen
128+
example: pktgen
129+
features: defmt
130+
- name: rtic-echo
131+
example: rtic-echo
132+
features: rtic-echo-example
133+
- name: rtic-echo with nucleo pins
134+
example: rtic-echo
135+
features: rtic-echo-example,example-nucleo-pins
136+
mcu:
137+
- stm32f107
138+
- stm32f429
139+
- stm32f745
122140
toolchain:
123141
- stable
124-
steps:
125-
- name: Checkout
126-
uses: actions/checkout@v3
127-
128-
- name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }})
129-
uses: actions-rs/toolchain@v1
130-
with:
131-
toolchain: ${{ matrix.toolchain }}
132-
target: ${{ matrix.target }}
133-
override: true
134-
135-
- name: cargo build f4 example pktgen
136-
uses: actions-rs/cargo@v1
137-
with:
138-
use-cross: false
139-
command: build
140-
args: --release --target=${{ matrix.target }} --example pktgen --features stm32f429
141-
142-
- name: cargo build f4 example ip
143-
uses: actions-rs/cargo@v1
144-
with:
145-
use-cross: false
146-
command: build
147-
args: --release --target=${{ matrix.target }} --example ip --features stm32f429,smoltcp-phy,log,smoltcp/socket-tcp,smoltcp/socket-icmp,smoltcp/log,smoltcp/verbose
148-
149-
- name: cargo build f4 example arp
150-
uses: actions-rs/cargo@v1
151-
with:
152-
use-cross: false
153-
command: build
154-
args: --release --target=${{ matrix.target }} --example arp --features stm32f407
155-
156-
- name: cargo build f4 example arp-smoltcp
157-
uses: actions-rs/cargo@v1
158-
with:
159-
use-cross: false
160-
command: build
161-
args: --release --target=${{ matrix.target }} --example arp-smoltcp --features stm32f407,smoltcp-phy,smoltcp/socket-icmp
162-
163-
- name: cargo build f1 example ip
164-
uses: actions-rs/cargo@v1
165-
with:
166-
use-cross: false
167-
command: build
168-
args: --release --target=${{ matrix.target }} --example ip-f107 --features stm32f107,smoltcp-phy,log,smoltcp/socket-tcp,smoltcp/socket-icmp,smoltcp/log,smoltcp/verbose
169-
170-
rtic-echo-example:
171-
name: rtic-echo example
172-
runs-on: ubuntu-20.04
173-
strategy:
174-
matrix:
175142
target:
176143
- thumbv7m-none-eabi
177-
toolchain:
178-
- stable
179-
features:
180-
- stm32f107
181-
- stm32f407
182-
- stm32f765
183-
- rtic-echo-example-altpin,stm32f765
184144
steps:
185145
- name: Checkout
186146
uses: actions/checkout@v3
@@ -192,12 +152,12 @@ jobs:
192152
target: ${{ matrix.target }}
193153
override: true
194154

195-
- name: build rtic-echo-example with features ${{ matrix.features }}
155+
- name: Build example ${{ matrix.example.name }} for ${{ matrix.mcu }}
196156
uses: actions-rs/cargo@v1
197157
with:
198158
use-cross: false
199159
command: build
200-
args: --release --target=${{ matrix.target }} --example rtic-echo --features rtic-echo-example,${{ matrix.features }}
160+
args: --release --target=${{ matrix.target }} --example ${{ matrix.example.example}} --features ${{ matrix.mcu }},${{ matrix.example.features }}
201161

202162
# Refs: https://github.com/rust-lang/crater/blob/9ab6f9697c901c4a44025cf0a39b73ad5b37d198/.github/workflows/bors.yml#L125-L149
203163
#
@@ -211,7 +171,6 @@ jobs:
211171
- build
212172
- test
213173
- examples
214-
- rtic-echo-example
215174
runs-on: ubuntu-20.04
216175
steps:
217176
- name: Mark the job as a success

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## Unreleased
2+
* General
3+
* Remove the `smi` feature and always enable miim/smi. Use `ieee802_3_miim` for SMI access
4+
* Split MAC and DMA setup into their own separate modules
5+
* CI
6+
* Test compilability of examples more extensively
7+
* Examples:
8+
* Switch to `defmt` as logger
9+
* Use `probe-run` as runner
10+
* Ensure that all examples build (and hopefully run) for all supported MCUs
11+
* Add more extensive example run and build docs
12+
* Remove arp-smoltcp example
13+
* Add `rtic-echo` example
14+
* Use a more simple `memory.x` that works for all supported MCUs
15+
16+
## [0.3.0](https://github.com/stm32-rs/stm32-eth/tree/v0.3.0)
17+
18+
* Enable ICMP, TCP, and UDP checksum offloading for IPv4 and IPv6. ([#48](https://github.com/stm32-rs/stm32-eth/pull/48))
19+
* Separate MAC and DMA into separate structs for separate access. ([#39](https://github.com/stm32-rs/stm32-eth/pull/39))
20+
* Add support for `stm32f107` and fix an MMC interrupt bug. ([#43](https://github.com/stm32-rs/stm32-eth/pull/43), [#42](https://github.com/stm32-rs/stm32-eth/pull/42), [#41](https://github.com/stm32-rs/stm32-eth/pull/41))
21+
* Update the HALs and dependencies to their latest versions as of 12-07-2022.
22+
* Add more examples

Cargo.toml

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ keywords = ["ethernet", "eth", "stm32", "stm32f4", "stm32f7"]
99
repository = "https://github.com/stm32-rs/stm32-eth"
1010
documentation = "https://docs.rs/stm32-eth/"
1111
edition = "2018"
12+
autoexamples = false
1213

1314
[badges]
1415
travis-ci = { repository = "astro/stm32-eth", branch = "master" }
@@ -23,7 +24,7 @@ aligned = "0.4"
2324
stm32f7xx-hal = { version = "0.7.0", optional = true }
2425
stm32f4xx-hal = { version = "0.13", optional = true }
2526
stm32f1xx-hal = { version = "0.9", optional = true }
26-
ieee802_3_miim = { version = "0.7", optional = true }
27+
ieee802_3_miim = "0.7"
2728
cortex-m = "0.7"
2829
log = { version = "0.4", optional = true }
2930
defmt = { version = "0.3", optional = true }
@@ -35,7 +36,7 @@ features = ["medium-ethernet", "proto-ipv4"]
3536
optional = true
3637

3738
[features]
38-
default = [ "ieee802_3_miim", "defmt" ]
39+
default = [ "defmt" ]
3940
device-selected = []
4041
fence = []
4142

@@ -63,14 +64,12 @@ stm32f779 = ["stm32f7xx-hal/stm32f779", "device-selected", "fence"]
6364
smoltcp-phy = ["smoltcp"]
6465

6566
# Example features
66-
rtic-echo-example = [ "ieee802_3_miim", "defmt", "smoltcp-phy", "smoltcp/defmt", "smoltcp/medium-ethernet", "smoltcp/socket-tcp" ]
67-
rtic-echo-example-altpin = [ ]
67+
example-nucleo-pins = [ ]
68+
rtic-echo-example = [ "defmt", "smoltcp-phy", "smoltcp/defmt", "smoltcp/medium-ethernet", "smoltcp/socket-tcp" ]
6869

6970
[dev-dependencies]
7071
cortex-m = "0.7"
7172
cortex-m-rt = "0.7"
72-
panic-itm = "0.4"
73-
cortex-m-semihosting = "0.3"
7473
fugit = "0.3"
7574
cortex-m-rtic = "1.0"
7675
defmt-rtt = "0.3"
@@ -79,29 +78,17 @@ systick-monotonic = "1.0"
7978

8079
[[example]]
8180
name = "pktgen"
82-
required-features = ["stm32f429"]
81+
required-features = [ "defmt" ]
8382

8483
[[example]]
8584
name = "ip"
8685
required-features = [
87-
"stm32f429", "smoltcp-phy", "log", "smoltcp/socket-tcp", "smoltcp/socket-icmp",
88-
"smoltcp/log", "smoltcp/verbose"
89-
]
90-
91-
[[example]]
92-
name = "ip-f107"
93-
required-features = [
94-
"stm32f107", "smoltcp-phy", "log", "smoltcp/socket-tcp", "smoltcp/socket-icmp",
95-
"smoltcp/log", "smoltcp/verbose"
96-
]
86+
"defmt", "smoltcp-phy", "smoltcp/defmt", "smoltcp/socket-tcp"
87+
]
9788

9889
[[example]]
9990
name = "arp"
100-
required-features = ["stm32f407"]
101-
102-
[[example]]
103-
name = "arp-smoltcp"
104-
required-features = ["stm32f407", "smoltcp-phy", "smoltcp/socket-icmp"]
91+
required-features = [ "defmt" ]
10592

10693
[[example]]
10794
name = "rtic-echo"

README.md

Lines changed: 64 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@
1010

1111
Please send pull requests.
1212

13-
## Building Examples
14-
15-
```bash
16-
cargo build --example="pktgen" --features="stm32f429"
17-
cargo build --example="ip" --features="stm32f429 smoltcp-phy log smoltcp/socket-tcp smoltcp/socket-icmp smoltcp/log smoltcp/verbose"
18-
cargo build --example="ip-f107" --features="stm32f107 smoltcp-phy log smoltcp/socket-tcp smoltcp/socket-icmp smoltcp/log smoltcp/verbose"
19-
```
20-
2113
## Usage
2214

2315
Add one of the following to the `[dependencies]` section in your `Cargo.toml` (with the correct MCU specified):
@@ -89,6 +81,69 @@ fn main() {
8981
}
9082
```
9183

92-
## [smoltcp] support
84+
85+
## `smoltcp` support
9386

9487
Use feature-flag `smoltcp-phy`
88+
89+
## Examples
90+
91+
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.
92+
93+
The examples use `defmt` and `defmt_rtt` for logging, and `panic_probe` over `defmt_rtt` for printing panic backtraces.
94+
95+
To run or build them, the following steps should be taken:
96+
97+
1. Determine the correct compilation target for the MCU that you're using. For `stm32f107`, it is `thumbv7m-none-eabi`. For all others, it is `thumbv7em-none-eabihf`.
98+
2. Determine the MCU feature necessary for running on your MCU, e.g. `stm32f745`.
99+
3. Determine the Additional required features (see section below) necessary to build the example.
100+
4. Follow the rest of the instructions in the ["Building examples"](#building-examples) or ["Running examples"](#running-examples) subsections.
101+
102+
### Additional required features
103+
104+
Besides the feature selecting the correct MCU to be used when building and/or running an example, the following additional features are required:
105+
106+
| Example | Additional required features |
107+
| ------------- | ---------------------------------------------------- |
108+
| `arp` | `defmt` |
109+
| `ip` | `defmt,smoltcp-phy,smoltcp/defmt,smoltcp/socket-tcp` |
110+
| `pktgen` | `defmt` |
111+
| `rtic-echo` | `rtic-echo-example` |
112+
113+
#### 144-pin nucleo boards
114+
115+
For `stm32` 144-pin nucleo boards that contain an MCU supported by this crate the `example-nucleo-pins` feature should be activated. This causes the examples to use PG11 as TX_EN and PG13 as TXD0, instead of PB11 and PB12, which is the configuration used on these boards.
116+
117+
### Building examples
118+
Run the following command:
119+
```bash
120+
cargo build --release --example <example> --features <MCU feature>,<additional required features> --target <MCU compilation target>
121+
```
122+
123+
For example, if we wish to build the `ip` example for an `stm32f429`, we should run the following command:
124+
125+
```bash
126+
cargo build --release --example ip --features stm32f429,defmt,smoltcp-phy,smoltcp/defmt,smoltcp/socket-tcp --target thumbv7em-none-eabihf
127+
```
128+
129+
### Running examples
130+
Install `probe-run` with `cargo install probe-run --version '~0.3'`
131+
132+
Find the correct value for `PROBE_RUN_CHIP` for your MCU from the list provided by `probe-run --list-chips`.
133+
134+
Ensure that `probe-run` can attach to your MCU
135+
136+
Then, run the following command:
137+
```bash
138+
DEFMT_LOG=info PROBE_RUN_CHIP=<probe-run chip> cargo run --release --example <example> --features <MCU feature>,<additional required features> --target <MCU compilation target>
139+
```
140+
141+
For example, if we wish to run the `rtic-echo` example on an `STM32F107RCT6`, we should run the following command:
142+
143+
```bash
144+
DEFMT_LOG=info PROBE_RUN_CHIP=STM32F107RC cargo run --release --example rtic-echo --features stm32f107,rtic-echo-example --target thumbv7m-none-eabi
145+
```
146+
147+
### Other pin configurations
148+
149+
If the usage of different pins is required, the types and `setup_pins` function in `examples/common.rs` should be edited. If the pin configuration is for a `nucleo` board or other commonly used board, a PR with the changes is most welcome.

0 commit comments

Comments
 (0)