Skip to content
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

Fix STM32 crashes on boot due to unset VTOR #4543

Merged
merged 1 commit into from
Jun 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,6 @@ void SystemInit(void)

/* Enable SYSCFGENR in APB2EN, needed for 1st call of NVIC_SetVector, to copy vectors from flash to ram */
RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN;

/* Configure the Cube driver */
SystemCoreClock = 8000000; // At this stage the HSI is used as system clock
HAL_Init();

/* Configure the System clock source, PLL Multiplier and Divider factors,
AHB/APBx prescalers and Flash settings */
SetSysClock();

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
*/

#include "stm32f0xx.h"
#include "hal_tick.h"

/**
* @}
*/
Expand Down Expand Up @@ -234,18 +234,7 @@ void SystemInit(void)

/* Enable SYSCFGENR in APB2EN, needed for 1st call of NVIC_SetVector, to copy vectors from flash to ram */
RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN;

/* Configure the Cube driver */
SystemCoreClock = 8000000; // At this stage the HSI is used as system clock
HAL_Init();

/* Configure the System clock source, PLL Multiplier and Divider factors,
AHB/APBx prescalers and Flash settings */
SetSysClock();

/* Reset the timer to avoid issues after the RAM initialization */
TIM_MST_RESET_ON;
TIM_MST_RESET_OFF;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
*/

#include "stm32f0xx.h"
#include "hal_tick.h"

/**
* @}
*/
Expand Down Expand Up @@ -234,18 +234,7 @@ void SystemInit(void)

/* Enable SYSCFGENR in APB2EN, needed for 1st call of NVIC_SetVector, to copy vectors from flash to ram */
RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN;

/* Configure the Cube driver */
SystemCoreClock = 8000000; // At this stage the HSI is used as system clock
HAL_Init();

/* Configure the System clock source, PLL Multiplier and Divider factors,
AHB/APBx prescalers and Flash settings */
SetSysClock();

/* Reset the timer to avoid issues after the RAM initialization */
TIM_MST_RESET_ON;
TIM_MST_RESET_OFF;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
*/

#include "stm32f0xx.h"
#include "hal_tick.h"

/**
* @}
*/
Expand Down Expand Up @@ -234,18 +234,7 @@ void SystemInit(void)

/* Enable SYSCFGENR in APB2EN, needed for 1st call of NVIC_SetVector, to copy vectors from flash to ram */
RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN;

/* Configure the Cube driver */
SystemCoreClock = 8000000; // At this stage the HSI is used as system clock
HAL_Init();

/* Configure the System clock source, PLL Multiplier and Divider factors,
AHB/APBx prescalers and Flash settings */
SetSysClock();

/* Reset the timer to avoid issues after the RAM initialization */
TIM_MST_RESET_ON;
TIM_MST_RESET_OFF;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
*/

#include "stm32f0xx.h"
#include "hal_tick.h"

/**
* @}
*/
Expand Down Expand Up @@ -234,18 +234,7 @@ void SystemInit(void)

/* Enable SYSCFGENR in APB2EN, needed for 1st call of NVIC_SetVector, to copy vectors from flash to ram */
RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN;

/* Configure the Cube driver */
SystemCoreClock = 8000000; // At this stage the HSI is used as system clock
HAL_Init();

/* Configure the System clock source, PLL Multiplier and Divider factors,
AHB/APBx prescalers and Flash settings */
SetSysClock();

/* Reset the timer to avoid issues after the RAM initialization */
TIM_MST_RESET_ON;
TIM_MST_RESET_OFF;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
*/

#include "stm32f0xx.h"
#include "hal_tick.h"

/**
* @}
*/
Expand Down Expand Up @@ -233,18 +233,7 @@ void SystemInit(void)

/* Enable SYSCFGENR in APB2EN, needed for 1st call of NVIC_SetVector, to copy vectors from flash to ram */
RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN;

/* Configure the Cube driver */
SystemCoreClock = 8000000; // At this stage the HSI is used as system clock
HAL_Init();

/* Configure the System clock source, PLL Multiplier and Divider factors,
AHB/APBx prescalers and Flash settings */
SetSysClock();

/* Reset the timer to avoid issues after the RAM initialization */
TIM_MST_RESET_ON;
TIM_MST_RESET_OFF;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
*/

#include "stm32f0xx.h"
#include "hal_tick.h"

/**
* @}
*/
Expand Down Expand Up @@ -233,18 +233,7 @@ void SystemInit(void)

/* Enable SYSCFGENR in APB2EN, needed for 1st call of NVIC_SetVector, to copy vectors from flash to ram */
RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN;

/* Configure the Cube driver */
SystemCoreClock = 8000000; // At this stage the HSI is used as system clock
HAL_Init();

/* Configure the System clock source, PLL Multiplier and Divider factors,
AHB/APBx prescalers and Flash settings */
SetSysClock();

/* Reset the timer to avoid issues after the RAM initialization */
TIM_MST_RESET_ON;
TIM_MST_RESET_OFF;
}

