NuttX启动流程

NuttX启动流程(NuttX7.1 stm32 源代码分析)


__start--                                 #处理器执行的第一条指令
        |
        v
   stm32_clockconfig()------              #初始化时钟
                           |
                           v
                 rcc_reset()              #复位rcc
                 stm32_stdclockconfig()   #初始化标准时钟
                 rcc_enableperipherals()  #使能外设时钟
                           |
        --------------------
        |
        v
   stm32_fpuconfig()                      #配置fpu
   stm32_lowsetup()                       #基本初始化串口,之后可以使用up_lowputc()
   stm32_gpioinit()                       #初始化gpio,只是调用stm32_gpioremap()设置重映射
   up_earlyserialinit()                   #初始化串口,之后可以使用up_putc()
   stm32_boardinitialize()--              #板级初始化
                           |
                           v
                 stm32_spiinitialize()    #初始化spi,只是调用stm32_configgpio()设置gpio
                 stm32_usbinitialize()    #初始化usb,只是调用stm32_configgpio()设置gpio
                 board_led_initialize()   #初始化led,只是调用stm32_configgpio()设置gpio
                           |
        --------------------
        |
        v
   os_start()---------------              #初始化操作系统
                           |
                           v
                 dq_init()                #初始化各种状态的任务列表(置为null)
                 g_pidhash[i]=            #初始化唯一可以确定的元素--进程ID
                 g_pidhash[PIDHASH(0)]=   #分配空闲任务的进程ID为0
                 g_idletcb=               #初始化空闲任务的任务控制块
                 sem_initialize()--       #初始化信号量
                                  |
                                  v
                       dq_init()          #将信号量队列置为null
                       sem_initholders()  #初始化持有者结构以支持优先级继承,shenzhou/nsh未调用
                                  |
                           --------
                           |
                           v
                 up_allocate_heap()       #分配用户模式的堆(设置堆的起点和大小)
                 kumm_initialize()        #初始化用户模式的堆
                 up_allocate_kheap()      #分配内核模式的堆,shenzhou/nsh未调用
                 kmm_initialize()         #初始化内核模式的堆,shenzhou/nsh未调用
                 task_initialize()        #初始化任务数据结构,shenzhou/nsh未调用
                 irq_initialize()         #将所有中断向量都指向同一个异常中断处理程序
                 wd_initialize()          #初始化看门狗数据结构
                 clock_initialize()       #初始化rtc
                 timer_initialize()       #配置POSIX定时器
                 sig_initialize()         #初始化信号
                 mq_initialize()          #初始化命名消息队列
                 pthread_initialize()     #初始化线程特定的数据,空函数
                 fs_initialize()---       #初始化文件系统
                                  |
                                  v
                       sem_init()         #初始化节点信号量为1
                       files_initialize() #初始化文件数组,空函数
                                  |
                           --------
                           |
                           v
                 net_initialize()--       #初始化网络
                                  |
                                  v
                       uip_initialize()   #初始化uIP层
                       net_initroute()    #初始化路由表,shenzhou/nsh未调用
                       netdev_seminit()   #初始化网络设备信号量
                       arptimer_init()    #初始化ARP定时器
                                  |
                           --------
                           |
                           v
                 up_initialize()---       #处理器特定的初始化
                                  |
                                  v
                       up_calibratedelay()#校准定时器
                       up_addregion()     #增加额外的内存段
                       up_irqinitialize() #设置中断优先级,关联硬件异常处理函数
                       up_pminitialize()  #初始化电源管理,shenzhou/nsh未调用
                       up_dmainitialize() #初始化DMA,shenzhou/nsh未调用
                       up_timerinit()     #初始化定时器中断
                       devnull_register() #注册/dev/null
                       devzero_register() #注册/dev/zero,shenzhou/nsh未调用
                       up_serialinit()    #注册串口控制台/dev/console和串口/dev/ttyS0
                       up_rnginitialize() #初始化并注册随机数生成器,shenzhou/nsh未调用
                       up_netinitialize() #初始化网络,是arch/arm/src/chip/stm32_eth.c中的
                       up_usbinitialize() #初始化usb驱动,shenzhou/nsh未调用
                       board_led_on()     #打开中断使能led,但很快会被其它地方的led操作改变状态
                                  |
                           --------
                           |
                           v
                 lib_initialize()         #初始化c库,空函数
                 group_allocate()         #分配空闲组
                 group_setupidlefiles()   #在空闲任务上创建stdout、stderr、stdin
                 group_initialize()       #完全初始化空闲组
                 os_bringup()------       #创建初始任务
                                  |
                                  v
                       KEKERNEL_THREAD()  #启动内核工作者线程
                       board_initialize() #最后一刻的板级初始化,shenzhou/nsh未调用
                       TASK_CREATE()      #启动默认应用程序
                                  |
                           --------
                           |
                           v
                 for up_idle()            #空闲任务循环
                           |
        --------------------
        |
        v
   for(;;)                                #不应该到达这里

 

 

 

你可能感兴趣的:(NUTTX)