From e5e6b2c513a5338a8b79c745eb841e1d3e063bc9 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 5 Nov 2011 13:56:57 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3470 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/ports/GCC/ARMCMx/STM32F4xx/cmparams.h | 57 +++++ os/ports/GCC/ARMCMx/STM32F4xx/ld/STM32F407xG.ld | 146 ++++++++++++ os/ports/GCC/ARMCMx/STM32F4xx/port.mk | 14 ++ os/ports/GCC/ARMCMx/STM32F4xx/vectors.c | 283 ++++++++++++++++++++++++ 4 files changed, 500 insertions(+) create mode 100644 os/ports/GCC/ARMCMx/STM32F4xx/cmparams.h create mode 100644 os/ports/GCC/ARMCMx/STM32F4xx/ld/STM32F407xG.ld create mode 100644 os/ports/GCC/ARMCMx/STM32F4xx/port.mk create mode 100644 os/ports/GCC/ARMCMx/STM32F4xx/vectors.c (limited to 'os') diff --git a/os/ports/GCC/ARMCMx/STM32F4xx/cmparams.h b/os/ports/GCC/ARMCMx/STM32F4xx/cmparams.h new file mode 100644 index 000000000..e5d942d61 --- /dev/null +++ b/os/ports/GCC/ARMCMx/STM32F4xx/cmparams.h @@ -0,0 +1,57 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, + 2011 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file GCC/ARMCMx/STM32F1xx/cmparams.h + * @brief ARM Cortex-M3 parameters for the STM32F1xx. + * + * @defgroup ARMCMx_STM32F1xx STM32F1xx Specific Parameters + * @ingroup ARMCMx_SPECIFIC + * @details This file contains the Cortex-M3 specific parameters for the + * STM32F1xx platform. + * @{ + */ + +#ifndef _CMPARAMS_H_ +#define _CMPARAMS_H_ + +/** + * @brief Cortex core model. + */ +#define CORTEX_MODEL CORTEX_M3 + +/** + * @brief Systick unit presence. + */ +#define CORTEX_HAS_ST TRUE + +/** + * @brief Memory Protection unit presence. + */ +#define CORTEX_HAS_MPU TRUE + +/** + * @brief Number of bits in priority masks. + */ +#define CORTEX_PRIORITY_BITS 4 + +#endif /* _CMPARAMS_H_ */ + +/** @} */ diff --git a/os/ports/GCC/ARMCMx/STM32F4xx/ld/STM32F407xG.ld b/os/ports/GCC/ARMCMx/STM32F4xx/ld/STM32F407xG.ld new file mode 100644 index 000000000..0476b0bf1 --- /dev/null +++ b/os/ports/GCC/ARMCMx/STM32F4xx/ld/STM32F407xG.ld @@ -0,0 +1,146 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, + 2011 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/* + * ST32F407xG memory setup. + */ +__main_stack_size__ = 0x0400; +__process_stack_size__ = 0x0400; + +MEMORY +{ + flash : org = 0x08000000, len = 1M + ram : org = 0x20000000, len = 112k + ethram : org = 0x2001C000, len = 16k + ccmram : org = 0x10000000, len = 64k +} + +__ram_start__ = ORIGIN(ram); +__ram_size__ = LENGTH(ram); +__ram_end__ = __ram_start__ + __ram_size__; + +SECTIONS +{ + . = 0; + _text = .; + + startup : ALIGN(16) SUBALIGN(16) + { + KEEP(*(vectors)) + } > flash + + constructors : ALIGN(4) SUBALIGN(4) + { + PROVIDE(__init_array_start = .); + KEEP(*(SORT(.init_array.*))) + KEEP(*(.init_array)) + PROVIDE(__init_array_end = .); + } > flash + + destructors : ALIGN(4) SUBALIGN(4) + { + PROVIDE(__fini_array_start = .); + KEEP(*(.fini_array)) + KEEP(*(SORT(.fini_array.*))) + PROVIDE(__fini_array_end = .); + } > flash + + .text : ALIGN(16) SUBALIGN(16) + { + *(.text.startup.*) + *(.text) + *(.text.*) + *(.rodata) + *(.rodata.*) + *(.glue_7t) + *(.glue_7) + *(.gcc*) + } > flash + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > flash + + .ARM.exidx : { + PROVIDE(__exidx_start = .); + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + PROVIDE(__exidx_end = .); + } > flash + + .eh_frame_hdr : + { + *(.eh_frame_hdr) + } > flash + + .eh_frame : ONLY_IF_RO + { + *(.eh_frame) + } > flash + + . = ALIGN(4); + _etext = .; + _textdata = _etext; + + .stacks : + { + . = ALIGN(8); + __main_stack_base__ = .; + . += __main_stack_size__; + . = ALIGN(8); + __main_stack_end__ = .; + __process_stack_base__ = .; + __main_thread_stack_base__ = .; + . += __process_stack_size__; + . = ALIGN(8); + __process_stack_end__ = .; + __main_thread_stack_end__ = .; + } > ram + + .data : + { + PROVIDE(_data = .); + *(.data) + . = ALIGN(4); + *(.data.*) + . = ALIGN(4); + *(.ramtext) + . = ALIGN(4); + PROVIDE(_edata = .); + } > ram AT > flash + + .bss : + { + PROVIDE(_bss_start = .); + *(.bss) + . = ALIGN(4); + *(.bss.*) + . = ALIGN(4); + *(COMMON) + . = ALIGN(4); + PROVIDE(_bss_end = .); + } > ram +} + +PROVIDE(end = .); +_end = .; + +__heap_base__ = _end; +__heap_end__ = __ram_end__; diff --git a/os/ports/GCC/ARMCMx/STM32F4xx/port.mk b/os/ports/GCC/ARMCMx/STM32F4xx/port.mk new file mode 100644 index 000000000..072e2d363 --- /dev/null +++ b/os/ports/GCC/ARMCMx/STM32F4xx/port.mk @@ -0,0 +1,14 @@ +# List of the ChibiOS/RT Cortex-M3 STM32 port files. +PORTSRC = $(CHIBIOS)/os/ports/GCC/ARMCMx/crt0.c \ + $(CHIBIOS)/os/ports/GCC/ARMCMx/STM32F4xx/vectors.c \ + ${CHIBIOS}/os/ports/GCC/ARMCMx/chcore.c \ + ${CHIBIOS}/os/ports/GCC/ARMCMx/chcore_v7m.c \ + ${CHIBIOS}/os/ports/GCC/ARMCMx/nvic.c + +PORTASM = + +PORTINC = ${CHIBIOS}/os/ports/common/ARMCMx/CMSIS/include \ + ${CHIBIOS}/os/ports/GCC/ARMCMx \ + ${CHIBIOS}/os/ports/GCC/ARMCMx/STM32F4xx + +PORTLD = ${CHIBIOS}/os/ports/GCC/ARMCMx/STM32F4xx/ld diff --git a/os/ports/GCC/ARMCMx/STM32F4xx/vectors.c b/os/ports/GCC/ARMCMx/STM32F4xx/vectors.c new file mode 100644 index 000000000..6ee8bb23e --- /dev/null +++ b/os/ports/GCC/ARMCMx/STM32F4xx/vectors.c @@ -0,0 +1,283 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, + 2011 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file GCC/ARMCMx/STM32F4xx/vectors.c + * @brief Interrupt vectors for the STM32F4xx family. + * + * @defgroup ARMCMx_STM32F4xx_VECTORS STM32F4xx Interrupt Vectors + * @ingroup ARMCMx_SPECIFIC + * @details Interrupt vectors for the STM32F4xx family. + * @{ + */ + +#include "ch.h" + +#if !defined(__DOXYGEN__) +extern void __main_stack_end__(void); +extern void ResetHandler(void); +extern void NMIVector(void); +extern void HardFaultVector(void); +extern void MemManageVector(void); +extern void BusFaultVector(void); +extern void UsageFaultVector(void); +extern void Vector1C(void); +extern void Vector20(void); +extern void Vector24(void); +extern void Vector28(void); +extern void SVCallVector(void); +extern void DebugMonitorVector(void); +extern void Vector34(void); +extern void PendSVVector(void); +extern void SysTickVector(void); +extern void Vector40(void); +extern void Vector44(void); +extern void Vector48(void); +extern void Vector4C(void); +extern void Vector50(void); +extern void Vector54(void); +extern void Vector58(void); +extern void Vector5C(void); +extern void Vector60(void); +extern void Vector64(void); +extern void Vector68(void); +extern void Vector6C(void); +extern void Vector70(void); +extern void Vector74(void); +extern void Vector78(void); +extern void Vector7C(void); +extern void Vector80(void); +extern void Vector84(void); +extern void Vector88(void); +extern void Vector8C(void); +extern void Vector90(void); +extern void Vector94(void); +extern void Vector98(void); +extern void Vector9C(void); +extern void VectorA0(void); +extern void VectorA4(void); +extern void VectorA8(void); +extern void VectorAC(void); +extern void VectorB0(void); +extern void VectorB4(void); +extern void VectorB8(void); +extern void VectorBC(void); +extern void VectorC0(void); +extern void VectorC4(void); +extern void VectorC8(void); +extern void VectorCC(void); +extern void VectorD0(void); +extern void VectorD4(void); +extern void VectorD8(void); +extern void VectorDC(void); +extern void VectorE0(void); +extern void VectorE4(void); +extern void VectorE8(void); +extern void VectorEC(void); +extern void VectorF0(void); +extern void VectorF4(void); +extern void VectorF8(void); +extern void VectorFC(void); +extern void Vector100(void); +extern void Vector104(void); +extern void Vector108(void); +extern void Vector10C(void); +extern void Vector110(void); +extern void Vector114(void); +extern void Vector118(void); +extern void Vector11C(void); +extern void Vector120(void); +extern void Vector124(void); +extern void Vector128(void); +extern void Vector12C(void); +extern void Vector130(void); +extern void Vector134(void); +extern void Vector138(void); +extern void Vector13C(void); +extern void Vector140(void); +extern void Vector144(void); +extern void Vector148(void); +extern void Vector14C(void); +extern void Vector150(void); +extern void Vector154(void); +extern void Vector158(void); +extern void Vector15C(void); +extern void Vector160(void); +extern void Vector164(void); +extern void Vector168(void); +extern void Vector16C(void); +extern void Vector170(void); +extern void Vector174(void); +extern void Vector178(void); +extern void Vector17C(void); +extern void Vector180(void); +extern void Vector184(void); +#endif + +/** + * @brief STM32 vectors table. + */ +#if !defined(__DOXYGEN__) +__attribute__ ((section("vectors"))) +#endif +void (*_vectors[])(void) = { + __main_stack_end__, ResetHandler, NMIVector, HardFaultVector, + MemManageVector, BusFaultVector, UsageFaultVector, Vector1C, + Vector20, Vector24, Vector28, SVCallVector, + DebugMonitorVector, Vector34, PendSVVector, SysTickVector, + Vector40, Vector44, Vector48, Vector4C, + Vector50, Vector54, Vector58, Vector5C, + Vector60, Vector64, Vector68, Vector6C, + Vector70, Vector74, Vector78, Vector7C, + Vector80, Vector84, Vector88, Vector8C, + Vector90, Vector94, Vector98, Vector9C, + VectorA0, VectorA4, VectorA8, VectorAC, + VectorB0, VectorB4, VectorB8, VectorBC, + VectorC0, VectorC4, VectorC8, VectorCC, + VectorD0, VectorD4, VectorD8, VectorDC, + VectorE0, VectorE4, VectorE8, VectorEC, + VectorF0, VectorF4, VectorF8, VectorFC, + Vector100, Vector104, Vector108, Vector10C, + Vector110, Vector114, Vector118, Vector11C, + Vector120, Vector124, Vector128, Vector12C, + Vector130, Vector134, Vector138, Vector13C, + Vector140, Vector144, Vector148, Vector14C, + Vector150, Vector154, Vector158, Vector15C, + Vector160, Vector164, Vector168, Vector16C, + Vector170, Vector174, Vector178, Vector17C, + Vector180, Vector184 +}; + +/** + * @brief Unhandled exceptions handler. + * @details Any undefined exception vector points to this function by default. + * This function simply stops the system into an infinite loop. + * + * @notapi + */ +#if !defined(__DOXYGEN__) +__attribute__ ((naked)) +#endif +void _unhandled_exception(void) { + + asm volatile ( + ".weak NMIVector \nNMIVector: \n\t" + ".weak HardFaultVector \nHardFaultVector: \n\t" + ".weak MemManageVector \nMemManageVector: \n\t" + ".weak BusFaultVector \nBusFaultVector: \n\t" + ".weak UsageFaultVector \nUsageFaultVector: \n\t" + ".weak Vector1C \nVector1C: \n\t" + ".weak Vector20 \nVector20: \n\t" + ".weak Vector24 \nVector24: \n\t" + ".weak Vector28 \nVector28: \n\t" + ".weak SVCallVector \nSVCallVector: \n\t" + ".weak DebugMonitorVector \nDebugMonitorVector: \n\t" + ".weak Vector34 \nVector34: \n\t" + ".weak PendSVVector \nPendSVVector: \n\t" + ".weak SysTickVector \nSysTickVector: \n\t" + ".weak Vector40 \nVector40: \n\t" + ".weak Vector44 \nVector44: \n\t" + ".weak Vector48 \nVector48: \n\t" + ".weak Vector4C \nVector4C: \n\t" + ".weak Vector50 \nVector50: \n\t" + ".weak Vector54 \nVector54: \n\t" + ".weak Vector58 \nVector58: \n\t" + ".weak Vector5C \nVector5C: \n\t" + ".weak Vector60 \nVector60: \n\t" + ".weak Vector64 \nVector64: \n\t" + ".weak Vector68 \nVector68: \n\t" + ".weak Vector6C \nVector6C: \n\t" + ".weak Vector70 \nVector70: \n\t" + ".weak Vector74 \nVector74: \n\t" + ".weak Vector78 \nVector78: \n\t" + ".weak Vector7C \nVector7C: \n\t" + ".weak Vector80 \nVector80: \n\t" + ".weak Vector84 \nVector84: \n\t" + ".weak Vector88 \nVector88: \n\t" + ".weak Vector8C \nVector8C: \n\t" + ".weak Vector90 \nVector90: \n\t" + ".weak Vector94 \nVector94: \n\t" + ".weak Vector98 \nVector98: \n\t" + ".weak Vector9C \nVector9C: \n\t" + ".weak VectorA0 \nVectorA0: \n\t" + ".weak VectorA4 \nVectorA4: \n\t" + ".weak VectorA8 \nVectorA8: \n\t" + ".weak VectorAC \nVectorAC: \n\t" + ".weak VectorB0 \nVectorB0: \n\t" + ".weak VectorB4 \nVectorB4: \n\t" + ".weak VectorB8 \nVectorB8: \n\t" + ".weak VectorBC \nVectorBC: \n\t" + ".weak VectorC0 \nVectorC0: \n\t" + ".weak VectorC4 \nVectorC4: \n\t" + ".weak VectorC8 \nVectorC8: \n\t" + ".weak VectorCC \nVectorCC: \n\t" + ".weak VectorD0 \nVectorD0: \n\t" + ".weak VectorD4 \nVectorD4: \n\t" + ".weak VectorD8 \nVectorD8: \n\t" + ".weak VectorDC \nVectorDC: \n\t" + ".weak VectorE0 \nVectorE0: \n\t" + ".weak VectorE4 \nVectorE4: \n\t" + ".weak VectorE8 \nVectorE8: \n\t" + ".weak VectorEC \nVectorEC: \n\t" + ".weak VectorF0 \nVectorF0: \n\t" + ".weak VectorF4 \nVectorF4: \n\t" + ".weak VectorF8 \nVectorF8: \n\t" + ".weak VectorFC \nVectorFC: \n\t" + ".weak Vector100 \nVector100: \n\t" + ".weak Vector104 \nVector104: \n\t" + ".weak Vector108 \nVector108: \n\t" + ".weak Vector10C \nVector10C: \n\t" + ".weak Vector110 \nVector110: \n\t" + ".weak Vector114 \nVector114: \n\t" + ".weak Vector118 \nVector118: \n\t" + ".weak Vector11C \nVector11C: \n\t" + ".weak Vector120 \nVector120: \n\t" + ".weak Vector124 \nVector124: \n\t" + ".weak Vector128 \nVector128: \n\t" + ".weak Vector12C \nVector12C: \n\t" + ".weak Vector130 \nVector130: \n\t" + ".weak Vector134 \nVector134: \n\t" + ".weak Vector138 \nVector138: \n\t" + ".weak Vector13C \nVector13C: \n\t" + ".weak Vector140 \nVector140: \n\t" + ".weak Vector144 \nVector144: \n\t" + ".weak Vector148 \nVector148: \n\t" + ".weak Vector14C \nVector14C: \n\t" + ".weak Vector150 \nVector150: \n\t" + ".weak Vector154 \nVector154: \n\t" + ".weak Vector158 \nVector158: \n\t" + ".weak Vector15C \nVector15C: \n\t" + ".weak Vector160 \nVector160: \n\t" + ".weak Vector164 \nVector164: \n\t" + ".weak Vector168 \nVector168: \n\t" + ".weak Vector16C \nVector16C: \n\t" + ".weak Vector170 \nVector170: \n\t" + ".weak Vector174 \nVector174: \n\t" + ".weak Vector178 \nVector178: \n\t" + ".weak Vector17C \nVector17C: \n\t" + ".weak Vector180 \nVector180: \n\t" + ".weak Vector184 \nVector184: \n\t" + ); + + while (TRUE) + ; +} + +/** @} */ -- cgit v1.2.3