计算机启动过程小结:
Boot Phases | (Ubuntu ) on Intel Intel PC | ARM embedded Linux |
BA | BIOS (CMOS) | Boot-option (BA/uboot) |
Boot loader | Boot loader (MBR) /GRUB/LILO | Uboot |
Kernal(OS) | Kernel (init tty7)—ctrl-ALt-F7 back… | Kernel +(device tree) |
Init/Service… | Upstart | Rootfs (init dir) |
他们之间互相关联和交叉。
1. BIOS (Basic Input/Output
最早的计算机硬件信息存储在CMOS芯片里,后来集成在BIOS。BIOS 成为开机第一段运行程序的专用芯片。其主要功能有
POST - Test computer hardware insuring hardware is properly functioning before starting process of loading Operating System. (硬件自检)
Bootstrap Loader - Process of locating the operating system. If capable Operating system located BIOS will pass the control to it. (引导程序加载)
BIOS - Software / Drivers which interfaces between the operating system and your hardware. When running DOS or Windows you are using complete BIOS support. (加载引导程序所需要的驱动)
CMOS Setup - Configuration program. Which allows you to configure hardware settings including system settings such as computer passwords, time, and date. (电脑BIOS密码,RTC日期时间)
当然还有其它的配置管理,比如选择启动设备顺序等
2. Boot Loader
Bootloader 引导程序,用于加载操作系统, Loads the operating system. When your machine loads its operating system, the BIOS (BA) reads the first 512 bytes of your bootable media (which is known as the master boot record, or MBR). (PC)
2.1 LILO Linux Loader
故名思意, 用于加载Linux系统的; 现在用的人不多. An example ,
/sbin/lilo -v –v Lilo.conf…. boot=/dev/hda map=/boot/map install=/boot/boot.b prompt timeout=100 compact default=Linux image=/boot/vmlinuz-2.4.18-14 (相当于ARM UImage…) label=Linux root=/dev/hdb3 read-only password=linux other=/dev/hda label=WindowsXP
|
2.2 Grub2: GRand Unified Bootloader
看来一个事情成立的时候需要有Think big and long;从这个名字看就特别高大上.(志存高远), 尽管现在用的Grub2 与最初的Grub差别还是挺大的.
Grub:a flexible and powerful boot loader program for a wide range of architectures. (1995年开始的项目, 2002 发现不够用,推到变成GRUB2 rewrite the core of GRUB to make it cleaner, safer, more robust, and more powerful.
主要的优势是灵活和兼容,利用Chain技术可以支持加载windows系统, 多操作系统系统(Linux+Windows). One of the important features in GRUB is flexibility; GRUB understands filesystems and kernel executable formats, so you can load an arbitrary operating system the way you like, without recording the physical position of your kernel on the disk. Thus you can load the kernel just by specifying its file name and the drive and partition where the kernel resides.
修改维护配置简单, */boot/grub/grub.cfg 修改完,update-grub 让修改生效.
2.3 UBoot universal bootloader
这个名字更加高大上,尽管它更多运用ARM平台. bootloader for Embedded(Risc) PowerPC, (Risc) ARM and (intel) MIPS Systems. 知道程序设计的人都知道,好的程序不是写出来的,是设计(design)出来的.
如果我们看看它的十大设计原则,你就能明白为啥它能在ARM平台形成垄断. (不过要同时满足这么多设计原则,那肯定是相当的不容易,普通的项目容易玩坏)
DesignRULES : Keep it Small /Fast/Simple/Portable/Configrable/Debugable/Usage/Maintainable/beautiful/Open....
1) 芯片自举程序跳转 (BA: boot assistant for Asmel的芯片;Boot-Option…)
2) 可以放在SD-card, EEROM, SPI-Flash,EMMC-Flash …
3) 接串口可以中断进入BOIS环境,查看修改运行参数...
一般Uboot完事, 加载DTB与Kernel.
| Uboot | BIOS&Grub/LILO |
..splash screen displayed | “Hit any key to stop autoboot: 0”… bootdelay=1 | “Press xx enter BIOS setup” “setup prompt timeout” –1? |
Parameter setting …. | printenv /saveenv | bootdelay=1 |
Key | bootArg /bootcmd (default) | Battery…. |
|
| AMI/AmericanMegatrends/… |
Boot flash image…. |
|
|
2.3.1 DTB
Device Tree blob. 有个设备树这个东西, Linux环境下开发(配置)驱动的难度大大降低. Tools: dtc (transfer between dts and dtb)
Ref :
http://flint.cs.yale.edu/feng/cos/resources/BIOS/
https://www.ibm.com/developerworks/library/l-bootload/index.html
https://www.gnu.org/software/grub/manual/grub/grub.html
http://www.denx.de/wiki/U-Boot/
https://ipwithease.com/difference-between-bios-and-cmos/