-
Notifications
You must be signed in to change notification settings - Fork 3k
STM32 : Clock source selection in json config file #4421
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a suggestion: You could reduce copy paste code by creating a private target that all three of the targets you are modifying inherit from. For example:
diff --git i/targets/targets.json w/targets/targets.json
index 454ee6f3c..80b4c269b 100644
--- i/targets/targets.json
+++ w/targets/targets.json
@@ -686,17 +686,30 @@
"release_versions": ["2"],
"device_name": "STM32F042K6"
},
+ "FAMILY_STM32": {
+ "inherits": ["Target"],
+ "public": false,
+ "supported_toolchains": ["ARM", "uARM", "IAR", "GCC_ARM"],
+ "default_toolchain": "ARM",
+ "extra_labels": ["STM"],
+ "release_versions": ["2", "5"],
+ "macros": ["TRANSACTION_QUEUE_SIZE_SPI=2"],
+ "device_has": ["ANALOGIN", "I2C", "I2CSLAVE", "I2C_ASYNCH", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_FC", "SERIAL_ASYNCH", "SLEEP", "SPI", "SPISLAVE", "SPI_ASYNCH", "STDIO_MESSAGES"],
+ "config": {
+ "clock_source": {
+ "help": "Mask value : USE_PLL_HSE_EXTC | USE_PLL_HSE_XTAL (need HW patch) | USE_PLL_HSI",
+ "value": "USE_PLL_HSE_EXTC|USE_PLL_HSI",
+ "macro_name": "CLOCK_SOURCE"
+ }
+ }
+ },
"NUCLEO_F070RB": {
+ "inherits": ["FAMILY_STM32"],
"supported_form_factors": ["ARDUINO", "MORPHO"],
"core": "Cortex-M0",
- "default_toolchain": "ARM",
- "extra_labels": ["STM", "STM32F0", "STM32F070RB"],
- "supported_toolchains": ["ARM", "uARM", "IAR", "GCC_ARM"],
- "inherits": ["Target"],
+ "extra_labels_add": ["STM32F0", "STM32F070RB"],
"detect_code": ["0755"],
- "macros": ["TRANSACTION_QUEUE_SIZE_SPI=2"],
- "device_has": ["ANALOGIN", "I2C", "I2CSLAVE", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_FC", "SERIAL_ASYNCH", "SLEEP", "SPI", "SPISLAVE", "SPI_ASYNCH", "STDIO_MESSAGES"],
- "release_versions": ["2", "5"],
+ "device_has_add": ["LOWPOWERTIMER"],
"device_name": "STM32F070RB"
},
"NUCLEO_F072RB": {
@@ -728,14 +741,10 @@
"NUCLEO_F103RB": {
"supported_form_factors": ["ARDUINO", "MORPHO"],
"core": "Cortex-M3",
- "default_toolchain": "ARM",
- "extra_labels": ["STM", "STM32F1", "STM32F103RB"],
- "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"],
- "inherits": ["Target"],
+ "extra_labels_add": ["STM32F1", "STM32F103RB"],
+ "inherits": ["FAMILY_STM32"],
"detect_code": ["0700"],
- "macros": ["TRANSACTION_QUEUE_SIZE_SPI=2"],
- "device_has": ["ANALOGIN", "CAN", "I2C", "I2CSLAVE", "I2C_ASYNCH", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_FC", "SERIAL_ASYNCH", "SLEEP", "SPI", "SPISLAVE", "SPI_ASYNCH", "STDIO_MESSAGES"],
- "release_versions": ["2", "5"],
+ "device_has_add": ["CAN"],
"device_name": "STM32F103RB"
},
"NUCLEO_F207ZG": {
@@ -1118,14 +1127,11 @@
"NUCLEO_L476RG": {
"supported_form_factors": ["ARDUINO", "MORPHO"],
"core": "Cortex-M4F",
- "default_toolchain": "ARM",
- "extra_labels": ["STM", "STM32L4", "STM32L476RG", "STM32L476xG"],
- "supported_toolchains": ["ARM", "uARM", "IAR", "GCC_ARM"],
- "inherits": ["Target"],
+ "extra_labels_add": ["STM32L4", "STM32L476RG", "STM32L476xG"],
+ "inherits": ["FAMILY_STM32"],
"detect_code": ["0765"],
- "macros": ["TRANSACTION_QUEUE_SIZE_SPI=2","USBHOST_OTHER"],
- "device_has": ["ANALOGIN", "ANALOGOUT", "CAN", "I2C", "I2CSLAVE", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SERIAL_FC", "SLEEP", "SPI", "SPISLAVE", "SPI_ASYNCH", "STDIO_MESSAGES", "TRNG"],
- "release_versions": ["2", "5"],
+ "macros_add": ["USBHOST_OTHER"],
+ "device_has_add": ["ANALOGOUT", "CAN", "LOWPOWERTIMER", "TRNG"],
"device_name": "STM32L476RG"
},
"NUCLEO_L486RG": {
@theotherjimmy |
The most important condition for a solution is that not-so-expert users should not have to worry about anything. Default clock or other settings should be initialised correctly for maximum performance on all mbed platforms, specific settings should be adjusted automatically when you include the USB device or host library in your project and/or any other lib (eg ethernet peripheral) that might require modifications (possibly generating a warning message when clockspeed or other default capabilities are affected). Is is doable to have a mechanism that calls a weak external ''init'' function at the end of the system startup (ie before object instantiations and before main). The weak function approach is used on the original mbed lpc1768 platforms for the MAC address resolution: extern "C" void mbed_mac_address(char * mac) {} provides the unique MAC hardware address to the ethernet peripheral lib by interrogating the mbed host interface device. |
No... With OS2 online compiler, there is no change as default value in the targets json file is the same. With OS5 online compiler, you can add a mbed_app json file to overwrite this config value @0xc0170 , please, correct me if I am wrong |
Can you please resolve conflicts? |
@jeromecoutant Bump on the conflicts. |
+1, good summary ! This patch looks fine to me. Providing defaults as they are, and providing a configuration for setting other clock sources. |
Thx Martin |
@jeromecoutant are you planning to continue this PR as is? if you are, could you rebase this PR to remove the merge conflicts? |
Hi |
- default value is the same as before patch - system_stm32f4xx.c file is copied to family level with all other ST cube files - specific clock configuration is now in a new file: system_clock.c - nvic_addr.h file is now in TARGET_STM level, and can be used everywhere
39b8a57
to
2ae2d98
Compare
Hi Work done for all ST F4
Note that I try to set the maximum frequency for all:
Internal tests have been executed with HSE and HSI. @theotherjimmy |
/morph test |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
Description
We propose to set the clock source from json config file.
Default values are kept to the same values as before this pull request,
but if user wants to explicitly use the internal or external clock, he can modify the targets json file or overwrite the config value in the mbed app json file.
Goal is to :
Status
IN DEVELOPMENT
I would like to get ARM and community feedback first.