【linux启动】嵌入式Linux系统启动过程分析
作者:互联网
一、概述
嵌入式linux系统启动过程一般包含以下几个过程:
- 上电
- 执行IROM(芯片内部只读存储器)中固化的代码。
- 执行uboot
- 加载内核到内存,启动内核。
- 挂载根文件系统rootfs
- 执行其中的脚本和应用程序。
二、内核的几个组成部分介绍
1、uboot介绍
(1)概述
- 是一个通用的bootloader
- Boot:完成硬件的初始化
-
Loader:加载操作系统内核,并启动内核.
- uboot支持多种处理器架构:ARM、PowerPC 、X86 、 Mips等等。
- 支持加载启动多种操作系统:linux、wince、VXworks等
- uboot的源码下载地址:https://ftp.denx.de/pub/u-boot/
(2)作用
- CPU的初始化(芯片级)主要采用ARM汇编语言,包含初始化缓存、MMC、Watchdog、终端、clock等。
- 板级初始化(采用C语言编写):主要初始化串口、网卡、USB、LCD等设备.
-
为操作系统的启动准备参数,加载操作系统镜像到内存,并启动.
(3)u-boot的开机打印信息分析
U-Boot 2014.07 (Apr 10 2021 - 02:16:01)---U-boot版本号 //时钟系统中各个总线上的时钟频率 PLL : [0] = 800000000, [1] = 800000000, [2] = 780000000, [3] = 800000000 (0) PLL1: CPU FCLK = 800000000, HCLK = 200000000 (G0) (7) PLL1: CPU FCLK = 800000000, HCLK = 200000000 (G1) (2) PLL3: MEM FCLK = 800000000, DCLK = 800000000, BCLK = 400000000, PCLK = 200000000 (1) PLL0: BUS BCLK = 400000000, PCLK = 200000000 (8) PLL0: CCI4 BCLK = 400000000, PCLK = 200000000 (3) PLL0: G3D BCLK = 400000000 (4) PLL0: CODA BCLK = 400000000, PCLK = 200000000 (5) PLL0: DISP BCLK = 400000000, PCLK = 200000000 (6) PLL0: HDMI PCLK = 133333333 I2C: ready DRAM: 1 GiB------------内存1GB Heap = 0x44000000~0x46000000 Code = 0x43c00000~0x43c83e48 GLD = 0x43bffeb8 GLBD = 0x43bffe68 SP = 0x43bffe68,0x43bffe48(CURR) PC = 0x43c06640 TAGS = 0x40000100 PAGE = 0x43c90000~0x43c9c000 MACH = [4330] VER = 0 BOARD= [GEC6818] MMC: NXP DWMMC: 0, NXP DWMMC: 1, NXP DWMMC: 2 In: serial Out: serial Err: serial ## DCDC_MODE(0x80): DCDC1[PFM], DCDC2[PFM], DCDC3[PFM], DCDC4[PWM], DCDC5[PWM] ## STATUS(0x00) : 0xe4 0x10 ## IRQ(0x48) : 0x00 0x00 0x00 0x00 0x00 ## CHG_TYPE : ADP ## BAT_VOL : 0mV ## BAT_CAP : 100% DONE: Logo bmp 300 by 300 (3bpp), len=270056 DRAW: 0x47000000 -> 0x46000000 DONE: Logo bmp 300 by 300 (3bpp), len=270056 DRAW: 0x47000000 -> 0x46000000 RGB: display.0 MIPI: display.0 DSIM_ESCMODE 1 : 0xc0 DSIM_STATUS : 0x10010f MIPI clk: 420MHz DSIM_ESCMODE 2 : 0x0 DSIM_STATUS : 0x10010f ## Skip BAT Animation. ## IRQ(0x48) : 0x00 0x00 0x00 0x00 0x00 ## chg_type : ADP ## battery_vol : 0mV ## battery_cap : 100% ## Booting Card did not respond to voltage select! Net: GEC6818 mac init... dwmac.c0060000 Hit any key to stop autoboot: 0---倒计时结束加载启动内核,倒计时结束前按下键盘上的任意按键,进入U-BOOT命令行
(4)uboot的命令
=> help //在uboot下执行help看uboot下的帮助文档 ? - alias for 'help' base - print or set address offset bdinfo - print Board Info structure blkcache - block cache diagnostics and control boot - boot default, i.e., run 'bootcmd' bootd - boot default, i.e., run 'bootcmd' bootefi - Boots an EFI payload from memory bootelf - Boot from an ELF image in memory bootm - boot application image from memory bootp - boot image via network using BOOTP/TFTP protocol bootvx - Boot vxWorks from an ELF image bootz - boot Linux zImage image from memory cmp - memory compare coninfo - print console devices and information cp - memory copy crc32 - checksum calculation dhcp - boot image via network using DHCP/TFTP protocol dm - Driver model low level access echo - echo args to console editenv - edit environment variable env - environment handling commands erase - erase FLASH memory exit - exit script ext2load - load binary file from a Ext2 filesystem ext2ls - list files in a directory (default /) ext4load - load binary file from a Ext4 filesystem ext4ls - list files in a directory (default /) ext4size - determine a file's size false - do nothing, unsuccessfully fatinfo - print information about filesystem fatload - load binary file from a dos filesystem fatls - list files in a directory (default /) fatmkdir - create a directory fatrm - delete a file fatsize - determine a file's size fatwrite - write file into a dos filesystem fdt - flattened device tree utility commands flinfo - print FLASH memory information fstype - Look up a filesystem type go - start application at address 'addr' gpio - query and control gpio pins gpt - GUID Partition Table help - print command description/usage iminfo - print header information for application image imxtract - extract a part of a multi-image itest - return true/false on integer compare ln - Create a symbolic link load - load binary file from a filesystem loadb - load binary file over serial line (kermit mode) loads - load S-Record file over serial line loadx - load binary file over serial line (xmodem mode) loady - load binary file over serial line (ymodem mode) loop - infinite loop on address range ls - list files in a directory (default /) md - memory display mdio - MDIO utility commands mii - MII utility commands mm - memory modify (auto-incrementing address) mmc - MMC sub system mmcinfo - display MMC info mtd - MTD utils mw - memory write (fill) nfs - boot image via network using NFS protocol nm - memory modify (constant address) part - disk partition related commands ping - send ICMP ECHO_REQUEST to network host printenv - print environment variables protect - enable or disable FLASH write protection pxe - commands to get and boot from pxe files random - fill memory with random pattern reset - Perform RESET of the CPU run - run commands in an environment variable save - save file to a filesystem saveenv - save environment variables to persistent storage setenv - set environment variables setexpr - set environment variable as the result of eval expression sf - SPI flash sub-system showvar - print local hushshell variables size - determine a file's size sleep - delay execution for some time source - run script from memory sysboot - command to get and boot from syslinux files test - minimal test like /bin/sh tftpboot - boot image via network using TFTP protocol true - do nothing, successfully usb - USB sub-system usbboot - boot from USB device version - print monitor, compiler and linker version
- bdinfo:打印出开发板的信息
GEC6818# bdinfo arch_number = 0x000010EA-------开发板的编号,要与内核源码中开发板编号一致 boot_params = 0x40000100-------启动内核所需参数在内存的0x40000100处 DRAM bank = 0x00000000 -> start = 0x40000000-----------内存的起始地址,结束地址0x7fffffff -> size = 0x40000000-----------内存的大小 1GB eth0name = dwmac.c0060000---网卡的名字 ethaddr = 00:e2:1c:ba:e8:60 --网卡的MAC地址 current eth = dwmac.c0060000 ip_addr = 192.168.51.5----------U-BOOT设置的网卡IP baudrate = 115200 bps-----------串口的波特率 TLB addr = 0x7FFF0000 relocaddr = 0x46000000 reloc off = 0x00000000 irq_sp = 0x7DF6BF00 sp start = 0x43BFFE6
- 启动内核的命令
boot - boot default, i.e., run 'bootcmd' bootd - boot default, i.e., run 'bootcmd' bootm - boot application image from memory bootp - boot image via network using BOOTP/TFTP protocol
- printenv:打印环境变量
GEC6818# printenv baudrate=115200 bootargs=lcd=at070tn92 tp=gslx680-linux root=/dev/mmcblk0p2 rw rootfstype=ext4 bootcmd=ext4load mmc 2:1 0x48000000 uImage;bootm 0x48000000
两个重要的环境变量:
bootargs启动参数:告诉内核一些重要启动信息 lcd=at070tn92-------------LCD屏驱动芯片的型号 tp=gslx680-linux-----------触摸屏的型号 root=/dev/mmcblk0p2----根文件系统在emmc的第2个分区 rw rootfstype=ext4--------根文件系统可读可写,类型是ext4 bootcmd--------------------启动命令环境变量,告诉U-boot一些信息 bootcmd=ext4load mmc 2:1 0x48000000 uImage;bootm 0x48000000 以ext4格式把内核镜像uImage从emmc的第1分区加载到内存的0x48000000处,然后去到内存0x48000000处,启动内核 bootdelay=3---------------倒计时3S bootfile=uImage ethact=dwmac.c0060000 ethaddr=00:e2:1c:ba:e8:60 ethprime=RTL8211------网卡芯片的型号 gatewayip=192.168.51.1-----------------默认网关 ipaddr=192.168.51.5---------------------开发板IP netmask=255.255.255.0----------------子网掩码 qtcrc=-1489582083 serverip=192.168.51.2-------------------服务器IP stderr=serial stdin=serial stdout=serial
标签:linux,系统启动,##,0x00,image,memory,boot,file,Linux 来源: https://www.cnblogs.com/yuanqiangfei/p/15584834.html