Skip to content

Commit

Permalink
hw/mcu/stm32f3: Use common startup code
Browse files Browse the repository at this point in the history
STM32F3 now uses common startup code for Cortex-M4 and
autogenerated linker script.

Flash cache initialization moved to hal_system_init.c to
make system_stm32f3xx.c more like original ST file
so future updates will be easier.

Unused ld scripts remove

NVIC_NUM_VECTOR corrected (probably value was from other MCU)

Signed-off-by: Jerzy Kasenberg <[email protected]>
  • Loading branch information
kasjer committed Jun 5, 2024
1 parent e2b7b1b commit 6164bc4
Show file tree
Hide file tree
Showing 19 changed files with 1,729 additions and 238 deletions.
6 changes: 5 additions & 1 deletion hw/mcu/stm/stm32f3xx/include/mcu/cmsis_nvic.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@

#include <stdint.h>

#define NVIC_NUM_VECTORS (16 + 81) // CORE + MCU Peripherals
extern uint32_t __isr_vector_start[];
extern uint32_t __isr_vector_end[];

/* Extract number of vectors from .interrupt section size */
#define NVIC_NUM_VECTORS (__isr_vector_end - __isr_vector_start)
#define NVIC_USER_IRQ_OFFSET 16

#include "stm32f3xx.h"
Expand Down
50 changes: 50 additions & 0 deletions hw/mcu/stm/stm32f3xx/include/mcu/mcu_vectors.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#if defined(STM32F301x8)
#include "vectors/stm32f301x8_vectors.h"
#elif defined(STM32F302x8)
#include "vectors/stm32f302x8_vectors.h"
#elif defined(STM32F302xC)
#include "vectors/stm32f302xc_vectors.h"
#elif defined(STM32F302xE)
#include "vectors/stm32f302xe_vectors.h"
#elif defined(STM32F303x8)
#include "vectors/stm32f303x8_vectors.h"
#elif defined(STM32F303xC)
#include "vectors/stm32f303xc_vectors.h"
#elif defined(STM32F303xE)
#include "vectors/stm32f303xe_vectors.h"
#elif defined(STM32F373xC)
#include "vectors/stm32f373xc_vectors.h"
#elif defined(STM32F334x8)
#include "vectors/stm32f334x8_vectors.h"
#elif defined(STM32F318xx)
#include "vectors/stm32f318xx_vectors.h"
#elif defined(STM32F328xx)
#include "vectors/stm32f328xx_vectors.h"
#elif defined(STM32F358xx)
#include "vectors/stm32f358xx_vectors.h"
#elif defined(STM32F378xx)
#include "vectors/stm32f378xx_vectors.h"
#elif defined(STM32F398xx)
#include "vectors/stm32f398xx_vectors.h"
#else
#error "Please select first the target STM32F3xx device used in your application"
#endif
117 changes: 117 additions & 0 deletions hw/mcu/stm/stm32f3xx/include/mcu/vectors/stm32f301x8_vectors.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

INT_VECTOR_STACK_TOP(__StackTop)
INT_VECTOR_RESET_HANDLER(Reset_Handler)
INT_VECTOR_NMI_HANDLER(NMI_Handler)
INT_VECTOR_HARDFAULT_HANDLER(HardFault_Handler)
INT_VECTOR_MEMMANAGE_HANDLER(MemManage_Handler)
INT_VECTOR_BUSFAULT_HANDLER(BusFault_Handler)
INT_VECTOR_USAGEFAULT_HANDLER(UsageFault_Handler)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_SVC_HANDLER(SVC_Handler)
INT_VECTOR_DEBUGMON_HANDLER(DebugMon_Handler)
INT_VECTOR_UNUSED(0)
INT_VECTOR_PENDSV_HANDLER(PendSV_Handler)
INT_VECTOR_SYSTICK_HANDLER(SysTick_Handler)
INT_VECTOR(WWDG_IRQHandler)
INT_VECTOR(PVD_IRQHandler)
INT_VECTOR(TAMP_STAMP_IRQHandler)
INT_VECTOR(RTC_WKUP_IRQHandler)
INT_VECTOR(FLASH_IRQHandler)
INT_VECTOR(RCC_IRQHandler)
INT_VECTOR(EXTI0_IRQHandler)
INT_VECTOR(EXTI1_IRQHandler)
INT_VECTOR(EXTI2_TSC_IRQHandler)
INT_VECTOR(EXTI3_IRQHandler)
INT_VECTOR(EXTI4_IRQHandler)
INT_VECTOR(DMA1_Channel1_IRQHandler)
INT_VECTOR(DMA1_Channel2_IRQHandler)
INT_VECTOR(DMA1_Channel3_IRQHandler)
INT_VECTOR(DMA1_Channel4_IRQHandler)
INT_VECTOR(DMA1_Channel5_IRQHandler)
INT_VECTOR(DMA1_Channel6_IRQHandler)
INT_VECTOR(DMA1_Channel7_IRQHandler)
INT_VECTOR(ADC1_IRQHandler)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR(EXTI9_5_IRQHandler)
INT_VECTOR(TIM1_BRK_TIM15_IRQHandler)
INT_VECTOR(TIM1_UP_TIM16_IRQHandler)
INT_VECTOR(TIM1_TRG_COM_TIM17_IRQHandler)
INT_VECTOR(TIM1_CC_IRQHandler)
INT_VECTOR(TIM2_IRQHandler)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR(I2C1_EV_IRQHandler)
INT_VECTOR(I2C1_ER_IRQHandler)
INT_VECTOR(I2C2_EV_IRQHandler)
INT_VECTOR(I2C2_ER_IRQHandler)
INT_VECTOR_UNUSED(0)
INT_VECTOR(SPI2_IRQHandler)
INT_VECTOR(USART1_IRQHandler)
INT_VECTOR(USART2_IRQHandler)
INT_VECTOR(USART3_IRQHandler)
INT_VECTOR(EXTI15_10_IRQHandler)
INT_VECTOR(RTC_Alarm_IRQHandler)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR(SPI3_IRQHandler)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR(TIM6_DAC_IRQHandler)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR(COMP2_IRQHandler)
INT_VECTOR(COMP4_6_IRQHandler)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR(I2C3_EV_IRQHandler)
INT_VECTOR(I2C3_ER_IRQHandler)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR(FPU_IRQHandler)
117 changes: 117 additions & 0 deletions hw/mcu/stm/stm32f3xx/include/mcu/vectors/stm32f302x8_vectors.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

