This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new f20e229be mcu/stm32: Fix uninitialized clock structs
f20e229be is described below

commit f20e229becd37159439df284df336f69ac6db2d8
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Thu Feb 9 10:02:51 2023 +0100

    mcu/stm32: Fix uninitialized clock structs
    
    osc_init and clk_init for most of STM32 MCUs were not
    initialized.
    In some cases random stack data could have initialized filed
    that otherwise would not be used due to syscfg values.
    Like for example external LSE could be selected even if not
    present and not configured in syscfg.
    
    This behavior was observed on STM32F7 in optimized build but
    probably could apply to all other cases hence all place
    are fixed now.
---
 hw/mcu/stm/stm32f0xx/src/clock_stm32f0xx.c | 4 ++--
 hw/mcu/stm/stm32f1xx/src/clock_stm32f1xx.c | 4 ++--
 hw/mcu/stm/stm32f3xx/src/clock_stm32f3xx.c | 4 ++--
 hw/mcu/stm/stm32f4xx/src/clock_stm32f4xx.c | 6 +++---
 hw/mcu/stm/stm32f7xx/src/clock_stm32f7xx.c | 4 ++--
 hw/mcu/stm/stm32l0xx/src/clock_stm32l0xx.c | 4 ++--
 hw/mcu/stm/stm32l1xx/src/clock_stm32l1xx.c | 4 ++--
 hw/mcu/stm/stm32l4xx/src/clock_stm32l4xx.c | 6 +++---
 hw/mcu/stm/stm32wbxx/src/clock_stm32wbxx.c | 6 +++---
 9 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/hw/mcu/stm/stm32f0xx/src/clock_stm32f0xx.c 
