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
commit 5472f775c19a054851a0fd28f4fb023605665d95 Author: Jerzy Kasenberg <[email protected]> AuthorDate: Fri Oct 4 11:52:43 2024 +0200 hw/mcu/stm32: Cleanup hal_system_init After NVIC_Relocate() was moved to different header all hal_system_init needs additional include Some leftover code was also cleaned. Signed-off-by: Jerzy Kasenberg <[email protected]> --- hw/mcu/stm/stm32f0xx/src/hal_system_init.c | 1 + hw/mcu/stm/stm32f1xx/src/hal_system_init.c | 5 +---- hw/mcu/stm/stm32f3xx/src/hal_system_init.c | 11 ++++------- hw/mcu/stm/stm32f4xx/src/hal_system_init.c | 5 +---- hw/mcu/stm/stm32f7xx/src/hal_system_init.c | 6 +----- hw/mcu/stm/stm32g0xx/src/hal_system_init.c | 9 +-------- hw/mcu/stm/stm32g4xx/src/hal_system_init.c | 7 +++---- hw/mcu/stm/stm32h7xx/src/hal_system_init.c | 5 +---- hw/mcu/stm/stm32l0xx/src/hal_system_init.c | 5 +---- .../stm/{stm32h7xx => stm32l1xx}/src/hal_system_init.c | 17 +---------------- hw/mcu/stm/stm32l1xx/src/system_stm32l1xx.c | 3 --- hw/mcu/stm/stm32l4xx/src/hal_system_init.c | 8 ++++---- hw/mcu/stm/stm32u5xx/src/hal_system_init.c | 5 +---- hw/mcu/stm/stm32wbxx/src/hal_system_init.c | 5 +---- 14 files changed, 21 insertions(+), 71 deletions(-) diff --git a/hw/mcu/stm/stm32f0xx/src/hal_system_init.c b/hw/mcu/stm/stm32f0xx/src/hal_system_init.c index 4206b8da9..33d46fdfe 100644 --- a/hw/mcu/stm/stm32f0xx/src/hal_system_init.c +++ b/hw/mcu/stm/stm32f0xx/src/hal_system_init.c @@ -20,6 +20,7 @@ #include "os/mynewt.h" #include "mcu/stm32_hal.h" #include <hal/hal_system.h> +#include "mynewt_cm.h" void SystemClock_Config(void); diff --git a/hw/mcu/stm/stm32f1xx/src/hal_system_init.c b/hw/mcu/stm/stm32f1xx/src/hal_system_init.c index 0610072d1..3f8e63b4c 100644 --- a/hw/mcu/stm/stm32f1xx/src/hal_system_init.c +++ b/hw/mcu/stm/stm32f1xx/src/hal_system_init.c @@ -20,16 +20,13 @@ #include "os/mynewt.h" #include "mcu/stm32_hal.h" #include <hal/hal_system.h> - -extern char __vector_tbl_reloc__[]; +#include "mynewt_cm.h" void SystemClock_Config(void); void hal_system_init(void) { - SCB->VTOR = (uint32_t)&__vector_tbl_reloc__; - /* Configure System Clock */ SystemClock_Config(); diff --git a/hw/mcu/stm/stm32f3xx/src/hal_system_init.c b/hw/mcu/stm/stm32f3xx/src/hal_system_init.c index 0c8b67a20..3f8e63b4c 100644 --- a/hw/mcu/stm/stm32f3xx/src/hal_system_init.c +++ b/hw/mcu/stm/stm32f3xx/src/hal_system_init.c @@ -20,27 +20,24 @@ #include "os/mynewt.h" #include "mcu/stm32_hal.h" #include <hal/hal_system.h> - -extern char __vector_tbl_reloc__[]; +#include "mynewt_cm.h" void SystemClock_Config(void); void hal_system_init(void) { - SCB->VTOR = (uint32_t)&__vector_tbl_reloc__; - /* Configure System Clock */ SystemClock_Config(); /* Update SystemCoreClock global variable */ SystemCoreClockUpdate(); + /* Relocate the vector table */ + NVIC_Relocate(); + if (PREFETCH_ENABLE) { __HAL_FLASH_PREFETCH_BUFFER_ENABLE(); } - - /* Relocate the vector table */ - NVIC_Relocate(); } diff --git a/hw/mcu/stm/stm32f4xx/src/hal_system_init.c b/hw/mcu/stm/stm32f4xx/src/hal_system_init.c index 96db76808..d819c47e7 100644 --- a/hw/mcu/stm/stm32f4xx/src/hal_system_init.c +++ b/hw/mcu/stm/stm32f4xx/src/hal_system_init.c @@ -20,16 +20,13 @@ #include "os/mynewt.h" #include "mcu/stm32_hal.h" #include <hal/hal_system.h> - -extern char __vector_tbl_reloc__[]; +#include "mynewt_cm.h" void SystemClock_Config(void); void hal_system_init(void) { - SCB->VTOR = (uint32_t)&__vector_tbl_reloc__; - /* Configure System Clock */ SystemClock_Config(); diff --git a/hw/mcu/stm/stm32f7xx/src/hal_system_init.c b/hw/mcu/stm/stm32f7xx/src/hal_system_init.c index 01e408b45..522a2a11c 100644 --- a/hw/mcu/stm/stm32f7xx/src/hal_system_init.c +++ b/hw/mcu/stm/stm32f7xx/src/hal_system_init.c @@ -20,16 +20,13 @@ #include "os/mynewt.h" #include "mcu/stm32_hal.h" #include <hal/hal_system.h> - -extern char __vector_tbl_reloc__[]; +#include "mynewt_cm.h" void SystemClock_Config(void); void hal_system_init(void) { - SCB->VTOR = (uint32_t)&__vector_tbl_reloc__; - /* Configure System Clock */ SystemClock_Config(); @@ -47,4 +44,3 @@ hal_system_init(void) __HAL_FLASH_PREFETCH_BUFFER_ENABLE(); #endif } - diff --git a/hw/mcu/stm/stm32g0xx/src/hal_system_init.c b/hw/mcu/stm/stm32g0xx/src/hal_system_init.c index dc995be19..bff9728fa 100644 --- a/hw/mcu/stm/stm32g0xx/src/hal_system_init.c +++ b/hw/mcu/stm/stm32g0xx/src/hal_system_init.c @@ -18,21 +18,15 @@ */ #include "os/mynewt.h" +#include "mynewt_cm.h" #include "mcu/stm32_hal.h" #include <hal/hal_system.h> -extern char __vector_tbl_reloc__[]; - -/* - * XXX BSP specific - */ void SystemClock_Config(void); void hal_system_init(void) { - SCB->VTOR = (uint32_t)&__vector_tbl_reloc__; - /* Configure System Clock */ SystemClock_Config(); @@ -50,4 +44,3 @@ hal_system_init(void) __HAL_FLASH_INSTRUCTION_CACHE_ENABLE(); } } - diff --git a/hw/mcu/stm/stm32g4xx/src/hal_system_init.c b/hw/mcu/stm/stm32g4xx/src/hal_system_init.c index 414a4daf0..eb8a213af 100644 --- a/hw/mcu/stm/stm32g4xx/src/hal_system_init.c +++ b/hw/mcu/stm/stm32g4xx/src/hal_system_init.c @@ -18,16 +18,13 @@ */ #include "os/mynewt.h" +#include "mynewt_cm.h" #include "mcu/stm32_hal.h" #include <hal/hal_system.h> -extern char __vector_tbl_reloc__[]; - void hal_system_init(void) { - SCB->VTOR = (uint32_t)&__vector_tbl_reloc__; - if (PREFETCH_ENABLE) { __HAL_FLASH_PREFETCH_BUFFER_ENABLE(); } @@ -39,5 +36,7 @@ hal_system_init(void) if (MYNEWT_VAL(STM32_ENABLE_DCACHE)) { __HAL_FLASH_DATA_CACHE_ENABLE(); } + + NVIC_Relocate(); } diff --git a/hw/mcu/stm/stm32h7xx/src/hal_system_init.c b/hw/mcu/stm/stm32h7xx/src/hal_system_init.c index 46d6e4bbc..8bd31e745 100644 --- a/hw/mcu/stm/stm32h7xx/src/hal_system_init.c +++ b/hw/mcu/stm/stm32h7xx/src/hal_system_init.c @@ -18,18 +18,15 @@ */ #include "os/mynewt.h" +#include "mynewt_cm.h" #include "mcu/stm32_hal.h" #include <hal/hal_system.h> -extern char __vector_tbl_reloc__[]; - void SystemClock_Config(void); void hal_system_init(void) { - SCB->VTOR = (uint32_t)&__vector_tbl_reloc__; - /* Configure System Clock */ SystemClock_Config(); diff --git a/hw/mcu/stm/stm32l0xx/src/hal_system_init.c b/hw/mcu/stm/stm32l0xx/src/hal_system_init.c index a784b41fe..8e97f8e59 100644 --- a/hw/mcu/stm/stm32l0xx/src/hal_system_init.c +++ b/hw/mcu/stm/stm32l0xx/src/hal_system_init.c @@ -18,18 +18,15 @@ */ #include "os/mynewt.h" +#include "mynewt_cm.h" #include "mcu/stm32_hal.h" #include <hal/hal_system.h> -extern char __vector_tbl_reloc__[]; - void SystemClock_Config(void); void hal_system_init(void) { - SCB->VTOR = (uint32_t)&__vector_tbl_reloc__; - /* Configure System Clock */ SystemClock_Config(); diff --git a/hw/mcu/stm/stm32h7xx/src/hal_system_init.c b/hw/mcu/stm/stm32l1xx/src/hal_system_init.c similarity index 71% copy from hw/mcu/stm/stm32h7xx/src/hal_system_init.c copy to hw/mcu/stm/stm32l1xx/src/hal_system_init.c index 46d6e4bbc..866afa6a1 100644 --- a/hw/mcu/stm/stm32h7xx/src/hal_system_init.c +++ b/hw/mcu/stm/stm32l1xx/src/hal_system_init.c @@ -18,25 +18,10 @@ */ #include "os/mynewt.h" -#include "mcu/stm32_hal.h" -#include <hal/hal_system.h> - -extern char __vector_tbl_reloc__[]; - -void SystemClock_Config(void); +#include "mynewt_cm.h" void hal_system_init(void) { - SCB->VTOR = (uint32_t)&__vector_tbl_reloc__; - - /* Configure System Clock */ - SystemClock_Config(); - - /* Update SystemCoreClock global variable */ - SystemCoreClockUpdate(); - - /* Relocate the vector table */ NVIC_Relocate(); } - diff --git a/hw/mcu/stm/stm32l1xx/src/system_stm32l1xx.c b/hw/mcu/stm/stm32l1xx/src/system_stm32l1xx.c index 0d24392c7..3d43dc258 100644 --- a/hw/mcu/stm/stm32l1xx/src/system_stm32l1xx.c +++ b/hw/mcu/stm/stm32l1xx/src/system_stm32l1xx.c @@ -98,9 +98,6 @@ SystemInit(void) /* Update SystemCoreClock global variable */ SystemCoreClockUpdate(); - - /* Relocate the vector table */ - NVIC_Relocate(); } /** diff --git a/hw/mcu/stm/stm32l4xx/src/hal_system_init.c b/hw/mcu/stm/stm32l4xx/src/hal_system_init.c index 5a1935b18..ac16557ab 100644 --- a/hw/mcu/stm/stm32l4xx/src/hal_system_init.c +++ b/hw/mcu/stm/stm32l4xx/src/hal_system_init.c @@ -18,18 +18,15 @@ */ #include "os/mynewt.h" +#include "mynewt_cm.h" #include "mcu/stm32_hal.h" #include <hal/hal_system.h> -extern char __vector_tbl_reloc__[]; - void SystemClock_Config(void); void hal_system_init(void) { - SCB->VTOR = (uint32_t)&__vector_tbl_reloc__; - /* Configure System Clock */ SystemClock_Config(); @@ -39,5 +36,8 @@ hal_system_init(void) if (PREFETCH_ENABLE) { __HAL_FLASH_PREFETCH_BUFFER_ENABLE(); } + + /* Relocate the vector table */ + NVIC_Relocate(); } diff --git a/hw/mcu/stm/stm32u5xx/src/hal_system_init.c b/hw/mcu/stm/stm32u5xx/src/hal_system_init.c index 46d6e4bbc..8bd31e745 100644 --- a/hw/mcu/stm/stm32u5xx/src/hal_system_init.c +++ b/hw/mcu/stm/stm32u5xx/src/hal_system_init.c @@ -18,18 +18,15 @@ */ #include "os/mynewt.h" +#include "mynewt_cm.h" #include "mcu/stm32_hal.h" #include <hal/hal_system.h> -extern char __vector_tbl_reloc__[]; - void SystemClock_Config(void); void hal_system_init(void) { - SCB->VTOR = (uint32_t)&__vector_tbl_reloc__; - /* Configure System Clock */ SystemClock_Config(); diff --git a/hw/mcu/stm/stm32wbxx/src/hal_system_init.c b/hw/mcu/stm/stm32wbxx/src/hal_system_init.c index b848c4c90..ef678d2dd 100644 --- a/hw/mcu/stm/stm32wbxx/src/hal_system_init.c +++ b/hw/mcu/stm/stm32wbxx/src/hal_system_init.c @@ -18,18 +18,15 @@ */ #include "os/mynewt.h" +#include "mynewt_cm.h" #include "mcu/stm32_hal.h" #include <hal/hal_system.h> -extern char __vector_tbl_reloc__[]; - void SystemClock_Config(void); void hal_system_init(void) { - SCB->VTOR = (uint32_t)&__vector_tbl_reloc__; - /* Configure System Clock */ SystemClock_Config();
