启动文件由汇编语言编写,是MCU上电复位后第一个执行的程序。主要执行以下内容:
- 初始化gp(global pointer)全局指针寄存器、sp(stack pointer)栈指针寄存器
- 将data数据从flash中加载至RAM中
- 清空bss段数据
- 初始化中断向量表
- 配置系统时钟
- 从Machine模式切换到User模式,进入main函数运行
CH32V103启动文件如下:
/********************************** (C) COPYRIGHT *******************************
* File Name : startup_ch32v10x.s
* Author : WCH
* Version : V1.0.0
* Date : 2020/04/30
* Description : CH32V10x vector table for eclipse toolchain.
*******************************************************************************/
.section .init,"ax",@progbits /* 声明section 为 .init */
.global _start /* 指明标签_start的属性为全局性的 */
.align 1
_start: /* 标签_start处 */
j handle_reset /* 跳转至 handle_reset处 */
.word 0x00000013 /* 内核设计需要,不用关注 */
.word 0x00000013
.word 0x00000013
.word 0x00000013
.word 0x00000013
.word 0x00000013
.word 0x00000013
.word 0x00000013
.word 0x00000013
.word 0x00000013
.word 0x00000013
.word 0x00000013
.word 0x00100073
.section .vector,"ax",@progbits
.align 1
_v