系统上电
↓
复位中断向量 → Reset_Handler (汇编启动文件)
↓
SystemInit (初始化时钟、内存等)
↓
main() → entry() [GCC]
↓
rtthread_startup() [components.c]
↓
├─→ rt_hw_interrupt_disable() // 关中断
├─→ rt_hw_board_init() // 板级初始化
│ └─→ rt_components_board_init() // 执行INIT_BOARD_EXPORT的函数
│ └─→ 调用.rti_fn.1段的函数
├─→ rt_show_version() // 显示版本
├─→ rt_system_timer_init() // 定时器初始化
├─→ rt_system_scheduler_init() // 调度器初始化
├─→ rt_application_init() // 创建main线程
│ └─→ rt_thread_create(“main”, main_thread_entry, …)
├─→ rt_system_timer_thread_init() // 定时器线程初始化
├─→ rt_thread_idle_init() // 空闲线程初始化
└─→ rt_system_scheduler_start() // 启动调度器
↓
多线程调度开始
↓
main线程运行 → main_thread_entry()
↓
rt_components_init() // 组件初始化
└─→ 依次调用.rti_fn.2到.rti_fn.6段的函数
├─→ INIT_PREV_EXPORT // “2” 段
├─→ INIT_DEVICE_EXPORT // “3” 段 ← st_lsm6dsr_init在这里调用
├─→ INIT_COMPONENT_EXPORT// “4” 段
├─→ INIT_ENV_EXPORT // “5” 段
└─→ INIT_APP_EXPORT // “6” 段
↓
main() // 用户主函数
↓
用户应用程序…
RT-Thread启动流程