简体   繁体   English

嵌入式Linux引导优化

[英]Embedded Linux Boot Optimization

I am doing project on Pandaboard using Embedded Linux (UBUNTU 12.10 Server Prebuild image) to optimize boot time. 我正在使用嵌入式Linux(UBUNTU 12.10 Server Prebuild映像)在Pandaboard上进行项目,以优化启动时间。 I need techniques or tools through which I can find boot time and techniques to optimize the boot time. 我需要可以找到启动时间的技术或工具,以及可以优化启动时间的技术。 If anyone can help. 如果有人可以帮助。

只需从/etc/init.d/rc文件中删除不需要的应用程序,并在每次进程初始化后放入echo,并检查哪个进程需要花费很多时间启动,如果您发现花费更多时间的应用程序,则对该应用程序进行调试,等等。上。

There is program that can be helpful to know the approximate boot-up time. 有一些程序可以帮助您了解大约的启动时间。 Check this link Time Stamp . 检查此链接时间戳

First of all the best you have to do is to compile yourself your own made kernel, get the source on the internet and do a make xconfig and then unselected everythin you don't need. 首先,您要做的最好的事情就是编译自己的内核,在Internet上获取源代码并执行make xconfig ,然后在不需要的所有内容上进行选择。 In a second time create your own root filesystem using Buildroot and make xconfig to select/unselect everything you need or not. 第二次使用Buildroot创建您自己的根文件系统, make xconfig选择/取消选择您需要或不需要的所有内容。

Hope this help. 希望能有所帮助。

I had the same problem and do that way, now it's clearly not the same ;) 我遇到了同样的问题,并且这样做了,现在显然不一样了;)

EDIT: Everything you need will be here 编辑:您需要的一切都将在这里

to analyze the boot process, you can use Bootchart2 , its available on github: https://github.com/mmeeks/bootchart 要分析启动过程,可以使用Bootchart2 ,它可以在github上找到: https : //github.com/mmeeks/bootchart

or Bootchart , from the Ubuntu packages: Bootchart ,来自Ubuntu软件包:

sudo apt-get update
sudo apt-get install bootchart pybootchartgui

There are broadly 3 areas where you can reduce boot time 您可以大致在3个领域中减少启动时间

  1. Bootloader: Modify the linker script to initialize only the required h/w. Bootloader:修改链接程序脚本以仅初始化所需的硬件。 Also, if you are using an SD card to boot, merge kernel and bootloader image to save time. 另外,如果您使用SD卡进行引导,请合并内核和引导加载程序映像以节省时间。
  2. Kernel: Remove unwanted modules from kernel config. 内核:从内核配置中删除不需要的模块。 Also try using compressed and uncompressed image. 另外,请尝试使用压缩和未压缩的图像。 If your CPU is good enough to handle it go compressed image and check uncompression time required for different compression types. 如果您的CPU足以处理压缩的图像并检查不同压缩类型所需的解压缩时间。
    1. Filesystem: FS size can be significantly reduced by removing the unwanted bins and libs. 文件系统:通过删除不需要的垃圾箱和库,可以大大减小FS大小。 Check for dependencies and use only the one's that are required. 检查依赖项,并仅使用所需的依赖项。

For more techniques and information on tools that help in measuring the boot time please refer to the following link. 有关有助于测量启动时间的工具的更多技术和信息,请参考以下链接。 Refer to Training Material 请参阅培训材料

The basic rule is: the fastest code is code that never gets loaded and run, so remove everything you don't need: 基本规则是:最快的代码是永远不会加载和运行的代码,因此请删除不需要的所有内容

  • in U-Boot: don't load and run the full U-Boot at all; 在U-Boot中:完全不加载并运行完整的U-Boot; use FALCON mode and have the SPL load the Linux kernel and DTB directly 使用FALCON模式并让SPL直接加载Linux内核和DTB
  • in Linux: remove all drivers and other stuff you don't really need; 在Linux中:删除所有您不需要的驱动程序和其他内容; load all drivers that are not essential for your core application as modules - and load them after your application was started. 将对核心应用程序不是必需的所有驱动程序作为模块加载-并在应用程序启动后加载它们。 If you take this serious, you may even want to start only one CPU core initially (and start the remaining ones after your application is running). 如果您认真对待,您甚至可能只想首先启动一个CPU内核(并在应用程序运行后启动其余的CPU内核)。
  • in user space: minimize the size of the root file system. 在用户空间中:最小化根文件系统的大小。 throuw out anything you don't need; 清除不需要的任何东西; configure tools (like busybox) to contain only the really needed functionality; 配置工具(例如busybox)以仅包含真正需要的功能; use efficient code (for example, link against musl libc instead of glibc) etc. 使用有效的代码(例如,针对musl libc而不是glibc的链接)等。

What can be acchieved by combining all these measures can be seen in this video - and yes, the complete code for this optimization is available here . 结合所有这些措施可以达到的目的可以在本视频中看到-是的, 此处提供了此优化的完整代码。

