How to get PWM running on STM32MP1 (on the Cortex-M4) #52597
Replies: 3 comments 4 replies
-
@JulianWeidinger Note that the wiki note provided doesn't apply to Zephyr. Then, unfortunately, in zephyr PWM is not yet available on STM32MP1, it should first be added in ^^@arnopo |
Beta Was this translation helpful? Give feedback.
-
The main principle is to not use an IP on Both Linux and Zephyr Regarding the Linux DT the timer 1 is not used by Linux Then to avoid that Linux unclock the IP you have to activate the resource manager https://wiki.st.com/stm32mpu/wiki/Resource_manager_for_coprocessing If you use the ST openSTLInux distribution you have the resource manager and timer 1 enabled for the Cortex_M4 usage So as e first step just select this configuration with menu on boot which allows you to select the m4-exemple DT
With this you should be able to manage the timer1 IP in zephyr. Regarding the use of PWM in Zephyr, @erwango has already given you the status and method for moving forward. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your help! If PWM is not implemented from Zephyr side for this board, then I won't be able to do it, since I started new with Zephyr and generally the Device Tree configuration. I now have an alternative without using the PWM module by creating a thread that simulates pwm. Are there any plans to implement PWM, or the resource manager for the STM32MP157C-DK2 board? Maybe my device tree configuration for pwm helps someone:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
Problem:
I am trying to implement a PWM LED on the Cortex M4 of the STM32MP157C-DK2 via Zephyr. Unfortunately already during the build process the following error and a number of subsequent errors come up:
...
> In file included from /root/apps_zephyr/rtos_zephyr/soc/arm/st_stm32/common/st_stm32_dt.h:14,
> from /root/apps_zephyr/rtos_zephyr/soc/arm/st_stm32/stm32mp1/soc.h:25,
> from /root/apps_zephyr/rtos_zephyr/drivers/pwm/pwm_stm32.c:12:
> /root/apps_zephyr/rtos_zephyr/drivers/pwm/pwm_stm32.c: In function 'get_tim_clk':
> /root/apps_zephyr/build/zephyr/include/generated/devicetree_generated.h:906:37: error: 'DT_N_S_soc_S_rcc_50000000_P_apb1_prescaler' undeclared (first use in this function); did you mean 'DT_N_S_soc_S_timer_44000000_P_st_prescaler'?
> 906 | #define DT_N_NODELABEL_rcc DT_N_S_soc_S_rcc_50000000
> | ^~~~~~~~~~~~~~~~~~~~~~~~~
> /root/apps_zephyr/rtos_zephyr/include/zephyr/devicetree.h:3892:29: note: in definition of macro 'DT_CAT3'
> 3892 | #define DT_CAT3(a1, a2, a3) a1 ## a2 ## a3
...
Suspected cause:
The Cortex-A7 manages as master the resources on the board and therefore the ahb prescalers for the timers are defined by the A7.
Since the Cortex-A7 runs OpenSTLinux and the Zephyr Project is built independently for the Cortex-M4, the zephyr build system does not know the prescaler. In the st,stm32mp1-rcc.yaml bindings file of the clocks the prescaler values are listed under the blocklist. So it is not possible to define the values in the device tree for the build process.
What have I done:
CONFIG_PWM=y
Question:
How is it possible to tell the Zephyr build system at compile time the values of the prescalers?
Beta Was this translation helpful? Give feedback.
All reactions