`
java-mans
  • 浏览: 11433355 次
文章分类
社区版块
存档分类
最新评论

重定位启动代码和向量表

 
阅读更多

//=====================================================================
//TITLE:
// 重定位启动代码和向量表
//AUTHOR:
// norains
//DATE:
// Thursday 30-September-2010
//Environment:
// KEIL MDK 4.0
// .NET Micro Framework Porting 4.1
//=====================================================================

叶帆在他的文章《【.Net Micro Framework PortingKit - 04】修改启动代码&重写向量表》(http://blog.csdn.net/yefanqiu/archive/2010/01/03/5125745.aspx)已经很明确地给出了适合STM32F103ZE使用的启动代码和向量表的修改方式。但我认为有一点不足,就是这些修改都是在.NET Micro Framework Porting 4.1原有的框架之上的,如果在向STM32F103ZE移植的同时,还有别的Solution需要兼顾,则是一件非常痛苦的事情。所以,在这里采用另外一种方式来修改启动代码和向量表。

首先,根据这篇文件《重定位编译文件》(http://blog.csdn.net/norains/archive/2010/09/29/5913611.aspx)的方式,先建立一个位于./Solutions/[MySolution]/DeviceCode/cores/arm路径下的dotNetMF.proj文件。这一步非常重要,因为文章后面所做的更改,都是在这文件上动手。当然不要忘记,还要对NativeSample.proj进行修改,让它连接到我们这个新的文件。

1.打开已经重定位成功的dotNetMF.proj文件,做如下的修改:

原语句:
<ItemGroup Condition="'$(INSTRUCTION_SET)'=='thumb2'">
<Compile Include="$(SPOCLIENT)/DeviceCode/cores/arm/AssemblyCode/arm/$(AS_SUBDIR)/FirstEntry.s" />
<Compile Include="$(SPOCLIENT)/DeviceCode/cores/arm/AssemblyCode/thumb2/$(AS_SUBDIR)/VectorsTrampolines.s" />
<Compile Include="$(SPOCLIENT)/DeviceCode/cores/arm/AssemblyCode/thumb2/$(AS_SUBDIR)/IDelayLoop.s" />
<Compile Include="$(SPOCLIENT)/DeviceCode/cores/arm/AssemblyCode/thumb2/$(AS_SUBDIR)/Sampling_Profiler_RAM.s" />
<Compile Include="$(SPOCLIENT)/DeviceCode/cores/arm/AssemblyCode/thumb2/$(AS_SUBDIR)/VectorsHandlers.s" />
<Compile Include="$(SPOCLIENT)/DeviceCode/cores/arm/AssemblyCode/thumb2/$(AS_SUBDIR)/VectorsTrampolines.s" />
</ItemGroup>

更改为:

<ItemGroup Condition="'$(INSTRUCTION_SET)'=='thumb2'">
<Compile Include="$(SPOCLIENT)/DeviceCode/cores/arm/AssemblyCode/thumb2/$(AS_SUBDIR)/FirstEntry.s" />
<Compile Include="$(SPOCLIENT)/Solutions/STM32F103ZE_RedCow/DeviceCode/cores/arm/AssemblyCode/thumb2/$(AS_SUBDIR)/VectorsHandlers.s" />
<Compile Include="$(SPOCLIENT)/Solutions/STM32F103ZE_RedCow/DeviceCode/cores/arm/AssemblyCode/thumb2/$(AS_SUBDIR)/VectorsTrampolines.s" />
<Compile Include="$(SPOCLIENT)/Solutions/STM32F103ZE_RedCow/DeviceCode/cores/arm/AssemblyCode/thumb2/$(AS_SUBDIR)/VectorsHandlers_Func.c" />
</ItemGroup>

原语句:

<ItemGroup>
<HFiles Include="../../Initialization/MasterConfig.h" />
<Compile Include="Diagnostics/Aborts.cpp" />
<Compile Include="Diagnostics/FIQ_Profiler.cpp" />
<Compile Include="Diagnostics/RamTest.cpp" />
<Compile Include="Diagnostics/RamTest.h" />
<LIB_FIRSTENTRY_OBJ Include="$(OBJ_DIR)/FirstEntry.$(OBJ_EXT)" />
</ItemGroup>

修改为:

<ItemGroup>
<LIB_FIRSTENTRY_OBJ Include="$(OBJ_DIR)/FirstEntry.$(OBJ_EXT)" />
</ItemGroup>


2. 拷贝一个VectorsTrampolines.s文件到./Solutions/[MySolution]/DeviceCode/cores/arm/AssemblyCode/thumb2/RVD_S,输入如下内容:

;*****************************************************************************

; Import the handle function
IMPORT NMIException
IMPORT HardFaultException
IMPORT MemManageException
IMPORT BusFaultException
IMPORT UsageFaultException
IMPORT SVCHandler
IMPORT DebugMonitor
IMPORT PendSVC
IMPORT SysTickHandler
IMPORT WWDG_IRQHandler
IMPORT PVD_IRQHandler
IMPORT TAMPER_IRQHandler
IMPORT RTC_IRQHandler
IMPORT FLASH_IRQHandler
IMPORT RCC_IRQHandler
IMPORT EXTI0_IRQHandler
IMPORT EXTI1_IRQHandler
IMPORT EXTI2_IRQHandler
IMPORT EXTI3_IRQHandler
IMPORT EXTI4_IRQHandler
IMPORT DMA1_Channel1_IRQHandler
IMPORT DMA1_Channel2_IRQHandler
IMPORT DMA1_Channel3_IRQHandler
IMPORT DMA1_Channel4_IRQHandler
IMPORT DMA1_Channel5_IRQHandler
IMPORT DMA1_Channel6_IRQHandler
IMPORT DMA1_Channel7_IRQHandler
IMPORT ADC1_2_IRQHandler
IMPORT USB_HP_CAN_TX_IRQHandler
IMPORT USB_LP_CAN_RX0_IRQHandler
IMPORT CAN_RX1_IRQHandler
IMPORT CAN_SCE_IRQHandler
IMPORT EXTI9_5_IRQHandler
IMPORT TIM1_BRK_IRQHandler
IMPORT TIM1_UP_IRQHandler
IMPORT TIM1_TRG_COM_IRQHandler
IMPORT TIM1_CC_IRQHandler
IMPORT TIM2_IRQHandler
IMPORT TIM3_IRQHandler
IMPORT TIM4_IRQHandler
IMPORT I2C1_EV_IRQHandler
IMPORT I2C1_ER_IRQHandler
IMPORT I2C2_EV_IRQHandler
IMPORT I2C2_ER_IRQHandler
IMPORT SPI1_IRQHandler
IMPORT SPI2_IRQHandler
IMPORT USART1_IRQHandler
IMPORT USART2_IRQHandler
IMPORT USART3_IRQHandler
IMPORT EXTI15_10_IRQHandler
IMPORT RTCAlarm_IRQHandler
IMPORT USBWakeUp_IRQHandler
IMPORT TIM8_BRK_IRQHandler
IMPORT TIM8_UP_IRQHandler
IMPORT TIM8_TRG_COM_IRQHandler
IMPORT TIM8_CC_IRQHandler
IMPORT ADC3_IRQHandler
IMPORT FSMC_IRQHandler
IMPORT SDIO_IRQHandler
IMPORT TIM5_IRQHandler
IMPORT SPI3_IRQHandler
IMPORT UART4_IRQHandler
IMPORT UART5_IRQHandler
IMPORT TIM6_IRQHandler
IMPORT TIM7_IRQHandler
IMPORT DMA2_Channel1_IRQHandler
IMPORT DMA2_Channel2_IRQHandler
IMPORT DMA2_Channel3_IRQHandler
IMPORT DMA2_Channel4_5_IRQHandler

EXPORT ARM_Vectors

IMPORT StackTop
IMPORT EntryPoint

;*****************************************************************************

AREA |.text|, CODE, READONLY

;Vector list

ARM_Vectors
DCD StackTop ; Top of Stack
DCD EntryPoint; Reset
DCD NMIException
DCD HardFaultException
DCD MemManageException
DCD BusFaultException
DCD UsageFaultException
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SVCHandler
DCD DebugMonitor
DCD 0 ; Reserved
DCD PendSVC
DCD SysTickHandler
DCD WWDG_IRQHandler
DCD PVD_IRQHandler
DCD TAMPER_IRQHandler
DCD RTC_IRQHandler
DCD FLASH_IRQHandler
DCD RCC_IRQHandler
DCD EXTI0_IRQHandler
DCD EXTI1_IRQHandler
DCD EXTI2_IRQHandler
DCD EXTI3_IRQHandler
DCD EXTI4_IRQHandler
DCD DMA1_Channel1_IRQHandler
DCD DMA1_Channel2_IRQHandler
DCD DMA1_Channel3_IRQHandler
DCD DMA1_Channel4_IRQHandler
DCD DMA1_Channel5_IRQHandler
DCD DMA1_Channel6_IRQHandler
DCD DMA1_Channel7_IRQHandler
DCD ADC1_2_IRQHandler
DCD USB_HP_CAN_TX_IRQHandler
DCD USB_LP_CAN_RX0_IRQHandler
DCD CAN_RX1_IRQHandler
DCD CAN_SCE_IRQHandler
DCD EXTI9_5_IRQHandler
DCD TIM1_BRK_IRQHandler
DCD TIM1_UP_IRQHandler
DCD TIM1_TRG_COM_IRQHandler
DCD TIM1_CC_IRQHandler
DCD TIM2_IRQHandler
DCD TIM3_IRQHandler
DCD TIM4_IRQHandler
DCD I2C1_EV_IRQHandler
DCD I2C1_ER_IRQHandler
DCD I2C2_EV_IRQHandler
DCD I2C2_ER_IRQHandler
DCD SPI1_IRQHandler
DCD SPI2_IRQHandler
DCD USART1_IRQHandler
DCD USART2_IRQHandler
DCD USART3_IRQHandler
DCD EXTI15_10_IRQHandler
DCD RTCAlarm_IRQHandler
DCD USBWakeUp_IRQHandler
DCD TIM8_BRK_IRQHandler
DCD TIM8_UP_IRQHandler
DCD TIM8_TRG_COM_IRQHandler
DCD TIM8_CC_IRQHandler
DCD ADC3_IRQHandler
DCD FSMC_IRQHandler
DCD SDIO_IRQHandler
DCD TIM5_IRQHandler
DCD SPI3_IRQHandler
DCD UART4_IRQHandler
DCD UART5_IRQHandler
DCD TIM6_IRQHandler
DCD TIM7_IRQHandler
DCD DMA2_Channel1_IRQHandler
DCD DMA2_Channel2_IRQHandler
DCD DMA2_Channel3_IRQHandler
DCD DMA2_Channel4_5_IRQHandler

;*****************************************************************************

END


3.拷贝一个VectorsHandlers.s文件到./Solutions/[MySolution]/DeviceCode/cores/arm/AssemblyCode/thumb2/RVD_S,输入如下内容:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright (c) Microsoft Corporation. All rights reserved.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;*****************************************************************************

EXPORT HARD_Breakpoint

;IMPORT HARD_Breakpoint_Handler ; HARD_Breakpoint_Handler(unsigned int*, unsigned int, unsigned int)
;*****************************************************************************

AREA ||i.HARD_Breakpoint||, CODE, READONLY ; void HARD_Breakpoint()

HARD_Breakpoint
; on entry, were are being called from C/C++ in system mode


;b HARD_Breakpoint_Handler ; address of vector routine in C to jump to, never expect to return


;*****************************************************************************


END


4. 在./Solutions/[MySolution]/DeviceCode/cores/arm/AssemblyCode/thumb2/RVD_S路径下,新建一个VectorsHandlers_Func.c文件,输入如下内容:


5. 在命令行中进入到NativeSample工程目录,输入Msbuild /t:rebuild /p:flavor=debug;memory=ram 进行编译。如果没有错误,那么在调试时应该也不会出现问题了。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics