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 方法都入 ...
随机推荐
- 未加载Microsoft.SqlServer.management.sdk.sfc version......
这个问题卡了我好久,于是决定记录下来,我这里缺失的是Microsoft.SqlServer.management.sdk.sfc version 12.0.0,当然你也可能后面是11开头的, 这个是由 ...
- 常用yum命令小结
基于rpm的软件包管理器 yum,是Yellow dog Updater, Modified的简称,是一种软件包管理器.它能够从指定的服务器自动下载RPM包并安装,可以自动处理依赖性关系,并且一次安装 ...
- JavaWeb学习总结第三篇--走进JSP页面元素
JavaWeb学习(三)—走进JSP页面元素 JSP:Java Server Pages,译为Java服务器页面.其脚本采用Java语言,继承了Java所有优点.JSP元素可以分为指令元素.脚本元素和 ...
- Android中怎样控制LogCat的自己定义输出
在Android开发中,LogCat是一个非常重要的调试工具,能够输出非常多关于项目或者手机的信息. 可是正是因为LogCat功能的过于强大,输出的信息量也是极为庞大的,那么我们就须要通过一定的方式依 ...
- Spring属性编辑器详解
1.常见的属性的注入:int,string,list,set,map 2.什么是属性编辑器及作用? (1)将spring配置文件中的字符串转换为相应的java对象 (2)spring内置了一些属性编辑 ...
- 微信小程序页面布局之弹性布局-Flex介绍
布局的传统解决方案,基于盒状模型,依赖 display 属性 + position属性 + float属性.它对于那些特殊布局非常不方便,比如,垂直居中就不容易实现. 2009年,W3C 提出了一种新 ...
- 公网yum 源地址
1. centos5.* 公网yum 源地址 [root@web ~]# cd /etc/yum.repos.d/[root@web yum.repos.d]# wget -O /etc/yum.r ...
- EasyDSS RTMP流媒体解决方案之直播录像自动清理方案
本文转自Marvin的博客: http://blog.csdn.net/marvin1311/article/details/78660592 EasyDSS_Solution直播录像清理 直播录像, ...
- 一种微信直播H5直播与存储回放的HLS摄像机方案
接上篇 在上一篇博客<一种流量成本节省60%以上的手机直播微信直播H5直播幼儿园直播方案>中,我们一共介绍了两种省钱的HLS直播途径: 方案一:编码器或者内网推流直接对接云存储的场景 如果 ...
- RPM包的使用
不同yum安装源配置文件 ls -l /etc/yum.repo.d RPM包的主包和子功能包 mount /dev/cdrom /media/cdrom cd /media/cdrom/Packag ...