cancel
Showing results for 
Search instead for 
Did you mean: 

Auto-generating Clock Configuration

anlavandier
Associate

Hi, we are working on an open-source library OS in Rust for embedded architectures, result of a collaboration between the French research institution INRIA and the Freie Universität Berlin, called Ariel OS. Our OS currently supports a variety of STM32 MCUs and we expect the list to grow with time.
To streamline user experience, we would like to provide some ways of automatically generating the clock configuration for the STM32 MCUs. We are envisioning a utility where users simply ask for specific frequency ranges for specific clocks and this utility would figure out the correct dividers/multipliers/multiplexers to use to comply with the users requirements.
To achieve this, we would need to be able to recreate the entire clock tree logic. As far as I understand, CubeMX recreates the clock tree in software and is able to calculate frequencies based on the chosen/defaults values of the clock parameters for any MCU using some kind of configuration file. For our project we would need to have access to some kind of clock tree representation logic and to the appropriate files. Is that possible ? 

3 REPLIES 3
Pavel A.
Super User

Can you think of a tool that translates Cube-generated SystemClockInit() from C to Rust?

Also, check the new development in the ST "HAL 2.0" library and related changes in generated clock init code here.

 

 

anlavandier
Associate

Thanks for your reply. 

I'm assuming that you meant SystemClockConfig() because I didn't find any function named SystemClockInit() in the generated C code. Regardless, I don't think that this is what I'm looking for. There are ways to set the values in the correct registers to tweak the clock dividers in Rust using the embassy framework. What I'm looking for is basically the logic that generates the  Clock Configuration Tab of CubeMX from the user selecting an MCU. 

I'll look into the HAL 2.0 but I'm worried that all the changes exposed here are downstream of CubeMX and thus not really of any uses for me.

Propose ST to employ you and help driving Rust support for them.