• 了解Uboot Bootstage

1.Kconfig Introduction

  • CONFIG_BOOTSTAGE
common/Kconfig:
config BOOTSTAGEbool "Boot timing and reporting"helpEnable recording of boot time while booting. To use it, insertcalls to bootstage_mark() with a suitable BOOTSTAGE_ID frombootstage.h. Only a single entry is recorded for each ID. You cangive the entry a name with bootstage_mark_name(). You can alsorecord elapsed time in a particular stage using bootstage_start()before starting and bootstage_accum() when finished. Bootstage willadd up all the accumulated time and report it.Normally, IDs are defined in bootstage.h but a small number ofadditional 'user' IDs can be used by passing BOOTSTAGE_ID_ALLOCas the ID.Calls to show_boot_progress() will also result in log entries butthese will not have names.
  • CONFIG_BOOTSTAGE_REPORT
config BOOTSTAGE_REPORTbool "Display a detailed boot timing report before booting the OS"depends on BOOTSTAGEhelpEnable output of a boot time report just before the OS is booted.This shows how long it took U-Boot to go through each stage of theboot process. The report looks something like this:Timer summary in microseconds:Mark    Elapsed  Stage0          0  reset3,575,678  3,575,678  board_init_f start3,575,695         17  arch_cpu_init A93,575,777         82  arch_cpu_init done3,659,598     83,821  board_init_r start                                                           3,910,375    250,777  main_loop29,916,167 26,005,792  bootm_start30,361,327    445,160  start_kernel
  • CONFIG_BOOTSTAGE_STASH_ADDR
config BOOTSTAGE_STASH_ADDRhex "Address to stash boot timing information"default 0helpProvide an address which will not be overwritten by the OS when itstarts, so that it can read this information when ready.
  • CONFIG_BOOTSTAGE_STASH_SIZE
config BOOTSTAGE_STASH_SIZEhex "Size of boot timing stash region"default 0x1000help                                                                                                     This should be large enough to hold the bootstage stash. A value of4096 (4KiB) is normally plenty.

2.BOOTSTAGE_ID_*

  enum bootstage_id {BOOTSTAGE_ID_START = 0,BOOTSTAGE_ID_CHECK_MAGIC,   /* Checking image magic */BOOTSTAGE_ID_CHECK_HEADER,  /* Checking image header */BOOTSTAGE_ID_CHECK_CHECKSUM,    /* Checking image checksum */BOOTSTAGE_ID_CHECK_ARCH,    /* Checking architecture */BOOTSTAGE_ID_CHECK_IMAGETYPE = 5,/* Checking image type */BOOTSTAGE_ID_DECOMP_IMAGE,  /* Decompressing image */BOOTSTAGE_ID_KERNEL_LOADED, /* Kernel has been loaded */BOOTSTAGE_ID_DECOMP_UNIMPL = 7, /* Odd decompression algorithm */BOOTSTAGE_ID_CHECK_BOOT_OS, /* Calling OS-specific boot function */BOOTSTAGE_ID_BOOT_OS_RETURNED,  /* Tried to boot OS, but it returned */BOOTSTAGE_ID_CHECK_RAMDISK = 9, /* Checking ram disk */                                                BOOTSTAGE_ID_RD_MAGIC,      /* Checking ram disk magic */BOOTSTAGE_ID_RD_HDR_CHECKSUM,   /* Checking ram disk heder checksum */BOOTSTAGE_ID_RD_CHECKSUM,   /* Checking ram disk checksum */BOOTSTAGE_ID_COPY_RAMDISK = 12, /* Copying ram disk into place */BOOTSTAGE_ID_RAMDISK,       /* Checking for valid ramdisk */BOOTSTAGE_ID_NO_RAMDISK,    /* No ram disk found (not an error) */BOOTSTAGE_ID_RUN_OS = 15,   /* Exiting U-Boot, entering OS */BOOTSTAGE_ID_NEED_RESET = 30,BOOTSTAGE_ID_POST_FAIL,     /* Post failure */BOOTSTAGE_ID_POST_FAIL_R,   /* Post failure reported after reloc */...

3.代码分析

3.1. 常用函数

 common/bootstage.c:int bootstage_init(bool first);ulong bootstage_add_record(enum bootstage_id id, const char *name,int flags, ulong mark);ulong bootstage_mark(enum bootstage_id id);ulong bootstage_mark_name(enum bootstage_id id, const char *name);  ulong bootstage_mark_code(const char *file, const char *func,int linenum);uint32_t bootstage_start(enum bootstage_id id, const char *name); uint32_t bootstage_accum(enum bootstage_id id);int bootstage_stash(void *base, int size);int bootstage_unstash(const void *base, int size);

3.2.bootstage初始化

 498 int bootstage_init(bool first)499 {500     struct bootstage_data *data;501     int size = sizeof(struct bootstage_data);502 503     gd->bootstage = (struct bootstage_data *)malloc(size);504     if (!gd->bootstage)505         return -ENOMEM;506     data = gd->bootstage;507     memset(data, '\0', size);508     if (first) {509         data->next_id = BOOTSTAGE_ID_USER;510         bootstage_add_record(BOOTSTAGE_ID_AWAKE, "reset", 0, 0);511     }512                                                                                                        513     return 0;514 }

  初始化全局变量gd->bootstage,然后调用bootstage_add_record添加record到结构体数组struct bootstage_record record[RECORD_COUNT]; 数组大小由RECORD_COUNT决定。

   19 enum {20     RECORD_COUNT = CONFIG_VAL(BOOTSTAGE_RECORD_COUNT),                                                 21 };

3.3.添加自定义

  • bootstage_mark(BOOTSTAGE_ID_RUN_OS);
  • bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_F, “board_init_f”);

