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

stm32xx: generate counters for EXTI IRQs #1698

Merged
merged 3 commits into from
Apr 2, 2024
Merged

Conversation

hawkw
Copy link
Member

@hawkw hawkw commented Mar 30, 2024

Since the TOML configuration for EXTI IRQ dispatching in stm32h7-sys
added in #1693 has a user-provided name for each pin's IRQ, we can
generate a nice ringbuf entry (and corresponding entry counter) for each
IRQ mapping. This seems nice to have for debugging purposes, so I've
added it.

When the ringbuf is enabled, stm32xx-sys now records a ringbuf entry
and corresponding counter for each gpio_irq_configure and
gpio_irq_configure IPC, and for each time an EXTI IRQ is dispatched.
This may be useful for debugging cases where a task forgets to enable or
disable its IRQ. When the stm32xx-sys/no-ringbuf feature flag is set,
we skip the IPC events, and just count the number of times we've
dispatched each IRQ --- this saves us some RAM while still recording the
most interesting information.

For example, here's me playing with the button on my Nucleo board:

$ cargo xtask humility app/demo-stm32h7-nucleo/app-h753.toml -- ringbuf drv_stm32xx_sys
    Finished dev [optimized + debuginfo] target(s) in 0.15s
     Running `target/debug/xtask humility app/demo-stm32h7-nucleo/app-h753.toml -- ringbuf drv_stm32xx_sys`
humility: attached via ST-Link V3
humility: ring buffer drv_stm32xx_sys::__RINGBUF in sys:
   TOTAL VARIANT
       3 GpioIrqEnable(button)
       2 GpioIrq(button)
       1 GpioIrqConfigure
 NDX LINE      GEN    COUNT PAYLOAD
   0  685        1        1 GpioIrqConfigure { irq: button, rising: false, falling: true }
   1  593        1        1 GpioIrqEnable(button)
   2  806        1        1 GpioIrq(button)
   3  593        1        1 GpioIrqEnable(button)
   4  806        1        1 GpioIrq(button)
   5  593        1        1 GpioIrqEnable(button)

Since the TOML configuration for EXTI IRQ dispatching in `stm32h7-sys`
added in #1693 has a user-provided name for each pin's IRQ, we can
generate a nice ringbuf entry (and corresponding entry counter) for each
IRQ mapping. This seems nice to have for debugging purposes, so I've
added it.

When the ringbuf is enabled, `stm32xx-sys` now records a ringbuf entry
and corresponding counter for each `gpio_irq_configure` and
`gpio_irq_configure` IPC, and for each time an EXTI IRQ is dispatched.
This may be useful for debugging cases where a task forgets to enable or
disable its IRQ. When the `stm32xx-sys/no-ringbuf` feature flag is set,
we skip the IPC events, and just count the number of times we've
dispatched each IRQ --- this saves us some RAM while still recording the
most interesting information.

For example, here's me playing with the button on my Nucleo board:

```console
$ cargo xtask humility app/demo-stm32h7-nucleo/app-h753.toml -- ringbuf drv_stm32xx_sys
    Finished dev [optimized + debuginfo] target(s) in 0.15s
     Running `target/debug/xtask humility app/demo-stm32h7-nucleo/app-h753.toml -- ringbuf drv_stm32xx_sys`
humility: attached via ST-Link V3
humility: ring buffer drv_stm32xx_sys::__RINGBUF in sys:
   TOTAL VARIANT
       3 GpioIrqEnable(button)
       2 GpioIrq(button)
       1 GpioIrqConfigure
 NDX LINE      GEN    COUNT PAYLOAD
   0  685        1        1 GpioIrqConfigure { irq: button, rising: false, falling: true }
   1  593        1        1 GpioIrqEnable(button)
   2  806        1        1 GpioIrq(button)
   3  593        1        1 GpioIrqEnable(button)
   4  806        1        1 GpioIrq(button)
   5  593        1        1 GpioIrqEnable(button)
```
@hawkw hawkw requested a review from cbiffle March 30, 2024 20:29
@hawkw hawkw marked this pull request as ready for review March 30, 2024 20:29
@hawkw hawkw requested a review from bcantrill March 30, 2024 20:29
@hawkw hawkw changed the title stm32xx: generate ingbuf/counters for EXTI IRQs stm32xx: generate ringbuf/counters for EXTI IRQs Mar 30, 2024
@hawkw
Copy link
Member Author

hawkw commented Mar 31, 2024

After a conversation with @cbiffle, I'm going to remove the ringbuf from this change and just generate event counters for IRQ triggers. This is for size reasons — the ringbuf code is pretty big, and it contains panics, and Cliff is currently trying to remove all panics from the sys task.

Now, we only generate counters, and only if "exti" is enabled. The
`sys` task for the STM32H7-Nucleo demo currently uses 2700B of flash and
1476B of RAM.
@hawkw hawkw changed the title stm32xx: generate ringbuf/counters for EXTI IRQs stm32xx: generate counters for EXTI IRQs Mar 31, 2024
@hawkw
Copy link
Member Author

hawkw commented Mar 31, 2024

Okay, as of 2f46737, this PR is now just counters, not ringbuf.

@hawkw hawkw enabled auto-merge (squash) April 2, 2024 21:09
@hawkw hawkw merged commit c361359 into master Apr 2, 2024
103 checks passed
hawkw added a commit that referenced this pull request Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants