RT-Thread 7. RT-Thread Studio ENV修改MCU型号

1. 修改MCU型号

在这里插入图片描述
在这里插入图片描述

2.在ENV界面输入
scons -c
scons --dist
3. dist下为更新后完整源代码

在这里插入图片描述

4.导入RT-Thread Studio

发现GD32F330已经生效了。

在这里插入图片描述

5. 自己编写startup_gd32f3x0.S,准确性待验证
;/*
; * Copyright (c) 2006-2021, RT-Thread Development Team
; *
; * SPDX-License-Identifier: Apache-2.0
; *
; * Change Logs:
; * Date           Author       Notes
; * 2018-05-22     tanek        first implementation
; */

.syntax unified
.cpu cortex-m4
.fpu softvfp
.thumb

.global  g_pfnVectors
.global  Default_Handler

    .section  .isr_vector,"a",%progbits
    .type  g_pfnVectors, %object

g_pfnVectors:
    .word     _estack                       // Top of Stack
    .word     Reset_Handler                     // Reset Handler
    .word     NMI_Handler                       // NMI Handler
    .word     HardFault_Handler                 // Hard Fault Handler
    .word     MemManage_Handler                 // MPU Fault Handler
    .word     BusFault_Handler                  // Bus Fault Handler
    .word     UsageFault_Handler                // Usage Fault Handler
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     SVC_Handler                       // SVCall Handler
    .word     DebugMon_Handler                  // Debug Monitor Handler
    .word     0                                 // Reserved
    .word     PendSV_Handler                    // PendSV Handler
    .word     SysTick_Handler                   // SysTick Handler

    // external interrupts handler
    .word     WWDGT_IRQHandler                  // 16:Window Watchdog Timer
    .word     LVD_IRQHandler                    // 17:LVD through EXTI Line detect
    .word     RTC_IRQHandler                    // 18:RTC Wakeup through EXTI Line
    .word     FMC_IRQHandler                    // 19:FMC
    .word     RCU_CTC_IRQHandler                // 20:RCU and CTC
    .word     EXTI0_1_IRQHandler                // 21:EXTI Line 0 and EXTI Line 1
    .word     EXTI2_3_IRQHandler                // 22:EXTI Line 2 and EXTI Line 3
    .word     EXTI4_15_IRQHandler               // 23:EXTI Line 4 to EXTI Line 15
    .word     TSI_IRQHandler                    // 24:TSI
    .word     DMA_Channel0_IRQHandler           // 25:DMA Channel 0 
    .word     DMA_Channel1_2_IRQHandler         // 26:DMA Channel 1 and DMA Channel 2
    .word     DMA_Channel3_4_IRQHandler         // 27:DMA Channel 3 and DMA Channel 4
    .word     ADC_CMP_IRQHandler                // 28:ADC and Comparator 0-1
    .word     TIMER0_BRK_UP_TRG_COM_IRQHandler  // 29:TIMER0 Break,Update,Trigger and Commutation
    .word     TIMER0_Channel_IRQHandler         // 30:TIMER0 Channel Capture Compare
    .word     TIMER1_IRQHandler                 // 31:TIMER1
    .word     TIMER2_IRQHandler                 // 32:TIMER2
    .word     TIMER5_DAC_IRQHandler             // 33:TIMER5 and DAC
    .word     0                                 // Reserved
    .word     TIMER13_IRQHandler                // 35:TIMER13
    .word     TIMER14_IRQHandler                // 36:TIMER14
    .word     TIMER15_IRQHandler                // 37:TIMER15
    .word     TIMER16_IRQHandler                // 38:TIMER16
    .word     I2C0_EV_IRQHandler                // 39:I2C0 Event
    .word     I2C1_EV_IRQHandler                // 40:I2C1 Event
    .word     SPI0_IRQHandler                   // 41:SPI0
    .word     SPI1_IRQHandler                   // 42:SPI1
    .word     USART0_IRQHandler                 // 43:USART0
    .word     USART1_IRQHandler                 // 44:USART1
    .word     0                                 // Reserved
    .word     CEC_IRQHandler                    // 46:CEC
    .word     0                                 // Reserved
    .word     I2C0_ER_IRQHandler                // 48:I2C0 Error
    .word     0                                 // Reserved
    .word     I2C1_ER_IRQHandler                // 50:I2C1 Error
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     USBFS_WKUP_IRQHandler             // 58:USBFS Wakeup
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     DMA_Channel5_6_IRQHandler         // 64:DMA Channel5 and Channel6 
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     0                                 // Reserved
    .word     USBFS_IRQHandler                  // 83:USBFS

    .size  g_pfnVectors, .-g_pfnVectors

    .section  .text.Reset_Handler
    .weak  Reset_Handler
    .type  Reset_Handler, %function
Reset_Handler:
    ldr r1, =_sidata
    ldr r2, =_sdata
    ldr r3, =_edata

    subs r3, r2
    ble fill_bss_start

loop_copy_data:
    subs r3, #4
    ldr r0, [r1,r3]
    str r0, [r2,r3]
    bgt loop_copy_data

fill_bss_start:
    ldr r1, =__bss_start
    ldr r2, =__bss_end
    movs r0, 0
    subs r2, r1
    ble startup_enter

loop_fill_bss:
    subs r2, #4
    str r0, [r1, r2]
    bgt loop_fill_bss

startup_enter:
    bl SystemInit
    bl entry

    /* Exception Handlers */
    .weak   NMI_Handler
    .type   NMI_Handler, %function
NMI_Handler:
    b       .
    .size   NMI_Handler, . - NMI_Handler

    .weak   MemManage_Handler
    .type   MemManage_Handler, %function
MemManage_Handler:
    b       .
    .size   MemManage_Handler, . - MemManage_Handler

    .weak   BusFault_Handler
    .type   BusFault_Handler, %function
BusFault_Handler:
    b       .
    .size   BusFault_Handler, . - BusFault_Handler

    .weak   UsageFault_Handler
    .type   UsageFault_Handler, %function
UsageFault_Handler:
    b       .
    .size   UsageFault_Handler, . - UsageFault_Handler

    .weak   SVC_Handler
    .type   SVC_Handler, %function
SVC_Handler:
    b       .
    .size   SVC_Handler, . - SVC_Handler

    .weak   DebugMon_Handler
    .type   DebugMon_Handler, %function
DebugMon_Handler:
    b       .
    .size   DebugMon_Handler, . - DebugMon_Handler

    .weak   PendSV_Handler
    .type   PendSV_Handler, %function
PendSV_Handler:
    b       .
    .size   PendSV_Handler, . - PendSV_Handler

    .weak   SysTick_Handler
    .type   SysTick_Handler, %function
SysTick_Handler:
    b       .
    .size   SysTick_Handler, . - SysTick_Handler

    /* IQR Handler */
    .section  .text.Default_Handler,"ax",%progbits
    .type  Default_Handler, %function
Default_Handler:
    b  .
    .size  Default_Handler, . - Default_Handler

    .macro  IRQ handler
    .weak   \handler
    .set    \handler, Default_Handler
    .endm

    IRQ WWDGT_IRQHandler
    IRQ LVD_IRQHandler
    IRQ RTC_IRQHandler
    IRQ FMC_IRQHandler
    IRQ RCU_CTC_IRQHandler
    IRQ  EXTI0_1_IRQHandler                
    IRQ  EXTI2_3_IRQHandler                
    IRQ  EXTI4_15_IRQHandler               
    IRQ  TSI_IRQHandler                    
    IRQ  DMA_Channel0_IRQHandler           
    IRQ  DMA_Channel1_2_IRQHandler         
    IRQ  DMA_Channel3_4_IRQHandler         
    IRQ  ADC_CMP_IRQHandler                
    IRQ  TIMER0_BRK_UP_TRG_COM_IRQHandler  
    IRQ  TIMER0_Channel_IRQHandler         
    IRQ  TIMER1_IRQHandler                 
    IRQ  TIMER2_IRQHandler                 
    IRQ  TIMER5_DAC_IRQHandler             
    IRQ  TIMER13_IRQHandler                
    IRQ  TIMER14_IRQHandler                
    IRQ  TIMER15_IRQHandler                
    IRQ  TIMER16_IRQHandler                
    IRQ  I2C0_EV_IRQHandler                
    IRQ  I2C1_EV_IRQHandler                
    IRQ  SPI0_IRQHandler                   
    IRQ  SPI1_IRQHandler                   
    IRQ  USART0_IRQHandler                 
    IRQ  USART1_IRQHandler                 
    IRQ  CEC_IRQHandler                    
    IRQ  I2C0_ER_IRQHandler                
    IRQ  I2C1_ER_IRQHandler                
    IRQ  USBFS_WKUP_IRQHandler             
    IRQ  DMA_Channel5_6_IRQHandler         
    IRQ  USBFS_IRQHandler                  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值