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

STM32 EXTI Rework #85508

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

KozhinovAlexander
Copy link
Collaborator

@KozhinovAlexander KozhinovAlexander commented Feb 10, 2025

Rework STM32 Zephyr EXTI driver to be independent from GPIO and compatible with most of the STM32 SoC's.

Addresses the issue #85366

This change introduces updated EXTI interrupt controller supporting interrupt/event lines handling also from peripherals.

Tested with following module tests since both of them were adapted to use new EXTI implementation:

  • tests/drivers/gpio/gpio_basic_api

build command:

west build -p auto -d tests/drivers/gpio/gpio_basic_api/build -b nucleo_h745zi_q/stm32h745xx/m7 tests/drivers/gpio/gpio_basic_api 

test report:

*** Booting Zephyr OS build v4.1.0-rc3-6-g92de9898d0da ***
Running TESTSUITE after_flash_gpio_config_trigger
===================================================================
START - test_gpio_config_trigger
 PASS - test_gpio_config_trigger in 0.011 seconds
===================================================================
START - test_gpio_config_twice_trigger
 PASS - test_gpio_config_twice_trigger in 0.011 seconds
===================================================================
TESTSUITE after_flash_gpio_config_trigger succeeded
Running TESTSUITE gpio_port
===================================================================
START - test_gpio_port
Validate device gpio@58020400 and gpio@58020400
Check gpio@58020400 output 7 connected to gpio@58020400 input 6
OUT 7 to IN 6 linkage works
- bits_physical
- pin_physical
- check_raw_output_levels
- check_logic_output_levels
- check_input_levels
- bits_logical
- check_pulls
 PASS - test_gpio_port in 0.026 seconds
===================================================================
TESTSUITE gpio_port succeeded
Running TESTSUITE gpio_port_cb_mgmt
===================================================================
START - test_gpio_callback_add_remove
callback_2 triggered: 1
callback_1 triggered: 1
callback_2 triggered: 1
 PASS - test_gpio_callback_add_remove in 3.608 seconds
===================================================================
START - test_gpio_callback_enable_disable
callback_2 triggered: 1
callback_1 triggered: 1
callback_2 triggered: 1
callback_1 triggered: 1
 PASS - test_gpio_callback_enable_disable in 3.610 seconds
===================================================================
START - test_gpio_callback_self_remove
callback_remove_self triggered: 1
callback_1 triggered: 1
callback_1 triggered: 1
 PASS - test_gpio_callback_self_remove in 2.508 seconds
===================================================================
TESTSUITE gpio_port_cb_mgmt succeeded
Running TESTSUITE gpio_port_cb_vari
===================================================================
START - test_gpio_callback_variants
callback triggered: 1
OUT init a0001, IN cfg 3400000, cnt 1
callback triggered: 1
OUT init 60010, IN cfg 5400000, cnt 1
callback triggered: 1
OUT init 60010, IN cfg 5c00000, cnt 1
callback triggered: 1
OUT init a0001, IN cfg 3c00000, cnt 1
Mode 4400000 not supported
Mode 2400000 not supported
Mode 4c00000 not supported
Mode 2c00000 not supported
callback triggered: 1
callback triggered: 2
OUT init a0001, IN cfg 7400000, cnt 2
 PASS - test_gpio_callback_variants in 5.538 seconds
===================================================================
TESTSUITE gpio_port_cb_vari succeeded

------ TESTSUITE SUMMARY START ------

SUITE PASS - 100.00% [after_flash_gpio_config_trigger]: pass = 2, fail = 0, skip = 0, total = 2 duration = 0.022 seconds
 - PASS - [after_flash_gpio_config_trigger.test_gpio_config_trigger] duration = 0.011 seconds
 - PASS - [after_flash_gpio_config_trigger.test_gpio_config_twice_trigger] duration = 0.011 seconds

SUITE PASS - 100.00% [gpio_port]: pass = 1, fail = 0, skip = 0, total = 1 duration = 0.026 seconds
 - PASS - [gpio_port.test_gpio_port] duration = 0.026 seconds

SUITE PASS - 100.00% [gpio_port_cb_mgmt]: pass = 3, fail = 0, skip = 0, total = 3 duration = 9.726 seconds
 - PASS - [gpio_port_cb_mgmt.test_gpio_callback_add_remove] duration = 3.608 seconds
 - PASS - [gpio_port_cb_mgmt.test_gpio_callback_enable_disable] duration = 3.610 seconds
 - PASS - [gpio_port_cb_mgmt.test_gpio_callback_self_remove] duration = 2.508 seconds

SUITE PASS - 100.00% [gpio_port_cb_vari]: pass = 1, fail = 0, skip = 0, total = 1 duration = 5.538 seconds
 - PASS - [gpio_port_cb_vari.test_gpio_callback_variants] duration = 5.538 seconds

------ TESTSUITE SUMMARY END ------

===================================================================
PROJECT EXECUTION SUCCESSFUL
  • tests/drivers/rtc/rtc_api

build command:

west build -p auto -d tests/drivers/rtc/rtc_api/build -b nucleo_h745zi_q/stm32h745xx/m7 tests/drivers/rtc/rtc_api -DOVERLAY_CONFIG=tests/drivers/rtc/rtc_api/boards/nucleo_h745zi_q.conf -DDTC_OVERLAY_FILE=tests/drivers/rtc/rtc_api/boards/nucleo_h745zi_q.overlay 

test report:

*** Booting Zephyr OS build v4.1.0-rc3-6-g92de9898d0da ***
Running TESTSUITE rtc_api
===================================================================
START - test_alarm
 PASS - test_alarm in 8.105 seconds
===================================================================
START - test_alarm_callback
 PASS - test_alarm_callback in 8.105 seconds
===================================================================
START - test_set_get_calibration
Calibrate (set,get): 1, 0
Calibrate (set,get): -1, 0
Calibrate (set,get): -10000, -9537
Calibrate (set,get): -20000, -20027
Calibrate (set,get): -30000, -29564
Calibrate (set,get): -40000, -40054
Calibrate (set,get): -50000, -49591
Calibrate (set,get): -60000, -60081
Calibrate (set,get): -70000, -69618
Calibrate (set,get): -80000, -80109
Calibrate (set,get): -90000, -89645
Calibrate (set,get): -100000, -100136
Calibrate (set,get): -110000, -109673
Calibrate (set,get): -120000, -120163
Calibrate (set,get): -130000, -129700
Calibrate (set,get): -140000, -140190
Calibrate (set,get): -150000, -149727
Calibrate (set,get): -160000, -160217
Calibrate (set,get): -170000, -169754
Calibrate (set,get): -180000, -180244
Calibrate (set,get): -190000, -189781
Calibrate (set,get): -200000, -200272
Calibrate (set,get): 10000, 9537
Calibrate (set,get): 20000, 20027
Calibrate (set,get): 30000, 29564
Calibrate (set,get): 40000, 40054
Calibrate (set,get): 50000, 49591
Calibrate (set,get): 60000, 60081
Calibrate (set,get): 70000, 69618
Calibrate (set,get): 80000, 80109
Calibrate (set,get): 90000, 89645
Calibrate (set,get): 100000, 100136
Calibrate (set,get): 110000, 109673
Calibrate (set,get): 120000, 120163
Calibrate (set,get): 130000, 129700
Calibrate (set,get): 140000, 140190
Calibrate (set,get): 150000, 149727
Calibrate (set,get): 160000, 160217
Calibrate (set,get): 170000, 169754
Calibrate (set,get): 180000, 180244
Calibrate (set,get): 190000, 189781
Calibrate (set,get): 200000, 200272
 PASS - test_set_get_calibration in 0.681 seconds
===================================================================
START - test_set_get_time
 PASS - test_set_get_time in 0.001 seconds
===================================================================
START - test_time_counting
 PASS - test_time_counting in 1.555 seconds
===================================================================
START - test_y2k
Rollover not supported
 SKIP - test_y2k in 0.003 seconds
===================================================================
TESTSUITE rtc_api succeeded

------ TESTSUITE SUMMARY START ------

SUITE PASS - 100.00% [rtc_api]: pass = 5, fail = 0, skip = 1, total = 6 duration = 18.450 seconds
 - PASS - [rtc_api.test_alarm] duration = 8.105 seconds
 - PASS - [rtc_api.test_alarm_callback] duration = 8.105 seconds
 - PASS - [rtc_api.test_set_get_calibration] duration = 0.681 seconds
 - PASS - [rtc_api.test_set_get_time] duration = 0.001 seconds
 - PASS - [rtc_api.test_time_counting] duration = 1.555 seconds
 - SKIP - [rtc_api.test_y2k] duration = 0.003 seconds

