Skip to content

STM32MP2 Series support #90295

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

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

Conversation

youssefz24
Copy link

@youssefz24 youssefz24 commented May 21, 2025

Add basic support of the Cortex-M33 core for the STM32MP2 series.
Provide support for the STM32MP257F-EV1 evaluation board.

It depends on the following PR from the STM32-HAL:zephyrproject-rtos/hal_stm32#282

This first step allows to run and debug the samples:

  • Hello_world
  • Blinky
  • Button

Signed-off-by: Youssef Zini youssef.zini@savoirfairelinux.com

Copy link

Hello @youssefz24, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

Copy link
Member

@erwango erwango left a comment

Choose a reason for hiding this comment

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

Thanks @youssefz24 for this work!

Some initial comments, but looks globally fine!

@erwango erwango requested a review from arnopo May 22, 2025 09:22
@arnopo

This comment was marked as resolved.

@youssefz24 youssefz24 force-pushed the topic/stm32mp2_support branch from dc679f5 to 8a8a74f Compare May 23, 2025 16:58
Copy link

github-actions bot commented May 23, 2025

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff
hal_stm32 zephyrproject-rtos/hal_stm32@5cbc642 zephyrproject-rtos/hal_stm32@468e5ad (main) zephyrproject-rtos/hal_stm32@5cbc642b..468e5ad4

All manifest checks OK

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@github-actions github-actions bot added manifest manifest-hal_stm32 DNM (manifest) This PR should not be merged (controlled by action-manifest) labels May 23, 2025
@youssefz24 youssefz24 requested review from nordicjm, arnopo and erwango May 23, 2025 17:02
Copy link
Collaborator

@arnopo arnopo left a comment

Choose a reason for hiding this comment

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

I only review until commit 2ff8bc2

@youssefz24
Copy link
Author

@erwango It seems I keep failing the CI twister test 7, when tracing back the issue it seems that it is linked to hwinfo.
Also, it builds psa crypto tests even thought I only have GPIO and LED as supported. any ideas how can I disable/skip those unrelated tests ? Or should I try to make the necessary additions ?
Sorry if my question seems a bit mundane. :/

@erwango
Copy link
Member

erwango commented Jun 12, 2025

Also, it builds psa crypto tests even thought I only have GPIO and LED as supported

That's SW backend stuff, so it should probably work.

, when tracing back the issue it seems that it is linked to hwinfo.

Indeed, strange but given the variety of impacted tests, you probably need to do it indeed. That should probably be quick.

reg = <0x44200000 DT_SIZE_K(64)>;
};