INT_VECTOR_STACK_TOP(__StackTop)
INT_VECTOR_RESET_HANDLER(Reset_Handler)
INT_VECTOR_NMI_HANDLER(NMI_Handler)
INT_VECTOR_HARDFAULT_HANDLER(HardFault_Handler)
INT_VECTOR_MEMMANAGE_HANDLER(MemManage_Handler)
INT_VECTOR_BUSFAULT_HANDLER(BusFault_Handler)
INT_VECTOR_USAGEFAULT_HANDLER(UsageFault_Handler)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_SVC_HANDLER(SVC_Handler)
INT_VECTOR_DEBUGMON_HANDLER(DebugMon_Handler)
INT_VECTOR_UNUSED(0)
INT_VECTOR_PENDSV_HANDLER(PendSV_Handler)
INT_VECTOR_SYSTICK_HANDLER(SysTick_Handler)
INT_VECTOR(WWDG_IRQHandler)
INT_VECTOR(PVD_IRQHandler)
INT_VECTOR(TAMP_STAMP_IRQHandler)
INT_VECTOR(RTC_WKUP_IRQHandler)
INT_VECTOR(FLASH_IRQHandler)
INT_VECTOR(RCC_IRQHandler)
INT_VECTOR(EXTI0_IRQHandler)
INT_VECTOR(EXTI1_IRQHandler)
INT_VECTOR(EXTI2_TSC_IRQHandler)
INT_VECTOR(EXTI3_IRQHandler)
INT_VECTOR(EXTI4_IRQHandler)
INT_VECTOR(DMA1_Channel1_IRQHandler)
INT_VECTOR(DMA1_Channel2_IRQHandler)
INT_VECTOR(DMA1_Channel3_IRQHandler)
INT_VECTOR(DMA1_Channel4_IRQHandler)
INT_VECTOR(DMA1_Channel5_IRQHandler)
INT_VECTOR(DMA1_Channel6_IRQHandler)
INT_VECTOR(DMA1_Channel7_IRQHandler)
INT_VECTOR(ADC1_IRQHandler)
INT_VECTOR(USB_HP_CAN_TX_IRQHandler)
INT_VECTOR(USB_LP_CAN_RX0_IRQHandler)
INT_VECTOR(CAN_RX1_IRQHandler)
INT_VECTOR(CAN_SCE_IRQHandler)
INT_VECTOR(EXTI9_5_IRQHandler)
INT_VECTOR(TIM1_BRK_TIM15_IRQHandler)
INT_VECTOR(TIM1_UP_TIM16_IRQHandler)
INT_VECTOR(TIM1_TRG_COM_TIM17_IRQHandler)
INT_VECTOR(TIM1_CC_IRQHandler)
INT_VECTOR(TIM2_IRQHandler)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR(I2C1_EV_IRQHandler)
INT_VECTOR(I2C1_ER_IRQHandler)
INT_VECTOR(I2C2_EV_IRQHandler)
INT_VECTOR(I2C2_ER_IRQHandler)
INT_VECTOR_UNUSED(0)
INT_VECTOR(SPI2_IRQHandler)
INT_VECTOR(USART1_IRQHandler)
INT_VECTOR(USART2_IRQHandler)
INT_VECTOR(USART3_IRQHandler)
INT_VECTOR(EXTI15_10_IRQHandler)
INT_VECTOR(RTC_Alarm_IRQHandler)
INT_VECTOR(USBWakeUp_IRQHandler)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR(SPI3_IRQHandler)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR(TIM6_DAC_IRQHandler)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR(COMP2_IRQHandler)
INT_VECTOR(COMP4_6_IRQHandler)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR(I2C3_EV_IRQHandler)
INT_VECTOR(I2C3_ER_IRQHandler)
INT_VECTOR(USB_HP_IRQHandler)
INT_VECTOR(USB_LP_IRQHandler)
INT_VECTOR(USBWakeUp_RMP_IRQHandler)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR_UNUSED(0)
INT_VECTOR(FPU_IRQHandler)
Loading

0 comments on commit 6164bc4

Please sign in to comment.