Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu/stm32/periph_eth: Add stm32_eth_tracing #18418

Merged
merged 2 commits into from
Sep 18, 2022

Conversation

maribu
Copy link
Member

@maribu maribu commented Aug 8, 2022

Contribution description

This PR improves debugging of the peripheral STM32 Ethernet driver. It was used to debug the issue fixed in #18416

It does two things:

  • sprinkle a bit more and more verbose DEBUG() output over the code
  • introduce the module stm32_eth_tracing that allows tracing and debugging the STM32 state
    • it uses GPIO LL for low overhead to be useful when DEBUG() impacts performance to much
    • one GPIO is toggled for each ISR entry
    • one GPIO is set on TX start and cleared on TX done
    • one GPIO is set on RX completed and cleared when the frame is passed up the network stack
    • by default, LEDs are used to allow seeing where the state machine is stuck without a scope or logic analyzer

Testing procedure

On an STM32 board with Ethernet and at least three LEDs, e.g. the Nucleo-F767ZI, run

USEMODULE=stm32_eth_tracing BOARD=nucleo-f767zi` -C examples/gnrc_networking flash term

For each IRQ LED0 should be toggled, LED1 should flash on TX briefly, and LED2 should flash on RX briefly. (LED1 and LED2 are flashed so fast that it is a bit tricky to see, but quite possible for the human eye when the room is a bit darker.

Issues/PRs references

Depends on and includes:

@maribu maribu added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Area: network Area: Networking Type: new feature The issue requests / The PR implemements a new feature for RIOT State: waiting for other PR State: The PR requires another PR to be merged first Area: cpu Area: CPU/MCU ports labels Aug 8, 2022
@github-actions github-actions bot added Area: boards Area: Board ports Area: build system Area: Build system Area: CI Area: Continuous Integration of RIOT components Platform: ARM Platform: This PR/issue effects ARM-based platforms and removed Area: network Area: Networking labels Aug 8, 2022
@maribu maribu force-pushed the cpu/stm32/periph/stm32_eth_tracing branch from 47b12f4 to e56e3d0 Compare August 8, 2022 13:41
@github-actions github-actions bot removed the Area: CI Area: Continuous Integration of RIOT components label Aug 8, 2022
@maribu maribu force-pushed the cpu/stm32/periph/stm32_eth_tracing branch from e56e3d0 to 8a6dd77 Compare August 9, 2022 19:59
@maribu maribu force-pushed the cpu/stm32/periph/stm32_eth_tracing branch from 8a6dd77 to 510a9c6 Compare September 14, 2022 11:59
@github-actions github-actions bot removed the Area: boards Area: Board ports label Sep 14, 2022
Add tracing support via GPIOs to trace the basic state of the Ethernet
peripheral. The following signals are provided:

- One GPIO pin is toggled on entry of the Ethernet ISR
- On TX start an GPIO is set, on TX completion it is cleared
- On RX complete an GPIO is set, once this is passed to the upper layer
  the GPIO is cleared again

In order to reduce the overhead, GPIO LL is used. By default the
on-board LEDs are used as tracing GPIOs. This makes it easy to debug
when the state machine gets stuck without the need to attach a scope or
logic analyzer.
@maribu maribu force-pushed the cpu/stm32/periph/stm32_eth_tracing branch from 510a9c6 to 44b62e8 Compare September 14, 2022 12:00
@maribu
Copy link
Member Author

maribu commented Sep 14, 2022

This may also be interesting to @fabian18

It can be used for two things:

  1. Debugging the state machine (by default the state is visualized via the three on-board LEDs, if present)
  2. Tracing the time the driver / hardware spends, as (instead of the three on-board LEDs) a logic analyzer can precisely trace the state transitions and the duration the driver spends in each state

@benpicco benpicco added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed State: waiting for other PR State: The PR requires another PR to be merged first labels Sep 18, 2022
Copy link
Contributor

@benpicco benpicco left a comment

Choose a reason for hiding this comment

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

Default behavior does not change and additional code is rather self-contained.

If you want this in (because it might still be valuable in the future) go for it.

@maribu
Copy link
Member Author

maribu commented Sep 18, 2022

Thx :)

@maribu maribu merged commit e402f1d into RIOT-OS:master Sep 18, 2022
@maribu maribu deleted the cpu/stm32/periph/stm32_eth_tracing branch September 19, 2022 08:39
@maribu maribu added this to the Release 2022.10 milestone Oct 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: build system Area: Build system Area: cpu Area: CPU/MCU ports 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: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation 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.

2 participants