exti2: interrupt-controller@46230000 {
Copy link
Collaborator

@KozhinovAlexander KozhinovAlexander Jun 13, 2025

Choose a reason for hiding this comment

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

@mathieuchopstm FYI: I see second exti instance. In #85508 I assumed one instance only. Do you see the need in #85508 to support multiple exti instances?

Copy link
Author

Choose a reason for hiding this comment

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

The STM32MP2 actually has 2 EXTI instances and the HAL/LL functions take the said instance as an argument (see intc_exti_stm32.c.
For now we only need the EXTI2, with the idea of adding EXTI1 when peripherals need it. (When I ll reach that step I'll update the driver again, hopefully your PR is merged before that :p )

Copy link
Collaborator

Choose a reason for hiding this comment

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

I have not checked the MP2 RefMan at all, but I have been told a few words about this dual-EXTI point, and from my understanding only a single instance is """visible"""[1] in a given context, i.e. the issue is not multi-instance but merely knowing which instance we're operating on. (Ignore my comment if my understanding is wrong)

[1] Not literally as in "not mapped in address space", but in the sense that only one instance is wired to a given CPU

Copy link
Collaborator

@KozhinovAlexander KozhinovAlexander Jun 13, 2025

Choose a reason for hiding this comment

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

Thank you both for very fast feedback. Let's stick then with current implementations and see, if extension to multi exti nodes will be needed later.
From my side I am planning to integrate MP2 dk1 later based on this PR.

Copy link
Author

Choose a reason for hiding this comment

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

@mathieuchopstm From what I got, the instances can actually be shared at runtime between the CPUs, with EXTI1 between CPU1 (CA35) and CPU2 (CM33), and EXTI2 betewen all three of them: CPU1 (CA35), CPU2 (CM33) and CPU3 (CM0+). It all comes down to access rights defined by the resource manager allowed by the RIF peripheral (Resource Isolation Framework).
For instance, in this context, GPIO interrupts are linked to EXTI2 while HPDMAx are linked to EXTI1. So to add HPDMA, I have to figure that out. Nevertheless, I agree that the tricky part will be knowing which instance we operating on for a given situation. We'll cross that bridge when we get there :D

@KozhinovAlexander yeah I agree. 🎩

@youssefz24
Copy link
Author

youssefz24 commented Jun 13, 2025

So to correct the CI twister test, I added the board support in the hwinfo driver. This requires changing the hal file used in the HAL to get the generic header and not the conf one, I opened a pull request in the STM32_HAL repo for this fix. Since the MP2 doesn t have a utils.h and uses HAL functions.
Perhaps you could take a look at this @arnopo @erwango , hoping it is the last stretch.

@youssefz24 youssefz24 force-pushed the topic/stm32mp2_support branch from 6ddf450 to d1e0db0 Compare June 13, 2025 11:51
@github-actions github-actions bot added the DNM (manifest) This PR should not be merged (controlled by action-manifest) label Jun 13, 2025
@youssefz24 youssefz24 requested a review from erwango June 13, 2025 12:17
@erwango
Copy link
Member

erwango commented Jun 13, 2025

Perhaps you could take a look at this @arnopo @erwango , hoping it is the last stretch.

Merged

Update west.yml to add the STM32MP2x SoC support in the STM32 HAL.
This is done after the merge of the PRs:
zephyrproject-rtos/hal_stm32#282
zephyrproject-rtos/hal_stm32#286

Signed-off-by: Youssef Zini <youssef.zini@savoirfairelinux.com>
Add the initial device tree source include (dtsi) files for the
stm32mp25 series boards, covering non-secure configuration for zephyr on
the Cortex-M33 core.
These files provide the basic hardware description, including CPU
(Cortex-M33), memory, RCC clock controller and NVIC interrupt
controller.

Key features:
- Set flash and RAM addresses to DDR memory.
- Adjust RCC peripheral address for non-secure context.

Signed-off-by: Youssef Zini <youssef.zini@savoirfairelinux.com>
Add initial soc support for the stm32mp2x series, including
initial Kconfig entries and default configuration files.
This enables Zephyr to recognize and build for the stm32mp2x series,
taking the stm32mp257f_ev1 as a baseline.

Includes:
- Kconfig and defconfig files for SoC selection and defaults
- soc.h for hal headers
- CMakeLists.txt for build system integration
- soc.yml update to register the new SoC

System Clock is configured statically from DTS. So no initialization
hook or soc.c needed.

Signed-off-by: Youssef Zini <youssef.zini@savoirfairelinux.com>
Add a linker script for the stm32mp2x soc series. It includes the
standard arm cortex-m linker and adds standard zephyr relocation
sections.
Replace the rom_start section name with .isr_vectors in the linker
script. This is necessary for the zephyr firmware to be started by the
remote proc driver which expects the section containing the vector table
to be named .isr_vectors.

Signed-off-by: Youssef Zini <youssef.zini@savoirfairelinux.com>
Introduce initial board support for the STM32MP257F-EV1. This includes:
- Board metadata (board.yml, stm32mp257f_ev1.yaml)
- Base software configuration (Kconfig.stm32mp257f_ev1)
- CMake build integration (board.cmake)
- Default configuration (stm32mp257f_ev1_stm32mp257fxx_m33_defconfig)
- Minimal device tree (stm32mp257f_ev1_stm32mp257fxx_m33.dts)
- Initial documentation and image for the stm32mp257f_ev1 board.
- OpenOCD configuration files for debugging support.

This enables the STM32MP257F-EV1 board to build and debug a hello world
sample.

Note that other necessary openocd configuration files are added to the
zephyr sdk directory and can be found in the stm-openocd repository[1].
[1]:https://github.com/STMicroelectronics/device-stm-openocd/tree/main

Signed-off-by: Youssef Zini <youssef.zini@savoirfairelinux.com>
Replace the use of `DT_NODELABEL(exti)` which depends on the node label
with the defined EXTI_NODE macro using the instance with the
`st_stm32_exti` compatible.
Since both macros point to the same node, this change doesn't affect
the code logic, but makes it independent of the node label, in
preparation for the addition of the STM32MP2 exti nodes.

Signed-off-by: Youssef Zini <youssef.zini@savoirfairelinux.com>
Add the mp2 exti2 dts to the dtsi file.
Add mp2 exti hal and ll function calls with EXTI2 instance. We use the
EXTI2 instance because it contains the GPIO interrupts in the non-secure
context. (We are trying to build the blinky sample as a first milestone)

Signed-off-by: Youssef Zini <youssef.zini@savoirfairelinux.com>
Add support for STM32MP2 series in the hwinfo driver.
The STM32MP2 series uses the HAL functions since it doesn't have a
ll_utils.

Signed-off-by: Youssef Zini <youssef.zini@savoirfairelinux.com>
Introduce DeviceTree binding for the STM32MP2 RCC clock controller,
enabling support for STM32MP2-specific clock configuration in Zephyr.
Update Kconfig.stm32 to add a dependency on STM32MP2 configuration,
allowing the use of STM32 LL RCC features when targeting STM32MP2
devices.
Add header for STM32MP2 per peripheral clock definitions.

Signed-off-by: Youssef Zini <youssef.zini@savoirfairelinux.com>
Add the stm32mp2 clock driver to the clock_control subsystem. The driver
is a reduced version of the generic stm32 clock driver.

Signed-off-by: Youssef Zini <youssef.zini@savoirfairelinux.com>
Remove gpio clock management from the GPIO driver when running on the
cortex-m33 on the mp2 and gpio clocks are managed by the cortex-A, being
the resource manager, allowed by the Resource Isolation Framework (RIF).
Also add a specific binding for the mp2 gpio to make clock property
optional.

Signed-off-by: Youssef Zini <youssef.zini@savoirfairelinux.com>
Add GPIO A-K nodes to the device tree for STM32MP2 SoC.
Note that GPIOs are disabled by default in the STM32MP2 SoC.

Signed-off-by: Youssef Zini <youssef.zini@savoirfairelinux.com>
Add gpio support for STM32MP257F-EV1 board.
Add the orange (&led0) LED to the device tree and enable GPIOJ.
Add the user button USER2 to the device tree and enable GPIOG.
This step allows building and debugging the blinky and button sample
applications.

Signed-off-by: Youssef Zini <youssef.zini@savoirfairelinux.com>
@youssefz24 youssefz24 force-pushed the topic/stm32mp2_support branch from d1e0db0 to d7785b1 Compare June 13, 2025 14:33
@github-actions github-actions bot removed the DNM (manifest) This PR should not be merged (controlled by action-manifest) label Jun 13, 2025
Copy link

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.