Optimizing embedded Linux Boot process , needs modifications in three level of embedded Linux design. 优化嵌入式Linux的启动过程,需要对嵌入式Linux设计的三个层次进行修改。

Note: you will need the source codes of bootloader and kernel 注意:您将需要Bootloader和内核的源代码

  1. Boot : the first step in optimizing and reducing boot time of board is optimizing boot loader. 引导:优化和减少电路板引导时间的第一步是优化引导加载程序。 first you should know what is your bootloader is. 首先,您应该知道什么是Bootloader。 If your bootloader is an opensource bootloader like u-boot than you have the opportunity to modify and optimize it. 如果您的引导程序是像u-boot这样的开源引导程序,那么您就有机会对其进行修改和优化。 In u-boot we have a procedure that we can skip unnecessary system check and just upload kernel image to ram and start. 在u-boot中,我们有一个过程可以跳过不必要的系统检查,而只是将内核映像上传到ram并启动。 the documentation and instruction for this is available in u-boot website. 有关文档和说明,请访问u-boot网站。 by doing this you will save about 4 ~ 5 second in boot. 这样做可以节省大约4到5秒钟的启动时间。

  1. Kernel : for having a quicker kernel , you should optimize kernel in many sections. 内核:为了拥有更快的内核,您应该在许多部分中优化内核。 for editing you can use on of Linux config menu. 要进行编辑,您可以使用Linux配置菜单上的。 I always use a low graphic menu. 我总是使用较低的图形菜单。 it need some dependency you can use it by this command: 它需要一些依赖性,您可以通过以下命令使用它:

    $ make menuconfig $ make menuconfig

    our goal for Linux kernel is to have smaller kernel image and less module to load in boot. 我们对Linux内核的目标是在引导时加载更小的内核映像和更少的模块。 first change the algorithm of compression from gzip to LZO. 首先将压缩算法从gzip更改为LZO。 the point of this action is gzip algorithm will take much time to extract kernel. 该操作的要点是gzip算法将花费大量时间来提取内核。 by using LZO we have a quicker kernel decompression process. 通过使用LZO,我们可以更快地进行内核解压缩。 the second , disable any unnecessary driver or module that you don't have it on your board or you don't use it any more. 第二,禁用您不需要的驱动程序或模块,或者您不再使用它。 by doing this , you will lose some device access and cannot use them in Linux but you will have two positive points: less Ram usage , quicker boot time. 这样,您将失去一些设备访问权限,并且无法在Linux中使用它们,但是您将获得两个积极的方面:更少的Ram使用率,更快的启动时间。 but please remind that some driver are necessary for Linux and by disabling them you will lose some of main features (for example if you disable I2C driver in Linux you will no longer have a HDMI interface) that you need or in worst case you will have a boot problem (such as boot-loop). 但是请注意,某些驱动程序对于Linux是必需的,并且禁用它们会丢失一些主要功能(例如,如果在Linux中禁用I2C驱动程序,则将不再具有HDMI接口),或者在最坏的情况下,您将拥有引导问题(例如引导循环)。 The third is to disable some of unusable filesystem to reduce kernel size and boot time. 第三是禁用一些不可用的文件系统,以减少内核大小和启动时间。 The Fourth is to remove some of compression algorithm to have smaller kernel image. 第四是删除一些压缩算法以具有较小的内核映像。 the last thing , If you are using a u-boot bootloader create a uImage instead of zImage. 最后,如果您使用的是u-boot引导程序,请创建一个uImage而不是zImage。 the following steps , are general and main actions , for having quicker boot as 1 second after power attach you should change more option. 以下步骤是常规操作和主要操作,为使电源连接后1秒钟更快启动,您应该更改更多选项。


  1. after two base layer modifications, now we should optimize boot process in user-space (root file system). 经过两次基本层修改后,现在我们应该优化用户空间(根文件系统)中的引导过程。 depend on witch system are you using , we have different changes to do. 取决于您使用的巫婆系统,我们有不同的操作要做。 in abstract root file system of Linux that have necessary package and system to boot Linux we should use systemd instead of Unix systemv , because systemd have a multi-task init. 在具有启动Linux所需软件包和系统的Linux抽象根文件系统中,我们应该使用systemd而不是Unix systemv,因为systemd具有多任务init。 system and it is faster , after that is udev that you should modify some of loading modules. 系统,速度更快,之后是udev,您应该修改一些加载模块。 if you have a graphical user-interface , we can use an easy trick to have a big boot time reduction by initing GUI first and load other module after loading GUI. 如果您具有图形用户界面,我们可以使用一个简单的技巧来减少启动时间,方法是先启动GUI,然后在加载GUI之后加载其他模块。

if you do all of following tasks , you can have quick boot time and fast system to work with. 如果执行以下所有任务,则可以缩短启动时间并快速使用系统。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM