RT-Thread OS的启动流程
1、RT进入main之前,
SystemInit函数初始化时钟。
2、main函数位于startup.c文件中。进行两个工作
系统开始前,rt_hw_interrupt_disable关闭所有中断。
之后使用rtthread_startup启动RTThread
3、函数rtthread_startup()完成的工作:
1、调用函数rt_hw_board_init 完成板子初始化工作
2、显示版本信息:rt_show_version
3、初始化系统滴答:rt_system_tick_init
4、系统内核对象初始化:rt_system_object_init
5、定时器初始化:rt_system_timer_init
6、系统堆栈初始化rt_system_heap_init
7、任务调度器初始化:rt_system_scheduler_init
8、rt_application_init //加入用户自定义的任务
9、FINSH模块初始化 ,
10、定时器线程初始化:rt_system_timer_thread_init
11、空闲任务初始化rt_thread_idle_init
12、开始任务调度,OS接管MCU:rt_system_scheduler_start
任务调度开始之后,OS就算是启动好了。之后的东西都是在OS的管理下运行了。
4、在RTT示例工程中添加外设驱动的方法:
驱动头文件加入board.h
RT-thread系统的main函数位于startup.c文件中。
/**
* This function will startup RT-Thread RTOS.
*/
void rtthread_startup(void)
{
/* init board */
rt_hw_board_init();//NVIC_config, SysTick_config, serial_device register, set CONSOLE for output(rt_kprintf(...)) in board.c /* show version */
rt_show_version(); //show the version of rtthread by serial device(set to be console-device in board.c) in kservice.c /* init tick */
rt_system_tick_init(); //empty fucntion(since 1.1.0) in clock.c /* init kernel object */
rt_system_object_init();//empty fucntion(since 0.3.0) in object.c /* init timer system */
rt_system_timer_init(); //init rt_timer_list[0].next=rt_timer_list[0].prev=rt_timer_list[0](means rt_timer_list is empty) in timer.c rt_system_heap_init((void*)STM32_SRAM_BEGIN, (void*)STM32_SRAM_END);//init system heap in mem.c /* init scheduler system */
rt_system_scheduler_init();//init the system scheduler, and init rt_thread_defunct(dead thread list) to be empty in scheduler.c /* init application */
rt_application_init(); //init all defined thread in application.c //#ifdef RT_USING_FINSH //replace finsh_set_device() after the function of rt_components_init() in rt_init_thread_entry() of application.c
/* init finsh */
//finsh_system_init(); //INIT_COMPONENT_EXPORT(finsh_system_init) in shell.c, so it needn't finsh_system_init here
//finsh_set_device( FINSH_DEVICE_NAME );//sets the input device of finsh shell(rt_device_open(dev, RT_DEVICE_OFLAG_RDWR |
RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM) in shell.c
//#endif /* init timer thread */
rt_system_timer_thread_init();//init system software timer thread(opened by #define RT_USING_TIMER_SOFT in rtconfig.h) in timer.c /* init idle thread */
rt_thread_idle_init(); //init idle thread(cleanup all dead thread), then start to be ready in idle.c /* start scheduler */
rt_system_scheduler_start(); //startup scheduler(first swith to the highest priority thread and enable interrupt )in scheduler.c /* never reach here */
return ;
}
int main(void)
{
/* disable interrupt first */
//enable interrupt(CPSIE I) when the first thread switch(rt_hw_context_switch_to) in lipcpu/cortex-m4/context_rvds.S
rt_hw_interrupt_disable(); /* startup RT-Thread RTOS */
rtthread_startup(); return ;
}
RT-Thread OS的启动流程的更多相关文章
- STM32 + RT Thread OS 学习笔记[二]
串口通讯例程 通过上面的练习,对STM32项目开发有了一个直观印象,接下来尝试对串口RS232进行操作. 1. 目标需求: 开机打开串口1,侦听上位机(使用电脑串口测试软件)发送的信息,然后原样输 ...
- STM32 + RT Thread OS 串口通讯
1. 创建项目 a) 禁用Finsh和console b) 默认情况下,项目文件包含了finsh,它使用COM1来通讯,另外,console输出(rt_kprintf)也使用了COM1.因 ...
- STM32 + RT Thread OS 学习笔记[三]
RTGUI 据说RTGUI是多线程的,因此与RT-Thread OS的耦合度较高,有可能要访问RT-Thread的线程控制块.如果要移植到其它OS,估计难度较大.目前还处于Alpha状态,最终将会包含 ...
- STM32 + RT Thread OS 学习笔记[四]
1. 补注 a) 硬件,打通通讯通道 若学习者购买了学习板,通常可以在学习板提供的示例代码中找到LCD的相关驱动代码,基本上,这里的驱动的所有代码都可以从里面找到. 从上面的示意图可见,M ...
- Tiny4412 Android 启动流程
Android系统的启动主要包括三个阶段: ①BootLoader启动 ②Linux Kernel启动 ③Android系统启动 前面我们大致分析了前面两个步骤,即u-boot和内核的启动流程(内核启 ...
- [SaltStack] salt-minion启动流程
SaltStack源码阅读 前面理了下salt-master的启动流程, 这次来看看salt-minion的启动流程. 启动salt-minion方法: /etc/init.d/salt-minion ...
- Android5 Zygote 与 SystemServer 启动流程分析
Android5 Zygote 与 SystemServer 启动流程分析 Android5 Zygote 与 SystemServer 启动流程分析 前言 zygote 进程 解析 zygoterc ...
- zookeeper启动流程简单梳理
等着測试童鞋完工,顺便里了下zookeeper的启动流程 zk3.4.6 启动脚本里面 nohup "$JAVA" "-Dzookeeper.log.dir=${ZOO_ ...
- 渣渣菜鸡的 ElasticSearch 源码解析 —— 启动流程(下)
关注我 转载请务必注明原创地址为:http://www.54tianzhisheng.cn/2018/08/12/es-code03/ 前提 上篇文章写完了 ES 流程启动的一部分,main 方法都入 ...
随机推荐
- js 第一篇(常用交互方法)
1. cocument.write("content") //向html 直接写入内容 2. alert("content") // 警告对话框 3. conf ...
- MySQL 事务1
本人应用的MySQL的版本为:5.6.22
- 【BZOJ4238】电压 DFS树
[BZOJ4238]电压 Description 你知道Just Odd Inventions社吗?这个公司的业务是“只不过是奇妙的发明(Just Odd Inventions)”.这里简称为JOI社 ...
- EasyDarwin在做拉模式转发海康RTSP摄像机视频流的过程中出现花屏问题的解决方案
问题描述 在3年前我当时基于EasyDarwin为用户开发了一款RTSP拉模式转发的程序,也发布了一篇博客<用Darwin开发RTSP级联服务器(拉模式转发)>,当时考虑的很简单,只要将R ...
- Servlet单例模式(注意)
package com.servlet; import java.io.IOException; import javax.servlet.ServletException; import javax ...
- 九度OJ 1171:C翻转 (矩阵计算)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4649 解决:1530 题目描述: 首先输入一个5 * 5的数组,然后输入一行,这一行有四个数,前两个代表操作类型,后两个数x y代表需操作 ...
- 九度OJ 1020:最小长方形 (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:6019 解决:2849 题目描述: 给定一系列2维平面点的坐标(x, y),其中x和y均为整数,要求用一个最小的长方形框将所有点框在 ...
- property 中的strong 与weak
strong关键字与retain关似,用了它,引用计数自动+1,用实例更能说明一切 @property (nonatomic, strong) NSString *string1; @property ...
- access 驱动在win64位出现问题
如果是调试的话,将应用程序池的 启动win32应用程序池 为 true
- Redis- 内存数据库Redis之安装部署
内存数据库Redis之安装部署 Redis是一款非关系型,key-value存储的内存数据库,Redis数据库完全在内存中,使用磁盘仅用于持久性.Redis的速度非常快,每秒能执行约11万集合,每秒约 ...