b/hw/mcu/stm/stm32f0xx/src/clock_stm32f0xx.c
index b2cf8a357..75dab1d67 100644
--- a/hw/mcu/stm/stm32f0xx/src/clock_stm32f0xx.c
+++ b/hw/mcu/stm/stm32f0xx/src/clock_stm32f0xx.c
@@ -48,8 +48,8 @@
 void
 SystemClock_Config(void)
 {
-    RCC_OscInitTypeDef osc_init;
-    RCC_ClkInitTypeDef clk_init;
+    RCC_OscInitTypeDef osc_init = {0};
+    RCC_ClkInitTypeDef clk_init = {0};
     HAL_StatusTypeDef status;
 
     /*
diff --git a/hw/mcu/stm/stm32f1xx/src/clock_stm32f1xx.c 
b/hw/mcu/stm/stm32f1xx/src/clock_stm32f1xx.c
index 5872c4645..eaa6b103d 100644
--- a/hw/mcu/stm/stm32f1xx/src/clock_stm32f1xx.c
+++ b/hw/mcu/stm/stm32f1xx/src/clock_stm32f1xx.c
@@ -45,8 +45,8 @@
 void
 SystemClock_Config(void)
 {
-    RCC_OscInitTypeDef osc_init;
-    RCC_ClkInitTypeDef clk_init;
+    RCC_OscInitTypeDef osc_init = {0};
+    RCC_ClkInitTypeDef clk_init = {0};
     HAL_StatusTypeDef status;
 
     /*
diff --git a/hw/mcu/stm/stm32f3xx/src/clock_stm32f3xx.c 
b/hw/mcu/stm/stm32f3xx/src/clock_stm32f3xx.c
index a57b95e77..fbdab0195 100644
--- a/hw/mcu/stm/stm32f3xx/src/clock_stm32f3xx.c
+++ b/hw/mcu/stm/stm32f3xx/src/clock_stm32f3xx.c
@@ -46,8 +46,8 @@
 void
 SystemClock_Config(void)
 {
-    RCC_OscInitTypeDef osc_init;
-    RCC_ClkInitTypeDef clk_init;
+    RCC_OscInitTypeDef osc_init = {0};
+    RCC_ClkInitTypeDef clk_init = {0};
     HAL_StatusTypeDef status;
 
     /*
diff --git a/hw/mcu/stm/stm32f4xx/src/clock_stm32f4xx.c 
b/hw/mcu/stm/stm32f4xx/src/clock_stm32f4xx.c
index 87d47a673..6121997e4 100644
--- a/hw/mcu/stm/stm32f4xx/src/clock_stm32f4xx.c
+++ b/hw/mcu/stm/stm32f4xx/src/clock_stm32f4xx.c
@@ -46,7 +46,7 @@
 static void
 config_i2s_pll(void)
 {
-    RCC_PeriphCLKInitTypeDef i2s_clock_init;
+    RCC_PeriphCLKInitTypeDef i2s_clock_init = {0};
 
     i2s_clock_init.PeriphClockSelection = RCC_PERIPHCLK_PLLI2S;
     i2s_clock_init.PLLI2S.PLLI2SM = MYNEWT_VAL(STM32_CLOCK_PLLI2S_PLLM);
@@ -62,8 +62,8 @@ config_i2s_pll(void)
 void
 SystemClock_Config(void)
 {
-    RCC_OscInitTypeDef osc_init;
-    RCC_ClkInitTypeDef clk_init;
+    RCC_OscInitTypeDef osc_init = {0};
+    RCC_ClkInitTypeDef clk_init = {0};
     HAL_StatusTypeDef status;
 
     /*
diff --git a/hw/mcu/stm/stm32f7xx/src/clock_stm32f7xx.c 
b/hw/mcu/stm/stm32f7xx/src/clock_stm32f7xx.c
index 0a6ce4f30..d04d7e79f 100644
--- a/hw/mcu/stm/stm32f7xx/src/clock_stm32f7xx.c
+++ b/hw/mcu/stm/stm32f7xx/src/clock_stm32f7xx.c
@@ -45,8 +45,8 @@
 void
 SystemClock_Config(void)
 {
-    RCC_OscInitTypeDef osc_init;
-    RCC_ClkInitTypeDef clk_init;
+    RCC_OscInitTypeDef osc_init = {0};
+    RCC_ClkInitTypeDef clk_init = {0};
     HAL_StatusTypeDef status;
 
     /* Enable the MCU instruction cache */
diff --git a/hw/mcu/stm/stm32l0xx/src/clock_stm32l0xx.c 
b/hw/mcu/stm/stm32l0xx/src/clock_stm32l0xx.c
index f87536f8f..39c1843b5 100644
--- a/hw/mcu/stm/stm32l0xx/src/clock_stm32l0xx.c
+++ b/hw/mcu/stm/stm32l0xx/src/clock_stm32l0xx.c
@@ -49,8 +49,8 @@
 void
 SystemClock_Config(void)
 {
-    RCC_OscInitTypeDef osc_init;
-    RCC_ClkInitTypeDef clk_init;
+    RCC_OscInitTypeDef osc_init = {0};
+    RCC_ClkInitTypeDef clk_init = {0};
     HAL_StatusTypeDef status;
 
     /*
diff --git a/hw/mcu/stm/stm32l1xx/src/clock_stm32l1xx.c 
b/hw/mcu/stm/stm32l1xx/src/clock_stm32l1xx.c
index ff20d3ada..7b68f9055 100644
--- a/hw/mcu/stm/stm32l1xx/src/clock_stm32l1xx.c
+++ b/hw/mcu/stm/stm32l1xx/src/clock_stm32l1xx.c
@@ -49,8 +49,8 @@
 void
 SystemClock_Config(void)
 {
-    RCC_OscInitTypeDef osc_init;
-    RCC_ClkInitTypeDef clk_init;
+    RCC_OscInitTypeDef osc_init = {0};
+    RCC_ClkInitTypeDef clk_init = {0};
     HAL_StatusTypeDef status;
 
     /*
diff --git a/hw/mcu/stm/stm32l4xx/src/clock_stm32l4xx.c 
b/hw/mcu/stm/stm32l4xx/src/clock_stm32l4xx.c
index 94ce0f6b6..33a799178 100644
--- a/hw/mcu/stm/stm32l4xx/src/clock_stm32l4xx.c
+++ b/hw/mcu/stm/stm32l4xx/src/clock_stm32l4xx.c
@@ -52,11 +52,11 @@
 void
 SystemClock_Config(void)
 {
-    RCC_OscInitTypeDef osc_init;
-    RCC_ClkInitTypeDef clk_init;
+    RCC_OscInitTypeDef osc_init = {0};
+    RCC_ClkInitTypeDef clk_init = {0};
     HAL_StatusTypeDef status;
 #if TRNG_ENABLED
-    RCC_PeriphCLKInitTypeDef  pclk_init;
+    RCC_PeriphCLKInitTypeDef pclk_init = {0};
 #endif
 
     /*
diff --git a/hw/mcu/stm/stm32wbxx/src/clock_stm32wbxx.c 
b/hw/mcu/stm/stm32wbxx/src/clock_stm32wbxx.c
index b00bf1ed4..1640d6c80 100644
--- a/hw/mcu/stm/stm32wbxx/src/clock_stm32wbxx.c
+++ b/hw/mcu/stm/stm32wbxx/src/clock_stm32wbxx.c
@@ -53,11 +53,11 @@
 void
 SystemClock_Config(void)
 {
-    RCC_OscInitTypeDef osc_init;
-    RCC_ClkInitTypeDef clk_init;
+    RCC_OscInitTypeDef osc_init = {0};
+    RCC_ClkInitTypeDef clk_init = {0};
     HAL_StatusTypeDef status;
 #if TRNG_ENABLED
-    RCC_PeriphCLKInitTypeDef  pclk_init;
+    RCC_PeriphCLKInitTypeDef pclk_init = {0};
 #endif
 
     /*

Reply via email to