3.4. config配置

CONFIG_ BOOTSTAGE=y
CONFIG_ SPL_BOOTSTAGE=y
CONFIG_ CMD_BOOTSTAGE=y
CONFIG_ BOOTSTAGE_STASH=y
CONFIG_ BOOTSTAGE_STASH_SIZE=0x4096
CONFIG_ BOOTSTAGE_REPORT=y
CONFIG_ BOOTSTAGE_RECORD_COUNT=40
CONFIG_ SPL_BOOTSTAGE_RECORD_COUNT=40

3.5.Debug

=> bootstage report
Timer summary in microseconds (6 records):Mark    Elapsed  Stage13,284,026          0  board_init_f16,594,567  3,310,541  board_init_r17,887,992  1,293,425  id=6417,898,594     10,602  main_loop17,961,225     62,631  id=173Accumulated time:102,461  dm_r849,307  dm_f
 => bootstage stash 0 0x4096
Stashed 7 records=> bootstage unstash 0 0x4096
Unstashed 7 records

Uboot Bootstage相关推荐

  1. u-boot之u-boot.bin的生成

    u-boot.bin 这里的u-boot.bin指的是不包含SPL的stage2部分的代码. 它会被SPL搬移到RAM的某个地址处开始运行. 本篇下面提到的u-boot.bin时, 也是指的这个概念. ...

  2. MT7621_移植篇(3) uboot编译+配置项分析

    U-Boot("通用引导加载程序",通常简称为U-Boot)是一种开源的主引导加载程序,用于嵌入式设备中打包引导设备操作系统内核的指令.它可用于多种计算机架构,包括68k.ARM. ...

  3. u-boot v2018.01 启动流程分析

    make smdkc100_defconfig 以被默认支持的smdkc100单板为背景分析u-boot v2018.01 参考图1可知uboot code链接顺序:                  ...

  4. uboot学习笔记之七-第三个函数board_init_r

    接上回.在borad_init_f函数执行完成,C语言环境就算完全建立起来了.下面就完全是C的代码了. 返回crt0.S , 执行board_init_r(common/board_r.c), 完成b ...

  5. 【正点原子Linux连载】第三十二章 U-Boot启动流程详解 -摘自【正点原子】I.MX6U嵌入式Linux驱动开发指南V1.0

    1)实验平台:正点原子阿尔法Linux开发板 2)平台购买地址:https://item.taobao.com/item.htm?id=603672744434 2)全套实验源码+手册+视频下载地址: ...

  6. U-Boot 之五 详解 U-Boot 及 SPL 的链接脚本、启动流程

      最近,工作重心要从裸机开发转移到嵌入式 Linux 系统开发,在之前的博文 Linux 之八 完整嵌入式 Linux 环境.(交叉)编译工具链.CPU 体系架构.嵌入式系统构建工具 中详细介绍了嵌 ...

  7. Uboot启动流程(一)

    Uboot启动流程简要概括 Uboot可以看作是一个比较复杂的综合裸机程序,学习之余对其启动流程进行一个简要的概括,理清自己的思路. 详细内容参考STM32MP1嵌入式Linux驱动开发指南 Uboo ...

  8. u-boot中filesize环境变量【转载】

    转载地址:https://blog.csdn.net/fzs333/article/details/48518559 U-Boot中的环境命令可以使用$(filesize)来确定刚下载(传输)得到的文 ...

  9. 使用Uboot启动内核并挂载NFS根文件系统

    配置编译好内核之后,将生成的内核文件uImage拷贝到/tftpboot/下,通过tftp服务器将内核下载到开发板,使用命令:tftp 31000000 uImage.下载完成之后配置bootargs ...

最新文章

  1. 为什么 P8 程序员的代码你写不出来?零拷贝了解一下
  2. 网络品牌推广带大家了解网站中有哪些常见的URL优化手段?
  3. VUE 新手入门感慨
  4. java线程协作_java 线程间的协作
  5. 卧虎藏龙2不显示服务器列表,《卧虎藏龙贰》iOS平台 合服公告(第2期)
  6. Hadoop基本原理之一:MapReduce
  7. Python数据结构与算法(五)--链表
  8. 40 行代码搞定主题词提取
  9. CSS3实现圆角效果
  10. 7-4 组从配置-操作
  11. C语言项目实践--图书管理系统
  12. 有限元法基本思想和分类
  13. Windows OCR推荐
  14. 马成荣版计算机应用基础 教案,课改理念在中职《计算机应用基础》教学中的应用...
  15. 【sketchup 2021】草图大师图像输出与渲染之Enscape渲染(优秀的实时渲染软件)的高级使用【灯光的添加、代理模型的添加、材质编辑器、视频编辑器、全景导出并编辑】
  16. python视频补帧_视频补帧软件(DAIN APP)
  17. linux驱动管道,Xilinx Linux 如何理解V4L2的管道驱动程序
  18. animals中文谐音_搞笑的英语句子谐音
  19. 利用PhotoSwipe进行完成图片预览功能
  20. 手机文件由百度网盘自动备份的设置

热门文章

  1. 关于伪原创 各类伪原创对比分析
  2. 跨境电商文案、翻译、模特受冲击 ChatGPT是如何把饭碗抢走的?
  3. 用了一个很蠢的方法定位服务不可用原因
  4. qq下载默认存放位置
  5. 平面设计师必备的10大技能
  6. Linux命令之日历cal
  7. NLP小白的Kaggle一轮游总结
  8. 分析为什么加锁和解锁操作是原子的
  9. 2015061908 - 人来人往
  10. 6.2.2 QT遇到 ‘QOpenGLWidget‘ file not found 问题的其中一种解决