/**
Expand Down
6 changes: 5 additions & 1 deletion targets/TARGET_STM/TARGET_STM32F0/mbed_overrides.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
void mbed_sdk_init() {
// Update the SystemCoreClock variable.
SystemCoreClockUpdate();
// Need to restart HAL driver after the RAM is initialized
HAL_Init();

/* Configure the System clock source, PLL Multiplier and Divider factors,
AHB/APBx prescalers and Flash settings */
SetSysClock();
SystemCoreClockUpdate();
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
*/

#include "stm32f1xx.h"
#include "hal_tick.h"


/**
* @}
Expand Down Expand Up @@ -254,17 +254,6 @@ void SystemInit (void)
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */
#endif

/* Configure the Cube driver */
SystemCoreClock = 8000000; // At this stage the HSI is used as system clock
HAL_Init();

/* Configure the System clock source, PLL Multiplier and Divider factors,
AHB/APBx prescalers and Flash settings */
SetSysClock();

/* Reset the timer to avoid issues after the RAM initialization */
TIM_MST_RESET_ON;
TIM_MST_RESET_OFF;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
*/

#include "stm32f1xx.h"
#include "hal_tick.h"


/**
* @}
Expand Down Expand Up @@ -252,17 +252,6 @@ void SystemInit (void)
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */
#endif

/* Configure the Cube driver */
SystemCoreClock = 8000000; // At this stage the HSI is used as system clock
HAL_Init();

/* Configure the System clock source, PLL Multiplier and Divider factors,
AHB/APBx prescalers and Flash settings */
SetSysClock();

/* Reset the timer to avoid issues after the RAM initialization */
TIM_MST_RESET_ON;
TIM_MST_RESET_OFF;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
*/

#include "stm32f1xx.h"
#include "hal_tick.h"


/**
* @}
Expand Down Expand Up @@ -254,17 +254,6 @@ void SystemInit (void)
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */
#endif

/* Configure the Cube driver */
SystemCoreClock = 8000000; // At this stage the HSI is used as system clock
HAL_Init();

/* Configure the System clock source, PLL Multiplier and Divider factors,
AHB/APBx prescalers and Flash settings */
SetSysClock();

/* Reset the timer to avoid issues after the RAM initialization */
TIM_MST_RESET_ON;
TIM_MST_RESET_OFF;
}

/**
Expand Down
6 changes: 5 additions & 1 deletion targets/TARGET_STM/TARGET_STM32F1/mbed_overrides.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ void mbed_sdk_init()
{
// Update the SystemCoreClock variable.
SystemCoreClockUpdate();
// Need to restart HAL driver after the RAM is initialized
HAL_Init();

/* Configure the System clock source, PLL Multiplier and Divider factors,
AHB/APBx prescalers and Flash settings */
SetSysClock();
SystemCoreClockUpdate();
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
*/

#include "stm32f2xx.h"
#include "hal_tick.h"

/**
* @}
Expand Down Expand Up @@ -203,20 +202,6 @@ void SystemInit(void)
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
#endif

#if (USE_PLL_HSE_XTAL != 0) || (USE_PLL_HSE_EXTC != 0)
SystemCoreClock = 120000000;
#else
SystemCoreClock = 96000000;
#endif
HAL_Init();

/* Configure the System clock source, PLL Multiplier and Divider factors,
AHB/APBx prescalers and Flash settings */
SetSysClock();

/* Reset the timer to avoid issues after the RAM initialization */
TIM_MST_RESET_ON;
TIM_MST_RESET_OFF;
}

/**
Expand Down
6 changes: 5 additions & 1 deletion targets/TARGET_STM/TARGET_STM32F2/mbed_overrides.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ void mbed_sdk_init()
{
// Update the SystemCoreClock variable.
SystemCoreClockUpdate();
// Need to restart HAL driver after the RAM is initialized
HAL_Init();

/* Configure the System clock source, PLL Multiplier and Divider factors,
AHB/APBx prescalers and Flash settings */
SetSysClock();
SystemCoreClockUpdate();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
*/

#include "stm32f3xx.h"
#include "hal_tick.h"


/**
* @}
Expand Down Expand Up @@ -213,17 +213,6 @@ void SystemInit(void)
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
#endif

/* Configure the Cube driver */
SystemCoreClock = 8000000; // At this stage the HSI is used as system clock
HAL_Init();

/* Configure the System clock source, PLL Multiplier and Divider factors,
AHB/APBx prescalers and Flash settings */
SetSysClock();

/* Reset the timer to avoid issues after the RAM initialization */
TIM_MST_RESET_ON;
TIM_MST_RESET_OFF;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
*/

#include "stm32f3xx.h"
#include "hal_tick.h"


/**
* @}
Expand Down Expand Up @@ -213,17 +213,6 @@ void SystemInit(void)
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
#endif

/* Configure the Cube driver */
SystemCoreClock = 8000000; // At this stage the HSI is used as system clock
HAL_Init();

/* Configure the System clock source, PLL Multiplier and Divider factors,
AHB/APBx prescalers and Flash settings */
SetSysClock();

/* Reset the timer to avoid issues after the RAM initialization */
TIM_MST_RESET_ON;
TIM_MST_RESET_OFF;
}

/**
Expand Down
Loading