------ TESTSUITE SUMMARY END ------

===================================================================
PROJECT EXECUTION SUCCESSFUL

@KozhinovAlexander KozhinovAlexander force-pushed the exti_stm32 branch 8 times, most recently from 48d57d5 to 4540804 Compare February 16, 2025 23:42
@KozhinovAlexander KozhinovAlexander force-pushed the exti_stm32 branch 3 times, most recently from 41c6fe7 to 49f0acc Compare February 17, 2025 22:49
@KozhinovAlexander
Copy link
Collaborator Author

@erwango Do you have ability to run all the EXTI/GPIO twister tests for different stm32 SoC on HW for this PR?

@erwango
Copy link
Member

erwango commented Feb 18, 2025

First, a big thanks for addressing this point.

@erwango Do you have ability to run all the EXTI/GPIO twister tests for different stm32 SoC on HW for this PR?

Yes, but we're currently busy with v4.1, so this topic will be addressed in low prio.

Then, one observation regarding the whole change.
I know this is WIP, but I've seen similar things already which can end up with lot of work achieved but never integrated, resulting in lot of frustration in both sides.
So here is my advice:
Even in WIP, please split your changes in multiple commits to explain the changes you're doing.
This may not be possible for some parts, and there will be fixup commits, which is ok on a WIP branch.
But it will help readers to understand where you're going, the big directions, and early prevent misalignments that would prevent eventual merge.
Otherwise, if you're not abl to do so, then maybe this is a bit early to share your work

For instance: here is an example of good draft PR: https://github.com/zephyrproject-rtos/zephyr/pull/85135/commits
(You'll see it's quite clean, I don't ask so much, but at least reader can understand the direction and is able to comment)

@KozhinovAlexander
Copy link
Collaborator Author

KozhinovAlexander commented Feb 18, 2025

@erwango Thanks for the advice. I have a commit-split definitely on my to-do list. I didn't do so, cause I have somehow cyclic dependency:

  1. I need a CI with all the tests to proceed faster - thus I've created a WIP
  2. I myself was not sure how the end work will look like until I've approached to some good shape of this work. But to approach to good shape I needed tests from CI (see 1.) :)

I hope you see my point. Sure I will split commits - thanks for the reminder ;)

@KozhinovAlexander KozhinovAlexander force-pushed the exti_stm32 branch 9 times, most recently from 6b46187 to a5e86c4 Compare March 1, 2025 19:41
add nucleo_h745zi_q_stm32h745xx_m7 overlay

Signed-off-by: Alexander Kozhinov <ak.alexander.kozhinov@gmail.com>
add nucleo_h745zi_q_stm32h745xx_m7 overlay

Signed-off-by: Alexander Kozhinov <ak.alexander.kozhinov@gmail.com>
@KozhinovAlexander KozhinovAlexander force-pushed the exti_stm32 branch 5 times, most recently from 0f909fc to af6b55b Compare March 2, 2025 22:08
make num-lines not required
add more exti lines and interrupts to
    interrupt-controller of stm32h7 in dts

Signed-off-by: Alexander Kozhinov <ak.alexander.kozhinov@gmail.com>
rework to support peripherals

Signed-off-by: Alexander Kozhinov <ak.alexander.kozhinov@gmail.com>
integrate interrupt controller

Signed-off-by: Alexander Kozhinov <ak.alexander.kozhinov@gmail.com>
integrate reworked interrut controller

Signed-off-by: Alexander Kozhinov <ak.alexander.kozhinov@gmail.com>
@KozhinovAlexander
Copy link
Collaborator Author

KozhinovAlexander commented Mar 3, 2025

@erwango Hi. I think I am so far with opening this PR for review. I've done all the changes needed to support the peripherals EXTI lines handling depending on supported number of EXTI lines.
I've also splitted the commits in logical blocks and done tests on my current target platfrom 8see PR description).
What is open: Currently I'am waiting for stm32g4 and stm32wb0 to be able to test on this platforms too.
Meanwhile you can begin to test it on your side. If you think you can add someone, who can also test/review, please feel free to do so.

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

Successfully merging this pull request may close these issues.

4 participants